/* ==========================================================================
   BREAKPOINTS — the standard scale (P1-6)
   --------------------------------------------------------------------------
   styles.css alone carried EIGHT: 480, 568, 640, 768, 900, 968, 1200 and a
   couple in rem. Nothing handled the 1200–1400 band where P1-1 bit hardest, and
   568 vs 640 vs 640 was three names for "a phone turned sideways".

   Five now, each with a job. Every one-off was a "collapse this grid to one
   column" rule, so remapping only shifts WHERE it collapses, never whether:
     568  -> 640    same intent, one fewer number
     900  -> 1024   both were 2-column grids giving up
     968  -> 1024   same
     1200 -> 1280   collapses EARLIER, which is the safe direction

     480px   phone
     640px   large phone / small tablet — list tables become cards here
     768px   tablet — the dominant one, 18 uses
     1024px  laptop
     1280px  wide laptop

   ⚠️ PX, NOT REM, and deliberately. A rem breakpoint moves when the reader
   changes their browser font size — so raising your font size would silently
   switch you to the phone layout on a desktop. Font SIZES are rem (P3-8);
   breakpoints describe the viewport and stay px. Two of these were rem after my
   own P1 work and have been corrected.

   CSS custom properties cannot be used in a media query condition, so the
   audit's "define them as variables" is not achievable in plain CSS — this
   comment is the definition.
   ========================================================================== */

/**
 * NS3 CRM - Styles
 *
 * Design Philosophy:
 * - Clean, professional appearance
 * - Mobile-first responsive design
 * - Consistent spacing and colors
 * - Accessible (WCAG 2.1 AA compliant)
 */

/* ========================================
   CSS VARIABLES (Design System)
   ======================================== */
:root {
  /* Brand Colors */
  --brand-primary: #2563EB;       /* Primary brand colour */
  --brand-primary-dark: #1D4ED8;  /* Darker shade for hover states */
  --brand-primary-light: #DBEAFE; /* Light shade for backgrounds */
  /* Legacy token names retained so existing references keep working (now point at the brand) */
  --lime-green: var(--brand-primary);
  --lime-green-dark: var(--brand-primary-dark);
  --lime-green-light: var(--brand-primary-light);
  --grey: #71717a;               /* Light grey */
  --grey-light: #e4e4e7;         /* Very light grey */

  /* Grays */
  --light-grey: #e5e5e5;
  --medium-grey: #cccccc;
  --dark-grey: #666666;
  --text-black: #000000;

  /* UI Colors */
  --white: #ffffff;
  --background: #f0f4f8;
  --border: #cccccc;
  --border-color: #d1d5db;
  --hover: #f3f3f3;

  /* Status Colors */
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
  --info: #2196f3;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-black);
  background-color: var(--background);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   LOGIN PAGE STYLES
   ======================================== */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, var(--lime-green) 0%, var(--lime-green-dark) 100%);
}

.login-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xl);
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-header {
  text-align: center;
  margin-bottom: var(--spacing-xl);
}

.logo-large {
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

.logo-large img {
  height: 100%;
  width: auto;
  max-width: 250px;
  object-fit: contain;
}

.login-header h1 {
  font-size: 1.5rem;
  color: var(--text-black);
  margin-bottom: var(--spacing-xs);
}

.subtitle {
  color: var(--dark-grey);
  font-size: 0.875rem;
}

/* ========================================
   FORM STYLES
   ======================================== */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.form-group label {
  font-weight: 500;
  color: var(--text-black);
  font-size: 0.875rem;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-color: var(--text-on-brand);
}

.form-group input:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

.form-group input::placeholder {
  color: var(--medium-grey);
}

/* Password Input with Toggle */
.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper input {
  flex: 1;
  padding-right: 50px;
}

.toggle-password {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.toggle-password:hover {
  opacity: 1;
}

/* Checkbox */
.checkbox-group {
  flex-direction: row;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--dark-grey);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary {
  padding: 14px 24px;
  background-color: var(--lime-green);
  color: var(--text-on-brand);
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--lime-green-dark);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--text-on-brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* utils/loading.js — the "working…" overlay for a save or a check-in. It blocks a second
   tap at once but only shows after 250ms, so a quick save does not flash.
   ⚠️ BELOW modals (2000), confirm dialogs (9999) and toasts: some flows open a dialog
   while it is up, and an overlay above the dialog would leave nothing clickable. */
.ns3-busy {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.18);
  opacity: 0;
  animation: ns3-busy-in 0.15s ease-out 0.25s forwards;
}
.ns3-busy-box {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 14px 20px;
  border-radius: var(--radius-md, 10px);
  background: var(--surface, #fff);
  color: var(--text-black, #0f172a);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  font-size: 0.9375rem;
  font-weight: 500;
}
.ns3-busy-spinner {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 3px solid var(--border-color, #e2e8f0);
  border-top-color: var(--brand, #2563eb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes ns3-busy-in {
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ns3-busy-spinner { animation-duration: 2s; }
}

/* ========================================
   MESSAGES
   ======================================== */
.error-message {
  padding: 12px 16px;
  background-color: var(--danger-wash);
  color: var(--danger-strong);
  border: 1px solid var(--danger-bright);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  text-align: center;
  animation: slideIn 0.3s ease;
}

.success-message {
  padding: 12px 16px;
  background-color: var(--ok-wash);
  color: var(--ok);
  border: 1px solid var(--ok-bright);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  text-align: center;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shake animation for errors */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.shake {
  animation: shake 0.3s ease;
}

/* ========================================
   LINKS
   ======================================== */
.link-secondary {
  color: var(--lime-green);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition-fast);
}

.link-secondary:hover {
  color: var(--lime-green-dark);
  text-decoration: underline;
}

.login-footer {
  text-align: center;
  margin-top: var(--spacing-md);
}

/* ========================================
   VERSION INFO
   ======================================== */
.login-version {
  text-align: center;
  margin-top: var(--spacing-xl);
  color: var(--medium-grey);
  font-size: 0.75rem;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 480px) {
  .login-body {
    padding: var(--spacing-md);
  }

  .login-container {
    padding: var(--spacing-lg);
  }

  .logo-large {
    height: 60px;
  }

  .logo-large img {
    max-width: 180px;
  }

  .login-header h1 {
    font-size: 1.25rem;
  }
}

/* ========================================
   MODULE LAYOUTS
   ======================================== */
.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.module-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-black);
  margin: 0;
}

.module-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.module-content {
  padding: var(--spacing-lg);
  background: var(--surface);
  min-height: calc(100vh - 200px);
}

/* ========================================
   FORM CONTROLS (Module Specific)
   ======================================== */
.search-input {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  min-width: 250px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-color: var(--text-on-brand);
}

.search-input:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

.filter-select {
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background-color: var(--text-on-brand);
  cursor: pointer;
  transition: border-color var(--transition-fast);
  min-width: 150px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

/* ========================================
   BUTTON VARIANTS
   ======================================== */
.btn-secondary {
  padding: 10px 20px;
  background-color: var(--text-on-brand);
  color: var(--dark-grey);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.btn-secondary:hover {
  background-color: var(--grey-light);
  border-color: var(--dark-grey);
  color: var(--text-black);
}

.btn-icon {
  padding: 8px 12px;
  background-color: var(--text-on-brand);
  color: var(--text-black);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background-color: var(--hover);
  border-color: var(--lime-green);
}

/* ========================================
   DATA TABLES
   ======================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table thead {
  background-color: var(--grey-light);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  color: var(--dark-grey);
  border-bottom: 2px solid var(--border-color);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--grey-light);
  font-size: 0.875rem;
  color: var(--text-black);
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: var(--lime-green-light);
  cursor: pointer;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table td.loading {
  text-align: center;
  padding: 40px;
  color: var(--dark-grey);
  font-style: italic;
}

/* ========================================
   INVOICE STATS
   ======================================== */
.invoice-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.stat-box {
  background: var(--surface);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  border-left: 4px solid var(--lime-green);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--dark-grey);
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-black);
}

/* ⚠️ Ten tiles share a row, so at laptop width each is ~150px — and a money value
   like £93,976.06 at 1.5rem is wider than that. It ran out of its tile and under the
   next one (2026-10-13). The value now scales with its own tile, never past 1.5rem,
   and may break rather than overflow on a very narrow screen. */
.invoice-stats .stat-box {
  min-width: 0;
  container-type: inline-size;
}
.invoice-stats .stat-value {
  font-size: clamp(1rem, 12cqi, 1.5rem);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* The dashboard's stat icon gave way to a long value ("Revenue This Month" squeezed
   its £ tile to a sliver). The page's own <style> sizes it; this only stops it shrinking. */
.stat-card .stat-icon {
  flex-shrink: 0;
}
.stat-card .stat-content {
  min-width: 0;
}

/* ========================================
   DIARY CALENDAR CONTROLS
   ======================================== */
.diary-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.view-switcher {
  display: flex;
  gap: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.view-btn {
  padding: 10px 20px;
  background-color: var(--text-on-brand);
  color: var(--text-black);
  border: none;
  border-right: 1px solid var(--border-color);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.view-btn:last-child {
  border-right: none;
}

.view-btn:hover {
  background-color: var(--hover);
}

.view-btn.active {
  background-color: var(--lime-green);
  color: var(--text-on-brand);
}

.date-navigation {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

#currentDateDisplay {
  min-width: 200px;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-black);
}

/* ========================================
   CALENDAR VIEWS
   ======================================== */
.calendar-view {
  display: none;
  padding: var(--spacing-lg);
}

.calendar-view.active {
  display: block;
}

.day-view-grid,
.week-view-grid,
.month-view-grid {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  min-height: 500px;
  padding: var(--spacing-lg);
}

/* Week View Grid */
.week-view-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.week-day-header {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--dark-grey);
  background: var(--grey-light);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.week-day-cell {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  min-height: 60px;
  background: var(--surface);
  position: relative;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
}

.week-day-cell:hover {
  background: var(--lime-green-light);
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime-green);
  box-shadow: var(--shadow-sm);
}

/* Month View Grid */
.month-view-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.month-day-header {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--dark-grey);
  background: var(--grey-light);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.month-day-header:last-child {
  border-right: none;
}

.month-day-cell {
  min-height: 100px;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.month-day-cell:nth-child(7n) {
  border-right: none;
}

.month-day-cell:hover {
  background: var(--lime-green-light);
}

.month-day-cell.other-month {
  background: var(--grey-light);
  opacity: 0.5;
}

.month-day-cell.today {
  background: var(--lime-alpha-10);
  border: 2px solid var(--lime-green);
}

.day-number {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--dark-grey);
  margin-bottom: 4px;
}

.month-day-cell.today .day-number {
  color: var(--lime-green);
  font-size: 1rem;
}

.event-summary {
  font-size: 0.6875rem;
  padding: 4px 6px;
  background: var(--lime-green-light);
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.event-summary:hover {
  background: var(--lime-green);
  color: white;
  transform: translateY(-1px);
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--dark-grey);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--text-black);
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--dark-grey);
}

/* ========================================
   LOADING STATES
   ======================================== */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  min-height: 200px;
}

.loading-spinner .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--grey-light);
  border-top-color: var(--lime-green);
}

/* ========================================
   RESPONSIVE MODULE LAYOUTS
   ======================================== */
@media (max-width: 768px) {
  .module-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .module-actions {
    width: 100%;
    flex-direction: column;
  }

  .search-input,
  .filter-select {
    width: 100%;
  }

  .invoice-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .diary-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .date-navigation {
    justify-content: space-between;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table th,
  .data-table td {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .invoice-stats {
    grid-template-columns: 1fr;
  }

  .view-switcher {
    width: 100%;
  }

  .view-btn {
    flex: 1;
  }
}

/* ========================================
   MODALS
   ======================================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  overflow-y: auto;
  padding: var(--spacing-lg);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

.modal-large {
  max-width: 900px;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  color: var(--text-black);
  font-size: 1.5rem;
}

/* X button in modal header */
.modal-header .close-modal {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--dark-grey);
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.modal-header .close-modal:hover {
  background: var(--grey-light);
  color: var(--text-black);
}

.modal-body {
  padding: var(--spacing-lg);
}

/* The Add Subcontractor form is placed directly inside .modal-content with no
   .modal-body wrapper, so without this it renders flush to the edges. Give the
   form the same inner padding the rest of the modals use. */
#addSubcontractorForm {
  padding: var(--spacing-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border);
}

/* ========================================
   STATUS SELECTION OPTIONS
   ======================================== */
.status-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-option {
  display: flex;
  align-items: flex-start;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-normal), border-color var(--transition-normal), color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal), opacity var(--transition-normal);
  background: var(--surface);
}

.status-option:hover {
  border-color: var(--lime-green);
  background: var(--lime-green-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.status-option input[type="radio"] {
  margin-top: 4px;
  margin-right: 12px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: var(--lime-green);
}

.status-option input[type="radio"]:checked ~ .status-option-content {
  color: var(--text-black);
}

.status-option:has(input[type="radio"]:checked) {
  border-color: var(--lime-green);
  background: var(--lime-green-light);
  box-shadow: var(--shadow-md);
}

.status-option-content {
  flex: 1;
}

.status-option-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.status-icon {
  font-size: 1.25rem;
}

.status-label {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-black);
}

.status-option-description {
  font-size: 0.875rem;
  color: var(--dark-grey);
  line-height: 1.4;
}

/* ========================================
   FORM SECTIONS
   ======================================== */
.form-section {
  margin-bottom: var(--spacing-xl);
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section h3 {
  margin-bottom: var(--spacing-md);
  color: var(--text-black);
  font-size: 1.125rem;
  border-bottom: 2px solid var(--lime-green);
  padding-bottom: var(--spacing-sm);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

/* P2-11: the Add Client form read Company Name (full) → Account Number →
   Type/Status → Name/Title → Email/Phone → Mobile, and the two lone fields
   STRETCHED to twice the width of the pairs above and below them. That is the
   ragged rhythm the audit meant: an account number and a mobile number are not
   long values and should not be the widest inputs on the page.
   `auto-fit` collapses the empty track, which is what causes the stretch, so a
   lone field is capped at one column's width instead. Anything that genuinely
   needs the room still says so with .full-width (address lines, notes).
   Not applied below the breakpoint, where the grid is a single column anyway
   and half-width would be simply wrong.
   Rows with three or more fields are untouched — there are 16 of them. */
@media (min-width: 640px) {
  .form-row > .form-group:only-child:not(.full-width) {
    max-width: calc(50% - (var(--spacing-md) / 2));
  }
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--text-black);
  font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  transition: border-color var(--transition-fast);
  font-family: inherit;
  background-color: var(--text-on-brand);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: var(--spacing-xs);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

/* P1-8: Add Client is roughly three screens of form, and Create/Cancel sat only
   at the very bottom — you had to scroll to the end to find out you could not
   save. The action row now sticks to the bottom of the viewport while the form
   is longer than the screen.
   Applied by js/utils/sticky-form-actions.js, which only marks forms that are
   ACTUALLY taller than the viewport — a short form keeps its ordinary inline
   row, because a floating bar under three fields looks broken. */
.form-actions.is-sticky {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin-top: var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--white, #fff);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
@media (prefers-reduced-motion: no-preference) {
  .form-actions.is-sticky { transition: box-shadow 0.2s ease; }
}

/* ========================================
   INVOICE LINE ITEMS
   ======================================== */
.invoice-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: var(--surface);
}

.item-row {
  display: grid;
  grid-template-columns: 2fr 80px 120px 100px 100px 120px 50px;
  gap: var(--spacing-sm);
  align-items: end;
}

.item-row .form-group {
  margin-bottom: 0;
}

.item-row .form-group label {
  font-size: 0.75rem;
  margin-bottom: var(--spacing-xs);
}

.item-row input {
  width: 100%;
  font-size: 0.8125rem;
}

.invoice-totals {
  background: var(--grey-light);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-top: var(--spacing-md);
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-xs) 0;
  font-size: 0.875rem;
}

.total-row.total-final {
  border-top: 2px solid var(--border-color);
  margin-top: var(--spacing-sm);
  padding-top: var(--spacing-sm);
  font-weight: 700;
  font-size: 1.125rem;
}

.total-label {
  color: var(--dark-grey);
}

.total-value {
  color: var(--text-black);
  font-weight: 600;
}

.btn-danger {
  background-color: var(--danger-bright);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background-color: var(--danger);
}

@media (max-width: 1024px) {
  .item-row {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }
}

/* ========================================
   DIARY CALENDAR GRIDS
   ======================================== */
.day-view-grid {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.time-label {
  padding: 12px 8px;
  text-align: right;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--dark-grey);
  background: var(--grey-light);
  border-bottom: 1px solid var(--border-color);
  border-right: 2px solid var(--border-color);
}

.time-slot {
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  min-height: 60px;
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.time-slot:hover {
  background: var(--lime-green-light);
}

.time-slot:last-of-type {
  border-bottom: none;
}

.event-block {
  background: var(--lime-green);
  color: white;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.event-block:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.event-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-time {
  font-size: 0.75rem;
  opacity: 0.9;
  margin-bottom: 2px;
}

.event-engineers {
  font-size: 0.6875rem;
  opacity: 0.85;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-block.priority-high {
  border-left: 4px solid var(--danger-bright);
}

.event-block.priority-medium {
  border-left: 4px solid var(--warn);
}

.event-block.priority-low {
  border-left: 4px solid var(--blue);
}

/* Week View Grid */
.week-view-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.week-day-header {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-black);
  background: var(--grey-light);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  line-height: 1.4;
}

.week-day-header:last-of-type {
  border-right: none;
}

.week-day-cell {
  padding: 4px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  min-height: 60px;
  background: var(--surface);
  position: relative;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
}

.week-day-cell:hover {
  background: var(--lime-green-light);
}

.week-day-cell:nth-child(8n) {
  border-right: none;
}

.event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime-green);
  flex-shrink: 0;
}

/* Month View Grid */
.month-view-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.month-day-header {
  padding: 12px 8px;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-black);
  background: var(--grey-light);
  border-bottom: 2px solid var(--border-color);
  border-right: 1px solid var(--border-color);
}

.month-day-header:last-child {
  border-right: none;
}

.month-day-cell {
  min-height: 100px;
  padding: 8px;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  position: relative;
}

.month-day-cell:nth-child(7n) {
  border-right: none;
}

.month-day-cell:hover {
  background: var(--lime-green-light);
}

.month-day-cell.today {
  background: var(--lime-alpha-10);
}

.month-day-cell.today .day-number {
  background: var(--lime-green);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.month-day-cell.other-month {
  background: var(--grey-light);
  opacity: 0.5;
}

.day-number {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-black);
  margin-bottom: 4px;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
.toast-container {
  position: fixed;
  /* P1-7: was top:20px, which put every toast squarely over the Profile /
     Support / Sign Out buttons in the 81px-tall sticky top bar. Offset below it.
     A shell with a different header height overrides --toast-top-offset. */
  top: var(--toast-top-offset, 5.5rem);
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.9) 100%);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-radius: 12px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  padding: 16px 18px;
  min-width: 320px;
  max-width: 450px;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
  transition: background-color 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: top right;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.toast-enter {
  opacity: 0;
  transform: translateX(380px) translateY(-10px) scale(0.95);
}

.toast-visible {
  opacity: 1;
  transform: translateX(0) translateY(0) scale(1);
}

.toast-exit {
  opacity: 0;
  transform: translateX(380px) scale(0.9);
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: -12px;
  overflow: hidden;
}

.toast-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-strong);
  font-weight: 500;
}

.toast-close {
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  font-size: 1.125rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-strong);
  transform: scale(1.05);
}

.toast-close:active {
  transform: scale(0.95);
}

.toast-success {
  background: linear-gradient(135deg, var(--ok-wash) 0%, var(--ok-tint) 100%);
  border-left: 3px solid var(--ok-bright);
}

.toast-success .toast-icon {
  background: linear-gradient(135deg, var(--ok-bright) 0%, var(--ok) 100%);
  color: white;
}

.toast-error {
  background: linear-gradient(135deg, var(--danger-wash) 0%, var(--danger-tint) 100%);
  border-left: 3px solid var(--danger-bright);
}

.toast-error .toast-icon {
  background: linear-gradient(135deg, var(--danger-bright) 0%, var(--danger) 100%);
  color: white;
}

.toast-warning {
  background: linear-gradient(135deg, var(--warn-wash) 0%, var(--warn-tint) 100%);
  border-left: 3px solid var(--warn);
}

.toast-warning .toast-icon {
  background: linear-gradient(135deg, var(--warn) 0%, var(--warn-strong) 100%);
  color: white;
}

.toast-info {
  background: linear-gradient(135deg, var(--blue-wash) 0%, var(--blue-tint) 100%);
  border-left: 3px solid var(--blue);
}

.toast-info .toast-icon {
  background: linear-gradient(135deg, var(--blue) 0%, var(--brand) 100%);
  color: white;
}

@media (max-width: 640px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .toast-enter {
    transform: translateY(-80px) scale(0.95);
  }

  .toast-exit {
    transform: translateY(-80px) scale(0.9);
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
/* Focus styles for keyboard navigation */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime-green);
  outline-offset: 2px;
}

/* Reduced motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   SETTINGS MODULE - MODERN STYLING
   ======================================== */
.settings-content {
  padding: var(--spacing-lg);
  background: transparent;
}

.settings-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
}

.settings-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-black);
  margin-bottom: var(--spacing-lg);
}

/* Modern Tabs */
.module-tabs {
  display: flex;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xl);
  padding: 6px;
  background: var(--grey-light);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.module-tabs .tab-button {
  /* inline-flex + gap because the label is now an SVG icon plus a <span>; it
     used to be one text node beginning with an emoji. */
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--dark-grey);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}

.module-tabs .tab-button:hover {
  color: var(--text-black);
  background: rgba(255, 255, 255, 0.6);
}

.module-tabs .tab-button.active {
  color: var(--text-black);
  background: var(--surface);
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* Section Header with Actions */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-black);
  margin: 0;
}

.section-header .btn-secondary,
.section-header .btn-primary {
  font-size: 0.875rem;
  padding: 10px 20px;
}

/* Users List Table */
.users-list {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.users-list .data-table {
  width: 100%;
  border-collapse: collapse;
}

.users-list .data-table thead th {
  background: var(--grey-light);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--dark-grey);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
}

.users-list .data-table tbody td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-black);
}

.users-list .data-table tbody tr:last-child td {
  border-bottom: none;
}

.users-list .data-table tbody tr:hover {
  background: var(--lime-green-light);
}

.users-list .data-table select {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.users-list .data-table select:hover {
  border-color: var(--lime-green);
}

.users-list .data-table select:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

/* Status Badge */
.users-list .data-table td:nth-child(4) {
  font-weight: 500;
  text-transform: capitalize;
}

/* Action Buttons in Table */
.users-list .data-table button {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 1.125rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  background: transparent;
  border: 1px solid transparent;
}

.users-list .data-table button:hover {
  background: var(--border-color);
  transform: scale(1.1);
}

/* Settings Forms */
.settings-form {
  margin-top: var(--spacing-lg);
}

.settings-form .form-group {
  margin-bottom: var(--spacing-lg);
}

.settings-form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-black);
  margin-bottom: var(--spacing-xs);
}

.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form input[type="password"],
.settings-form input[type="tel"],
.settings-form input[type="number"],
.settings-form textarea,
.settings-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  color: var(--text-black);
  background: var(--surface);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.settings-form input:focus,
.settings-form textarea:focus,
.settings-form select:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

.settings-form textarea {
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
}

/* Form Row Grid */
.settings-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.settings-form .form-group.full-width {
  grid-column: 1 / -1;
}

/* Responsive Settings */
@media (max-width: 768px) {
  .settings-content {
    padding: var(--spacing-md);
  }

  .settings-section {
    padding: var(--spacing-lg);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  .section-header .btn-secondary,
  .section-header .btn-primary {
    width: 100%;
  }

  .module-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .users-list {
    overflow-x: auto;
  }

  .users-list .data-table {
    min-width: 600px;
  }

  .settings-form .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   QUOTES MODULE STYLES
   ============================================ */

/* Line Items Container */
#lineItemsContainer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* Line Item Row */
.line-item {
  padding: 15px;
  background: var(--surface-muted);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.line-item-row {
  display: grid;
  /* Six columns, authored for the QUOTES row: type, description, qty, price,
     total, remove. */
  grid-template-columns: 120px 1fr 80px 100px 100px 40px;
  gap: 10px;
  align-items: center;
}

/* ⚠️ Invoices and recurring invoices share `.line-item-row` but have NO type
   select, so they were laying five children into the six-column quote grid —
   description squeezed into 120px while quantity took the 1fr. Give them their
   own tracks. */
.invoice-line-item .line-item-row {
  grid-template-columns: 1fr 80px 100px 100px 40px;
}

/* Invoice rows carry a per-line VAT rate select, so they have one column more. */
.invoice-line-item .line-item-row-vat {
  grid-template-columns: 1fr 80px 100px 90px 100px 40px;
}

.line-item-type {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.875rem;
}

.line-item-description {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.875rem;
}

.line-item-quantity,
.line-item-price {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: right;
}

.line-item-subtotal {
  font-weight: 600;
  color: var(--brand);
  text-align: right;
  font-size: 0.875rem;
}

.remove-line-item {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Quote View Styles */
.quote-view {
  padding: 20px;
}

.quote-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 25px;
  padding: 20px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.quote-description,
.quote-notes,
.quote-terms {
  margin: 20px 0;
  padding: 15px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.quote-line-items-table {
  width: 100%;
  margin: 15px 0 25px 0;
  border-collapse: collapse;
}

.quote-line-items-table thead {
  background: var(--surface-inset);
}

.quote-line-items-table th,
.quote-line-items-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.quote-line-items-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.quote-line-items-table td {
  font-size: 0.875rem;
}

.quote-line-items-table td:nth-child(3),
.quote-line-items-table td:nth-child(4),
.quote-line-items-table td:nth-child(5) {
  text-align: right;
}

/* Quote Totals */
.quote-totals {
  margin: 25px 0;
  padding: 20px;
  background: var(--surface-muted);
  border-radius: 8px;
  max-width: 400px;
  margin-left: auto;
}

.quote-total-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9375rem;
}

.quote-total-final {
  border-top: 2px solid var(--brand);
  margin-top: 10px;
  padding-top: 12px;
  font-size: 1.125rem;
  color: var(--brand);
}

/* Responsive */
@media (max-width: 768px) {
  .line-item-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Must repeat at this specificity: `.invoice-line-item .line-item-row` above is
     MORE specific than a bare `.line-item-row`, so without these the desktop grid
     would survive the breakpoint and the row would overflow the screen. */
  .invoice-line-item .line-item-row,
  .invoice-line-item .line-item-row-vat {
    grid-template-columns: 1fr;
  }

  .line-item-subtotal {
    text-align: left;
  }

  .quote-info-grid {
    grid-template-columns: 1fr;
  }

  .quote-line-items-table {
    font-size: 0.75rem;
  }

  .quote-line-items-table th,
  .quote-line-items-table td {
    padding: 8px;
  }
}

/* ========================================
   ROLE PERMISSIONS TABLE
   ======================================== */
.role-permissions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.permission-section {
  background: white;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.permission-section h3 {
  margin: 0;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.permissions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.permissions-table thead th {
  background: var(--surface-muted);
  color: var(--text-body);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.permissions-table thead th:first-child {
  min-width: 180px;
}

.permissions-table thead th:not(:first-child) {
  text-align: center;
  min-width: 85px;
}

.permissions-table tbody tr {
  transition: background-color 0.15s ease;
}

.permissions-table tbody tr:nth-child(even) {
  background-color: var(--surface-muted);
}

.permissions-table tbody tr:hover {
  background-color: var(--line);
}

.permissions-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-body);
}

.permissions-table tbody td:first-child {
  font-weight: 500;
  color: var(--text-strong);
}

.permission-cell {
  text-align: center;
  font-size: 0.875rem;
  white-space: nowrap;
}
.permission-cell svg { vertical-align: -2px; }

/* The tick/cross now carries the colour (ns3-dot-success / ns3-dot-muted), so
   the cell itself no longer needs to. */
.permission-cell.has-permission {
  font-weight: 600;
}

/* A qualified permission — "(View)", "(Own)". */
.permission-note {
  margin-left: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ⚠️ WAS: .permissions-table tbody td:not(.permission-cell) { color:#dc3545 }
   The permission NAME is the only cell in the row that is not a
   .permission-cell, so that rule painted the entire left-hand column
   danger-red and bold — every permission in the matrix looked like a warning.
   It was presumably meant for the not-allowed cells, which now colour
   themselves through the icon. */
.permissions-table tbody td:not(.permission-cell) {
  color: var(--text-strong);
  font-weight: 500;
}

.role-summary {
  background: linear-gradient(135deg, var(--surface-muted) 0%, var(--line) 100%);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
}

.role-summary h3 {
  margin: 0 0 16px 0;
  color: var(--text-body);
  font-size: 1rem;
  font-weight: 600;
}

.role-summary ul {
  margin: 0;
  padding-left: 24px;
  line-height: 1.8;
}

.role-summary li {
  margin-bottom: 8px;
  color: var(--text-body);
  font-size: 0.875rem;
}

.role-summary strong {
  color: var(--text-strong);
  font-weight: 600;
}

@media (max-width: 768px) {
  .permissions-table {
    font-size: 0.6875rem;
  }

  .permissions-table thead th,
  .permissions-table tbody td {
    padding: 8px 6px;
  }

  .permissions-table thead th:first-child {
    min-width: 120px;
  }

  .permissions-table thead th:not(:first-child) {
    min-width: 60px;
  }

  .permission-cell {
    font-size: 0.875rem;
  }
}

/* ========================================
   BROADCAST ANNOUNCEMENT BANNER
   ======================================== */
.broadcast-banner {
  position: relative;
  padding: 14px 20px;
  font-size: 0.875rem;
  line-height: 1.6;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  animation: slideDown 0.3s ease-out;
  z-index: 999;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.broadcast-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.broadcast-icon {
  font-size: 1.125rem;
  flex-shrink: 0;
}

.broadcast-message {
  flex: 1;
  font-weight: 500;
  white-space: pre-wrap;
}

.broadcast-close {
  background: none;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.broadcast-close:hover {
  opacity: 1;
}

/* Broadcast Types */
.broadcast-info {
  background: linear-gradient(135deg, var(--blue-wash) 0%, var(--blue-tint) 100%);
  color: var(--blue-deep);
  border-left: 4px solid var(--blue);
}

.broadcast-info .broadcast-close {
  color: var(--blue-deep);
}

.broadcast-warning {
  background: linear-gradient(135deg, var(--warn-tint) 0%, var(--warn-tint) 100%);
  color: var(--warn-strong);
  border-left: 4px solid var(--warn);
}

.broadcast-warning .broadcast-close {
  color: var(--warn-strong);
}

.broadcast-success {
  background: linear-gradient(135deg, var(--ok-wash) 0%, var(--ok-tint) 100%);
  color: var(--ok-deep);
  border-left: 4px solid var(--ok-bright);
}

.broadcast-success .broadcast-close {
  color: var(--ok-deep);
}

.broadcast-danger {
  background: linear-gradient(135deg, var(--danger-wash) 0%, var(--danger-tint) 100%);
  color: var(--danger-strong);
  border-left: 4px solid var(--danger-bright);
}

.broadcast-danger .broadcast-close {
  color: var(--danger-strong);
}

@media (max-width: 768px) {
  .broadcast-banner {
    padding: 12px 16px;
    font-size: 0.8125rem;
  }

  .broadcast-icon {
    font-size: 1rem;
  }

  .broadcast-close {
    font-size: 1rem;
  }
}

/* ========================================
   REPORTS & ANALYTICS STYLES (Phase B6)
   ======================================== */

.reports-container {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.reports-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--line);
}

.reports-header h2 {
  margin: 0 0 8px 0;
  font-size: 1.75rem;
  color: var(--text-strong);
}

.reports-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.reports-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.reports-header-actions .form-select {
  min-width: 150px;
}

/* Reports Tabs */
.reports-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 25px;
  background: var(--surface-inset);
  padding: 6px;
  border-radius: 12px;
}

.tab-btn {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-strong);
}

.tab-btn.active {
  background: white;
  color: var(--text-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Tab Content */
.reports-tab-content {
  min-height: 400px;
}

.loading-spinner {
  text-align: center;
  padding: 60px 20px;
  font-size: 1rem;
  color: var(--text-muted);
}

.error-message {
  text-align: center;
  padding: 40px 20px;
  background: var(--danger-wash);
  border: 1px solid var(--danger-tint);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.9375rem;
}

/* Report Section */
.report-section {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

/* Report Card */
.report-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
}

.report-card h3 {
  margin: 0 0 20px 0;
  font-size: 1.25rem;
  color: var(--text-strong);
  font-weight: 600;
}

.report-card h4 {
  margin: 20px 0 15px 0;
  font-size: 1rem;
  color: var(--text-strong);
  font-weight: 600;
}

.report-subtitle {
  margin: -10px 0 15px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.metric-box {
  background: var(--surface-muted);
  padding: 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.metric-box label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-strong);
}

.metric-value.text-success {
  color: var(--ok);
}

.metric-value.text-danger {
  color: var(--danger-bright);
}

.metric-value.text-warning {
  color: var(--warn);
}

/* Invoice Aging */
.aging-brackets {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.aging-bracket {
  background: var(--surface-muted);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.aging-label {
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 8px;
  font-size: 0.875rem;
}

.aging-bar {
  height: 24px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.aging-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue) 0%, var(--blue-deep) 100%);
  transition: width 0.5s ease;
}

.aging-value {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Compliance Rate */
.compliance-rate {
  background: var(--surface-muted);
  padding: 20px;
  border-radius: 10px;
  margin-top: 20px;
}

.compliance-label {
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 10px;
  font-size: 0.9375rem;
}

.compliance-bar {
  height: 32px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.compliance-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ok) 0%, var(--ok) 100%);
  transition: width 0.5s ease;
}

.compliance-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ok);
  text-align: center;
}

/* Alert Boxes */
.alert-box {
  padding: 15px 20px;
  border-radius: 8px;
  margin-top: 15px;
  border-left: 4px solid;
}

.alert-box strong {
  font-weight: 600;
}

.alert-danger {
  background: var(--danger-wash);
  border-left-color: var(--danger-bright);
  color: var(--danger-strong);
}

.overdue-list {
  margin: 10px 0 0 0;
  padding-left: 20px;
}

.overdue-list li {
  margin: 5px 0;
}

/* Data Tables */
.table-responsive {
  overflow-x: auto;
  margin-top: 15px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead th {
  background: var(--surface-muted);
  padding: 12px 15px;
  text-align: left;
  font-weight: 600;
  color: var(--text-strong);
  border-bottom: 2px solid var(--line);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background-color 0.2s ease;
}

.data-table tbody tr:hover {
  background: var(--surface-muted);
}

.data-table tbody td {
  padding: 12px 15px;
  color: var(--text-strong);
}

.data-table tbody td.text-success {
  color: var(--ok);
  font-weight: 600;
}

.data-table tbody td.text-danger {
  color: var(--danger-bright);
  font-weight: 600;
}

.data-table tbody td.text-warning {
  color: var(--warn);
  font-weight: 600;
}

.data-table tbody td.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-faint);
  font-style: italic;
}

/* Two Column Layout */
.two-column-layout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .reports-header {
    flex-direction: column;
    gap: 20px;
  }

  .reports-header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .reports-tabs {
    flex-direction: column;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-column-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .report-card {
    padding: 15px;
  }

  .data-table {
    font-size: 0.75rem;
  }

  .data-table thead th,
  .data-table tbody td {
    padding: 8px 10px;
  }
}

/* ========================================
   PAGE-BASED VIEWS SYSTEM
   Modal Replacement Architecture
   ======================================== */

/* View Containers */
.view-container {
  width: 100%;
  height: 100%;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Breadcrumb Navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

.breadcrumb a {
  color: var(--lime-green);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--lime-green-dark);
  text-decoration: underline;
}

.breadcrumb span {
  color: var(--dark-grey);
}

.breadcrumb span:before {
  content: '›';
  margin-right: 8px;
  color: var(--medium-grey);
}

/* The first crumb needs no leading separator, and the legacy
   .breadcrumb-separator spans are redundant now every span draws its own '›'
   — with a literal '>' inside they rendered "› >" (P2-14, UX audit). */
.breadcrumb > span:first-child:before,
.breadcrumb > .breadcrumb-link:first-child:before {
  content: none;
}
.breadcrumb .breadcrumb-separator {
  display: none;
}

/* Breadcrumb ancestors are clickable — make them look it (P0-3, UX audit:
   "Contracts" in the crumb gave no visual hint it was the way back). */
.breadcrumb .breadcrumb-link {
  color: var(--lime-green);
  cursor: pointer;
}
.breadcrumb .breadcrumb-link:hover {
  text-decoration: underline;
}

/* P3-1 (UX audit): there was NO visible keyboard focus anywhere — 9 rules set
   outline: none. WCAG 2.4.7. :where() keeps specificity at zero so any
   component can still override deliberately. */
/* ⚠️ :where() means ZERO specificity, which is what lets a component override
   this deliberately — but it also means ANY later `outline: none` silently
   wins. There are 12 in this file. Each was checked: all but one replace the
   outline with a visible box-shadow ring, and that one (.attention-row) is
   fixed below. If you add `outline: none`, add a replacement ring with it. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* P1-1 (UX audit): tables scroll inside their wrapper, never the page. */
.table-responsive,
.data-table-container {
  overflow-x: auto;
}

/* Page Forms (Replacement for Modal Forms) */
.page-form {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.page-form .form-section {
  margin-bottom: 40px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
}

.page-form .form-section:last-of-type {
  border-bottom: none;
}

.page-form .form-section h3 {
  margin: 0 0 20px 0;
  color: var(--text-black);
  font-size: 1.125rem;
  font-weight: 600;
}

.page-form .form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.page-form .form-row:last-child {
  margin-bottom: 0;
}

.page-form .form-group {
  display: flex;
  flex-direction: column;
}

.page-form .form-group.full-width {
  grid-column: 1 / -1;
}

.page-form label {
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-black);
  font-size: 0.875rem;
}

.page-form input[type="text"],
.page-form input[type="email"],
.page-form input[type="tel"],
.page-form input[type="number"],
.page-form input[type="date"],
.page-form select,
.page-form textarea {
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s, opacity 0.2s;
}

.page-form input:focus,
.page-form select:focus,
.page-form textarea:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}

.page-form textarea {
  resize: vertical;
  min-height: 100px;
}

.page-form .form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 30px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
}

/* Tabbed Detail View */
.detail-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 30px;
  background: var(--surface);
  padding: 0 20px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.detail-tab-btn {
  padding: 16px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--dark-grey);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s, opacity 0.2s;
  position: relative;
  top: 2px;
}

.detail-tab-btn:hover {
  color: var(--lime-green);
  background: var(--hover);
}

.detail-tab-btn.active {
  color: var(--lime-green);
  border-bottom-color: var(--lime-green);
}

.detail-tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.detail-tab-content.active {
  display: block;
}

/* Tabbed detail panels used by the client & site detail views. Without this
   global rule the site detail had no display rule for inactive panels, so every
   tab's content stacked below the Details cards instead of swapping in place. */
.client-tab-content {
  display: none;
}

.client-tab-content.active {
  display: block;
}

/* Detail View Sections */
.detail-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.detail-view .detail-header {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--radius-md);
  margin-bottom: 30px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.detail-view .detail-header h2 {
  margin: 0 0 10px 0;
  font-size: 1.75rem;
  color: var(--text-black);
}

.detail-view .detail-header .detail-meta {
  display: flex;
  gap: 20px;
  align-items: center;
  color: var(--dark-grey);
  font-size: 0.875rem;
}

.detail-view .detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.detail-view .detail-content {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Responsive Page Forms */
@media (max-width: 768px) {
  .page-form {
    padding: 20px;
  }

  .page-form .form-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .page-form .form-group.full-width {
    grid-column: 1;
  }

  .breadcrumb {
    padding: 10px 15px;
    font-size: 0.8125rem;
  }

  .detail-tabs {
    overflow-x: auto;
    padding: 0 10px;
  }

  .detail-tab-btn {
    padding: 12px 16px;
    font-size: 0.875rem;
    white-space: nowrap;
  }

  .detail-view {
    padding: 10px;
  }

  .detail-view .detail-header,
  .detail-view .detail-content {
    padding: 20px;
  }

  .detail-view .detail-header h2 {
    font-size: 1.375rem;
  }
}

/* ========================================
   FORM BUILDER STYLES
   ======================================== */

/* Template Cards */
.template-type-section {
  margin-bottom: 32px;
}

.template-type-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-black);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.template-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.template-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: background-color var(--transition-normal), border-color var(--transition-normal), color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal), opacity var(--transition-normal);
  cursor: pointer;
}

.template-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--lime-green);
}

.template-card.active {
  border-left: 4px solid var(--lime-green);
}

.template-card.inactive {
  opacity: 0.7;
}

.template-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.template-card-header h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-black);
  margin: 0;
}

.badge-active {
  background: var(--lime-green);
  color: var(--text-on-brand);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-inactive {
  background: var(--grey-light);
  color: var(--grey);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.template-card-body {
  margin-bottom: 16px;
}

.template-meta {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
  color: var(--grey);
  font-size: 0.875rem;
}

.template-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.template-settings .badge {
  background: var(--grey-light);
  color: var(--grey);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.template-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary-small,
.btn-primary-small,
.btn-danger-small {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-secondary-small {
  background: var(--grey-light);
  color: var(--text-black);
}

.btn-secondary-small:hover {
  background: var(--grey);
  color: var(--text-on-brand);
}

.btn-primary-small {
  background: var(--lime-green);
  color: var(--text-on-brand);
}

.btn-primary-small:hover {
  background: var(--lime-green-dark);
}

.btn-danger-small {
  background: var(--error);
  color: var(--text-on-brand);
}

.btn-danger-small:hover {
  background: var(--danger);
}

/* Form Builder Container */
.form-builder-container {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 20px;
  height: calc(100vh - 200px);
  overflow: hidden;
}

.builder-panel {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.builder-panel h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-black);
}

.builder-panel h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 16px 0 8px 0;
  color: var(--text-black);
}

/* Settings Panel */
.settings-panel .form-group {
  margin-bottom: 16px;
}

.settings-panel label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-black);
}

.settings-panel input[type="text"],
.settings-panel input[type="number"],
.settings-panel select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.settings-panel input[type="checkbox"] {
  margin-right: 8px;
}

.settings-panel hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* Builder Canvas */
.builder-canvas {
  display: flex;
  flex-direction: column;
}

.builder-toolbar {
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.form-sections {
  flex: 1;
  overflow-y: auto;
}

.empty-builder-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--grey);
  background: var(--grey-light);
  border-radius: var(--radius-md);
  border: 2px dashed var(--border);
}

/* Builder Section */
.builder-section {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  padding: 16px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
}

.section-actions {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: var(--grey-light);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  font-size: 0.875rem;
}

.btn-icon:hover:not(:disabled) {
  background: var(--grey);
  color: var(--text-on-brand);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Drop Zone */
.section-fields {
  min-height: 60px;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--background);
}

.section-fields.drag-over {
  border-color: var(--lime-green);
  background: var(--lime-green-light);
}

.empty-section {
  text-align: center;
  color: var(--grey);
  padding: 20px;
  font-size: 0.875rem;
}

/* Builder Field */
.builder-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.builder-field:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--lime-green);
}

.field-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-icon {
  font-size: 1.125rem;
}

.field-label {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-black);
}

.field-type-badge {
  background: var(--grey-light);
  color: var(--grey);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.field-actions {
  display: flex;
  gap: 4px;
}

.field-required-badge {
  display: inline-block;
  background: var(--error);
  color: var(--text-on-brand);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  margin-top: 4px;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--grey);
  margin-top: 4px;
}

/* Field Palette */
.fields-palette {
  padding: 16px;
}

.palette-help {
  font-size: 0.8125rem;
  color: var(--grey);
  margin-bottom: 12px;
}

.field-palette-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.palette-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.palette-field:hover {
  background: var(--lime-green-light);
  border-color: var(--lime-green);
}

.palette-field:active {
  cursor: grabbing;
}

.palette-icon {
  font-size: 1.125rem;
}

.palette-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-black);
}

/* Template Preview */
.template-preview {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
}

.template-preview h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 24px 0 16px 0;
  color: var(--text-black);
}

.template-preview h3:first-child {
  margin-top: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.setting-item {
  padding: 12px;
  background: var(--background);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.setting-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-black);
}

/* Preview Sections */
.preview-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-section {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 20px;
}

.preview-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-black);
}

.preview-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-field {
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.preview-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-black);
}

.preview-field .required-star {
  color: var(--error);
  margin-left: 2px;
}

.preview-field .field-meta {
  font-size: 0.75rem;
  color: var(--grey);
  margin: 4px 0;
}

/* Responsive Form Builder */
@media (max-width: 1280px) {
  .form-builder-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .builder-panel {
    max-height: none;
  }

  .fields-palette {
    order: -1;
  }

  .field-palette-items {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .palette-field {
    flex: 0 0 auto;
    min-width: 140px;
  }
}

/* ========================================
   FORM COMPLETION STYLES
   ======================================== */

/* Form Status Bar */
.form-status-bar {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
}

.status-item strong {
  color: var(--text-black);
}

.badge-draft {
  background: var(--grey-light);
  color: var(--grey);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-in-progress {
  background: var(--info);
  color: var(--text-on-brand);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-completed {
  background: var(--success);
  color: var(--text-on-brand);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-locked {
  background: var(--dark-grey);
  color: var(--text-on-brand);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Form Completion Container */
.form-completion-container {
  max-width: 800px;
  margin: 0 auto;
}

.form-sections-completion {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Form Section (Completion View) */
.form-section-complete {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.form-section-complete .section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-black);
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.section-fields-complete {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Form Field Group */
.form-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-black);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-field-label .required-star {
  color: var(--error);
  font-size: 1rem;
}

/* Form Inputs */
.form-field-input,
.form-field-textarea,
.form-field-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}

.form-field-input:focus,
.form-field-textarea:focus,
.form-field-select:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-green-light);
}

.form-field-input:disabled,
.form-field-textarea:disabled,
.form-field-select:disabled {
  background: var(--grey-light);
  cursor: not-allowed;
}

.form-field-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Checkbox and Radio */
.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.checkbox-label:hover,
.radio-label:hover {
  background: var(--background);
}

.form-field-checkbox,
.form-field-radio {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Photo Field */
.photo-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.photo-preview {
  min-height: 150px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
  padding: 12px;
}

.photo-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
}

.photo-preview p {
  color: var(--grey);
  font-size: 0.875rem;
}

/* Signature Field */
.signature-field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signature-canvas {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: crosshair;
  display: block;
  max-width: 100%;
}

.signature-canvas-main {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: crosshair;
  width: 100%;
  height: 200px;
}

/* Photo Upload Section */
.photo-upload-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-delete-photo {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--error);
  color: var(--text-on-brand);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  transition: opacity var(--transition-fast);
}

.btn-delete-photo:hover {
  opacity: 1;
}

.photo-upload-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.photo-count {
  font-size: 0.875rem;
  color: var(--grey);
}

/* Signature Section */
.signature-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signature-preview img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--background);
  padding: 8px;
}

.signature-controls {
  display: flex;
  gap: 8px;
}

/* Responsive Form Completion */
@media (max-width: 768px) {
  .form-completion-container {
    padding: 0;
  }

  .form-section-complete {
    padding: 16px;
  }

  .form-status-bar {
    flex-direction: column;
    gap: 12px;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .signature-canvas-main {
    height: 150px;
  }
}

/* ========================================
   FORMS GRID (IN JOBS MODULE)
   ======================================== */

.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}

.form-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--lime-green);
}

.form-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.form-card-header h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-black);
  margin: 0;
  flex: 1;
}

.form-card-body {
  margin-bottom: 12px;
  font-size: 0.8125rem;
  color: var(--grey);
}

.form-card-body p {
  margin: 4px 0;
}

.form-card-actions {
  display: flex;
  gap: 8px;
}

.empty-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--grey);
}

/* ===========================================================================
   Status / priority / job-type badges (Jobs, PPM, etc.)
   Added v8.7.8 — these classes were referenced by JS but never defined,
   so urgency/status colour-coding was silently invisible. (issues #127)
   =========================================================================== */
.badge-status-new,
.badge-status-scheduled,
.badge-status-in_progress,
.badge-status-awaiting_review,
.badge-status-awaiting_parts,
.badge-status-needs_rebook,
.badge-status-temporary_fix,
.badge-status-completed,
.badge-status-invoiced,
.badge-status-cancelled,
.badge-priority-low,
.badge-priority-normal,
.badge-priority-high,
.badge-priority-urgent,
.badge-ppm,
.badge-breakdown,
.badge-repair,
.badge-inspection,
.badge-installation {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

/* Job status */
.badge-status-new          { background: var(--indigo-tint); color: var(--indigo-deep); }
.badge-status-scheduled    { background: var(--blue-tint); color: var(--blue-deep); }
.badge-status-in_progress  { background: var(--warn-tint); color: var(--warn-deep); }
/* A3 — the engineer has finished, the office has not looked yet. Deliberately
   NOT green: it is not done, and a green badge is read as done at a glance. */
.badge-status-awaiting_review { background: var(--blue-wash); color: var(--blue-deep); }

/* ===========================================================================
   N4 — a control this role cannot use (js/utils/role-gate.js)
   Greyed rather than hidden, deliberately: a button that disappears from a page
   you are looking at reads as a fault, while a greyed one with a reason tells
   you what to do next. `pointer-events: none` is what actually stops the click
   on non-form elements, where `disabled` means nothing.
   =========================================================================== */
.is-role-gated {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(100%);
}

/* The title attribute is not reachable by keyboard or touch, so give focus a
   visible cue too — the element keeps aria-disabled for screen readers. */
.is-role-gated:focus-visible {
  outline: 2px solid var(--dark-grey, #6b7280);
  outline-offset: 2px;
}

/* N2 — an invoice with no customer PO. Quiet on purpose: this is a prompt, not
   an error. Plenty of customers never issue one, and a red row for every such
   invoice trains people to ignore the column. */
.po-missing {
  margin-left: 8px;
  font-size: 0.7rem;
  vertical-align: middle;
}
.badge-status-awaiting_parts { background: var(--warn-tint); color: var(--warn-deep); }
.badge-status-needs_rebook { background: var(--danger-tint); color: var(--danger-strong); }
.badge-status-temporary_fix { background: var(--violet-tint); color: var(--violet-deep); }
.badge-status-completed    { background: var(--ok-tint); color: var(--ok-deep); }
.badge-status-invoiced     { background: var(--teal-tint); color: var(--ok-deep); }
.badge-status-cancelled    { background: var(--surface-inset); color: var(--text-muted); }

/* Priority */
.badge-priority-low        { background: var(--surface-inset); color: var(--text-muted); }
.badge-priority-normal     { background: var(--blue-tint); color: var(--blue-deep); }
.badge-priority-high       { background: var(--warn-tint); color: var(--warn-deep); }
.badge-priority-urgent     { background: var(--danger-tint); color: var(--danger-strong); }

/* Entrapment — someone trapped in a lift. Deliberately louder than any
   priority badge: this is the only life-safety flag in the system. */
.entrapment-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--danger-strong);
  color: var(--text-on-brand);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.row-entrapment { background: var(--danger-wash) !important; }

.entrapment-banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 6px;
  border-left: 5px solid var(--danger-strong);
  background: var(--danger-wash);
  color: var(--danger-deep);
  font-size: 0.95rem;
}

.entrapment-field {
  padding: 10px 12px;
  border: 1px solid var(--danger-tint);
  border-radius: 6px;
  background: var(--danger-wash);
}

.entrapment-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--danger-deep);
  cursor: pointer;
}

.entrapment-check input { width: auto; margin: 0; }

.entrapment-hint,
.field-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Job type */
.badge-ppm                 { background: var(--blue-tint); color: var(--blue-deep); }
.badge-breakdown           { background: var(--danger-tint); color: var(--danger-strong); }
.badge-repair              { background: var(--warn-tint); color: var(--warn-deep); }
.badge-inspection          { background: var(--violet-tint); color: var(--violet-deep); }
.badge-installation        { background: var(--ok-tint); color: var(--ok-deep); }

/* Urgent stat-card highlight (Jobs dashboard) */
.stat-card.stat-urgent {
  border: 1px solid var(--danger-soft);
  background: var(--danger-wash);
}

/* Table row urgency highlighting (PPM / Contracts / Inventory) */
.data-table tr.row-warning,
tr.row-warning { background: var(--warn-wash); }
.data-table tr.row-warning:hover,
tr.row-warning:hover { background: var(--warn-tint); }
.data-table tr.row-danger,
tr.row-danger { background: var(--danger-wash); }
.data-table tr.row-danger:hover,
tr.row-danger:hover { background: var(--danger-tint); }

/* Invoice builder live line total (was unstyled — only .line-item-subtotal existed) */
.line-item-total {
  font-weight: 600;
}

/* ===========================================================================
   Notifications module (v8.8.0 — module wired up; markup now rendered)
   =========================================================================== */
.notification-stats {
  display: flex;
  gap: 24px;
  margin: 8px 0 16px;
  color: var(--grey);
  font-size: 0.875rem;
}
.notification-stats strong { color: var(--text-black); }

.notification-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.notification-filter-tab {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: 999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}
.notification-filter-tab:hover { background: var(--hover); }
.notification-filter-tab.active {
  background: var(--lime-green);
  border-color: var(--lime-green);
  color: var(--text-on-brand);
}

.notification-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: var(--surface);
}
.notification-item.unread { border-left: 3px solid var(--lime-green); background: var(--surface-muted); }
.notification-icon { font-size: 1.25rem; }
.notification-content { flex: 1; }
.notification-header { display: flex; justify-content: space-between; gap: 12px; }
.notification-title { font-weight: 600; color: var(--text-black); }
.notification-time { color: var(--grey); font-size: 0.75rem; white-space: nowrap; }
.notification-message { color: var(--dark-grey); font-size: 0.875rem; margin-top: 2px; }
.notification-actions { display: flex; gap: 4px; align-items: flex-start; }

/* ===========================================================================
   Leads pipeline / kanban (v8.8.0 — module wired up; markup now rendered)
   =========================================================================== */
.pipeline-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.pipeline-stat {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--lime-green);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.pipeline-stat .stat-value { font-size: 1.375rem; font-weight: 700; color: var(--text-black); }
.pipeline-stat .stat-label { font-size: 0.75rem; color: var(--grey); text-transform: uppercase; }
.pipeline-stat .stat-amount { font-size: 0.8125rem; color: var(--dark-grey); margin-top: 4px; }

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: start;
}
.pipeline-column {
  background: var(--background);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 120px;
}
.pipeline-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 10px;
  font-weight: 600;
  color: var(--text-black);
}
.column-count {
  background: var(--grey-light);
  color: var(--grey);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
}
.pipeline-empty { color: var(--grey); font-size: 0.8125rem; text-align: center; padding: 16px 0; }

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}
.lead-card:hover { box-shadow: var(--shadow-md); }
.lead-card.urgency-high { border-left: 3px solid var(--warning); }
.lead-card.urgency-urgent { border-left: 3px solid var(--error); }
.lead-card-header { display: flex; justify-content: space-between; gap: 8px; }
.lead-title { font-weight: 600; color: var(--text-black); }
.lead-value { font-weight: 700; color: var(--lime-green); white-space: nowrap; }
.lead-company { color: var(--dark-grey); font-size: 0.8125rem; margin: 2px 0 6px; }
.lead-contact { color: var(--grey); font-size: 0.75rem; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lead-badge {
  background: var(--grey-light);
  color: var(--grey);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.6875rem;
}
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lead-action-btn {
  flex: 1;
  min-width: 64px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
}
.lead-action-btn:hover { background: var(--hover); }
.lead-action-btn.convert { background: var(--lime-green); border-color: var(--lime-green); color: var(--text-on-brand); }
.lead-action-btn.lost { color: var(--error); }

/* ===========================================================================
   Confirm dialog (v8.9.4 — these rules lived only in the unloaded app.css, so
   every confirm rendered unstyled). Ported into the loaded sheet. (issue: CIC)
   =========================================================================== */
.confirm-dialog {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  animation: confirmFadeIn 0.2s forwards;
}
.confirm-dialog-content {
  background-color: var(--text-on-brand);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9);
  animation: confirmScaleIn 0.2s forwards;
}
@keyframes confirmFadeIn { to { opacity: 1; } }
@keyframes confirmScaleIn { to { transform: scale(1); } }
.confirm-dialog-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.confirm-dialog-icon.danger { background-color: var(--danger-tint); color: var(--danger); }
.confirm-dialog-icon.warning { background-color: var(--warn-tint); color: var(--warn-strong); }
.confirm-dialog-icon.info { background-color: var(--brand-primary-light); color: var(--brand-primary); }
.confirm-dialog-title {
  font-size: 1.125rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-black);
}
.confirm-dialog-message {
  font-size: 0.875rem;
  text-align: center;
  color: var(--dark-grey);
  margin-bottom: 24px;
  line-height: 1.5;
}
.confirm-dialog-actions { display: flex; gap: 12px; justify-content: center; }
.confirm-dialog-actions button {
  flex: 1;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast), opacity var(--transition-fast);
}
.confirm-dialog-actions .btn-confirm { background-color: var(--brand-primary); color: var(--text-on-brand); }
.confirm-dialog-actions .btn-confirm:hover { background-color: var(--brand-primary-dark); }
.confirm-dialog-actions .btn-confirm.danger { background-color: var(--danger); }
.confirm-dialog-actions .btn-confirm.danger:hover { background-color: var(--danger-strong); }
.confirm-dialog-actions .btn-cancel { background-color: var(--surface-inset); color: var(--text-body); }
.confirm-dialog-actions .btn-cancel:hover { background-color: var(--line); }

/* ===== Sidebar nav sections (grouped, scannable menu) ===== */
.nav-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--surface-inset);
}
.nav-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px 2px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  /* P3-6 (UX audit): #9AA0A6 on white at 11px bold measured 2.64:1 — WCAG needs
     4.5:1. #5F6368 measures ~5.9:1 and keeps the same quiet, secondary feel. */
  color: var(--text-muted);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.nav-section-title:hover {
  color: var(--text-strong);
}
/* Chevron indicates expand/collapse; rotates when the section is collapsed */
.nav-section-title::after {
  content: '▾';
  font-size: 0.5625rem;
  opacity: 0.7;
  transition: transform 0.15s ease;
}
.nav-section.collapsed .nav-section-title::after {
  transform: rotate(-90deg);
}
/* Collapsed section hides its nav items */
.nav-section.collapsed .nav-item {
  display: none;
}
/* Hide section labels when the sidebar is collapsed to icons... */
.sidebar.collapsed .nav-section-title {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}
/* ...and in icon-only mode always show the icons (the headers aren't clickable there) */
.sidebar.collapsed .nav-section.collapsed .nav-item {
  display: flex;
}

/* ============================================================================
   NEEDS ATTENTION  (roadmap N1)
   One screen showing work that has already stalled. Read-only by design: every
   row deep-links to the record it came from, so this never becomes a second
   place to work. See public/js/modules/attention.js.
   ============================================================================ */

.module-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-black);
  margin: 0;
}

.attention-subhead {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--dark-grey);
}

.attention-summary {
  padding: var(--spacing-lg) var(--spacing-lg) 0;
}

.attention-totals,
.attention-allclear {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.9375rem;
}

.attention-totals {
  background: var(--brand-primary-light);
  border: 1px solid var(--brand-primary);
  color: var(--blue-deep);
}

.attention-allclear {
  background: var(--ok-wash);
  border: 1px solid var(--success);
  color: var(--ok-deep);
  font-weight: 600;
}

.attention-error-inline { color: var(--error); }

.attention-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  align-items: start;
}

.attention-card {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  border-left: 4px solid var(--brand-primary);
  overflow: hidden;
}

.attention-card--money  { border-left-color: var(--blue); }
.attention-card--ops    { border-left-color: var(--violet); }
.attention-card--safety { border-left-color: var(--error); }
.attention-card--sales  { border-left-color: var(--warn); }

/* A cleared section stays on screen rather than disappearing — "nothing
   outstanding" is information, and a section vanishing looks like a bug. */
.attention-card--clear { opacity: 0.72; }
.attention-card--error { border-left-color: var(--error); }

.attention-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-color);
}

.attention-card-icon { font-size: 1.375rem; line-height: 1; }
.attention-card-heading { flex: 1; min-width: 0; }

.attention-card-heading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-black);
}

.attention-card-heading p {
  margin: 3px 0 0;
  font-size: 0.8125rem;
  color: var(--dark-grey);
  line-height: 1.4;
}

.attention-count {
  flex-shrink: 0;
  min-width: 32px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--grey-light);
  color: var(--text-black);
  font-weight: 700;
  font-size: 0.9375rem;
  text-align: center;
}

.attention-card--clear .attention-count {
  background: var(--ok-tint);
  color: var(--ok-deep);
}

.attention-card-body { padding: 6px 0; max-height: 420px; overflow-y: auto; }

.attention-list { list-style: none; margin: 0; padding: 0; }

.attention-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.attention-row:hover {
  background: var(--hover);
  border-left-color: var(--brand-primary);
}

/* P3-1: this used to share the :hover rule AND set `outline: none`, so a
   keyboard user tabbing through Needs Attention got a faint background change
   and nothing else — the global :where(...):focus-visible rule has zero
   specificity and loses to this selector. A hover tint is not a focus
   indicator. WCAG 2.4.7. */
.attention-row:focus-visible {
  background: var(--hover);
  border-left-color: var(--brand-primary);
  outline: 2px solid var(--brand-primary);
  outline-offset: -2px;
}

.attention-row--critical { background: var(--danger-wash); }
.attention-row--critical:hover { background: var(--danger-tint); }

.attention-row-main { display: flex; flex-direction: column; min-width: 0; }

/* Wraps rather than truncating. Ellipsis clipped the END of the line — which on
   these rows is the amount ("INV-1772797545057 — …") or how badly a certificate
   has lapsed ("LIFT 2 — Insurance expired …"). On a money-and-safety screen the
   clipped half was the half that mattered. */
.attention-row-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-black);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.attention-row-sub { font-size: 0.78125rem; color: var(--dark-grey); }

.attention-row-age {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--dark-grey);
  white-space: nowrap;
}

.attention-row--critical .attention-row-age {
  color: var(--error);
  font-weight: 600;
}

.attention-clear,
.attention-loading,
.attention-error {
  margin: 0;
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--dark-grey);
}

.attention-clear { color: var(--ok-deep); font-weight: 500; }
.attention-error { color: var(--error); }

@media (max-width: 640px) {
  .attention-sections { grid-template-columns: 1fr; padding: var(--spacing-md); }
  .attention-row { flex-wrap: wrap; }
}

/* ============================================================================
   AUDIT 2026-08-19 — classes referenced by the modules with NO rule anywhere
   (findings C-18, F-16, X-01). Each block below styles selectors that were
   already being written into the markup and resolving to nothing.
   ============================================================================ */

/* --- F-16: standalone button variants -------------------------------------
   There is no base `.btn` rule in this stylesheet. `.btn-danger` and
   `.btn-success` only ever set colours, so a `<button class="btn-danger">` used
   on its own (Contract detail, Engineer detail) rendered as a browser-default
   button with a red fill. Scoped with :not(.btn-icon) because .btn-danger is
   also used as a modifier on icon buttons, which must stay square. */
button.btn-danger:not(.btn-icon),
button.btn-success:not(.btn-icon) {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}
button.btn-danger:not(.btn-icon):hover,
button.btn-success:not(.btn-icon):hover { transform: translateY(-1px); }

/* C-18c: `.btn-success` is used in quotes, contracts, invoices and diary and had
   no rule at all. */
.btn-success {
  background-color: var(--success, #4caf50);
  color: var(--white, #fff);
}
.btn-success:hover { background-color: var(--ok); }

/* --- C-18b: the page-* layout convention ----------------------------------
   `.page-view`, `.page-header`, `.page-content` and `.page-detail` are written
   by invoices, recurring-invoices, quotes, contracts and engineers, and had ZERO
   rules — those pages fell back to raw document flow. */
.page-view { display: block; }
.page-view[hidden], .page-view.hidden { display: none; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  margin-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}
.page-header h1, .page-header h2 { margin: 0; }

.page-content,
.page-detail {
  background: var(--white, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-lg, 24px);
  min-width: 0;                 /* keeps wide tables inside their own scroller */
}

.detail-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  align-items: center;
}

/* --- X-01 / C-18a: clickable rows -----------------------------------------
   `.data-table tbody tr:hover` already supplies the hover fill and pointer
   cursor for EVERY row — which is why non-clickable rows looked clickable. The
   rows are now genuinely clickable (utils/row-click.js); what was missing is a
   keyboard focus ring, since no row was reachable without a mouse. */
.clickable-row { cursor: pointer; }
.clickable-row:focus-visible {
  outline: 2px solid var(--brand-primary, #2563EB);
  outline-offset: -2px;
}

/* --- C-18: filter bars on ppm / quotes / contracts ------------------------- */
.filters-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  background: var(--white, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.filter-search {
  flex: 1 1 220px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}
.filter-search:focus-visible {
  outline: 2px solid var(--brand-primary, #2563EB);
  outline-offset: 1px;
}

/* --- C-18d: the PPM detail modal ------------------------------------------
   Its whole content was unstyled: it failed to open (missing index), would blank
   on any history error, AND had no rules once it did open. */
.ppm-details, .contract-details { display: grid; gap: var(--spacing-lg, 24px); }
.tasks-list { margin: 0; padding-left: 1.25rem; display: grid; gap: 4px; }
.engineers-list, .linked-ppms-list { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-color);
}
.history-item:last-child { border-bottom: none; }
.text-primary { color: var(--brand-primary, #2563EB); }

/* --- C-18: modal footers -------------------------------------------------- */
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  padding-top: var(--spacing-md);
  margin-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

@media (max-width: 640px) {
  .page-header { align-items: flex-start; flex-direction: column; }
  .modal-actions { justify-content: stretch; }
  .modal-actions > * { flex: 1 1 auto; }
}

/* --- C-18: remaining module-local classes with no rule --------------------- */

/* quotes — the service library picker and line-item header */
.quotes-view .btn-sm, .btn-sm { padding: 6px 12px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-md);
}
.line-items-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-md); margin-bottom: var(--spacing-sm);
}
.service-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--spacing-sm);
}
.service-library-category { margin-bottom: var(--spacing-md); }
.service-library-items { display: contents; }
.service-library-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
  background: var(--white, #fff);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.service-library-item:hover { border-color: var(--brand-primary, #2563EB); box-shadow: var(--shadow-sm); }
.service-library-item:focus-visible { outline: 2px solid var(--brand-primary, #2563EB); outline-offset: 2px; }
.service-library-item-header { display: flex; justify-content: space-between; gap: var(--spacing-sm); }
.service-library-item-name { font-weight: 600; }
.service-library-item-price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.service-library-item-desc { font-size: 0.8125rem; color: var(--text-muted, #6b7280); }

/* invoices — detail body and totals (the v8.35 reference look relied on these) */
.invoice-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 4px; }
.invoice-description { color: var(--text-muted, #6b7280); margin-bottom: var(--spacing-md); }
.invoice-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg, 24px);
}
.invoice-line-items-table { width: 100%; border-collapse: collapse; }
.invoice-line-items-table th, .invoice-line-items-table td {
  padding: 10px 12px; border-bottom: 1px solid var(--border-color); text-align: left;
}
.invoice-line-items-table td:last-child, .invoice-line-items-table th:last-child {
  text-align: right; font-variant-numeric: tabular-nums;
}
.invoice-total-row {
  display: flex; justify-content: flex-end; gap: var(--spacing-lg, 24px);
  padding: 6px 12px; font-variant-numeric: tabular-nums;
}
.invoice-total-final {
  display: flex; justify-content: flex-end; gap: var(--spacing-lg, 24px);
  padding: 10px 12px; margin-top: 4px;
  border-top: 2px solid var(--border-color);
  font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums;
}

/* forms builder */
.module-header-left { display: flex; flex-direction: column; gap: 2px; }
.module-header-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }
.module-subtitle { color: var(--text-muted, #6b7280); font-size: 0.875rem; }
.section-description { color: var(--text-muted, #6b7280); font-size: 0.8125rem; margin-bottom: var(--spacing-sm); }
.signature-section {
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
}

/* diary */
.engineer-item {
  display: flex; align-items: center; gap: var(--spacing-sm);
  padding: 6px 8px; border-radius: var(--radius-sm);
}
.engineer-item:hover { background: var(--brand-primary-light, #DBEAFE); }

/* --- LED-01: per-card stage selector on the leads board -------------------- */
.lead-stage-picker { display: inline-flex; align-items: center; }
.lead-stage-select {
  padding: 4px 8px;
  font-size: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--white, #fff);
  cursor: pointer;
  max-width: 110px;
}
.lead-stage-select:focus-visible { outline: 2px solid var(--brand-primary, #2563EB); outline-offset: 1px; }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Screen-reader-only label text (the stage select needs a name, without adding
   visible clutter to an already dense card). */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* --- ENG-02: inline notes editor on the engineer detail page --------------- */
.info-card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-md); margin-bottom: var(--spacing-sm);
}
.info-card-header h3 { margin: 0; }
.notes-inline-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font: inherit;
  resize: vertical;
}
.notes-inline-input:focus-visible {
  outline: 2px solid var(--brand-primary, #2563EB);
  outline-offset: 1px;
}

/* --- X-02: shared ⋮ row action menu (utils/row-menu.js) --------------------
   Lifted out of the inline <style> block in invoices.js so every list can use
   the same menu. position:fixed so the table container's overflow cannot clip
   it; utils/row-menu.js places it from the toggle's rect. */
.row-menu-toggle {
  font-size: 1.25rem;
  line-height: 1;
  padding: 2px 10px;
  border-radius: var(--radius-md);
}
.row-menu-dropdown {
  display: none;
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  padding: 6px;
  background: var(--white, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.row-menu-dropdown.open { display: block; }
.row-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  font: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.row-menu-dropdown button:hover { background: var(--surface-inset); }
.row-menu-dropdown button:focus-visible {
  outline: 2px solid var(--brand-primary, #2563EB);
  outline-offset: -2px;
}
.row-menu-dropdown button.danger { color: var(--danger); }
.row-menu-dropdown button.danger:hover { background: var(--danger-wash); }

/* --- DSH-01: Needs Attention summary on the Dashboard ---------------------- */
.attention-summary {
  margin-top: var(--spacing-lg, 24px);
  background: var(--white, #fff);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-lg, 24px);
}
.attention-summary-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--spacing-md); margin-bottom: var(--spacing-md);
}
.attention-summary-header h2 { margin: 0; font-size: 1.125rem; }
.attention-summary-all { font-size: 0.875rem; font-weight: 600; color: var(--brand-primary, #2563EB); text-decoration: none; }
.attention-summary-all:hover { text-decoration: underline; }

.attention-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--spacing-md);
}
.attention-summary-tile {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  background: var(--surface-muted);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.attention-summary-tile:hover { border-color: var(--brand-primary, #2563EB); box-shadow: var(--shadow-sm); }
.attention-summary-tile:focus-visible { outline: 2px solid var(--brand-primary, #2563EB); outline-offset: 2px; }
/* A count of zero must not shout for attention — only rows with work do. */
.attention-summary-tile.has-items { background: var(--warn-wash); border-color: var(--warn-tint); }
.attention-summary-icon { font-size: 1.125rem; }
.attention-summary-count { font-size: 1.625rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.attention-summary-title { font-size: 0.8125rem; color: var(--text-muted, #6b7280); }
.attention-summary-error { font-size: 0.75rem; color: var(--warn-strong); }
.attention-summary-clear { margin: 0; color: var(--text-muted, #6b7280); }

@media (max-width: 640px) {
  .attention-summary-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

/* ==========================================================================
   NS3 DESIGN SYSTEM — the shared partials (UX audit Sprint 3, P2-3)
   --------------------------------------------------------------------------
   Everything below styles the output of js/utils/ui.js and js/utils/icons.js.
   The audit found four visual languages in one product; these rules are the
   one language they collapse into, taken from the invoice detail — the
   reference look agreed in v8.35.0.

   The `ns3-` prefix is deliberate. Class names like .card, .badge and .table
   already exist here with page-specific meanings, and reusing them would make
   the shared components inherit whichever page they happened to land on —
   exactly the divergence this file is meant to end.
   ========================================================================== */

:root {
  /* Tone ramp for badges and status. Six tones, one meaning each — see the
     STATUS_TONE map in ui.js for which status uses which. */
  --tone-neutral-bg: #f1f5f9;
  --tone-neutral-fg: #475569;
  --tone-neutral-br: #e2e8f0;
  --tone-info-bg: #dbeafe;
  --tone-info-fg: #1e40af;
  --tone-info-br: #bfdbfe;
  --tone-success-bg: #dcfce7;
  --tone-success-fg: #166534;
  --tone-success-br: #bbf7d0;
  --tone-warning-bg: #fef3c7;
  --tone-warning-fg: #92400e;
  --tone-warning-br: #fde68a;
  --tone-danger-bg: #fee2e2;
  --tone-danger-fg: #991b1b;
  --tone-danger-br: #fecaca;

  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text-strong: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --line: #e2e8f0;
}

/* --- icons ---------------------------------------------------------------
   Inline SVG replacing the emoji set (P2-1). `currentColor` is the whole
   point: an icon now takes the colour of the button, link or badge it sits in,
   which no emoji could ever do. `flex-shrink: 0` because these sit next to
   labels that are allowed to truncate and the icon must not. */
.ns3-icon {
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}

/* --- visually hidden (labels, captions, skip link) ----------------------- */
.ns3-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Skip link (P3-2): first focusable element on the page, invisible until it
   has focus. A keyboard user should not have to tab through 20 nav links to
   reach the table they came for. */
.ns3-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--brand-primary);
  color: var(--text-on-brand);
  border-radius: 0 0 var(--radius-md) 0;
  font-weight: 600;
  text-decoration: none;
}
.ns3-skip-link:focus {
  left: 0;
}

/* --- badges (P2-5) ------------------------------------------------------- */
.ns3-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.ns3-badge-neutral { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); border-color: var(--tone-neutral-br); }
.ns3-badge-info    { background: var(--tone-info-bg);    color: var(--tone-info-fg);    border-color: var(--tone-info-br); }
.ns3-badge-success { background: var(--tone-success-bg); color: var(--tone-success-fg); border-color: var(--tone-success-br); }
.ns3-badge-warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); border-color: var(--tone-warning-br); }
.ns3-badge-danger  { background: var(--tone-danger-bg);  color: var(--tone-danger-fg);  border-color: var(--tone-danger-br); }

/* --- buttons ------------------------------------------------------------- */
.ns3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-body);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  /* P3-9: named properties, not `transition: all`. `all` animates layout
     properties too, which is what made large tables jank. */
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast);
}
.ns3-btn:hover:not(:disabled) { background: var(--surface-muted); border-color: var(--line-strong); }
.ns3-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ns3-btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-on-brand);
}
.ns3-btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}
.ns3-btn-danger { background: var(--danger); border-color: var(--danger); color: var(--text-on-brand); }
.ns3-btn-danger:hover:not(:disabled) { background: var(--danger-strong); border-color: var(--danger-strong); }
.ns3-btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.ns3-btn-ghost:hover:not(:disabled) { background: var(--surface-muted); color: var(--text-body); }

/* --- page header (P2-3, P3-4) -------------------------------------------- */
.ns3-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--line);
}
.ns3-page-heading { min-width: 0; }
.ns3-page-header h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.25;
}
.ns3-page-icon { color: var(--brand-primary); }
.ns3-page-subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.ns3-page-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }

/* Breadcrumbs. The separator is CSS — contracts.js used to ALSO emit a literal
   ">" as its own item, so the trail read "Contracts › > › Contract Details"
   (P2-14). Emitting it here means a module cannot get it wrong again. */
.ns3-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.ns3-breadcrumbs li + li::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 6px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
  vertical-align: middle;
  opacity: 0.7;
}
.ns3-breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.ns3-breadcrumbs a:hover { color: var(--brand-primary); text-decoration: underline; }
.ns3-breadcrumbs [aria-current='page'] { color: var(--text-body); font-weight: 600; }

/* --- filter bar (P2-4, P2-8, P3-5) --------------------------------------- */
.ns3-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.ns3-filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ns3-filter-search { flex: 1 1 260px; }
.ns3-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ns3-search-wrap { position: relative; display: block; }
.ns3-search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.ns3-filter-bar .ns3-input,
.ns3-filter-bar .ns3-select {
  width: 100%;
  /* P2-4: these were raw browser inputs about 100px wide on four pages, with
     the placeholder clipped mid-word ("Search by company, cor"). */
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-body);
}
.ns3-filter-bar .ns3-input { padding-left: 34px; }
.ns3-filter-bar .ns3-select {
  min-width: 150px;
  /* P2-8: style the select ourselves — the Reports date range was the one raw
     native control left among styled ones, and it showed. */
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.ns3-filter-bar .ns3-input:focus,
.ns3-filter-bar .ns3-select:focus {
  outline: none;
  border-color: var(--brand-primary);
  /* P3-1 note: the old input ring was rgba(142,189,109,0.1) — 10% alpha, which
     is effectively invisible. This one can actually be seen. */
  box-shadow: 0 0 0 3px var(--brand-alpha);
}
.ns3-filter-actions { display: flex; gap: var(--spacing-sm); margin-left: auto; }

/* --- tables (P1-3, P2-7, P2-12) ------------------------------------------ */
.ns3-table-wrap {
  /* The table scrolls inside itself; the PAGE never scrolls sideways. */
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.ns3-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.ns3-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 11px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.ns3-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text-body);
  vertical-align: middle;
}
.ns3-table tbody tr:last-child td { border-bottom: 0; }
.ns3-table tbody tr:hover { background: var(--surface-muted); }
/* P2-12: JOB-2026-0101 was breaking across three lines in a narrow first
   column. Reference numbers never wrap. */
.ns3-nowrap { white-space: nowrap; }

/* P2-12: JOB-2026-0101 broke across THREE lines in a narrow first column.
   nowrap alone is not enough — the column also has to be allowed the width,
   or the browser squeezes it and the rest of the row overflows instead. */
.ns3-col-id { white-space: nowrap; width: 1%; min-width: 8.5rem; }
.ns3-align-right { text-align: right; }
.ns3-align-center { text-align: center; }
.ns3-muted { color: var(--text-muted); }

/* Row actions — icon + label, outlined: the Sites treatment, which the audit
   judged the best of the three in use (P2-7). */
.ns3-row-actions-cell { white-space: nowrap; }
.ns3-row-actions { display: inline-flex; gap: 6px; }
.ns3-row-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
    border-color var(--transition-fast);
}
.ns3-row-action:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.ns3-row-action-danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.ns3-row-action:disabled { opacity: 0.45; cursor: not-allowed; }

/* Below 900px the labels go and the icons stay — the buttons keep their
   aria-label, which is why renderRowActions sets one even when text is
   visible. */
@media (max-width: 1024px) {
  .ns3-row-action-label { display: none; }
  .ns3-row-action { padding: 6px; }
}

/* --- empty state (P2-13) ------------------------------------------------- */
.ns3-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.ns3-empty-icon { color: var(--line-strong); }
.ns3-empty h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-strong); }
.ns3-empty p { margin: 0; max-width: 46ch; color: var(--text-muted); font-size: 0.875rem; }
.ns3-empty .ns3-btn { margin-top: 6px; }

/* --- detail pages (P2-3 styles B and D) ---------------------------------- */
.ns3-detail-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  /* Flat, not the blue gradient banner that made Client detail look like it
     came from a different product (P2-3 style D, and code-health item 4). */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.ns3-hero-main { min-width: 0; }
.ns3-hero-title { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ns3-hero-title h1 { margin: 0; font-size: 1.375rem; font-weight: 700; color: var(--text-strong); }
.ns3-hero-subtitle { margin: 6px 0 0; color: var(--text-muted); font-size: 0.9375rem; }
.ns3-hero-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }
.ns3-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
  margin: var(--spacing-md) 0 0;
}
.ns3-hero-meta dt {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.ns3-hero-meta dd { margin: 3px 0 0; font-size: 0.9375rem; color: var(--text-strong); font-weight: 600; }

.ns3-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--spacing-lg);
  align-items: start;
}
.ns3-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.ns3-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: 14px var(--spacing-lg);
  border-bottom: 1px solid var(--line);
}
.ns3-card-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-strong);
}
.ns3-card-header h2 .ns3-icon { color: var(--text-muted); }
.ns3-card-actions { display: flex; gap: var(--spacing-sm); }
.ns3-card-body { padding: var(--spacing-lg); }

/* Definition lists, not "**Label:** value" paragraphs. Contract Details was
   rendering markdown into innerHTML, so the asterisks were literally on
   screen (P2-3 style B). */
.ns3-field-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md) var(--spacing-lg);
  margin: 0;
}
.ns3-field { min-width: 0; }
.ns3-field-wide { grid-column: 1 / -1; }
.ns3-field dt {
  margin: 0 0 3px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.ns3-field dd {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}

/* Yes/no values. Contract Details showed a bare ❌ emoji, which reads as
   ambiguous on screen and as nothing useful to a screen reader. */
/* Standalone value-colour utilities. These existed ONLY as scoped rules
   (.metric-value.text-success, .data-table tbody td.text-success), so a
   <span class="text-success"> anywhere else — Contract Details profit and
   margin — rendered in the default colour and the class did nothing. Same
   family as the missing .badge rules found on 2026-08-19. */
.text-success { color: var(--ok-deep); font-weight: 600; }
.text-danger  { color: var(--danger-strong); font-weight: 600; }
.text-muted   { color: var(--text-muted); }

.ns3-bool { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.ns3-bool-yes { color: var(--ok-deep); }
.ns3-bool-no { color: var(--text-muted); }

/* A list of records linked to the one being viewed (Contract Details → linked
   PPM schedules). Was a <ul> whose bullet was a 🔧 emoji inside a badge. */
/* Free text inside a detail card — issue descriptions, internal notes. The old
   markup carried style="white-space: pre-wrap" inline on each one. */
.ns3-prose {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ns3-linked-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.ns3-linked-list li {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--border-light, #eef0f4);
  font-size: 0.875rem;
  min-width: 0;
}
.ns3-linked-list li:last-child { border-bottom: 0; }
.ns3-linked-list li > span:first-of-type { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ns3-linked-list .ns3-muted { flex: none; }

@media (max-width: 640px) {
  .ns3-page-header { align-items: flex-start; flex-direction: column; }
  .ns3-page-actions { width: 100%; }
  .ns3-filter-actions { margin-left: 0; width: 100%; }
  .ns3-detail-hero { flex-direction: column; }
}

/* ==========================================================================
   LEGACY BADGE CLASSES — the missing half of P2-5
   --------------------------------------------------------------------------
   The audit reported statuses rendering as "plain lowercase text" on Quotes,
   Invoices, PPM, Parts, Contracts, Engineers, Clients and Subcontractors. The
   modules were NOT missing badge markup — every one of them emits
   `<span class="badge badge-secondary">…</span>` already. The stylesheet simply
   had no rule for any of these classes:

     .badge  .badge-primary  .badge-secondary  .badge-info
     .badge-success  .badge-warning  .badge-danger
     .status-active  .status-inactive

   Zero matches, all of them — so the span rendered as bare inline text and the
   status read as raw data (`draft`, `overdue`, `active`). Exactly the shape of
   audit C-18: a class referenced in code with no rule anywhere.

   Fixing it here rather than in eight modules means the pages converge on the
   same tone ramp as renderStatusBadge() without any of them being rewritten.
   The already-styled families (.badge-active, .badge-status-*, .badge-draft,
   .badge-in-progress, .badge-completed, .badge-locked) keep their own colours —
   they were never broken, and changing them was not asked for.
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge-secondary,
.status-inactive { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); border-color: var(--tone-neutral-br); }
.badge-info,
.badge-primary   { background: var(--tone-info-bg);    color: var(--tone-info-fg);    border-color: var(--tone-info-br); }
.badge-success,
.status-active   { background: var(--tone-success-bg); color: var(--tone-success-fg); border-color: var(--tone-success-br); }
.badge-warning   { background: var(--tone-warning-bg); color: var(--tone-warning-fg); border-color: var(--tone-warning-br); }
.badge-danger    { background: var(--tone-danger-bg);  color: var(--tone-danger-fg);  border-color: var(--tone-danger-br); }

/* .status-active / .status-inactive are also applied WITHOUT .badge — the
   engineers list sets both classes, but the engineer detail view sets only the
   status class — so they need the pill shape themselves. */
.status-active,
.status-inactive {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

/* ==========================================================================
   FILTER BARS — the rest of P2-4 and P2-8
   --------------------------------------------------------------------------
   `.filters-section`, `.filter-search` and `.filter-select` were already
   styled. Two classes the same markup uses were not:

     .filter-group   16 uses across assets, contracts, inventory, ppm, quotes
                     — zero rules, so its label and control ran together inline
     .filter-input   subcontractors' search box — zero rules, which is why the
                     audit saw a raw ~100px browser input with the placeholder
                     clipped mid-word ("Search by company, cor")

   Same lesson as the badge block above: the modules were emitting the right
   markup and the stylesheet had nothing to say about it.
   ========================================================================== */

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.filter-group > label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* The search group takes the slack so the box is never the ~100px the audit
   measured. */
.filter-group:has(.filter-search),
.filter-group:has(.filter-input) {
  flex: 1 1 260px;
}
/* ⚠️ `.filter-search` carries `flex: 1 1 220px` for a ROW of filters. Inside a
   `.filter-group`, which is a COLUMN, that basis became its HEIGHT — the PPM and
   Quotes search boxes were 220px tall (2026-10-13). A search with no label above it
   sits on the same line as the selects beside it. */
.filter-group > .filter-search,
.filter-group > .filter-input {
  flex: 0 0 auto;
}
.filter-group:has(> .filter-search:only-child),
.filter-group:has(> .filter-input:only-child) {
  align-self: flex-end;
}

.filter-input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
}
.filter-search,
.filter-input {
  width: 100%;
}
.filter-input:focus,
.filter-search:focus {
  outline: none;
  border-color: var(--brand-primary);
  /* The old ring was rgba(142,189,109,0.1) — 10% alpha of a colour the app no
     longer even uses as its primary. It was invisible (P3-1). */
  box-shadow: 0 0 0 3px var(--brand-alpha);
}

/* P2-8: the Reports date range was a raw native <select> sitting among styled
   ones. Styling the class means every select in a filter bar matches, whichever
   page it is on. */
.filter-select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.filter-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-alpha);
}

/* P2-8: native checkboxes were 13px OS defaults — including the entrapment
   flag, which is a safety-critical control sitting inside a red banner. */
input[type='checkbox'],
input[type='radio'] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* Tone classes for the icons that REPLACED coloured emoji (P2-1).
   🔴 🟠 🟡 🟢 🔵 ✅ ❌ 🚨 ⚠️ were carrying their meaning in their colour —
   priority, health, pass/fail. A monochrome SVG in their place would have been
   a tidier-looking regression, so these keep the colour and add a shape. */
.ns3-dot-danger  { color: var(--danger); }
.ns3-dot-warning { color: var(--orange); }
.ns3-dot-caution { color: var(--warn-strong); }
.ns3-dot-success { color: var(--ok); }
.ns3-dot-info    { color: var(--brand); }
.ns3-dot-muted   { color: var(--text-faint); }

/* ==========================================================================
   INLINE FORM VALIDATION — UX audit P2-9 / P2-10
   --------------------------------------------------------------------------
   Every form used to lean on native browser validation, so a missing field got
   the OS tooltip "Please fill in this field." — unbranded, one field at a time,
   gone on the next click, with no inline state left behind. These are the
   styles for js/utils/form-validate.js, which replaces it.
   ========================================================================== */

/* The offending control. Border AND a ring, so it is not colour alone. */
.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.is-invalid:focus {
  outline: none;
  border-color: var(--danger-strong) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.28);
}

/* The message under the field. Carries an icon glyph in ::before rather than a
   colour alone — red text on its own is invisible to a colour-blind reader. */
.field-error {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  /* A little breathing room BELOW as well: the message is the last child of
     .form-group, so without it the text sits hard against the next label. */
  margin: 5px 0 2px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--danger-strong);
}
.field-error::before {
  content: '!';
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--danger);
  color: var(--text-on-brand);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
}

/* The summary at the top of the form. On a long form the first bad field can
   be well below the fold, and a submit that does nothing looks like a fault. */
.form-error-summary {
  margin: 0 0 var(--spacing-lg);
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid var(--danger-tint);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-wash);
  color: var(--danger-deep);
  font-size: 0.875rem;
}
.form-error-summary strong { display: block; margin-bottom: 6px; }
.form-error-summary ul { margin: 0; padding-left: 1.25rem; }
.form-error-summary li { margin: 2px 0; }
.form-error-summary a {
  color: var(--danger-strong);
  text-decoration: underline;
}
.form-error-summary a:hover { color: var(--danger-deep); }


/* ==========================================================================
   P1-4 · THE SIDEBAR NAV SCROLLS WITH NO CUE
   --------------------------------------------------------------------------
   Measured in the real shell: 1383px of nav in a 554px box, so more than half
   the items sit below the fold with nothing to say so — and macOS hides the
   scrollbar until you actually scroll.

   The four sections are already collapsible AND remember their state in
   localStorage (company-app.js), so the structural half of this is done. What
   was missing is the affordance: a fade at the bottom edge that appears only
   while there is more to scroll to.
   ========================================================================== */
.sidebar-nav,
.sidebar nav {
  position: relative;
  overflow-y: auto;
  /* A thin, always-visible track beats macOS's hide-until-scrolled default when
     the whole point is telling someone there IS more. */
  scrollbar-width: thin;
}
.sidebar-nav::-webkit-scrollbar,
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-thumb,
.sidebar nav::-webkit-scrollbar-thumb {
  /* Also on a white sidebar — a light thumb would be invisible. */
  background: rgba(15, 23, 42, 0.18);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.sidebar nav::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.32);
}

/* The fade. `is-scrollable` is set by js/utils/nav-scroll-cue.js only while the
   nav actually overflows AND is not scrolled to the end, so it disappears once
   you reach the bottom rather than implying there is always more. */
.sidebar-scroll-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.5rem;
  pointer-events: none;
  opacity: 0;
  /* ⚠️ Matches the SIDEBAR's background, which is white — an earlier version
     used a dark slate gradient on the assumption of a dark nav and rendered as
     a grey smudge over the section headings. Screenshot the thing. */
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.97));
}
.sidebar-scroll-fade.is-visible { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .sidebar-scroll-fade { transition: opacity 0.18s ease; }
}

/* ==========================================================================
   P1-3 · TABLES ON A PHONE
   --------------------------------------------------------------------------
   At 514px every list table kept its full desktop column widths, the page
   scrolled sideways, and the primary buttons were pushed off screen.

   js/utils/table-scroll.js already gives every table its own scroll box, which
   is the audit's stated MINIMUM. This is the preferred fix: below 640px a list
   table becomes a stack of cards, one per row, with each cell labelled.

   HOW THE LABELS WORK — no markup change, no JS.
   js/utils/table-labels.js copies each column's heading onto its cells as
   `data-label`, and the ::before below prints it. Doing it in CSS content from
   an attribute means the label cannot drift from the heading, and a module that
   renders a new table gets it free.

   ONLY tables that are genuinely a LIST of records stack. A table used for
   layout — invoice line items, the role-permissions matrix — keeps its grid,
   because a two-column matrix read as cards is worse, not better. Those opt out
   with data-no-stack.
   ========================================================================== */
@media (max-width: 640px) {
  /* ⚠️ display:none, not the usual visually-hidden clip. `overflow: hidden`
     does NOT apply to a table-header-group in every engine, so the clipped
     thead's <th> cells still laid out at their full desktop widths and kept the
     document scrolling sideways — measured at 510px, header cells reaching
     747px. The headings are not lost: table-labels.js has already copied each
     one onto its cells, and the ::before below prints them, which modern screen
     readers announce. */
  .ns3-table-wrap table:not([data-no-stack]) thead { display: none; }

  .ns3-table-wrap table:not([data-no-stack]),
  .ns3-table-wrap table:not([data-no-stack]) tbody,
  .ns3-table-wrap table:not([data-no-stack]) tr,
  .ns3-table-wrap table:not([data-no-stack]) td {
    display: block;
    width: auto;
  }

  .ns3-table-wrap table:not([data-no-stack]) tr {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--white, #fff);
  }
  .ns3-table-wrap table:not([data-no-stack]) tr:last-child { margin-bottom: 0; }

  .ns3-table-wrap table:not([data-no-stack]) td {
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: var(--spacing-sm);
    align-items: start;
    padding: 6px 0;
    border: 0;
    border-bottom: 1px solid var(--border-light, #eef0f4);
    text-align: left !important;
  }
  .ns3-table-wrap table:not([data-no-stack]) td:last-child { border-bottom: 0; }

  .ns3-table-wrap table:not([data-no-stack]) td::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    /* A cell with no heading (the actions column) prints nothing rather than
       an empty label block. */
    min-height: 0;
  }
  /* An empty label leaves the value full width instead of a 40% gap. */
  .ns3-table-wrap table:not([data-no-stack]) td:not([data-label]),
  .ns3-table-wrap table:not([data-no-stack]) td[data-label=""] {
    grid-template-columns: 1fr;
  }
  .ns3-table-wrap table:not([data-no-stack]) td:not([data-label])::before,
  .ns3-table-wrap table:not([data-no-stack]) td[data-label=""]::before {
    content: none;
  }

  /* Row actions sit on their own line and stay reachable. */
  .ns3-table-wrap table:not([data-no-stack]) td.ns3-row-actions-cell .ns3-row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* The wrapper no longer needs to scroll — nothing overflows once stacked. */
  .ns3-table-wrap { overflow-x: visible; }
}

/* ==========================================================================
   P2-15 · PLANNER DAY VIEW
   --------------------------------------------------------------------------
   Was 07:00–18:00 of empty grid with no current-time indicator, nowhere for
   all-day events to go, and nothing said when a day was simply empty.
   ========================================================================== */

/* #dayViewGrid keeps its own grid definition (app.css) and holds ONLY grid
   children. The empty notice is rendered as a SIBLING before it — putting it
   inside made it a grid item and broke the two-column layout. */

/* An empty day is a normal answer, so say it — above the grid, not instead of
   it, because the slots are still how you add something. */
.day-empty-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-md);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* All-day / untimed events had nowhere to sit and never appeared at all. */
.time-label-allday,
.time-slot-allday { background: var(--grey-light, #f8fafc); }
.time-label-allday {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.time-slot-allday { min-height: 44px; }

/* The current time. Drawn only on today, positioned by minutes through the
   hour. The dot on the left edge is what makes it read as "now" rather than as
   a border between two rows. */
.day-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--danger);
  z-index: 3;
  pointer-events: none;
}
.day-now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}
.time-label-now { color: var(--danger); font-weight: 700; }

/* ==========================================================================
   P2-16 · CHART GRIDLINES AND AXIS
   --------------------------------------------------------------------------
   Invoice Aging was plain div bars: relative lengths with nothing to read them
   against. Gridlines at 25/50/75% plus an axis of real money values, so a bar
   can be READ rather than just compared with the bar above it.
   ========================================================================== */
.chart-gridded .aging-bar {
  position: relative;
  background-image: repeating-linear-gradient(
    to right,
    var(--border-light, #eef0f4) 0 1px,
    transparent 1px 25%
  );
}
.chart-gridded .aging-fill { position: relative; z-index: 1; }

.chart-axis {
  position: relative;
  height: 1.1rem;
  margin-top: 4px;
  /* MARGIN, not padding. The labels are positioned with `left: %`, which
     resolves against this element's PADDING box — so horizontal padding made
     the percentage scale 32px wider than the bar track and every label drifted
     linearly, ±16px at the ends. Margin insets the box itself, so `left: 50%`
     is genuinely the middle of the track.
     16px because .aging-bracket has 15px padding plus a 1px border. */
  margin-left: 16px;
  margin-right: 16px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.chart-axis span {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  white-space: nowrap;
}
/* The end labels would hang off the track, so they anchor to it instead. */
.chart-axis span:first-child { transform: none; }
.chart-axis span:last-child { transform: translateX(-100%); }

.aging-share {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   KNOWLEDGE BASE (N3)
   ═══════════════════════════════════════════════════════════════════════════
   Built as reading surfaces rather than as another table. Everything else in
   the app is a list of records you scan; this is prose you read while stuck
   mid-task, so the results are cards with a text snippet and the article body
   gets a measured line length instead of the full page width.

   Colours come from the existing tone tokens. No dark-mode block: the project
   measured ~1,270 hard-coded colours across the stylesheets and deliberately
   deferred dark mode rather than half-doing it, so adding a lone dark variant
   here would be the inconsistency, not the fix.
   ══════════════════════════════════════════════════════════════════════════ */

/* A one-line status message above a list. Used when half the knowledge base
   failed to load — saying so matters, because someone who silently sees only
   half concludes the answer does not exist and goes to ask a person. */
.ns3-inline-notice {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 8px);
  padding: 10px 14px;
  margin-bottom: var(--spacing-md, 16px);
  border: 1px solid var(--tone-neutral-br, #d9dee5);
  border-radius: var(--radius-md, 8px);
  background: var(--tone-neutral-bg, #f4f6f8);
  color: var(--tone-neutral-fg, #33404d);
  font-size: 0.9rem;
}
.ns3-inline-notice-warn {
  border-color: var(--tone-warning-br, #e7c66a);
  background: var(--tone-warning-bg, #fdf6e3);
  color: var(--tone-warning-fg, #6b5115);
}
.ns3-inline-notice svg { flex: 0 0 auto; }

.knowledge-count {
  margin: 0 0 var(--spacing-sm, 8px);
  color: var(--text-body, #55606d);
  font-size: 0.875rem;
}

.knowledge-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--spacing-sm, 10px);
}

.knowledge-card {
  border: 1px solid var(--border-color, #e3e7ec);
  border-radius: var(--radius-md, 10px);
  background: var(--surface, #fff);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition-fast, .15s), box-shadow var(--transition-fast, .15s);
}
.knowledge-card:hover {
  border-color: var(--brand-primary, #1f6feb);
  box-shadow: var(--shadow-sm, 0 1px 3px rgb(0 0 0 / 8%));
}
/* Focus is VISIBLE. These cards are keyboard-reachable (role=button,
   tabindex=0), and a card you can tab to but cannot see you have tabbed to is
   worse than one you cannot reach. */
.knowledge-card:focus-visible {
  outline: 2px solid var(--brand-primary, #1f6feb);
  outline-offset: 2px;
}

.knowledge-card-head {
  display: flex;
  align-items: baseline;
  gap: var(--spacing-sm, 8px);
  flex-wrap: wrap;
}
.knowledge-card-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text-strong, #1b2430);
}

.knowledge-card-snippet {
  margin: 6px 0 0;
  color: var(--text-body, #55606d);
  font-size: 0.9rem;
  line-height: 1.5;
}

.knowledge-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.knowledge-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--tone-neutral-br, #d9dee5);
  background: var(--tone-neutral-bg, #f4f6f8);
  color: var(--tone-neutral-fg, #33404d);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
/* The two sources are colour-coded as well as labelled. A reader must never
   have to work out whether they are reading NS3's instructions or their own
   company's process — the second one is the half that cannot be replaced. */
.knowledge-chip-platform {
  border-color: var(--tone-info-br, #a8c7f0);
  background: var(--tone-info-bg, #eef5ff);
  color: var(--tone-info-fg, #1d4e8f);
}
.knowledge-chip-company {
  border-color: var(--tone-success-br, #a9d8b6);
  background: var(--tone-success-bg, #eefaf1);
  color: var(--tone-success-fg, #1f6b3a);
}

.knowledge-tag {
  padding: 2px 7px;
  border-radius: var(--radius-sm, 4px);
  background: var(--surface-muted, #f1f3f6);
  color: var(--text-body, #55606d);
  font-size: 0.72rem;
  white-space: nowrap;
}

.knowledge-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--spacing-md, 16px);
}

/* ── the article itself ──────────────────────────────────────────────────── */

.knowledge-article,
.knowledge-editor { max-width: 60rem; }

.knowledge-article-head { margin-bottom: var(--spacing-lg, 24px); }
.knowledge-article-head h1 {
  margin: 10px 0 0;
  font-size: 1.6rem;
  line-height: 1.25;
  color: var(--text-strong, #1b2430);
}
.knowledge-article-summary {
  margin: 8px 0 0;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-body, #55606d);
}
.knowledge-article-byline {
  margin: 10px 0 0;
  font-size: 0.8rem;
  /* --text-muted (#64748b), NOT --medium-grey. --medium-grey is #cccccc, which
     against a white card measures 1.61:1 — the byline was there and could not
     be read. Caught by measuring the rendered page, not by reading the CSS;
     #7a838f was only ever the fallback, and the token beat it. */
  color: var(--text-muted, #64748b);
}

/* 68 characters is about the point at which the eye stops tracking reliably
   from one line to the next, and this is the one screen in the product people
   read properly rather than scan. */
.knowledge-article-body {
  max-width: 68ch;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-body, #3d4753);
}
.knowledge-article-body h2 {
  margin: 1.6em 0 .4em;
  font-size: 1.15rem;
  color: var(--text-strong, #1b2430);
}
.knowledge-article-body p { margin: 0 0 1em; }
.knowledge-article-body ul,
.knowledge-article-body ol { margin: 0 0 1em 1.2em; padding: 0; }
.knowledge-article-body li { margin-bottom: .4em; }

.knowledge-article-tags { margin-top: var(--spacing-lg, 24px); }

.knowledge-article-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm, 10px);
  margin-top: var(--spacing-xl, 32px);
  padding-top: var(--spacing-md, 16px);
  border-top: 1px solid var(--border-color, #e3e7ec);
}

/* ── editor ──────────────────────────────────────────────────────────────── */

.knowledge-editor h1 { font-size: 1.4rem; margin: 0 0 4px; }
.knowledge-editor textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
}
.knowledge-editor .form-group-full { grid-column: 1 / -1; }
.knowledge-editor .form-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  /* --text-muted (#64748b), NOT --medium-grey. --medium-grey is #cccccc, which
     against a white card measures 1.61:1 — the byline was there and could not
     be read. Caught by measuring the rendered page, not by reading the CSS;
     #7a838f was only ever the fallback, and the token beat it. */
  color: var(--text-muted, #64748b);
}

@media (max-width: 40rem) {
  .knowledge-card-head h3 { font-size: 0.95rem; }
  .knowledge-article-head h1 { font-size: 1.35rem; }
}

/* ── contextual help: the "?" on every page header ──────────────────────────
   Quiet until wanted. It sits with the page's own actions, so it must not
   compete with the primary button beside it — this is the control you notice
   only at the moment you need it. */
.ns3-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md, 8px);
  background: transparent;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  transition: color var(--transition-fast, .15s), background var(--transition-fast, .15s),
              border-color var(--transition-fast, .15s);
}
.ns3-help-btn:hover {
  color: var(--brand-primary, #1f6feb);
  background: var(--surface-muted, #f1f3f6);
  border-color: var(--border-color, #e3e7ec);
}
.ns3-help-btn:focus-visible {
  outline: 2px solid var(--brand-primary, #1f6feb);
  outline-offset: 2px;
}
/* A page with no actions row gets the button in the header itself, which is a
   flex row with the heading — push it to the end so it lands top-right where a
   help control is looked for, rather than jammed against the title. */
.ns3-page-header > .ns3-help-btn { margin-left: auto; align-self: flex-start; }

.knowledge-screen-filter {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm, 8px);
  flex-wrap: wrap;
}
.knowledge-screen-filter .ns3-btn { margin-left: auto; }

/* ── the Support menu ──────────────────────────────────────────────────────
   Fixed-position, positioned from the button's own rect in JS, for the reason
   written on the row menus: an absolutely-positioned dropdown gets clipped by
   whichever ancestor happens to carry an overflow, and the top bar has one. */
.ns3-support-menu {
  z-index: 1000;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--border-color, #e3e7ec);
  border-radius: var(--radius-md, 10px);
  background: var(--surface, #fff);
  box-shadow: var(--shadow-lg, 0 10px 30px rgb(0 0 0 / 14%));
}
.ns3-support-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  background: none;
  color: var(--text-body, #334155);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}
.ns3-support-menu button:hover { background: var(--surface-muted, #f1f3f6); }
.ns3-support-menu button:focus-visible {
  outline: 2px solid var(--brand-primary, #1f6feb);
  outline-offset: -2px;
}
.ns3-support-menu svg { flex: 0 0 auto; color: var(--text-muted, #64748b); }

/* ── Auto-dialler SIMs on the lift page (v8.59.0) ─────────────────────────── */
.sim-section { grid-column: 1 / -1; }
.sim-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
}
.sim-section-head h3 { margin-bottom: 0; }
.sim-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 12px 16px;
  margin-top: 12px;
}
.sim-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  margin-bottom: 8px;
}
.sim-card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  color: var(--text-strong);
}
.sim-card-actions { display: flex; gap: 6px; }
.sim-history {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.sim-empty { color: var(--text-muted); }

/* ==========================================================================
   LIFT PAGE (Sites → a lift) — v8.60.0
   The lift page's layout classes (detail-grid / detail-section / detail-row /
   detail-group / detail-value) had rules only in app.css, which no office shell
   loads, and detail-group / detail-value had rules nowhere — so every lift's
   details rendered as one long column of plain text. Scoped to the lift view:
   other modules reuse these class names with their own markup.
   ========================================================================== */
#sitesViewLiftView .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--spacing-md);
}
#sitesViewLiftView .detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md) var(--spacing-lg);
}
#sitesViewLiftView .detail-section h3 {
  margin: 0 0 var(--spacing-md);
  font-size: 1rem;
  color: var(--text-strong);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--line);
}
#sitesViewLiftView .detail-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-sm) var(--spacing-md);
}
#sitesViewLiftView .detail-row + .detail-row {
  margin-top: var(--spacing-sm);
}
#sitesViewLiftView .detail-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
#sitesViewLiftView .detail-value {
  margin: 0;
  color: var(--text-body);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}
@media (max-width: 640px) {
  #sitesViewLiftView .detail-grid { grid-template-columns: 1fr; }
  #sitesViewLiftView .detail-section { padding: var(--spacing-md); }
}

/* ==========================================================================
   ASSETS — "Who's calling?" dialler lookup + SIM contracts view (v8.60.0)
   ========================================================================== */
.dialler-lookup {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}
.dialler-lookup-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.0625rem;
  color: var(--text-strong);
}
.dialler-lookup-hint,
.dialler-lookup-coverage,
.dialler-lookup-note {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.dialler-lookup-form {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
  flex-wrap: wrap;
}
.dialler-lookup-form input {
  flex: 1 1 240px;
  min-width: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.dialler-lookup-results:not(:empty) { margin-top: var(--spacing-sm); }
.dialler-match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-inset);
}
.dialler-match + .dialler-match { margin-top: 8px; }
.dialler-match.is-exact { border-color: var(--ok); }
.dialler-match-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dialler-match-site { margin-top: 2px; color: var(--text-body); }
.dialler-match-extra:not(:empty) {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.dialler-match-number {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.assets-view-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--line);
}
.assets-view-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
}
.assets-view-tab.is-active {
  color: var(--text-strong);
  border-bottom-color: var(--brand);
}
.assets-view-count {
  font-size: 0.75rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-inset);
  color: var(--text-muted);
}
.sims-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: var(--spacing-sm);
  color: var(--text-body);
}
.sims-summary-danger { color: var(--danger); }
.sims-summary-warning { color: var(--warn-strong); }
.sims-renewal-date {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.ns3-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8125rem; }
@media (max-width: 640px) {
  .dialler-match { flex-direction: column; align-items: stretch; }
  .dialler-lookup { padding: var(--spacing-md); }
}

/* ══ PROJECTS (v8.61.0) — modules/projects.js ═════════════════════════════ */
.projects-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}
.projects-summary-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--spacing-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.projects-summary-value { font-size: 1.375rem; font-weight: 700; color: var(--text-strong); }
.projects-summary-label { font-size: 0.8125rem; color: var(--text-muted); }
.projects-sub { font-size: 0.8125rem; margin-top: 2px; }
.projects-breadcrumb { margin-bottom: var(--spacing-sm); }
.project-hero { margin-bottom: var(--spacing-md); }
.project-hero .ns3-hero-actions { flex-wrap: wrap; }
.project-tabs { flex-wrap: wrap; }
.project-tabs .detail-tab-btn { display: inline-flex; align-items: center; gap: 6px; }
.project-tab-count {
  font-size: 0.75rem;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--tone-warning-bg);
  color: var(--tone-warning-fg);
}
.project-tab-body { display: flex; flex-direction: column; gap: var(--spacing-md); }
.project-tab-body > .ns3-card { margin: 0; }
.project-tab-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }
.project-subhead { margin: var(--spacing-sm) 0 0; font-size: 1rem; color: var(--text-strong); }
.project-inline-label { font-size: 0.8125rem; color: var(--text-muted); }
.project-inline-check { display: flex; align-items: center; gap: 8px; margin: var(--spacing-sm) 0; color: var(--text-body); }
.project-fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
  margin: var(--spacing-sm) 0 var(--spacing-md);
}
.project-fieldset legend { padding: 0 6px; font-weight: 600; color: var(--text-strong); }
.project-pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.project-pick-list > label { display: flex; align-items: center; gap: 8px; }
.project-pick-site { padding: 6px 0; border-bottom: 1px solid var(--line); }
.project-pick-site:last-child { border-bottom: 0; }
.project-pick-site-label { display: flex; align-items: center; gap: 8px; }
.project-pick-lifts { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 0 0 26px; }
.project-pick-lifts label { display: inline-flex; align-items: center; gap: 6px; }

/* Programme (timeline) */
.project-timeline { position: relative; display: flex; flex-direction: column; gap: 6px; }
.project-timeline-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr; gap: var(--spacing-sm); align-items: center; }
.project-timeline-label { font-size: 0.8125rem; color: var(--text-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-timeline-track { position: relative; height: 18px; background: var(--surface-muted); border-radius: var(--radius-sm); }
.project-timeline-bar { position: absolute; border-radius: var(--radius-sm); }
.project-timeline-bar.is-planned { top: 2px; height: 6px; background: var(--tone-info-br); }
.project-timeline-bar.is-actual { top: 9px; height: 7px; background: var(--tone-warning-fg); }
.project-timeline-bar.is-actual.is-complete { background: var(--tone-success-fg); }
.project-timeline-bar.is-actual.is-skipped { background: var(--tone-neutral-fg); }
.project-timeline-now {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--tone-danger-fg);
  opacity: 0.55;
  pointer-events: none;
}
.project-timeline-legend { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.project-timeline-legend span { display: inline-block; width: 14px; height: 6px; border-radius: 2px; }
.project-timeline-legend .is-planned { background: var(--tone-info-br); }
.project-timeline-legend .is-actual { background: var(--tone-success-fg); }
.project-timeline-legend .is-today { width: 2px; height: 12px; background: var(--tone-danger-fg); }

/* Stages */
.project-stages { display: flex; flex-direction: column; gap: var(--spacing-md); }
.project-stages > .ns3-card { margin: 0; }
.project-stage.is-in_progress { border-left: 3px solid var(--tone-warning-fg); }
.project-stage.is-complete { border-left: 3px solid var(--tone-success-fg); }
.project-stage.is-skipped { opacity: 0.8; }
.project-stage .ns3-card-header h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.project-stage .ns3-card-actions { flex-wrap: wrap; }
.project-stage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--text-body);
}
.project-stage-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.8125rem; color: var(--text-muted); margin-bottom: var(--spacing-sm); }
.project-override, .project-blockers {
  font-size: 0.8125rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin: 6px 0;
}
.project-override { background: var(--tone-neutral-bg); color: var(--tone-neutral-fg); }
.project-blockers { background: var(--tone-warning-bg); color: var(--tone-warning-fg); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.project-checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.project-check-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px var(--spacing-md);
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.project-check-item:last-child { border-bottom: 0; }
.project-check-main { display: flex; align-items: center; gap: 8px; color: var(--text-body); }
.project-check-mark { color: var(--text-muted); display: inline-flex; }
.project-check-item.is-done .project-check-mark { color: var(--tone-success-fg); }
.project-check-control { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.project-check-text { display: inline-flex; gap: 6px; align-items: center; }
.project-check-input { min-width: 160px; }
.project-check-docs { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.8125rem; }
.project-check { width: 18px; height: 18px; }
.project-check-meta { grid-column: 1 / -1; font-size: 0.75rem; color: var(--text-muted); padding-left: 24px; }
.project-required {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--tone-info-bg);
  color: var(--tone-info-fg);
  margin-left: 4px;
}

/* Editors: checklist rows, budget lines, billing lines */
.project-ck-row, .project-line-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.project-ck-row .ck-text, .project-line-row .bl-desc, .project-line-row .bs-label { flex: 1 1 200px; }
.project-line-row .bl-amount, .project-line-row .bs-value { width: 110px; }
.project-ck-row .ck-req { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; }

/* Money */
.project-total-row td { font-weight: 600; border-top: 2px solid var(--line); }
.project-over { color: var(--tone-danger-fg); font-weight: 600; }
.project-billing-totals { margin-top: var(--spacing-sm); }

/* Items & documents */
.project-item-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.project-item-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.project-share { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; }

/* History */
.project-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.project-history li { display: grid; grid-template-columns: 150px 1fr auto; gap: var(--spacing-sm); padding: 8px var(--spacing-md); border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.project-history li:last-child { border-bottom: 0; }
.project-history time { color: var(--text-muted); white-space: nowrap; }
.project-history-text { color: var(--text-body); }
.project-history-who { color: var(--text-muted); white-space: nowrap; }
@media (max-width: 640px) {
  .project-timeline-row { grid-template-columns: 1fr; }
  .project-check-item { grid-template-columns: 1fr; }
  .project-check-control { justify-content: flex-start; }
  .project-history li { grid-template-columns: 1fr; gap: 2px; }
}
.project-visits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.project-visits li { display: grid; grid-template-columns: 110px 1fr auto auto; gap: var(--spacing-sm); align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.project-visits li:last-child { border-bottom: 0; }
.project-visits time { color: var(--text-muted); white-space: nowrap; }
.project-visits-empty { margin-top: var(--spacing-sm); }
@media (max-width: 640px) {
  .project-visits li { grid-template-columns: 1fr auto; }
}
/* Settings → Project templates */
.project-templates-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--spacing-md); flex-wrap: wrap; margin-bottom: var(--spacing-md); }
.project-templates-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); }
.template-stage { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--spacing-sm) var(--spacing-md); margin-bottom: var(--spacing-sm); background: var(--surface-muted); display: flex; flex-direction: column; gap: 6px; }
.template-stage-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.template-stage-head .ts-name { flex: 1 1 220px; font-weight: 600; }
.template-stage-days { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--text-muted); }
.template-stage-days input { width: 70px; }
.ts-checklist { display: flex; flex-direction: column; }
/* Inline inputs in the project editors (outside .form-group, so styled here). */
.project-check-input,
#planStartDate,
.project-ck-row input[type="text"], .project-ck-row select,
.project-line-row input, .project-line-row select,
.template-stage input[type="text"], .template-stage-days input {
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  background-color: var(--surface);
  color: var(--text-body);
}
.project-check-input:focus, #planStartDate:focus,
.project-ck-row input:focus, .project-ck-row select:focus,
.project-line-row input:focus, .project-line-row select:focus,
.template-stage input:focus {
  outline: none;
  border-color: var(--lime-green);
  box-shadow: 0 0 0 3px var(--lime-alpha-35);
}
.project-tab-body .ns3-card-actions { align-items: center; flex-wrap: wrap; }
.job-project-badge { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.875rem; color: var(--text-muted); }
.stat-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.lift-projects { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lift-projects li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   SHARED RECORD-DETAIL LAYOUT — office only (v8.62.0)
   Clients, the Planner's event detail, Jobs, Leads, PPM, Recurring Invoices and
   Surveys all lay records out with detail-section / detail-grid / detail-row /
   detail-item / detail-label / detail-value — classes whose only rules lived in
   app.css, which no office shell loads, so those screens rendered as plain
   stacked text. Scoped to `.office-app` (the office shell's <body>) because the
   engineer app, the customer portal and Platform Admin load this stylesheet too
   and style the same class names their own way.
   ========================================================================== */
.office-app .detail-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  min-width: 0;
}
.office-app .detail-section:last-child { margin-bottom: 0; }
.office-app .detail-section.full-width { grid-column: 1 / -1; }
.office-app .detail-section h3,
.office-app .survey-details > h3 {
  margin: 0 0 var(--spacing-md);
  font-size: 1rem;
  color: var(--text-strong);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--line);
}
.office-app .survey-details > h3 { margin-top: var(--spacing-lg); }
.office-app .survey-details > h3:first-child { margin-top: 0; }
.office-app .detail-section h4 { margin: 0 0 var(--spacing-sm); font-size: 0.875rem; color: var(--text-strong); }
/* A heading inside a section's own header row (Jobs tabs: title + button). */
.office-app .detail-section > :not(h3) h3 { margin: 0; padding-bottom: 0; border-bottom: 0; }
.office-app .detail-section ul,
.office-app .detail-section ol { font-size: 0.875rem; color: var(--text-body); }
/* Grids that already space their sections. */
.office-app .ppm-details > .detail-section,
.office-app .contract-details > .detail-section { margin-bottom: 0; }
/* Inside the client page's own card, sections are panels, not cards in a card. */
.office-app .page-detail .detail-section { background: var(--surface-muted); }

/* A grid of fields. Most modules write <div><strong>Label:</strong> value</div>. */
.office-app .detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-sm) var(--spacing-lg);
  min-width: 0;
}
.office-app .detail-grid > .full-width { grid-column: 1 / -1; }
.office-app .detail-grid > .detail-section { margin-bottom: 0; }
.office-app .detail-grid > div { color: var(--text-body); font-size: 0.875rem; overflow-wrap: anywhere; }
.office-app .detail-grid > div > strong:first-child { color: var(--text-muted); font-weight: 600; margin-right: 4px; }

/* Label : value rows (Planner event detail, Leads). */
.office-app .detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--spacing-md);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
}
.office-app .detail-row:last-child { border-bottom: 0; }
.office-app .detail-row > .detail-label { flex: 0 0 auto; }
.office-app .detail-row > :last-child { text-align: right; color: var(--text-body); overflow-wrap: anywhere; }
.office-app .detail-label { color: var(--text-muted); font-weight: 600; font-size: 0.8125rem; }
.office-app .detail-value { color: var(--text-body); }

/* Stacked label-over-value (Recurring Invoices). */
.office-app .detail-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.office-app .detail-item > .detail-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.office-app .detail-item > .detail-value { font-size: 0.875rem; overflow-wrap: anywhere; }

.office-app .detail-description { color: var(--text-body); font-size: 0.875rem; line-height: 1.5; white-space: pre-line; }
.office-app .detail-grid + .detail-description { margin-top: var(--spacing-sm); }

/* Surveys: one card per lift surveyed. */
.office-app .lift-detail-card {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}
.office-app .lift-detail-card h4 { margin: 0 0 var(--spacing-sm); font-size: 0.9375rem; color: var(--text-strong); }

/* Label-over-value GROUPS in a grid (the site page and the lift page:
   .detail-row > .detail-group > label + p.detail-value). The lift page has had
   its own copy of this since v8.60.0; the site page had none. */
.office-app .detail-row:has(> .detail-group) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--spacing-sm) var(--spacing-md);
  padding: 0;
  border-bottom: 0;
  font-size: inherit;
}
.office-app .detail-row:has(> .detail-group) + .detail-row { margin-top: var(--spacing-sm); }
.office-app .detail-row:has(> .detail-group) > :last-child { text-align: left; }
.office-app .detail-group.full-width { grid-column: 1 / -1; }
.office-app .detail-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.office-app .detail-group p,
.office-app .detail-section > p.detail-value {
  margin: 0;
  color: var(--text-body);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}
.office-app .detail-grid > .detail-section { font-size: inherit; }

/* The site page's cards (Sites → a site → Details): label : value rows whose
   classes had no rules anywhere, so "Site Name Main Hospital Block" ran
   together as one line of text. */
.office-app .client-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--spacing-md);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
}
.office-app .client-detail-row:last-child { border-bottom: 0; }
.office-app .client-detail-label { flex: 0 0 auto; color: var(--text-muted); font-weight: 600; font-size: 0.8125rem; }
.office-app .client-detail-value { color: var(--text-body); text-align: right; overflow-wrap: anywhere; }
.office-app .client-detail-value.highlight { color: var(--text-strong); font-weight: 600; }

@media (max-width: 640px) {
  .office-app .detail-section { padding: var(--spacing-md); }
  .office-app .detail-row,
  .office-app .client-detail-row { flex-direction: column; gap: 2px; }
  .office-app .detail-row > :last-child,
  .office-app .client-detail-value { text-align: left; }
}

/* ==========================================================================
   SIDEBAR BADGE — the unread count on Notifications and Mail.
   The rule lived only in app.css, which no office shell loads, so the
   Notifications badge has rendered unstyled since it was added. (v8.65.0)
   ========================================================================== */
.nav-item .nav-badge {
  margin-left: auto;
  min-width: 1.25rem;
  padding: 0 0.35rem;
  height: 1.25rem;
  border-radius: 0.625rem;
  background: var(--danger);
  color: var(--text-on-brand);
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.25rem;
  text-align: center;
  flex: 0 0 auto;
}
.sidebar.collapsed .nav-item .nav-badge { position: absolute; top: 0.25rem; right: 0.25rem; margin-left: 0; }
.nav-item[hidden] { display: none !important; }
/* A [hidden] button must stay hidden even where .btn-* sets display. */
.mail-app [hidden], .mail-compose [hidden], .settings-section [hidden] { display: none !important; }

/* ==========================================================================
   MAIL (v8.65.0) — three panes on a desktop, two on a phone.
   ========================================================================== */
.btn-link { background: none; border: 0; padding: 4px 6px; color: var(--brand); cursor: pointer; font: inherit; text-decoration: underline; }
.btn-link:hover { color: var(--brand-dark); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.form-group-narrow { max-width: 120px; }

.mail-loading { display: flex; align-items: center; gap: 10px; padding: var(--spacing-xl); color: var(--text-muted); }
.mail-app { display: flex; flex-direction: column; gap: var(--spacing-sm); min-height: calc(100vh - 210px); }
.mail-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm); }
.mail-search { display: flex; align-items: center; gap: 6px; flex: 1 1 220px; max-width: 420px; padding: 0 10px;
  border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--surface); color: var(--text-muted); }
.mail-search input { border: 0; outline: 0; padding: 9px 0; width: 100%; background: transparent; color: var(--text-body); font: inherit; }
.mail-toggle { padding: 8px 14px; border: 1px solid var(--border-color); border-radius: 999px; background: var(--surface); color: var(--text-body); cursor: pointer; font: inherit; }
.mail-toggle[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.mail-status { margin-left: auto; color: var(--text-muted); font-size: 0.8125rem; }
.mail-banner { padding: 10px 14px; border-radius: var(--radius-md); font-size: 0.875rem; line-height: 1.5; }
.mail-banner-info { background: var(--tone-info-bg); border: 1px solid var(--tone-info-br); color: var(--tone-info-fg); }
.mail-banner-error { background: var(--tone-danger-bg); border: 1px solid var(--tone-danger-br); color: var(--tone-danger-fg); }
.mail-banner .ns3-icon { vertical-align: -3px; }

.mail-panes { display: grid; grid-template-columns: 200px minmax(280px, 380px) minmax(0, 1fr); gap: 0;
  flex: 1; min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.mail-folders { border-right: 1px solid var(--line); padding: 8px; overflow-y: auto; background: var(--surface-muted); }
.mail-folder { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-body); cursor: pointer; font: inherit; text-align: left; }
.mail-folder:hover { background: var(--hover); }
.mail-folder.is-active { background: var(--blue-wash); color: var(--brand-dark); font-weight: 600; }
.mail-folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-count { min-width: 1.4rem; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--text-on-brand); font-size: 0.75rem; text-align: center; }
.mail-folder-select { display: none; }

.mail-list { border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.mail-rows { list-style: none; margin: 0; padding: 0; }
.mail-row { display: grid; gap: 2px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--text-body); cursor: pointer; font: inherit; text-align: left; }
.mail-row:hover { background: var(--hover); }
.mail-row.is-selected { background: var(--blue-wash); }
.mail-row.is-unread .mail-row-who, .mail-row.is-unread .mail-row-subject { font-weight: 700; color: var(--text-strong); }
.mail-row.is-unread { box-shadow: inset 3px 0 0 var(--brand); }
.mail-row-top { display: flex; justify-content: space-between; gap: 8px; }
.mail-row-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-when { flex: none; color: var(--text-muted); font-size: 0.75rem; }
.mail-row-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; }
.mail-row-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 0.8125rem; }
.mail-row-loading, .mail-row-empty { padding: 24px 14px; color: var(--text-muted); list-style: none; }
.mail-flag { color: var(--danger); }
.mail-clip, .mail-answered { color: var(--text-muted); }
.mail-chip { display: inline-flex; align-items: center; gap: 4px; justify-self: start; margin-top: 2px; padding: 1px 8px; border-radius: 999px;
  background: var(--tone-success-bg); color: var(--tone-success-fg); font-size: 0.75rem; text-decoration: none; }
a.mail-chip:hover { text-decoration: underline; }
.mail-more { padding: 12px; text-align: center; }

.mail-reader { overflow-y: auto; padding: 16px 20px; min-width: 0; }
.mail-reader-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 300px; color: var(--text-muted); }
.mail-back { display: none; }
.mail-reader-subject { margin: 0 0 8px; font-size: 1.25rem; color: var(--text-strong); overflow-wrap: anywhere; }
.mail-reader-from { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mail-reader-meta { margin: 6px 0 10px; font-size: 0.8125rem; overflow-wrap: anywhere; }
.mail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mail-actions .btn-icon { padding: 6px 9px; }
.mail-actions .btn-icon.is-on { color: var(--danger); border-color: var(--danger); }
.mail-move { padding: 6px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--surface); font: inherit; }
.mail-attachments { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.mail-attachment { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border-color);
  border-radius: var(--radius-md); background: var(--surface-muted); color: var(--text-body); cursor: pointer; font: inherit; font-size: 0.8125rem; }
.mail-attachment:hover { border-color: var(--brand); }
.mail-images-bar, .mail-note { margin: 10px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--tone-warning-bg); color: var(--tone-warning-fg); font-size: 0.8125rem; }
.mail-frame { display: block; width: 100%; min-height: 200px; margin-top: 12px; border: 0; background: var(--surface); }

.mail-compose { position: fixed; right: 24px; bottom: 0; z-index: 1200; width: min(680px, calc(100vw - 48px)); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: var(--shadow-lg); overflow: hidden; }
.mail-compose-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--surface-muted); border-bottom: 1px solid var(--line); }
.mail-compose-fields { display: grid; gap: 4px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.mail-compose-fields label { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.8125rem; }
.mail-compose-fields label[hidden] { display: none; }
.mail-compose-fields input { padding: 7px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font: inherit; color: var(--text-body); background: var(--surface); }
.mail-compose-fields .btn-link { justify-self: start; }
.mail-compose-editor { flex: 1; overflow-y: auto; min-height: 220px; }
.mail-compose-files { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 6px 14px; }
.mail-compose-files:empty { display: none; }
.mail-file { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--border-color); border-radius: 999px; font-size: 0.8125rem; }
.mail-file .btn-icon { padding: 2px 4px; border: 0; }
.mail-compose-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.mail-attach { cursor: pointer; }
.mail-compose-note { margin-left: auto; font-size: 0.8125rem; }

.rich-editor { display: flex; flex-direction: column; height: 100%; }
.rich-editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.rich-editor-btn { display: inline-flex; padding: 6px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-body); cursor: pointer; }
.rich-editor-btn:hover { background: var(--hover); }
.rich-editor-btn.is-active { background: var(--blue-wash); color: var(--brand-dark); }
.rich-editor-link { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.rich-editor-link[hidden] { display: none; }
.rich-editor-link-input { width: 220px; padding: 4px 6px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font: inherit; }
.rich-editor-area { padding: 12px 14px; outline: 0; line-height: 1.55; color: var(--text-body); overflow-wrap: anywhere; }
.rich-editor-area.is-empty::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; position: absolute; }
.rich-editor-area blockquote { margin: 8px 0 8px 4px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--text-muted); }
.rich-editor-area img { max-width: 100%; }
#sigEditor { border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 8px; }

.mail-settings-status { padding: 10px 14px; margin: 8px 0 12px; border-radius: var(--radius-md); background: var(--surface-muted); }
.mail-settings-status.is-on { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.mail-settings-notes { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-md); background: var(--tone-info-bg); color: var(--tone-info-fg); font-size: 0.875rem; }
.mail-settings-notes p { margin: 4px 0; }
.sig-logo-preview img, .company-logo-preview img { max-height: 64px; max-width: 240px; }
.company-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-md); }
.company-logo-preview { display: flex; align-items: center; justify-content: center; min-width: 160px; min-height: 80px; padding: 8px;
  border: 1px dashed var(--border-color); border-radius: var(--radius-md); text-align: center; }
.company-logo-actions { display: flex; align-items: center; gap: 8px; }
.company-logo-actions label { cursor: pointer; }

@media (max-width: 1024px) {
  .mail-panes { grid-template-columns: 170px minmax(240px, 320px) minmax(0, 1fr); }
}
/* A phone: the list, then the message — two panes, one at a time. */
@media (max-width: 768px) {
  .mail-panes { grid-template-columns: 1fr; min-height: 0; }
  .mail-folders { display: none; }
  .mail-folder-select { display: block; margin: 8px; padding: 8px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font: inherit; background: var(--surface); }
  .mail-list { border-right: 0; }
  .mail-app[data-view="read"] .mail-list { display: none; }
  .mail-app[data-view="list"] .mail-reader { display: none; }
  .mail-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; padding-left: 0; text-decoration: none; }
  .mail-reader { padding: 12px; }
  .mail-status { margin-left: 0; width: 100%; }
  .mail-compose { right: 0; left: 0; top: 0; width: 100%; max-height: none; border-radius: 0; }
}

/* ===========================================================================
   DEMO BAR (v8.66.0) — on every screen of a prospect's private demo copy
   (js/utils/demo-bar.js): made up, what is switched off, when access ends.
   =========================================================================== */
.demo-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0;
  padding: 9px 16px;
  background: var(--warn-wash);
  border-bottom: 1px solid var(--warn-tint);
  color: var(--warn-deep);
  font-size: 0.875rem;
  line-height: 1.4;
}
.demo-bar-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn);
  color: var(--text-on-brand);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.demo-bar-text { flex: 1 1 320px; }
.demo-bar-links { display: flex; flex-wrap: wrap; gap: 14px; margin-left: auto; }
.demo-bar-links a { color: var(--warn-deep); font-weight: 600; text-decoration: underline; white-space: nowrap; }
.engineer-main > .demo-bar { margin: 0 0 12px; border-radius: 0 0 10px 10px; }

/* Settings → Import & Export (v8.67.0) */
.dt-card { border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--spacing-md); margin-top: var(--spacing-md); background: var(--surface); }
.dt-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 var(--spacing-sm); font-size: 1.0625rem; }
.dt-card h4 { margin: var(--spacing-md) 0 6px; font-size: 0.9375rem; }
.dt-type-info { background: var(--surface-muted); border-radius: var(--radius-md); padding: var(--spacing-sm) var(--spacing-md); margin-bottom: var(--spacing-md); }
.dt-type-info p { margin: 0 0 6px; }
.dt-guide { margin-top: var(--spacing-sm); }
.dt-guide summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.dt-required { display: inline-block; font-size: 0.75rem; font-weight: 600; color: var(--danger-strong); background: var(--danger-wash); border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.dt-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm); margin: var(--spacing-sm) 0; }
.dt-mapping, .dt-results { border-top: 1px solid var(--line); margin-top: var(--spacing-md); padding-top: var(--spacing-sm); }
.dt-mapping select { min-width: 200px; max-width: 100%; }
.dt-sample { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-warning { display: flex; align-items: center; gap: 6px; color: var(--warn-deep); background: var(--warn-wash); border-radius: var(--radius-md); padding: 8px 12px; }
.dt-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--spacing-sm); margin: var(--spacing-sm) 0; }
.dt-count { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; color: var(--text-muted); font-size: 0.875rem; background: var(--surface-muted); }
.dt-count span { display: block; font-size: 1.5rem; font-weight: 700; color: var(--text-strong); }
.dt-count-ok { background: var(--ok-wash); }
.dt-count-ok span { color: var(--ok-deep); }
.dt-count-bad { background: var(--danger-wash); }
.dt-count-bad span { color: var(--danger-strong); }
.dt-export-one { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--spacing-sm); }
.dt-export-one .form-group { margin-bottom: 0; min-width: 220px; }
.dt-blockers { margin: 8px 0; padding-left: 1.2em; text-align: left; }
@media (max-width: 640px) {
  .dt-mapping select { min-width: 140px; }
  .dt-sample { max-width: 120px; }
}

/* Profile pictures beside people's names (v8.69.0) — utils/avatar.js */
.ns3-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--blue-tint); color: var(--blue-deep); font-weight: 700; line-height: 1; vertical-align: middle; }
.ns3-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ns3-person { display: inline-flex; align-items: center; gap: 8px; }

/* Lift → Autodialler tab, and Assets → Who's calling? (v8.69.0) */
.dialler-head { display: flex; justify-content: space-between; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; margin-bottom: var(--spacing-sm); }
.dialler-head h3 { display: flex; align-items: center; gap: 8px; margin: 0; }
#liftTab-autodialler .detail-section { grid-column: 1 / -1; }
.dialler-match-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ===========================================================================
   GED AI (v8.71.0) — the assistant's panel on the right, its cards, the sidebar
   button, "Write with Ged Ai" in Mail, and the settings screens
   (js/modules/ged-panel.js, js/utils/ged-write.js, js/modules/ged-settings.js).
   Sits above Mail compose (1200) and below the working overlay (1900) and modals (2000).
   =========================================================================== */
.ged-scrim { position: fixed; inset: 0; z-index: 1490; background: rgba(15, 23, 42, 0.28); opacity: 0; transition: opacity var(--transition-normal); pointer-events: none; }
.ged-scrim.is-open { opacity: 1; }
.ged-scrim[hidden] { display: none; }
.ged-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 1500; width: min(440px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform var(--transition-normal); }
.ged-panel.is-open { transform: translateX(0); }
.ged-panel[hidden] { display: none; }
.ged-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-muted); }
.ged-head-icon { width: 40px; height: 40px; flex: 0 0 auto; }
.ged-head-text { flex: 1; min-width: 0; }
.ged-head-text h2 { margin: 0; font-size: 1.125rem; color: var(--text-strong); }
.ged-head-text p { margin: 0; font-size: 0.8125rem; color: var(--text-muted); }
.ged-bar { display: flex; gap: 12px; padding: 6px 12px; border-bottom: 1px solid var(--line); }
.ged-bar[hidden] { display: none; }
.ged-bar .btn-link { display: inline-flex; align-items: center; gap: 4px; }
.ged-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ged-note { margin: 0; color: var(--text-muted); font-size: 0.875rem; }
.ged-note--error { color: var(--tone-danger-fg); }
.ged-suggests { display: flex; flex-direction: column; gap: 6px; }
.ged-suggest { text-align: left; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--surface); color: var(--text-body); font: inherit; font-size: 0.875rem; cursor: pointer; }
.ged-suggest:hover { border-color: var(--brand-primary); background: var(--brand-primary-light); }
.ged-msg { max-width: 92%; padding: 10px 12px; border-radius: var(--radius-md); font-size: 0.9375rem; line-height: 1.5; color: var(--text-body); overflow-wrap: anywhere; }
.ged-msg p { margin: 0 0 8px; } .ged-msg p:last-child { margin-bottom: 0; }
.ged-msg ul { margin: 0 0 8px 18px; padding: 0; } .ged-msg li { margin: 2px 0; }
.ged-msg--user { align-self: flex-end; background: var(--brand-primary); color: var(--white); }
.ged-msg--assistant { align-self: flex-start; background: var(--surface-muted); border: 1px solid var(--line); }
.ged-msg--thinking { color: var(--text-muted); font-style: italic; }
.ged-msg--error { align-self: flex-start; background: var(--tone-danger-bg); color: var(--tone-danger-fg); border: 1px solid var(--tone-danger-br); }
.ged-hidden-note { margin-top: 6px; font-size: 0.75rem; opacity: 0.85; }
.ged-copy { margin-top: 6px; padding-left: 0; }
.ged-source { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.ged-source .btn-link { display: inline-flex; align-items: center; gap: 4px; padding-left: 0; }
.ged-source-body { margin-top: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.875rem; }
.ged-source-body[hidden] { display: none; }
.ged-source-body h2 { font-size: 0.9375rem; margin: 10px 0 4px; }
.ged-card { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--tone-info-br); border-radius: var(--radius-md); background: var(--surface); }
.ged-card-title { font-weight: 600; color: var(--text-strong); margin-bottom: 6px; }
.ged-card-lines { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 0; font-size: 0.875rem; }
.ged-card-lines dt { color: var(--text-muted); } .ged-card-lines dd { margin: 0; white-space: pre-wrap; }
.ged-card-actions { display: flex; gap: 8px; margin-top: 10px; }
.ged-card-status { margin-top: 8px; font-size: 0.875rem; color: var(--text-muted); }
.ged-card-status--done strong { color: var(--tone-success-fg); }
.ged-card-status--refused strong, .ged-card-status--failed strong { color: var(--tone-danger-fg); }
.ged-compose { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.ged-compose[hidden] { display: none; }
.ged-compose textarea { flex: 1; resize: none; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font: inherit; color: var(--text-body); background: var(--surface); }
.ged-foot { padding: 8px 12px 10px; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--text-muted); background: var(--surface-muted); }
.ged-convs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ged-conv { display: flex; align-items: center; gap: 8px; }
.ged-conv-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); font: inherit; color: var(--text-body); cursor: pointer; text-align: left; }
.ged-conv-open:hover { border-color: var(--brand-primary); }
.ged-conv-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ged-conv-when { font-size: 0.75rem; color: var(--text-muted); }
.ged-nav-item { width: 100%; border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
.ged-nav-item .nav-icon img { display: block; width: 18px; height: 18px; }
@media (max-width: 520px) {
  .ged-panel { width: 100vw; }
}

/* Write with Ged Ai (Mail compose) */
.ged-write { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ged-write-btn { display: inline-flex; align-items: center; gap: 6px; }
.ged-write-note { font-size: 0.8125rem; }
.ged-write-row { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ged-write-input { width: min(320px, 60vw); padding: 6px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font: inherit; }
.ged-write-error { font-size: 0.8125rem; }

/* Company Settings → Ged Ai, and the platform card */
.ged-switch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ged-switch-list li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.ged-switch-list li.is-off { color: var(--text-muted); }
.ged-switch-list .ged-switch-words { font-size: 0.8125rem; color: var(--text-muted); }
.ged-status-line { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0 0 12px; font-size: 0.875rem; }
.ged-style-box { width: 100%; min-height: 140px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font: inherit; }
.ged-platform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 14px; }
.ged-platform-usage { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; font-size: 0.875rem; }
.ged-platform-usage div { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-muted); }
.ged-platform-usage strong { display: block; font-size: 1.0625rem; color: var(--text-strong); }

/* v8.74.0 — the owner's own words, the allowance line, the platform split, the Settings sub-tabs */
.ged-owner-rule { margin-top: 10px; padding: 8px 12px; border: 1px solid var(--tone-warning-br, var(--line)); border-left: 4px solid var(--tone-warning-fg); border-radius: var(--radius-md); background: var(--tone-warning-bg); }
.ged-owner-rule-head { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 600; color: var(--text-strong); }
.ged-owner-rule-words { margin: 6px 0 0; padding: 0; font-size: 0.9375rem; white-space: pre-wrap; color: var(--text-body); }
.ged-usage--warn { color: var(--tone-warning-fg); font-weight: 600; }
.ged-usage--full { color: var(--tone-danger-fg); font-weight: 600; }
.ged-platform-split { margin: 8px 0; font-size: 0.875rem; }
.ged-platform-split table { margin-top: 4px; }
.ged-price-table input { width: 90px; }
.ged-subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--line); }
.ged-subtab { padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-size: 0.9375rem; color: var(--text-muted); cursor: pointer; }
.ged-subtab.is-active { color: var(--brand-primary); border-bottom-color: var(--brand-primary); font-weight: 600; }
.ged-profile-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin: 0 0 12px; padding: 0; list-style: none; }
.ged-profile-list label { display: block; height: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md); cursor: pointer; }
.ged-profile-list input:checked + span { color: var(--brand-primary); }
.ged-area-table select { min-width: 110px; }
.ged-meter { height: 8px; border-radius: 4px; background: var(--surface-muted); border: 1px solid var(--line); overflow: hidden; margin: 4px 0 10px; }
.ged-meter > span { display: block; height: 100%; background: var(--brand-primary); }
.ged-meter--warn > span { background: var(--tone-warning-fg); }
.ged-meter--full > span { background: var(--tone-danger-fg); }
.ged-learn-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.ged-learn-list li { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.ged-learn-list .ged-learn-meta { font-size: 0.75rem; color: var(--text-muted); }
.ged-learn-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ged-interview-q { padding: 10px 12px; border: 1px solid var(--tone-info-br); border-radius: var(--radius-md); background: var(--tone-info-bg); color: var(--text-strong); margin-bottom: 8px; }

/* ── Sub-contractors (v8.72.0) ─────────────────────────────────────────────
   The badge on a job (list, visits) that is with a sub-contractor firm, and the
   firm detail page on Subcontractors (People, Jobs). */
.badge-subcontractor { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--brand-primary-light); color: var(--brand-primary-dark); text-transform: none; }
.sub-firm-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.sub-firm-header h2 { margin: 0; font-size: 1.25rem; }
.sub-people-table td, .sub-people-table th { vertical-align: middle; }
.sub-person-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
/* v8.72.1: a [hidden] element must stay hidden where .ns3-page-header / .ns3-filter-bar /
   .form-group set display — the firm page hides the list's header, and sub-contractor mode
   hides the parts modal's stock and supplier fields, by the attribute. */
#module-subcontractors [hidden], .subcontractor-mode [hidden] { display: none !important; }
/* v8.73.0 — Company Settings → Logo and colour */
.company-colour-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm) var(--spacing-md); margin-top: var(--spacing-md); }
.company-colour-row label { font-weight: 600; }
.company-colour-row input[type="color"] { width: 48px; height: 36px; padding: 2px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; }

/* v8.76.0 — Planner: a PPM visit that is DUE, worked out from its schedule rather than booked. Dashed, so it reads as
   "still to arrange"; clicking it opens Create job (utils/ppm-create-job.js). */
.event-block.event-ppm-due {
  border: 2px dashed var(--text-on-brand, white);
  box-shadow: none;
}
.event-summary.event-ppm-due {
  border-left-style: dashed !important;
  font-style: italic;
}

/* v8.77.0 — Settings → Billing (js/modules/billing-settings.js) and the "account suspended" page (company-app.js,
   Billing-SCOPE B4). */
.billing-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--spacing-sm) var(--spacing-md); margin: 0 0 var(--spacing-md); }
.billing-facts dt { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin: 0; }
.billing-facts dd { margin: 2px 0 0; color: var(--text-strong); }
.billing-notice { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin: var(--spacing-sm) 0 0; border: 1px solid var(--tone-warning-br); border-radius: var(--radius-md); background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.billing-notice .ns3-icon { flex: none; margin-top: 2px; }
.billing-badge { text-transform: none; padding: 2px 8px; vertical-align: middle; }
.billing-method { margin: 0 0 var(--spacing-sm); }
.billing-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); margin-top: var(--spacing-md); }
.billing-card-panel { margin-top: var(--spacing-md); padding: var(--spacing-md); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-muted); }
.billing-card-panel[hidden] { display: none; }
.billing-square-card { min-height: 90px; margin-bottom: var(--spacing-sm); }
.billing-amount { text-align: right; white-space: nowrap; }
.billing-collect-error { margin-top: 4px; font-size: 0.75rem; color: var(--danger-strong); }
.billing-row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.billing-bill-modal { max-width: 640px; }
.billing-hold-page { max-width: 960px; margin: 0 auto; }
body.ns3-billing-held .sidebar,
body.ns3-billing-held #sidebarToggle,
body.ns3-billing-held #openEngineerBtn { display: none !important; }
body.ns3-billing-held .main-content { margin-left: 0 !important; }

/* ── Texts (v8.79.0): send-a-text icon and window ──────────────────────────
   utils/sms-link.js. The small speech-bubble button placed right after a mobile number (hidden until the page
   knows the person holds sms.send), its crossed-out form and "No texts" label for a number the company has marked
   (SMS-SCOPE D4), and the send-a-text window: who, the sender, the texts already sent, the message with its fixed
   "NoReply: " prefix (D2), the segment meter and the cost before Send. */
.sms-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; margin-left: 4px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: none; color: var(--brand); cursor: pointer; vertical-align: middle;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.sms-link[hidden] { display: none; }
.sms-link:hover { background: var(--blue-wash); border-color: var(--blue-tint); color: var(--brand-dark); }
.sms-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.sms-link--off { color: var(--tone-danger-fg); }
.sms-link--off:hover { background: var(--tone-danger-bg); border-color: var(--tone-danger-br); color: var(--tone-danger-fg); }
.sms-no-texts {
  display: inline-block; margin-left: 4px; padding: 1px 6px; vertical-align: middle;
  border: 1px solid var(--tone-danger-br); border-radius: 10px;
  background: var(--tone-danger-bg); color: var(--tone-danger-fg);
  font-size: 0.6875rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
}

.sms-window { max-width: 540px; }
.sms-window .modal-header h3 { margin: 0; }
.sms-window .modal-footer { flex-wrap: wrap; }
.sms-test-banner {
  display: flex; align-items: center; gap: 8px; margin: 0 0 var(--spacing-md); padding: 8px 12px;
  border: 1px solid var(--tone-warning-br); border-radius: var(--radius-md);
  background: var(--tone-warning-bg); color: var(--tone-warning-fg); font-size: 0.875rem;
}
.sms-test-banner .ns3-icon { flex: none; }
.sms-notice {
  margin: 0 0 var(--spacing-md); padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface-muted); color: var(--text-body); font-size: 0.875rem;
}
.sms-notice p { margin: 0 0 8px; display: flex; align-items: flex-start; gap: 6px; flex-wrap: wrap; }
.sms-notice ul { margin: 6px 0 0; padding-left: 20px; }
.sms-notice .ns3-icon { flex: none; margin-top: 2px; }
p.sms-notice { display: flex; align-items: flex-start; gap: 6px; }
.sms-notice--warn { border-color: var(--tone-warning-br); background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.sms-notice--danger { border-color: var(--tone-danger-br); background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.sms-notice--info { border-color: var(--tone-info-br); background: var(--tone-info-bg); color: var(--tone-info-fg); }
.sms-who { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--spacing-sm) var(--spacing-md); margin: 0 0 var(--spacing-sm); }
.sms-who dt { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin: 0; }
.sms-who dd { margin: 2px 0 0; color: var(--text-strong); overflow-wrap: anywhere; }
.sms-noreply { margin: 0 0 var(--spacing-md); }
.sms-section-title { display: block; margin: 0 0 6px; font-size: 0.875rem; font-weight: 600; color: var(--text-strong); }
.sms-history { list-style: none; margin: 0 0 var(--spacing-md); padding: 0; max-height: 200px; overflow-y: auto; display: grid; gap: 6px; }
.sms-history li { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-muted); }
.sms-history-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; font-size: 0.75rem; color: var(--text-muted); }
.sms-history-status { font-weight: 600; color: var(--text-body); }
.sms-history-status--bad { color: var(--tone-danger-fg); }
.sms-history-body { margin-top: 4px; font-size: 0.875rem; color: var(--text-body); white-space: pre-wrap; overflow-wrap: anywhere; }
.sms-history-empty { margin: 0 0 var(--spacing-md); font-size: 0.875rem; }
.sms-compose {
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface);
  padding: 8px 10px 4px;
}
.sms-compose:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-alpha); }
.sms-prefix { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); user-select: none; }
.sms-body-input {
  display: block; width: 100%; min-height: 96px; margin: 2px 0 0; padding: 0;
  border: 0; outline: none; resize: vertical; background: transparent;
  color: var(--text-body); font: inherit; font-size: 0.9375rem; line-height: 1.45;
}
.sms-meter { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; margin: 6px 0 0; font-size: 0.75rem; color: var(--text-muted); }
.sms-meter-note { flex-basis: 100%; }
.sms-meter--over { color: var(--tone-danger-fg); }
.sms-cost { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 var(--spacing-sm); font-size: 0.875rem; color: var(--text-body); }
.sms-cost .ns3-muted { font-size: 0.75rem; }
.sms-cost-refuse { color: var(--tone-danger-fg); font-weight: 600; }
.sms-mark-link { padding-left: 0; font-size: 0.8125rem; color: var(--text-muted); }
.sms-mark-link:hover { color: var(--text-strong); }
.sms-error { margin: var(--spacing-sm) 0 0; color: var(--tone-danger-fg); font-size: 0.875rem; font-weight: 600; }
.sms-error:empty { display: none; }
@media (max-width: 480px) {
  .sms-window .modal-header, .sms-window .modal-body, .sms-window .modal-footer { padding: var(--spacing-md); }
  .sms-window .modal-footer > button { flex: 1 1 100%; }
  .sms-history { max-height: 160px; }
}

/* ── Texts (v8.79.0): Settings → SMS, Texts sent ── */
/* js/modules/sms-settings.js (Settings → SMS: .sms-set-*; Texts sent: .sms-log-*), and in js/modules/settings.js the
   Text column of Notifications → "What your customers are told" (.cust-text-*), the Automations "Send a text" meter
   (.rule-sms-*) and the numbers under each person in User Management (.user-number, .user-phone-row). The send-a-text
   window's own classes (.sms-meter, .sms-notice …) belong to js/utils/sms-link.js and are not used here. */
.sms-set-status { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin: 0 0 var(--spacing-sm); border: 1px solid var(--line); border-radius: var(--radius-md); }
.sms-set-status .ns3-icon { flex: none; margin-top: 2px; }
.sms-set-status ul { margin: 4px 0 0; padding-left: 18px; }
.sms-set-status--on { border-color: var(--tone-success-br); background: var(--tone-success-bg); color: var(--tone-success-fg); }
.sms-set-status--off { border-color: var(--tone-warning-br); background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.sms-set-test { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; margin: 0 0 var(--spacing-sm); border: 1px solid var(--tone-warning-br); border-radius: var(--radius-md); background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.sms-set-test .ns3-icon { flex: none; margin-top: 2px; }
.sms-set-badge { text-transform: none; padding: 2px 8px; vertical-align: middle; }
.sms-set-sender-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-sm); }
.sms-set-sender-row input { flex: 0 1 240px; min-width: 0; }
.sms-set-sender-check { margin: 4px 0 0; font-size: 0.8125rem; color: var(--text-muted); }
.sms-set-sender-check--bad { color: var(--tone-danger-fg); font-weight: 600; }
.sms-set-sample { display: block; margin-top: 4px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-muted); color: var(--text-body); font-size: 0.875rem; overflow-wrap: anywhere; }
.sms-set-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--spacing-sm) var(--spacing-md); margin: 0 0 var(--spacing-md); }
.sms-set-facts dt { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin: 0; }
.sms-set-facts dd { margin: 2px 0 0; color: var(--text-strong); overflow-wrap: anywhere; }
.sms-set-meter { max-width: 420px; height: 8px; margin: 0 0 var(--spacing-md); border: 1px solid var(--line); border-radius: 4px; background: var(--surface-muted); overflow: hidden; }
.sms-set-meter > span { display: block; height: 100%; background: var(--brand); }
.sms-set-meter--warn > span { background: var(--tone-warning-fg); }
.sms-set-meter--full > span { background: var(--tone-danger-fg); }
.sms-set-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); margin-top: var(--spacing-md); }
.sms-set-num { text-align: right; white-space: nowrap; }
/* Texts sent */
.sms-log-count { margin: var(--spacing-sm) 0; font-size: 0.8125rem; }
.sms-log td { vertical-align: top; }
.sms-log tbody tr[hidden] { display: none !important; }
.sms-log-when { white-space: nowrap; }
.sms-log-note { font-size: 0.75rem; color: var(--text-muted); }
.sms-log-msg { min-width: 200px; max-width: 420px; }
.sms-log-msg-short, .sms-log-msg-full { white-space: pre-wrap; overflow-wrap: anywhere; }
.sms-log-msg-full[hidden], .sms-log-msg-short[hidden] { display: none; }
.sms-log-more { margin-left: 4px; padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.sms-log-more:hover, .sms-log-more:focus-visible { text-decoration: underline; }
.sms-log-st { font-weight: 600; color: var(--text-body); }
.sms-log-st--good { color: var(--tone-success-fg); }
.sms-log-st--bad { color: var(--tone-danger-fg); }
.sms-log-st--wait { color: var(--tone-warning-fg); }
/* Settings → Notifications: the Text column (D8) */
.cust-text-off { margin: 0 0 var(--spacing-sm); padding: 8px 12px; border: 1px solid var(--tone-warning-br); border-radius: var(--radius-md); background: var(--tone-warning-bg); color: var(--tone-warning-fg); font-size: 0.875rem; }
.cust-text-off[hidden] { display: none; }
.cust-text-sample { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 0.8125rem; }
.cust-text-words { color: var(--text-muted); font-style: italic; overflow-wrap: anywhere; }
.cust-text-cost { color: var(--text-faint); font-size: 0.75rem; }
/* Automations: "Send a text" */
.rule-sms-meter { margin: 0 0 4px; font-size: 0.875rem; font-weight: 600; color: var(--text-body); }
/* User Management: saved numbers with the send-a-text icon */
.user-number { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--text-muted); }
.user-number-label { font-size: 0.75rem; font-weight: 600; }
.user-phone-row { display: flex; align-items: center; gap: 6px; }
.user-phone-row input { flex: 1 1 auto; min-width: 0; }

/* ── Texts (v8.79.0): autodialler texts, unmatched texts ── */
/* js/modules/dialler.js (the lift's Autodialler tab) and js/modules/unmatched-texts.js (Assets → Autodiallers).
   The text is escaped; pre-wrap keeps its line breaks. */
.dialler-sms-text { margin: 0 0 4px; padding: 6px 10px; border-left: 3px solid var(--tone-info-br); border-radius: var(--radius-sm); background: var(--surface-muted); color: var(--text-strong); font-size: 0.875rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialler-sms-text.is-empty { color: var(--text-muted); font-style: italic; }
#liftDiallerCallsTable .dialler-sms-text { min-width: 180px; max-width: 60ch; }
.unmatched-texts { margin: 0 0 var(--spacing-md); padding: var(--spacing-md); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--radius-md); background: var(--surface); }
.unmatched-texts .settings-hint { margin-top: 0; }
.unmatched-list { display: grid; gap: var(--spacing-sm); margin: 0; padding: 0; list-style: none; }
.unmatched-item { padding: var(--spacing-sm) 12px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.unmatched-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 6px; font-size: 0.8125rem; color: var(--text-muted); }
.unmatched-from { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text-strong); }
.unmatched-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-sm); margin-top: var(--spacing-sm); }
#linkUnmatchedModal .dialler-sms-text { margin: 0 0 12px; }
.unmatched-warn { margin: 4px 0 8px; padding: 6px 10px; border: 1px solid var(--tone-warning-br); border-radius: var(--radius-md); background: var(--tone-warning-bg); color: var(--tone-warning-fg); font-size: 0.8125rem; }
.unmatched-warn.is-on { border-color: var(--warn); font-weight: 600; }
