/* ============================================
   PostPro Nexus — Global Design Tokens
   AMT brand (turquoise) · Inter typography
   Single source of truth — no per-module overrides
   Dark mode via [data-theme="dark"] on <html>
   ============================================ */

/* Inter for UI, JetBrains Mono for code/data.
   2026-05-19: Trimmed Inter to 400-700 (dropped 300 + 800). Per-page font
   imports (Bebas Neue, Outfit, Roboto, Dancing Script, Roboto Mono) are
   being removed across the app — Inter + JetBrains Mono is the entire stack. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================
   LIGHT THEME (default)
   ============================================ */
:root {
  color-scheme: light;

  /* ── AMT brand palette (theme-invariant) ── */
  --amt-turquoise: #4FC3CA;
  --amt-turquoise-dark: #3BA8AE;
  --amt-turquoise-darker: #2D8A8F;
  --amt-turquoise-light: rgba(79, 195, 202, 0.1);
  --amt-dark-grey: #152E35;
  --amt-grey: #38484D;
  --amt-light-grey: #A89E9E;
  --amt-green: #5DBB63;
  --amt-green-dark: #059669;
  --amt-green-light: rgba(93, 187, 99, 0.1);
  --amt-pp-grey: #B4ABA8;
  --amt-dms-grey: #AFB3B6;

  /* ── Surfaces (slate-based neutrals, WCAG AA+ contrast) ── */
  --bg-color:       #F8FAFC;  /* app background */
  --bg-primary:     #F8FAFC;
  --bg-secondary:   #FFFFFF;  /* cards, inputs */
  --bg-tertiary:    #F1F5F9;  /* rows, stat boxes, modal chrome */
  --bg-hover:       #E2E8F0;  /* hover state */
  --bg-active:      rgba(79, 195, 202, 0.08);
  --card-bg:        #FFFFFF;

  /* ── Text hierarchy ── */
  --text-main:      #0F172A;  /* body */
  --text-primary:   #0F172A;  /* headings */
  --text-secondary: #334155;  /* secondary */
  --text-muted:     #64748B;  /* meta, labels */
  --text-on-accent: #FFFFFF;  /* text on turquoise */

  /* ── Borders ── */
  --border-color:   #E2E8F0;
  --border-light:   #E2E8F0;
  --border-medium:  #CBD5E1;
  --border-strong:  #94A3B8;
  --grid-line:      rgba(15, 23, 42, 0.04);
  --grid-color:     rgba(148, 163, 184, 0.08);
  --grid-size:      32px;

  /* ── Brand accent (turquoise is theme-invariant) ── */
  --accent-color:     var(--amt-turquoise);
  --accent-primary:   var(--amt-turquoise);
  --accent-secondary: var(--amt-turquoise-dark);
  --accent-light:     var(--amt-turquoise-light);
  --accent-gradient:  linear-gradient(135deg, #4FC3CA 0%, #3BA8AE 100%);

  /* ── Sidebar / header (always dark — brand top bar) ── */
  --sidebar-bg:          #0F172A;
  --sidebar-bg-hover:    #1E293B;
  --sidebar-bg-active:   rgba(79, 195, 202, 0.15);
  --sidebar-text:        #94A3B8;
  --sidebar-text-bright: #F8FAFC;
  --sidebar-border:      rgba(255, 255, 255, 0.08);

  /* ── Status / signal colors ── */
  --tech-blue:   #3B82F6;
  --tech-cyan:   #06B6D4;
  --tech-green:  #059669;
  --tech-red:    #DC2626;
  --tech-purple: #8B5CF6;
  --tech-orange: #EA580C;
  --tech-yellow: #EAB308;

  --status-success: #059669;
  --status-warning: #EA580C;
  --status-error:   #DC2626;
  --status-info:    #3B82F6;

  /* ── Department colors ── */
  --dept-technical: var(--amt-turquoise);
  --dept-operations: var(--tech-green);
  --dept-sales:      var(--tech-orange);
  --dept-finance:    var(--amt-turquoise);
  --dept-customer:   var(--amt-turquoise);
  --dept-logistics:  var(--tech-purple);
  --dept-hr:         var(--tech-green);

  /* ── Elevation ── */
  --shadow-sm:   0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-md:   0 4px 6px -1px rgb(15 23 42 / 0.08), 0 2px 4px -2px rgb(15 23 42 / 0.05);
  --shadow-lg:   0 10px 25px -5px rgb(15 23 42 / 0.10), 0 8px 10px -6px rgb(15 23 42 / 0.05);
  --shadow-card: 0 1px 3px 0 rgb(15 23 42 / 0.04), 0 1px 2px -1px rgb(15 23 42 / 0.04);

  /* ── Layout ── */
  --sidebar-width:     260px;
  --sidebar-collapsed: 72px;
  --topbar-height:     72px;

  /* ── Motion ── */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   350ms ease;

  /* ── Radii ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* ── Shared semantic tokens (used across modules; were previously inline)
     These are aliases for legibility + are overridden per-theme below. ── */
  --surface-muted:     var(--bg-tertiary);
  --surface-hover:     var(--bg-hover);
  --surface-secondary: var(--bg-tertiary);
  --surface-border:    var(--border-light);

  --accent-bg:         var(--accent-light);

  /* Legacy-named text aliases (some inline templates reference these) */
  --text-color:     var(--text-primary);
  --text-tertiary:  var(--text-muted);

  /* Alternate color-name aliases referenced by older code paths.
     Mapping each to its semantic equivalent keeps existing code working
     without requiring per-file edits, and gives the theme system a
     single point of control. */
  --accent-cyan:     var(--tech-cyan);
  --accent-red:      var(--tech-red);
  --tech-turquoise:  var(--amt-turquoise);
  --tech-amber:      var(--tech-orange);
  --tech-amber-bg:   var(--alert-warning-bg);
  --tech-amber-dark: var(--alert-warning-text);
  --danger-red:      var(--tech-red);
  --danger-color:    var(--status-error);
  --error-red:       var(--tech-red);
  --warning-amber:   var(--tech-orange);
  --warning-color:   var(--status-warning);
  --success-green:   var(--tech-green);
  --color-green:     var(--tech-green);
  --color-orange:    var(--tech-orange);
  --color-red:       var(--tech-red);
  --green-600:       var(--tech-green);
  --red-500:         var(--tech-red);
  --primary:         var(--accent-primary);
  --primary-color:   var(--accent-primary);

  --background:      var(--bg-primary);
  --bg-header:       var(--sidebar-bg);
  --bg-surface:      var(--bg-secondary);
  --surface-bg:      var(--bg-secondary);
  --hover-bg:        var(--bg-hover);

  --info-bg:         var(--alert-info-bg);
  --info-border:     var(--alert-info-border);

  /* Missing alert-border variants */
  --alert-purple-border: rgba(139, 92, 246, 0.25);
  --alert-pink-bg:       rgba(236, 72, 153, 0.10);
  --alert-pink-text:     #BE185D;

  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;

  /* Module-specific tokens previously only inline-aliased. Defining
     them globally gives the theme system central control and prevents
     silent fall-through to hardcoded fallback values. */
  --cal-leave-color:    var(--text-muted);   /* calendar leave strip */
  --detail-header-bg:   var(--bg-tertiary);  /* organization/module detail header bg */
  --role-accent:        var(--amt-turquoise); /* admin-roles accent stripe */

  /* Alert tints — light tints for notifications/callouts */
  --alert-warning-bg:      rgba(234, 179, 8, 0.10);
  --alert-warning-border:  rgba(234, 179, 8, 0.35);
  --alert-warning-text:    #B45309;
  --alert-warning-subtext: #92400E;

  --alert-danger-bg:     rgba(220, 38, 38, 0.10);
  --alert-danger-border: rgba(220, 38, 38, 0.30);
  --alert-danger-text:   #991B1B;

  --alert-info-bg:     rgba(59, 130, 246, 0.10);
  --alert-info-border: rgba(59, 130, 246, 0.30);
  --alert-info-text:   #1E40AF;

  --alert-success-bg:     rgba(5, 150, 105, 0.10);
  --alert-success-border: rgba(5, 150, 105, 0.30);
  --alert-success-text:   #065F46;

  --alert-blue-bg:      rgba(59, 130, 246, 0.08);
  --alert-blue-border:  rgba(59, 130, 246, 0.25);
  --alert-blue-text:    #1E40AF;

  --alert-purple-bg:   rgba(139, 92, 246, 0.10);
  --alert-purple-text: #6D28D9;
}

/* ============================================
   DARK THEME — redefine the same tokens.
   Everything downstream uses var(), so swapping
   these values switches the entire UI.

   NOTE: selector is html[data-theme="dark"] (specificity 0,1,1)
   intentionally — beats any stray `:root {}` block (0,1,0) in
   per-page inline <style>. Do not downgrade to [data-theme="dark"].
   ============================================ */
html[data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces — layered dark slate (matches ex-finance "deep obsidian") */
  --bg-color:       #0B1120;
  --bg-primary:     #0B1120;
  --bg-secondary:   #111827;   /* cards, inputs */
  --bg-tertiary:    #1A2236;   /* rows, stat boxes */
  --bg-hover:       rgba(255, 255, 255, 0.05);
  --bg-active:      rgba(79, 195, 202, 0.12);
  --card-bg:        #111827;

  /* Text */
  --text-main:      #F1F5F9;
  --text-primary:   #F1F5F9;
  --text-secondary: #CBD5E1;
  --text-muted:     #94A3B8;
  /* --text-on-accent stays white */

  /* Borders (translucent whites) */
  --border-color:  rgba(255, 255, 255, 0.08);
  --border-light:  rgba(255, 255, 255, 0.06);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.20);
  --grid-line:     rgba(148, 163, 184, 0.06);

  /* Accent stays turquoise; slightly brighter light-mix on dark */
  --accent-light:  rgba(79, 195, 202, 0.15);

  /* Sidebar — keep dark, but blend with app background */
  --sidebar-bg:          #0F172A;
  --sidebar-bg-hover:    rgba(255, 255, 255, 0.04);
  --sidebar-bg-active:   rgba(79, 195, 202, 0.16);
  --sidebar-text:        #94A3B8;
  --sidebar-text-bright: #F8FAFC;
  --sidebar-border:      rgba(255, 255, 255, 0.06);

  /* Status colors — slightly brighter for dark surfaces (WCAG AA on dark) */
  --tech-blue:   #60A5FA;
  --tech-cyan:   #22D3EE;
  --tech-green:  #34D399;
  --tech-red:    #F87171;
  --tech-purple: #A78BFA;
  --tech-orange: #FB923C;
  --tech-yellow: #FBBF24;
  --status-success: #34D399;
  --status-warning: #FB923C;
  --status-error:   #F87171;
  --status-info:    #60A5FA;

  /* Elevation — deeper black for more separation on dark backgrounds */
  --shadow-sm:   0 1px 2px 0 rgb(0 0 0 / 0.35);
  --shadow-md:   0 4px 12px -2px rgb(0 0 0 / 0.45);
  --shadow-lg:   0 16px 40px -8px rgb(0 0 0 / 0.55);
  --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.35), 0 1px 2px -1px rgb(0 0 0 / 0.30);

  /* Alert tints — brighter text on dark surfaces (WCAG AA on dark) */
  --alert-warning-bg:      rgba(251, 191, 36, 0.14);
  --alert-warning-border:  rgba(251, 191, 36, 0.35);
  --alert-warning-text:    #FBBF24;
  --alert-warning-subtext: #FCD34D;

  --alert-danger-bg:     rgba(248, 113, 113, 0.12);
  --alert-danger-border: rgba(248, 113, 113, 0.30);
  --alert-danger-text:   #F87171;

  --alert-info-bg:     rgba(96, 165, 250, 0.12);
  --alert-info-border: rgba(96, 165, 250, 0.30);
  --alert-info-text:   #60A5FA;

  --alert-success-bg:     rgba(52, 211, 153, 0.12);
  --alert-success-border: rgba(52, 211, 153, 0.30);
  --alert-success-text:   #34D399;

  --alert-blue-bg:      rgba(96, 165, 250, 0.10);
  --alert-blue-border:  rgba(96, 165, 250, 0.25);
  --alert-blue-text:    #93C5FD;

  --alert-purple-bg:     rgba(167, 139, 250, 0.14);
  --alert-purple-text:   #A78BFA;
  --alert-purple-border: rgba(167, 139, 250, 0.35);
  --alert-pink-bg:       rgba(236, 72, 153, 0.15);
  --alert-pink-text:     #F472B6;
}

/* Honour OS preference on first visit (JS persists explicit choice after) */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg-color: #0B1120; --bg-primary: #0B1120; --bg-secondary: #111827;
    --bg-tertiary: #1A2236; --bg-hover: rgba(255,255,255,0.05);
    --bg-active: rgba(79,195,202,0.12); --card-bg: #111827;
    --text-main: #F1F5F9; --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1; --text-muted: #94A3B8;
    --border-color: rgba(255,255,255,0.08); --border-light: rgba(255,255,255,0.06);
    --border-medium: rgba(255,255,255,0.12); --border-strong: rgba(255,255,255,0.20);
    --grid-line: rgba(148,163,184,0.06); --accent-light: rgba(79,195,202,0.15);
    --sidebar-bg-hover: rgba(255,255,255,0.04);
    --tech-blue: #60A5FA; --tech-cyan: #22D3EE; --tech-green: #34D399;
    --tech-red: #F87171; --tech-purple: #A78BFA; --tech-orange: #FB923C;
    --status-success: #34D399; --status-warning: #FB923C;
    --status-error: #F87171; --status-info: #60A5FA;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.35);
    --shadow-md: 0 4px 12px -2px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 16px 40px -8px rgb(0 0 0 / 0.55);
    --shadow-card: 0 1px 3px 0 rgb(0 0 0 / 0.35), 0 1px 2px -1px rgb(0 0 0 / 0.30);
  }
}

/* ============================================
   Dark-mode overrides for nexus-core.js injected styles.
   nexus-core.js is off-limits per CLAUDE.md — its <style> block
   is injected at runtime with hardcoded light-theme values for
   the user dropdown. These rules use html[data-theme="dark"]
   (specificity 0,1,1) to win over its bare `.class` selectors.
   ============================================ */
html[data-theme="dark"] .user-header-btn {
  border-color: var(--sidebar-border);
  color: var(--text-primary);
}
html[data-theme="dark"] .user-header-btn:hover {
  background: var(--bg-hover);
}
html[data-theme="dark"] .user-header-avatar {
  background: var(--bg-hover);
  color: var(--text-primary);
}
html[data-theme="dark"] .user-header-menu {
  background: var(--card-bg);
  border-color: var(--border-medium);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}
html[data-theme="dark"] .menu-divider {
  background: var(--border-light);
}
html[data-theme="dark"] .menu-item {
  color: var(--text-primary);
}
html[data-theme="dark"] .menu-item:hover {
  background: var(--bg-hover);
}
html[data-theme="dark"] .menu-email {
  color: var(--text-muted);
}
html[data-theme="dark"] .menu-item-danger {
  color: var(--tech-red);
}

/* ============================================
   MOBILE / TOUCH BASELINE
   Applies to all pages. Module-specific mobile rules
   (tables collapsing, sidebar drawers, etc.) still live
   in their own stylesheets; this is the shared foundation.

   Rules (per ui-ux-pro-max UX guide):
   • Touch targets ≥ 44×44px (severity: High)
   • ≥ 8px gap between adjacent touch targets
   • Form fields: min-height 44px for thumb accuracy
   • Overscroll contained (no accidental pull-to-refresh)
   • Prevent iOS text-size auto-inflation
   ============================================ */

/* Global touch-scroll + text-inflate guards */
html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  /* 2026-05-19 root-cause fix for the "Times New Roman" reports:
     Many per-page <style> blocks declare `body { font-family: inherit; }`.
     With Inter only declared on body, that override walked up to <html>,
     which has no font-family by default, so the cascade landed on the
     UA initial value ("serif" / Times). Setting it on <html> means every
     `inherit` below — body or descendant — actually inherits Inter.
     Keep the body declaration too for belt-and-braces and so devtools
     shows the canonical stack at the body level. */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}
body {
  overscroll-behavior-y: contain;
}

/* ========== Mobile tablet and down (<= 768px) ========== */
@media (max-width: 768px) {
  /* Touch-sized icon buttons across every page */
  .header-icon-btn,
  .topbar-btn,
  .theme-toggle {
    width: 44px;
    height: 44px;
  }

  /* Header: SINGLE row on mobile — never wrap (would push page content
     down unpredictably and collide with sticky positioning). Items that
     don't fit are hidden at the 480px breakpoint further below.
     overflow-x: clip to keep dropdowns visible vertically but trim
     any horizontal overflow from squeezed content. */
  .header,
  .topbar {
    flex-wrap: nowrap;
    padding: 6px 10px;
    height: 56px;
    min-height: 56px;
    max-height: 56px;
    gap: 6px;
    overflow-x: clip;
    overflow-y: visible;
  }
  .header-left,
  .topbar-left {
    gap: 8px;
    min-width: 0;
    flex: 0 1 auto;
  }
  .header-right,
  .topbar-right {
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 0;
    justify-content: flex-end;
    margin-left: auto;
  }

  /* User badge: hide the name, keep the avatar */
  .header-user-badge .header-user-name { display: none; }
  .header-avatar {
    width: 36px;
    height: 36px;
  }

  /* Logo divider: hide on mobile (saves horizontal space) */
  .logo-divider { display: none; }

  /* On mobile, swap the Command Center page title for the Nexus logo
     (matches every other page's header). Bebas Neue at 1.75rem otherwise
     wraps to two lines once the hamburger + right-side icons claim their
     space on a 390px viewport. */
  .topbar .page-title,
  .header .page-title {
    display: none;
  }
  .topbar-mobile-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
  }
  .topbar-mobile-logo img {
    height: 24px;
    width: auto;
    display: block;
  }

  /* Logo image: slightly smaller on mobile */
  .header-left img,
  .topbar-left img { height: 24px; max-height: 28px; }

  /* Module "badge" in the header (TICKETS, MACHINES, etc.) */
  .header .badge,
  .topbar .badge {
    font-size: 12px;
    padding: 2px 6px;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  /* Module action buttons stay inline, no wrap, small gap */
  .header-actions,
  .topbar-actions {
    flex-wrap: nowrap;
    gap: 4px;
    flex-shrink: 0;
  }
  .header-actions .btn,
  .header-actions .btn-secondary,
  .topbar-actions .btn,
  .topbar-actions .btn-secondary {
    min-height: 40px;
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  /* Forms: 44px minimum for inputs so keyboard users can tap accurately */
  .input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="url"],
  input[type="tel"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;  /* prevents iOS zoom on focus */
  }
  textarea { min-height: 88px; }

  /* Buttons: min 40px for proper tap area */
  .btn, .btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
    min-height: 40px;
  }
  .btn-sm {
    min-height: 36px;
  }

  /* Cards: tighten padding slightly on small screens */
  .card {
    padding: 14px;
  }

  /* Tables: enable smooth horizontal scroll.
     Apply to the card WRAPPER because <table> itself can't scroll. */
  .card:has(> table),
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Tables reset their row-height to a compact 40px for touch rows */
  table td, table th {
    min-height: 44px;
  }

  /* Dialogs: fullscreen on small phones */
  dialog {
    max-width: 100vw;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }
  .modal-body { max-height: calc(100vh - 130px); }
  .modal-header,
  .modal-footer {
    border-radius: 0;
    padding: 14px 16px;
  }

  /* Tabs: horizontal scroll with hidden scrollbar */
  .tabs,
  .reply-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tabs::-webkit-scrollbar,
  .reply-tabs::-webkit-scrollbar { display: none; }

  /* Hide the system-status "Connected" label text — dot + badge remain */
  .system-status .status-text { display: none; }

  /* Main content padding shrinks on mobile */
  main,
  .main-content,
  .main-container,
  .page-wrapper,
  .dashboard {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Collapse utility grids to a single column on narrow screens */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Stats grids — 2 columns on tablet, 1 on phone */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Form rows go single-column */
  .form-row {
    grid-template-columns: 1fr !important;
  }

  /* Filter bars wrap */
  .filter-bar,
  .filters-bar,
  .filters-section,
  #filtersSection {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Sidebars: if a module uses a left sidebar, default it to
     hidden-by-default with transform, revealed via .open.
     NOTE: selectors here must stay at (0,1,0) specificity so the
     `.open` rule below (at 0,2,0) can override the transform. An
     earlier version used `:not()` which pushed specificity to (0,4,0)
     and silently broke the mobile hamburger — sidebar never slid in. */
  .sidebar,
  .kc-sidebar,
  .hr-sidebar,
  .fin-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    z-index: 200;
  }
  .sidebar.open,
  .kc-sidebar.open,
  .hr-sidebar.open,
  .fin-sidebar.open {
    transform: translateX(0);
  }

  /* Body takes full width when sidebar is hidden */
  .main-content,
  .kc-main,
  .hr-main,
  .fin-main {
    margin-left: 0 !important;
    width: 100%;
  }
}

/* ========== Small phones (<= 480px) ========== */
@media (max-width: 480px) {
  /* Even tighter header padding */
  .header,
  .topbar {
    padding: 6px 8px;
    gap: 4px;
  }
  .header-left img,
  .topbar-left img { height: 20px; max-height: 24px; }
  .header .logo-text,
  .topbar .logo-text {
    font-size: 18px;
  }
  /* Hide module badge (TICKETS/MACHINES/etc. text) — logo still identifies the app */
  .header .badge,
  .topbar .badge { display: none; }

  /* Module-specific quick-nav links — hide on 480 */
  .header-actions > .header-icon-btn[title="Live Dashboard"],
  .header-actions > .header-icon-btn[title="Field Service Map"],
  .header-actions > .header-icon-btn[title="Service / Install Calendar"] {
    display: none;
  }

  /* Module action buttons (Add / Export / Import / etc.) — hide ALL from header.
     This includes the primary action. Pages that need the primary action
     accessible on mobile should provide an in-page affordance (empty-state
     CTA, FAB, or inline list "New" button). Hiding gives us breathing room. */
  .header-actions .btn,
  .header-actions .btn-secondary,
  .topbar-actions .btn:not([data-theme-toggle]),
  .topbar-actions .btn-secondary { display: none; }

  /* Compress header-right icons further + drop low-priority ones.
     Priority kept at 480px: user avatar, theme toggle, logout.
     Priority dropped: admin link (rare on mobile), home link (browser back). */
  .header-icon-btn,
  .topbar-btn {
    width: 36px;
    height: 36px;
  }
  .header-avatar { width: 30px; height: 30px; }
  .header-right > a[href="/index.html"],
  .topbar-right > a[href="/index.html"] { display: none; }
  /* Admin is already display:none for non-admins via JS; for admins on
     mobile, prefer keeping the admin link visible only on 481px+ */
  .header-right > a#adminBtn,
  .topbar-right > a#adminBtn { display: none; }

  /* Allow header-right to shrink if content still overflows */
  .header-right, .topbar-right { flex-shrink: 1; min-width: 0; }

  /* Card padding */
  .card { padding: 12px; }
  .modal-body { padding: 16px; }
}

/* Accessibility: respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

body {
  /* 2026-05-19 polish pass: graph-paper grid background removed. It was
     pure decoration — no signal, hurt readability of any data-dense table
     or list, and was the loudest thing on every page. Plain background
     surfaces now read clean. */
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03'; /* Inter refinements */
  min-height: 100vh;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Typography ---
   2026-05-19: Stack is Inter + JetBrains Mono only. Display use cases
   (logo, module badge, what used to be Bebas Neue) become Inter 600
   uppercase with wider tracking — same "display" feel, one family. */
h1, h2, h3, h4, h5, h6 {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* Display utility — replaces Bebas Neue. Inter 600/700 uppercase tracked. */
.font-display,
.logo-text,
.sidebar-brand {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Mono utility — code, ticket IDs, tabular numbers in headings. */
.tech-font,
.font-mono,
code,
pre,
kbd,
samp {
  font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

/* Tabular-numerics utility — apply to any column of counts / durations / dates. */
.num,
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

/* ============================================
   DARK MODULE HEADER
   ============================================ */
.header { 
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  padding: 0 24px; 
  position: sticky; 
  top: 0; 
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

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

.logo-text {
  /* Inter 700 uppercase tracked replaces Bebas Neue (2026-05-19 typography pass) */
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--sidebar-text-bright);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.logo-divider {
  height: 24px;
  width: 1px;
  background: var(--sidebar-border);
  margin: 0 10px;
}

/* Header module title badge — Inter 600 uppercase tracked replaces Bebas Neue */
.header .badge {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: none;
  background: transparent;
  color: var(--sidebar-text-bright);
}

/* Back to dashboard link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.back-link:hover {
  color: var(--sidebar-text-bright);
  background: var(--sidebar-bg-hover);
}

/* ============================================
   SHARED LOOKUPS / DROPDOWNS / SELECT-COMBO
   Used by: machine-detail country picker, ticket assignment,
   org lookup, user pickers, and any .select-* combobox.
   Class names deliberately kept generic so new lookup
   components inherit correct dark-mode styling for free.
   ============================================ */

/* Generic combobox container (wraps trigger + dropdown) */
.select-container,
.user-select-container {
  position: relative;
  width: 100%;
}

/* The visible trigger button */
.select-display,
.user-select-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  min-height: 22px;
  transition: border-color var(--transition-fast);
}

.select-display:hover,
.user-select-display:hover {
  border-color: var(--border-strong);
}

.select-display.open,
.user-select-display.open {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Clear (×) button inside the trigger */
.select-clear,
.user-select-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px; line-height: 1;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.select-clear:hover,
.user-select-clear:hover {
  background: var(--tech-red);
  color: #fff;
}

/* The dropdown panel itself */
.select-dropdown,
.user-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--card-bg);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
}

.select-dropdown.open,
.user-select-dropdown.open {
  display: block;
}

/* Sticky search input header */
.select-search,
.dropdown-search-container {
  position: sticky;
  top: 0;
  background: var(--card-bg);
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  z-index: 1;
}

.select-search input,
.dropdown-search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select-search input:focus,
.dropdown-search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.select-search input::placeholder,
.dropdown-search-input::placeholder {
  color: var(--text-muted);
}

/* Individual option rows */
.select-option,
.user-select-option,
.dropdown-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-fast);
}

.select-option:last-child,
.user-select-option:last-child,
.dropdown-option:last-child {
  border-bottom: none;
}

.select-option:hover,
.user-select-option:hover,
.dropdown-option:hover {
  background: var(--bg-hover);
}

.select-option.selected,
.user-select-option.selected,
.dropdown-option.selected {
  background: var(--accent-light);
  color: var(--accent-secondary);
}

.select-option.hidden,
.user-select-option.hidden,
.dropdown-option.hidden {
  display: none;
}

/* Empty-state message inside dropdown */
.select-empty,
.dropdown-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================
   THEME TOGGLE
   ============================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-bright);
  border-color: var(--sidebar-text);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Theme toggle outside the dark topbar (e.g. on cards) */
.theme-toggle--light {
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

.theme-toggle--light:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* ============================================
   UNIFIED BUTTON STYLES
   ============================================ */

/* Primary Button - AMT Turquoise */
.btn,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-gradient);
  color: white;
  padding: 10px 20px;
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 8px rgba(79, 195, 202, 0.25);
}

.btn:hover,
.btn-primary:hover {
  background: linear-gradient(135deg, #3BA8AE 0%, #2D8A8F 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 195, 202, 0.35);
}

.btn:disabled,
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary Button - Outlined */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-primary);
  padding: 10px 20px;
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  text-align: center;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Danger Button */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--tech-red);
  color: white;
  padding: 10px 20px;
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-danger:hover {
  background: #DC2626;
  transform: translateY(-1px);
}

/* Ghost Button */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--text-secondary);
  padding: 10px 20px;
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Small Button */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Large Button */
.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

/* Icon Button */
.btn-icon {
  padding: 10px;
  min-width: 40px;
  min-height: 40px;
}

/* Header Buttons */
.header .btn {
  background: var(--accent-primary);
  border: none;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-md);
}

.header .btn:hover {
  background: var(--accent-secondary);
}

.header .btn-secondary {
  background: transparent;
  border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
}

.header .btn-secondary:hover {
  background: var(--sidebar-bg-hover);
  border-color: var(--sidebar-text);
  color: var(--sidebar-text-bright);
}

/* ============================================
   CARDS - Modern Clean Design
   ============================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Remove futuristic clip-path and corner decorations */
.card::before,
.card::after {
  display: none;
}

/* ============================================
   FORM INPUTS
   ============================================ */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  color: var(--text-main);
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: var(--bg-secondary);
}

.input:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  outline: none;
}

.input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* ============================================
   ORGANIZATION LOOKUP (Autocomplete)
   ============================================ */
.org-lookup {
  position: relative;
}

.org-lookup-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.org-lookup-results.open {
  display: block;
}

.org-lookup-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-main);
  transition: background var(--transition-fast);
}

.org-lookup-item:hover,
.org-lookup-item.active {
  background: var(--accent-light);
  color: var(--accent-secondary);
}

.org-lookup-hint {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.org-lookup-selected {
  border-color: var(--accent-primary);
  background: var(--accent-light);
}

/* ============================================
   LIST ROWS
   ============================================ */
.row {
  padding: 14px 16px;
  margin-bottom: 2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

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

.row.selected {
  background: var(--accent-light);
  border-left-color: var(--accent-primary);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 20px;
  text-transform: capitalize;
}

.badge-green {
  background: var(--amt-green-light);
  color: var(--amt-green);
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.badge-gray {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.badge-cyan,
.badge-blue {
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise-dark);
}

.badge-red {
  background: rgba(239, 68, 68, 0.1);
  color: var(--tech-red);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.1);
  color: var(--tech-purple);
}

.badge-orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--tech-orange);
}

.badge-warning {
  background: rgba(249, 115, 22, 0.1);
  color: #EA580C;
}

.badge-info {
  background: rgba(59, 130, 246, 0.08);
  color: #2563EB;
}

.badge-category {
  background: transparent;
  color: var(--amt-turquoise-dark);
  border: 1.5px solid var(--amt-turquoise-dark);
}

.pill-customer-visible {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  font-size: 9px;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.1);
  color: var(--tech-purple);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  margin-left: 4px;
  white-space: nowrap;
}

/* ============================================
   MODALS / DIALOGS
   ============================================ */
dialog {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  color: var(--text-main);
  padding: 0;
  max-width: 90vw;
  max-height: 90vh;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  overflow: hidden;
}

dialog[open] {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

dialog::backdrop {
  background: rgba(21, 46, 53, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
}

/* ── Modal motion ─────────────────────────────────────────────
   Tasteful enter/exit for native <dialog>. Subtle scale + fade,
   no slide-from-side. Applies to anything opened with .showModal().
   The exit animation only runs when JS adds .nx-dialog-closing
   before calling .close(); see closeNexusDialog() in nexus-core.js. */
@keyframes nx-dialog-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes nx-dialog-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, -50%) scale(0.985); }
}
@keyframes nx-dialog-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes nx-dialog-backdrop-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

dialog[open]:not(.nx-dialog-closing):not(.nx-drawer) {
  animation: nx-dialog-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
dialog[open]:not(.nx-dialog-closing):not(.nx-drawer)::backdrop {
  animation: nx-dialog-backdrop-in 160ms ease-out;
}
dialog.nx-dialog-closing {
  animation: nx-dialog-out 140ms cubic-bezier(0.4, 0, 1, 1) forwards;
}
dialog.nx-dialog-closing::backdrop {
  animation: nx-dialog-backdrop-out 140ms ease-in forwards;
}

@media (prefers-reduced-motion: reduce) {
  dialog[open]:not(.nx-dialog-closing):not(.nx-drawer),
  dialog[open]:not(.nx-dialog-closing):not(.nx-drawer)::backdrop,
  dialog.nx-dialog-closing,
  dialog.nx-dialog-closing::backdrop {
    animation: none !important;
  }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-tertiary);
}

.modal-header h3 {
  font-weight: 600;
  font-size: 18px;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-tertiary);
}

/* ============================================
   TABLES
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

tr:hover {
  background: var(--bg-hover);
}

/* ============================================
   STATS & DETAILS
   ============================================ */
.stat-box {
  padding: 20px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}

.stat-number {
  font-family: inherit;
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.detail-label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
  letter-spacing: 0.03em;
}

.detail-value {
  font-family: inherit;
  font-size: 15px;
  color: var(--text-main);
  font-weight: 500;
}

/* ============================================
   LOADING STATES
   ============================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  border: 3px solid var(--border-light);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
}

/* ============================================
   SCROLLBARS
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--amt-light-grey);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--accent-primary); }

/* ============================================
   ITEM CARDS (components/tools)
   ============================================ */
.item-card {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-fast);
}

.item-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.item-image {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.item-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ============================================
   FORM SECTIONS
   ============================================ */
.form-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.form-section h4 {
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 16px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ============================================
   COMMAND CENTER V2 - SIDEBAR LAYOUT
   ============================================ */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: width var(--transition-normal);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .search-input,
.sidebar.collapsed .search-shortcut,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item-text,
.sidebar.collapsed .nav-item-badge,
.sidebar.collapsed .user-details,
.sidebar.collapsed .nav-section-title {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 20px 0;
}

/* In collapsed state, center the collapse button */
.sidebar.collapsed .sidebar-collapse-btn {
  position: static;
  transform: none;
  margin: 0 auto;
}

.sidebar.collapsed .sidebar-search {
  padding: 8px 12px;
}

.sidebar.collapsed .search-input-wrapper {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-section-header {
  justify-content: center;
  padding: 8px 0;
}

.sidebar.collapsed .nav-section-toggle {
  margin: 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .nav-item-icon {
  margin-right: 0;
}

.sidebar.collapsed .sidebar-footer {
  padding: 16px 0;
}

.sidebar.collapsed .user-info {
  justify-content: center;
}

.sidebar.collapsed .user-avatar {
  margin: 0 auto;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  display: none;
  flex-shrink: 0;
}

/* Hide ALL logos when sidebar is collapsed */
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .sidebar-logo-icon {
  display: none;
}

.sidebar-collapse-btn {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-bright);
}

.sidebar-brand {
  /* Inter 700 uppercase tracked replaces Bebas Neue (2026-05-19 typography pass) */
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text-bright);
}

/* Sidebar Search */
.sidebar-search {
  padding: 16px 16px 8px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--sidebar-bg-hover);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.search-input-wrapper:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.search-input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 195, 202, 0.15);
}

.search-icon {
  color: var(--sidebar-text);
  flex-shrink: 0;
}

.sidebar-search .search-placeholder {
  color: var(--sidebar-text);
  font-size: 14px;
  font-family: inherit;
  flex: 1;
  min-width: 0;
  text-align: left;
}

.sidebar-search .search-input-wrapper {
  border: 1px solid var(--sidebar-border);
  width: 100%;
}

.sidebar-search .search-input-wrapper:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(79, 195, 202, 0.15);
}

/* Hide search shortcut */
.sidebar-search .search-shortcut,
.search-shortcut {
  display: none;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.nav-loading {
  padding: 20px;
  text-align: center;
  color: var(--sidebar-text);
  font-size: 14px;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 6px;
  cursor: pointer;
  user-select: none;
  background: none;
  border: none;
  width: 100%;
  color: inherit;
  font: inherit;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
}

.nav-section-toggle {
  color: var(--sidebar-text);
  transition: transform var(--transition-fast);
}

.nav-section.collapsed .nav-section-toggle {
  transform: rotate(-90deg);
}

.nav-section.collapsed .nav-section-items {
  display: none;
}

.nav-section-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-item:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-bright);
}

.nav-item.active {
  background: var(--sidebar-bg-active);
  color: var(--accent-primary);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
}

.nav-item-icon svg {
  width: 18px;
  height: 18px;
}

.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon {
  color: inherit;
}

.nav-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item-badge {
  background: var(--accent-primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.nav-item-badge.locked-badge {
  background: transparent;
  color: var(--sidebar-text);
  padding: 0;
  min-width: auto;
}

.locked-indicator {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--text-muted);
  vertical-align: middle;
}

.locked-indicator svg {
  width: 12px;
  height: 12px;
}

.nav-item.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-item.locked:hover {
  background: transparent;
  color: var(--sidebar-text);
}

/* ============================================
   FOCUS-VISIBLE STYLES - Keyboard accessibility
   ============================================ */
.nav-item:focus-visible,
.nav-section-header:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

.topbar-btn:focus-visible,
.mobile-menu-btn:focus-visible,
.sidebar-collapse-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.module-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: var(--shadow-md);
}

.command-item:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  background: var(--bg-tertiary);
}

.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.view-btn:focus-visible,
.tab:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.dept-module-card:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  text-align: left;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  display: block;
  font-size: 12px;
  color: var(--sidebar-text);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-normal);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* Top Bar */
.topbar {
  height: var(--topbar-height);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 8px;
}

.page-title {
  /* Inter 700 uppercase tracked replaces Bebas Neue (2026-05-19 typography pass) */
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-text-bright);
}

/* Mobile-only logo in the topbar (shown via the @media (max-width: 768px)
   block above, hidden on desktop). Used only on index.html/command
   center where the sidebar normally carries the logo.
   NOTE: must use min-width (not a bare rule) — the bare rule would
   always be the last declaration and would override the mobile flex
   rule even inside the 768px breakpoint. */
@media (min-width: 769px) {
  .topbar-mobile-logo { display: none; }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* System Status */
.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-success);
  animation: pulse 2s infinite;
}

.topbar .system-status {
  padding: 8px 16px;
  background: var(--amt-green-light);
  border-radius: var(--radius-lg);
  margin-right: 12px;
  font-size: 13px;
  color: var(--status-success);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--status-success);
}

.topbar-btn {
  background: none;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.topbar-btn:hover {
  background: var(--sidebar-bg-hover);
  color: var(--sidebar-text-bright);
}

.topbar-btn.active {
  color: var(--accent-primary);
}

.topbar-btn.logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--status-error);
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard {
  flex: 1;
  padding: 32px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

/* Welcome Section */
.welcome-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding: 28px 32px;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
}

.welcome-title {
  font-family: inherit;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: 15px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card.loading {
  opacity: 0.6;
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.technical { background: var(--amt-turquoise-light); color: var(--amt-turquoise); }
.stat-icon.operations { background: var(--amt-green-light); color: var(--amt-green); }
.stat-icon.sales { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.stat-icon.finance { background: var(--amt-turquoise-light); color: var(--amt-turquoise); }

.stat-content {
  flex: 1;
}

.stat-value {
  font-family: inherit;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 8px;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.stat-change.positive {
  color: var(--status-success);
  background: var(--amt-green-light);
}

.stat-change.negative {
  color: var(--status-error);
  background: rgba(239, 68, 68, 0.1);
}

/* Dashboard Grid */
.dashboard-grid {
  display: block;
  margin-bottom: 32px;
}

.pinned-modules {
  width: 100%;
}

/* Dashboard Sections */
.dashboard-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-title svg {
  color: var(--amt-turquoise);
}

.section-action {
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-primary);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.section-action:hover {
  color: var(--accent-secondary);
}

/* ============================================
   MODULE CARDS
   ============================================ */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.module-card-loading,
.modules-loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.module-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  position: relative;
}

.module-card:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.module-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.module-card.locked:hover {
  background: var(--bg-tertiary);
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.module-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
}

.module-icon svg {
  width: 26px;
  height: 26px;
}

.module-icon.technical { background: var(--amt-turquoise-light); color: var(--amt-turquoise); }
.module-icon.operations { background: var(--amt-green-light); color: var(--amt-green); }
.module-icon.sales { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.module-icon.finance { background: var(--amt-turquoise-light); color: var(--amt-turquoise); }
.module-icon.customer { background: var(--amt-turquoise-light); color: var(--amt-turquoise); }
.module-icon.logistics { background: rgba(139, 92, 246, 0.1); color: #8B5CF6; }
.module-icon.hr { background: var(--amt-green-light); color: var(--amt-green); }

.module-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.module-count {
  font-size: 13px;
  color: var(--text-muted);
}

.module-access-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.module-access-badge.admin {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.module-access-badge.editor {
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
}

.module-access-badge.viewer {
  background: var(--amt-green-light);
  color: var(--amt-green);
}

.module-access-badge.locked {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
}

/* ============================================
   QUICK STATS / ACTIVITY LIST
   ============================================ */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item,
.stat-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.activity-item:hover,
.stat-item:hover {
  background: var(--bg-hover);
}

.activity-icon,
.stat-item-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg,
.stat-item-icon svg {
  width: 20px;
  height: 20px;
}

.activity-content,
.stat-item-content {
  flex: 1;
  min-width: 0;
}

.activity-text,
.stat-item-label {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.activity-text strong {
  font-weight: 600;
  color: var(--text-primary);
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-item-value {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   COMMAND PALETTE
   ============================================ */
.command-palette {
  width: 600px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.command-palette-content {
  display: flex;
  flex-direction: column;
}

.command-search {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
}

.command-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.command-search input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text-primary);
  outline: none;
}

.command-search input:focus {
  outline: none;
  box-shadow: none;
  background: transparent;
}

.command-search input::placeholder {
  color: var(--text-muted);
}

.command-search input::selection {
  background: rgba(79, 195, 202, 0.2);
}

.command-search kbd {
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}

.command-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
}

.command-section {
  margin-bottom: 12px;
}

.command-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.command-item:hover {
  background: var(--bg-tertiary);
}

.command-item.selected,
.command-item.command-item-active {
  background: var(--accent-light);
}

.command-item.command-item-active {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.command-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.command-item-icon svg {
  width: 18px;
  height: 18px;
}

.command-item-content {
  flex: 1;
}

.command-item-title {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}

.command-item-description {
  font-size: 12px;
  color: var(--text-muted);
}

.command-item[style*="cursor: not-allowed"] {
  opacity: 0.5;
}

/* ============================================
   QUICK CREATE MODAL
   ============================================ */
.quick-create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.quick-create-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 16px;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.quick-create-item:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.quick-create-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-create-icon svg {
  width: 24px;
  height: 24px;
}

.quick-create-label {
  font-weight: 500;
  font-size: 14px;
  text-align: center;
  color: var(--text-primary);
}

.no-quick-actions {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   DEPARTMENT VIEW
   ============================================ */
.department-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.department-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
}

.department-header:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.department-header:hover {
  background: var(--bg-tertiary);
}

.department-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
}

.department-icon svg {
  width: 24px;
  height: 24px;
}

.department-info {
  flex: 1;
}

.department-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.department-meta,
.department-count {
  font-size: 13px;
  color: var(--text-muted);
}

.department-toggle {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.department-section.expanded .department-toggle,
.department-group.expanded .department-toggle {
  transform: rotate(180deg);
}

.department-content {
  display: none;
  padding: 20px 24px;
  background: var(--bg-tertiary);
}

.department-section.expanded .department-content,
.department-group.expanded .department-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.dept-module-item,
.dept-module-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
}

.dept-module-item:hover,
.dept-module-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

.dept-module-item.locked,
.dept-module-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.dept-module-item.locked:hover,
.dept-module-card.locked:hover {
  border-color: var(--border-light);
  box-shadow: none;
}

.dept-module-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dept-module-icon svg {
  width: 18px;
  height: 18px;
}

.dept-module-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}

/* ============================================
   HEADER USER BADGE
   ============================================ */
.header-user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sidebar-border);
  border-radius: 24px;
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}

.header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.header-user-name {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text-bright);
  white-space: nowrap;
}

/* Header Icon Buttons */
.header-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.header-icon-btn:hover {
  background: var(--sidebar-bg-hover);
  border-color: var(--sidebar-text);
  color: var(--sidebar-text-bright);
}

.header-icon-btn svg {
  width: 20px;
  height: 20px;
}

.header-icon-btn.logout-btn:hover {
  border-color: #EF4444;
  color: #EF4444;
}

/* Header Actions Group */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  padding-right: 16px;
  border-right: 1px solid var(--sidebar-border);
}

/* ============================================
   VIEW TOGGLE
   ============================================ */
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
}

.view-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-family: inherit;
}

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

.view-btn.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   MOBILE SIDEBAR BACKDROP
   ============================================ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(21, 46, 53, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}

body.sidebar-open {
  overflow: hidden;
}

/* ============================================
   USER AVATAR IMAGE (replaces inline style)
   ============================================ */
.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* ============================================
   LOCKED MODULE CARD STATES (replaces inline styles)
   ============================================ */
.module-icon-locked { opacity: 0.4; }
.module-name-locked { opacity: 0.5; }
.module-count-locked { opacity: 0.4; }

/* Command palette locked items */
.command-item-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Quick create empty state */
.quick-create-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .mobile-menu-btn {
    display: flex;
  }
  
  .topbar {
    padding: 0 20px;
  }
  
  .dashboard {
    padding: 20px;
  }
  
  .welcome-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .system-status .status-text {
    display: none;
  }
  
  .modules-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .modules-grid {
    grid-template-columns: 1fr;
  }
  
  .quick-create-grid {
    grid-template-columns: 1fr;
  }
  
  .department-content {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   SIDEBAR SCROLLBAR
   ============================================ */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--sidebar-border);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--sidebar-text);
}

/* ============================================
   UTILITY: Screen Reader Only
   ============================================ */
.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================
   TABS - Consistent Style
   ============================================ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   ALERTS / NOTIFICATIONS
   ============================================ */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.alert-message {
  font-size: 14px;
  opacity: 0.9;
}

.alert-info {
  background: var(--amt-turquoise-light);
  color: var(--amt-turquoise-dark);
}

.alert-success {
  background: var(--amt-green-light);
  color: var(--amt-green);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}

/* ============================================
   TOOLTIP
   ============================================ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text-bright);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  margin-bottom: 8px;
}

[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state-icon svg {
  width: 32px;
  height: 32px;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-description {
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto;
}

/* ============================================
   SKELETON LOADERS
   ============================================ */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-hover) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  min-height: 140px;
}

.skeleton-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.skeleton-text {
  height: 14px;
  width: 70%;
  margin-bottom: 8px;
}

.skeleton-text-sm {
  height: 12px;
  width: 50%;
}

/* ============================================
   RECENTLY USED MODULES
   ============================================ */
.recently-used-section {
  margin-bottom: 24px;
}

.recently-used-section .section-title {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.recently-used-grid {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.recently-used-grid .module-card {
  min-width: 180px;
  flex-shrink: 0;
  padding: 18px 20px;
}

/* ============================================
   RICHER CARD STATES
   ============================================ */
.module-card:active:not(.locked) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.command-item:active:not(.command-item-locked) {
  background: var(--accent-light);
}

/* ============================================
   PREFERS-REDUCED-MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
    transition-duration: 0.01ms;
    scroll-behavior: auto;
  }

  .skeleton {
    animation: none;
    background: var(--bg-tertiary);
  }

  .module-card:hover,
  .stat-card:hover {
    transform: none;
  }

  .status-indicator {
    animation: none;
  }
}

/* ============================================
   SLA CONFIG PANEL — Machine Type Settings
   ============================================ */

/* Section container */
.sla-configs-section {
  border-top: 2px solid var(--accent-primary);
  padding-top: 20px;
  margin-top: 12px;
}

.sla-configs-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.sla-configs-header-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sla-configs-header-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sla-configs-header-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--accent-primary);
}

.sla-configs-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.sla-configs-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Tab strip */
.sla-config-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 0;
}

/* Main panel */
.sla-config-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Each SLA section card */
.sla-config-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--card-bg);
  border-left: 3px solid var(--border-color);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sla-config-section:hover {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Section color accents — left border */
.sla-section--response   { border-left-color: var(--accent-primary); }
.sla-section--subsequent { border-left-color: #8B5CF6; }
.sla-section--remote     { border-left-color: #3B82F6; }
.sla-section--onsite     { border-left-color: #F59E0B; }
.sla-section--collection { border-left-color: #EC4899; }

/* Section header */
.sla-section-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.sla-section-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  opacity: 0.55;
}

.sla-section--response   .sla-section-icon { color: var(--accent-primary); }
.sla-section--subsequent .sla-section-icon { color: #8B5CF6; }
.sla-section--remote     .sla-section-icon { color: #3B82F6; }
.sla-section--onsite     .sla-section-icon { color: #F59E0B; }
.sla-section--collection .sla-section-icon { color: #EC4899; }

.sla-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  line-height: 1.3;
}

.sla-section-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Priority grid — 4 columns */
.sla-priority-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

/* Individual priority field */
.sla-priority-field {
  position: relative;
}

/* Priority labels with colored dots */
.sla-priority-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.sla-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Priority dot colors */
.sla-priority--critical .sla-priority-dot { background: #EF4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18); }
.sla-priority--high     .sla-priority-dot { background: #F97316; box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.18); }
.sla-priority--medium   .sla-priority-dot { background: #EAB308; box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.18); }
.sla-priority--low      .sla-priority-dot { background: #94A3B8; box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.18); }

/* Priority label text colors */
.sla-priority--critical .sla-priority-label { color: #DC2626; }
.sla-priority--high     .sla-priority-label { color: #EA580C; }
.sla-priority--medium   .sla-priority-label { color: #CA8A04; }
.sla-priority--low      .sla-priority-label { color: #64748B; }

/* Input with unit suffix */
.sla-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sla-time-input {
  padding-right: 32px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.sla-time-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.sla-input-unit {
  position: absolute;
  right: 8px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Focus color override per priority */
.sla-priority--critical .sla-time-input:focus { border-color: #EF4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12); }
.sla-priority--high     .sla-time-input:focus { border-color: #F97316; box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.12); }
.sla-priority--medium   .sla-time-input:focus { border-color: #EAB308; box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.12); }
.sla-priority--low      .sla-time-input:focus { border-color: #94A3B8; box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.12); }

/* Config tabs */
.sla-config-tab {
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
  background: var(--card-bg);
  color: var(--text-secondary);
  line-height: 1;
}

.sla-config-tab:hover {
  background: var(--bg-hover);
  border-color: var(--border-medium);
}

.sla-config-tab--active {
  background: var(--amt-dark-grey);
  color: #fff;
  border-color: var(--amt-dark-grey);
  box-shadow: 0 1px 3px rgba(21, 46, 53, 0.2);
}

.sla-config-tab--active:hover {
  background: var(--amt-grey);
  border-color: var(--amt-grey);
}

.sla-config-tab--active svg {
  opacity: 0.8;
}

.sla-config-tab-remove {
  margin-left: 2px;
  font-size: 10px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}

.sla-config-tab-remove:hover {
  opacity: 1;
}

.sla-config-tab-badge {
  background: var(--accent-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
}

.sla-config-tab--active .sla-config-tab-badge {
  background: rgba(255, 255, 255, 0.25);
}

/* Group members header above SLA panel */
.sla-group-members {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
}

.sla-group-members-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.sla-group-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--accent-light);
  color: var(--accent-secondary);
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.sla-group-edit-btn {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.sla-group-edit-btn:hover {
  background: var(--accent-light);
}

/* Warranty / Cover sub-tab bar within machine config */
.sla-warranty-subtabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 12px;
  padding: 0 2px;
  overflow-x: auto;
}

.sla-warranty-subtab {
  position: relative;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.sla-warranty-subtab:hover {
  color: var(--text-primary);
}

.sla-warranty-subtab--active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  font-weight: 600;
}

.sla-warranty-subtab--add {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  opacity: 0.6;
}

.sla-warranty-subtab--add:hover {
  opacity: 1;
  color: var(--accent-primary);
}

.sla-warranty-subtab-remove {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.sla-warranty-subtab:hover .sla-warranty-subtab-remove {
  opacity: 0.6;
}

.sla-warranty-subtab-remove:hover {
  opacity: 1;
  color: var(--danger-color, #ef4444);
}

/* Responsive: stack on narrow modals */
@media (max-width: 480px) {
  .sla-priority-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .sla-configs-header {
    flex-direction: column;
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================================
   AGENT PRESENCE — read-only header pill (mirrors Microsoft Teams)
   Mounted next to #userInfo for users with is_ticketing_team_member.
   Source of truth: Teams. Users update their status in Teams; Nexus
   polls Graph every 60s and reflects what Teams reports.
   ============================================================ */
.presence-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  margin-right: 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: help;        /* read-only: hover hint, not a clickable control */
  user-select: none;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
  font-family: inherit;
  white-space: nowrap;
}

.presence-pill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: inherit;
}
.presence-pill-icon svg { display: block; }
.presence-pill-label { display: inline-block; }

/* Available — AMT green */
.presence-pill[data-status="available"] {
  background: var(--amt-green-light);
  border-color: rgba(93, 187, 99, 0.35);
  color: var(--amt-green-dark);
}
.presence-pill[data-status="available"]:hover {
  background: rgba(93, 187, 99, 0.18);
}
.presence-pill[data-status="available"] .presence-pill-icon {
  color: var(--amt-green);
  filter: drop-shadow(0 0 3px rgba(93, 187, 99, 0.55));
}

/* Away — neutral muted (default) */
/* Away — yellow, matching Teams' "stepped away" convention */
.presence-pill[data-status="away"] {
  background: rgba(234, 179, 8, 0.10);
  border-color: rgba(234, 179, 8, 0.35);
  color: #854D0E;
}
.presence-pill[data-status="away"] .presence-pill-icon {
  color: #CA8A04;
}

/* Busy — red; the icon SVG already includes a white bar (Teams DnD pattern) */
.presence-pill[data-status="busy"] {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.30);
  color: #991B1B;
}
.presence-pill[data-status="busy"] .presence-pill-icon {
  color: #DC2626;
}

/* Off-duty — planned absence, calm violet tone (red is reserved for true urgency) */
.presence-pill[data-status="off_duty"] {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
  color: #6D28D9;
}
.presence-pill[data-status="off_duty"] .presence-pill-icon {
  color: #8B5CF6;
}

@media (prefers-reduced-motion: reduce) {
  .presence-pill { transition: none; }
  .presence-pill[data-status="available"] .presence-pill-icon { filter: none; }
}


/* ---- Team coverage widget (tickets.html) ---- */
.presence-coverage {
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
.presence-coverage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.presence-coverage-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.presence-coverage-gap-count {
  font-size: 11px;
  font-weight: 600;
  color: #991B1B;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 2px 8px;
  border-radius: 10px;
}
.presence-coverage-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.presence-coverage-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  min-height: 32px;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.presence-coverage-chip:hover {
  background: var(--bg-hover);
}
.presence-coverage-team-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.presence-coverage-team-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.presence-coverage-chip.has-gap {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.35);
}
.presence-coverage-chip.has-gap .presence-coverage-team-count {
  color: #991B1B;
}
.presence-coverage-chip.empty-team {
  opacity: 0.55;
}
.presence-coverage-chip.empty-team .presence-coverage-team-count {
  color: var(--text-muted);
}

/* ============================================================
   SECTION TABS — top-level tab strip on tickets.html
   Sits above the stats grid. Two tabs: Tickets, Team Coverage.
   Designed for "data-dense dashboard" aesthetic: subtle borders,
   amber/green accent on active, minimal chrome.
   ============================================================ */
.section-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 0 0 2px;
  position: relative;
}
.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
  font-family: inherit;
  margin-bottom: -1px; /* overlap parent border for clean active state */
  position: relative;
}
.section-tab svg { color: currentColor; }
.section-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.section-tab:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: -2px;
  border-radius: 4px 4px 0 0;
}
.section-tab.is-active,
.section-tab[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--amt-green, #5DBB63);
}
.section-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: #DC2626;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Section panels — hidden when not active. Use both attribute + class for redundancy. */
.section-panel.hidden,
.section-panel[hidden] { display: none; }

/* ============================================================
   TEAM COVERAGE — expanded view (Team Coverage tab)
   Card-per-team grid; each card is dense and scannable. Member rows
   use Slack/Teams-style avatar with a status-dot overlay so eyes track
   to the dot instantly. Team-color accent stripe on the left edge gives
   each team a quick visual identity without being noisy.
   ============================================================ */

/* Status palette — one source of truth for the dot and text colors. */
.coverage-status-available { --status-color: #5DBB63; }
.coverage-status-busy      { --status-color: #DC2626; }
.coverage-status-away      { --status-color: #EAB308; }
.coverage-status-off_duty  { --status-color: #8B5CF6; }

/* Page header at top of the coverage panel */
.coverage-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 4px 0 20px;
  flex-wrap: wrap;
}
.coverage-page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.coverage-page-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.coverage-gap-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #991B1B;
  font-size: 12px;
  font-weight: 600;
}
.coverage-gap-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #DC2626;
  display: inline-block;
}

/* KPI strip — 2026-05-19 redesign.
   Was: 5-column grid of card-sized KPI boxes, each ~80px tall with a
   decorative coloured left-stripe. Ate ~120px above the team grid and
   competed visually with the team cards.
   Now: single inline row (matches .inline-summary on the tickets list).
   Same data, ~1/3 the vertical, scannable in one second. Filter pill row
   below it picks up the "click to filter" affordance. */
.coverage-kpis {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 4px 0 16px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.coverage-kpi {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  flex-direction: row-reverse; /* label first, value to its right */
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  position: relative;
  overflow: visible;
}
/* 2026-05-19: decorative left-stripe removed. Severity now carried by the
   colored dot in .coverage-kpi-dot and (for "warn" state) by the muted
   tinted background already on .coverage-kpi.is-warn. */
.coverage-kpi[data-status="available"] { --status-color: #5DBB63; }
.coverage-kpi[data-status="busy"]      { --status-color: #DC2626; }
.coverage-kpi[data-status="away"]      { --status-color: #EAB308; }
.coverage-kpi[data-status="off_duty"]  { --status-color: #8B5CF6; }
.coverage-kpi[data-status="gap"]       { --status-color: #94A3B8; }
.coverage-kpi:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
  cursor: default;
}
.coverage-kpi.is-warn {
  background: rgba(220, 38, 38, 0.06);
  border-color: rgba(220, 38, 38, 0.25);
}
.coverage-kpi-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 0;
}
.coverage-kpi.is-warn .coverage-kpi-value { color: var(--tech-red); }
.coverage-kpi-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-muted);
  margin: 0;
}
.coverage-kpi-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94A3B8;
  flex-shrink: 0;
}
.coverage-kpi-dot[data-status="available"] { background: #5DBB63; }
.coverage-kpi-dot[data-status="busy"]      { background: #DC2626; }
.coverage-kpi-dot[data-status="away"]      { background: #EAB308; }
.coverage-kpi-dot[data-status="off_duty"]  { background: #8B5CF6; }
.coverage-kpi-dot[data-status="gap"]       { background: #DC2626; }
@media (max-width: 600px) {
  .coverage-kpis { gap: 6px; padding: 8px 10px; }
  .coverage-kpi { padding: 3px 8px; }
}

/* Filter pills — All / Gaps / With available / On leave */
.coverage-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.coverage-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.coverage-filter-pill:hover { background: var(--bg-hover); }
.coverage-filter-pill:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}
.coverage-filter-pill.is-active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-primary);
}
.coverage-filter-pill.is-active .coverage-filter-pill-count {
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
}
.coverage-filter-pill.is-danger:not(.is-active) {
  border-color: rgba(220, 38, 38, 0.35);
  color: #991B1B;
}
.coverage-filter-pill.is-danger:not(.is-active) .coverage-filter-pill-count {
  background: rgba(220, 38, 38, 0.1);
  color: #991B1B;
}
.coverage-filter-pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border-radius: 10px;
  line-height: 1;
}

/* Grid of team cards */
.coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}

.coverage-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 160ms ease;
}
.coverage-card:hover {
  border-color: var(--border-medium);
}
.coverage-card.has-gap {
  border-color: rgba(220, 38, 38, 0.35);
}
.coverage-card.outside-hours {
  opacity: 0.92;
}
.coverage-card.outside-hours:not(.has-gap) {
  border-color: var(--border-color);
  box-shadow: none;
}
.coverage-card-regions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.coverage-region-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 4px;
  border: 1px solid transparent;
}
.coverage-region-chip.is-open {
  color: var(--tech-green);
  background: rgba(5, 150, 105, 0.1);
  border-color: rgba(5, 150, 105, 0.25);
}
.coverage-region-chip.is-closed {
  color: var(--text-muted);
  background: var(--bg-hover);
  border-color: var(--border-color);
}
.coverage-card-local-time {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.coverage-card-hours-banner {
  padding: 8px 18px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}
.coverage-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}
.coverage-card-name-block { padding-top: 2px; }
.coverage-card-name-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.coverage-card-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.005em;
  line-height: 1.3;
  /* Allow up to 2 lines, then ellipsis. Better than one-line truncation —
     team names like "Global Customer Success Representative" would otherwise
     get cut to "Global Customer Success R...". Variable card height is fine. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.coverage-card-count {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}
.coverage-card-count-big {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.coverage-card-count-slash {
  font-size: 16px;
  font-weight: 400;
  color: var(--text-muted);
  margin: 0 1px;
}
.coverage-card-count-total {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
}
.coverage-card-count-label {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.coverage-card-count.has-gap .coverage-card-count-big {
  color: #DC2626;
}

.coverage-card-gap-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(220, 38, 38, 0.06);
  border-bottom: 1px solid rgba(220, 38, 38, 0.18);
  color: #991B1B;
  font-size: 12px;
  font-weight: 500;
}
.coverage-card-gap-banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #DC2626;
  flex-shrink: 0;
}

/* Member list */
.coverage-member-list {
  list-style: none;
  padding: 4px 0;
  margin: 0;
  max-height: 420px;
  overflow-y: auto;
}
.coverage-member-empty {
  padding: 14px 18px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}
.coverage-member {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: default;
  transition: background-color 160ms ease;
}
.coverage-member:hover {
  background: var(--bg-hover);
}
.coverage-member[data-status="away"],
.coverage-member[data-status="off_duty"] {
  opacity: 0.78;
}
/* 2026-05-19: no-calls left-rail removed. Carried by .tm-member-pill.is-no-calls
   on the member chip + the No calls tag inside the row. */

/* Avatar with status-dot overlay (Slack/Teams pattern).
   Outer .coverage-avatar wraps but does NOT clip — so the dot pokes outside.
   The inner .coverage-avatar-inner is the circular mask for the photo. */
.coverage-avatar {
  position: relative;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-block;
  overflow: visible;
}
.coverage-avatar-inner {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--bg-tertiary);
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.coverage-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.coverage-avatar-initials {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.coverage-avatar-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--card-bg);
  background: #94A3B8;
  z-index: 1;
}
.coverage-avatar-dot[data-status="available"] { background: #5DBB63; }
/* Busy → red; the white bar (added via ::before below) appears only when the
   reason indicates active engagement (call / meeting / Do Not Disturb).
   Generic busy stays solid red. Matches Microsoft Teams convention. */
.coverage-avatar-dot[data-status="busy"]      { background: #DC2626; }
/* Away → yellow, matching Teams' "stepped away briefly" semantic. */
.coverage-avatar-dot[data-status="away"]      { background: #EAB308; }
/* Out of Office uses violet rather than red — red is reserved for true ops
   urgency on this page (coverage gaps). Planned absence is calm, not alarming. */
.coverage-avatar-dot[data-status="off_duty"]  { background: #8B5CF6; }

/* "Engaged" indicator — horizontal white bar across the dot for DnD / call /
   meeting reasons. Same shape Teams uses for its Do Not Disturb icon. The
   dot is already position:absolute (anchored to avatar's bottom-right), so
   it serves as the positioning context for ::before. */
.coverage-avatar-dot[data-reason="in_teams_call"]::before,
.coverage-avatar-dot[data-reason="in_teams_meeting"]::before,
.coverage-avatar-dot[data-reason="teams_dnd"]::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 22%;
  right: 22%;
  height: 2px;
  background: #fff;
  transform: translateY(-50%);
  border-radius: 1px;
}

/* Identity column: name on top, status + tags on a single meta line below */
.coverage-member-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.coverage-member-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.coverage-member-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
}
.coverage-member-meta-status {
  font-weight: 500;
}
.coverage-member-meta-status[data-status="available"] { color: #1F7A33; }
.coverage-member-meta-status[data-status="busy"]      { color: #991B1B; }
.coverage-member-meta-status[data-status="off_duty"]  { color: #6D28D9; }
.coverage-member-meta-status[data-status="away"]      { color: #854D0E; }
.coverage-member-meta-sep { color: var(--text-muted); opacity: 0.5; }
.coverage-member-meta-tag { color: var(--text-muted); font-weight: 500; }
.coverage-member-meta-tag.lead { color: #1F7A33; font-weight: 600; }
.coverage-member-meta-tag.warn { color: #92400E; font-weight: 600; }
.coverage-member-meta-return {
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
}

/* Last-7-day pickup-rate fragment — appended to the meta line when the
   sample is significant (>= 5 rings). Color-coded by tier. */
.coverage-member-meta-pickup {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: help;
}
.coverage-member-meta-pickup[data-tier="good"] { color: #1F7A33; }
.coverage-member-meta-pickup[data-tier="warn"] { color: #92400E; }
.coverage-member-meta-pickup[data-tier="bad"]  { color: #991B1B; }

/* ============================================================
   INBOUND CALL PLACEHOLDER BANNER (ticket-detail page)
   Shown at the top of a ticket whose ticket_type === 'inbound_call'.
   Amber-toned with a leading phone icon and larger action buttons —
   designed to clearly signal "this needs a decision before it counts
   as real work".
   ============================================================ */
.inbound-call-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 20px;
  padding: 20px 24px;
  /* 2026-05-19: gradient + 5px left-stripe + glow box-shadow replaced with
     a single flat amber tint + 1px border. Severity is still loud (amber +
     "Action required" pill + the icon), but no longer the loudest thing on
     the page. */
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 12px;
  flex-wrap: wrap;
}
.inbound-call-banner-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #F59E0B;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.inbound-call-banner-body { flex: 1 1 260px; min-width: 0; }
.inbound-call-banner-title {
  font-size: 16px;
  font-weight: 700;
  color: #78350F;
  letter-spacing: -0.005em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.inbound-call-banner-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: #B45309;
  padding: 2px 8px;
  border-radius: 4px;
}
.inbound-call-banner-hint {
  font-size: 13px;
  color: #78350F;
  opacity: 0.85;
  line-height: 1.5;
}
.inbound-call-banner-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.inbound-call-banner-btn {
  white-space: nowrap;
  padding: 10px 18px !important;
  font-weight: 600 !important;
}
.inbound-call-banner-btn.btn-promote {
  background: #B45309 !important;
  border-color: #B45309 !important;
  color: #fff !important;
}
.inbound-call-banner-btn.btn-promote:hover {
  background: #92400E !important;
  border-color: #92400E !important;
}

/* Pending-call count badge on the "Support Calls" ticket-type tab */
.ticket-type-btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  background: #DC2626;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ticket-type-btn-badge.hidden { display: none; }

/* Team-level pickup footer — quietly tucked at the bottom of each team card */
.coverage-card-footer {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 10px 18px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  font-size: 11.5px;
  color: var(--text-muted);
}
.coverage-card-footer-stat {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.coverage-card-footer-stat[data-tier="good"] { color: #1F7A33; }
.coverage-card-footer-stat[data-tier="warn"] { color: #92400E; }
.coverage-card-footer-stat[data-tier="bad"]  { color: #991B1B; }
.coverage-card-footer-label { line-height: 1.4; }

/* Open ticket count chip — shows utilization at a glance */
.coverage-member-tickets {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px 3px 7px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  cursor: default;
}
.coverage-member-tickets-icon { display: inline-flex; opacity: 0.85; }
/* Empty-state placeholder keeps the grid columns aligned across all rows */
.coverage-member-tickets,
.coverage-member-tickets-placeholder {
  min-width: 36px;
  min-height: 22px;
  box-sizing: border-box;
  justify-content: center;
}
.coverage-member-tickets-placeholder {
  display: inline-block;
  visibility: hidden;
}

/* Teams chat deep-link button — appears on hover/focus; always present on
   touch devices for tap reach. Subtle until interacted with so the rows
   don't look noisy. */
.coverage-member-chat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
  opacity: 0;
}
.coverage-member:hover .coverage-member-chat,
.coverage-member:focus-within .coverage-member-chat,
.coverage-member-chat:focus-visible {
  opacity: 1;
}
.coverage-member-chat:hover {
  color: #464EB8; /* Microsoft Teams purple */
  background: rgba(70, 78, 184, 0.08);
  border-color: rgba(70, 78, 184, 0.25);
}
.coverage-member-chat:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}
.coverage-member-chat-placeholder {
  display: inline-block;
  width: 28px;
  height: 28px;
}
/* On touch / coarse pointer devices, always show the chat affordance */
@media (hover: none) {
  .coverage-member-chat { opacity: 0.65; }
}

/* ============================================================
   Per-member stats — Click-to-open modal
   Each member row in Team Coverage is clickable; opens a wide
   modal showing the member's 7-day stats and the team aggregate
   for comparison.
   ============================================================ */
.coverage-member-clickable {
  cursor: pointer;
}
.coverage-member-clickable:focus-visible {
  outline: 2px solid var(--accent, #5b5fc7);
  outline-offset: -2px;
}

/* Modal frame */
.coverage-stats-modal {
  max-width: 720px;
  width: 92vw;
  padding: 0;
  border: 1px solid var(--border, rgba(91, 95, 199, 0.18));
  border-radius: 14px;
  background: var(--card-bg, #fff);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.coverage-stats-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

/* Header */
.coverage-stats-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border, rgba(91, 95, 199, 0.12));
}
.coverage-stats-modal-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.coverage-stats-modal-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-hover, rgba(91, 95, 199, 0.1));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.coverage-stats-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.coverage-stats-modal-initials {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.coverage-stats-modal-id-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.coverage-stats-modal-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.coverage-stats-modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.coverage-stats-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(91, 95, 199, 0.18));
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 120ms ease;
}
.coverage-stats-modal-close:hover {
  background: var(--bg-hover, rgba(91, 95, 199, 0.08));
  color: var(--text);
}

/* Stats sections */
.coverage-stats-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, rgba(91, 95, 199, 0.08));
}
.coverage-stats-section:last-of-type {
  border-bottom: none;
}
.coverage-stats-section-team {
  background: var(--bg-tertiary, rgba(91, 95, 199, 0.025));
}
.coverage-stats-section-title {
  margin: 0 0 12px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 6-stat grid — wraps to 3×2 on narrow widths */
.coverage-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 600px) {
  .coverage-stats-grid { grid-template-columns: repeat(6, 1fr); }
}

.coverage-stat-card {
  padding: 10px 12px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(91, 95, 199, 0.12));
  border-radius: 8px;
  min-width: 0;
}
.coverage-stats-section-team .coverage-stat-card {
  background: var(--card-bg, #fff);
}
.coverage-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coverage-stat-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}
.coverage-stat-card[data-tier="good"] .coverage-stat-value { color: #166534; }
.coverage-stat-card[data-tier="warn"] .coverage-stat-value { color: #92400E; }
.coverage-stat-card[data-tier="bad"]  .coverage-stat-value { color: #991B1B; }
.coverage-stat-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.3;
}

/* Footer */
.coverage-stats-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border, rgba(91, 95, 199, 0.12));
  background: var(--bg-tertiary, rgba(91, 95, 199, 0.02));
  border-radius: 0 0 14px 14px;
}
.coverage-stats-modal-foot-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================================
   Scoreboard widget
   Top 5 answerers in the last 7 days. Lives between filter pills
   and the team grid.
   ============================================================ */
.coverage-scoreboard {
  margin: 16px 0;
  padding: 16px 18px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, rgba(91, 95, 199, 0.12));
  border-radius: 10px;
}
.coverage-scoreboard-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.coverage-scoreboard-title {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: var(--text);
}
.coverage-scoreboard-hint {
  font-size: 11px;
  color: var(--text-muted);
}
.coverage-scoreboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.coverage-scoreboard-row {
  display: grid;
  grid-template-columns: 28px 32px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-tertiary, rgba(91, 95, 199, 0.03));
}
.coverage-scoreboard-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-hover, rgba(91, 95, 199, 0.1));
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.coverage-scoreboard-rank[data-rank="1"] { background: #FCD34D; color: #78350F; }
.coverage-scoreboard-rank[data-rank="2"] { background: #E5E7EB; color: #4B5563; }
.coverage-scoreboard-rank[data-rank="3"] { background: #FED7AA; color: #9A3412; }
.coverage-scoreboard-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover, rgba(91, 95, 199, 0.1));
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.coverage-scoreboard-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.coverage-scoreboard-initials {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}
.coverage-scoreboard-identity {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.coverage-scoreboard-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coverage-scoreboard-team {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coverage-scoreboard-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: rgba(124, 58, 237, 0.12);
  color: #6D28D9;
  border-radius: 10px;
}
.coverage-scoreboard-stats {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
}
.coverage-scoreboard-answered {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.coverage-scoreboard-answered-label {
  color: var(--text-muted);
}
.coverage-scoreboard-rate {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.coverage-scoreboard-rate[data-tier="good"] { background: #DCFCE7; color: #166534; }
.coverage-scoreboard-rate[data-tier="warn"] { background: #FEF3C7; color: #92400E; }
.coverage-scoreboard-rate[data-tier="bad"]  { background: #FEE2E2; color: #991B1B; }

/* ============================================================
   WhatsApp panel — Phase 3a (read-only chat display on ticket-detail)
   Familiar chat-bubble layout: inbound left, outbound right. Tinted
   surface around messages to visually separate the WhatsApp thread
   from the email/note thread above it.
   ============================================================ */
/* ── WhatsApp drawer wrapper ── */
.whatsapp-drawer-wrap { position: relative; z-index: 1000; }
.whatsapp-drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1001;
}
.whatsapp-drawer-wrap.open .whatsapp-drawer-backdrop {
  display: block;
}
@media (min-width: 1100px) {
  /* On wide screens the drawer doesn't need a backdrop — the ticket page
     remains usable next to it. */
  .whatsapp-drawer-wrap.open .whatsapp-drawer-backdrop { display: none; }
}
.whatsapp-drawer {
  position: fixed;
  top: 64px;            /* under the top navbar */
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: #fff;
  border-left: 1px solid #E2E8F0;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.08);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  z-index: 1002;
  overflow: hidden;
}
.whatsapp-drawer-wrap.open .whatsapp-drawer {
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .whatsapp-drawer { transition: none; }
}
.whatsapp-drawer-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #25D366;     /* WhatsApp green */
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4), 0 2px 4px rgba(0,0,0,0.1);
  z-index: 1003;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.whatsapp-drawer-launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5), 0 2px 4px rgba(0,0,0,0.1);
}
.whatsapp-drawer-launcher:active { transform: scale(0.97); }
.whatsapp-drawer-launcher:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -6px;
}
.whatsapp-drawer-launcher-icon { width: 28px; height: 28px; display: block; }
.whatsapp-drawer-launcher-icon svg { width: 100%; height: 100%; }
.whatsapp-drawer-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #DC2626;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ── Mobile responsive ──
   On phones the drawer takes the full viewport (minus the navbar) so the
   compose area has room and chat bubbles read comfortably. Launcher
   shrinks and respects the safe-area inset so it clears the home-bar on
   iOS. */
@media (max-width: 640px) {
  .whatsapp-drawer {
    top: 56px;
    width: 100vw;
    border-left: none;
  }
  .whatsapp-drawer-launcher {
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(16px + env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
  }
  .whatsapp-drawer-launcher-icon { width: 24px; height: 24px; }
  .whatsapp-panel-header { padding: 10px 12px; }
  .whatsapp-panel-title { font-size: 14px; }
  .whatsapp-panel-sub { font-size: 12px; }
  /* Hide the verbose 24h-window badge on phones — it eats the header.
     The functional check is still enforced server-side. */
  .whatsapp-window-badge { display: none; }
}


/* The actual chat panel — inside the drawer */
.whatsapp-panel {
  margin: 0;
  border: none;
  border-radius: 0;
  background: #F0FDF4;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}
.whatsapp-panel-flash {
  animation: whatsapp-panel-flash-anim 1.5s ease-out;
}
@keyframes whatsapp-panel-flash-anim {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); border-color: #22c55e; }
  40%  { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.0); border-color: #22c55e; }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); border-color: #D1FAE5; }
}
@media (prefers-reduced-motion: reduce) {
  .whatsapp-panel-flash { animation: none; }
}
.whatsapp-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #D1FAE5;
  flex-shrink: 0;
}
.whatsapp-panel-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.whatsapp-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted, #64748B);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.whatsapp-drawer-close:hover { background: #F1F5F9; color: #0F172A; }
.whatsapp-drawer-close:active { background: #E2E8F0; }
.whatsapp-drawer-close:focus-visible {
  outline: 2px solid #25D366;
  outline-offset: 1px;
}
.whatsapp-panel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.whatsapp-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #25D366;   /* WhatsApp green */
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.whatsapp-panel-title-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.whatsapp-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.whatsapp-panel-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.whatsapp-window-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}
.whatsapp-window-badge[data-state="open"] {
  background: #DCFCE7;
  color: #166534;
}
.whatsapp-window-badge[data-state="closed"] {
  background: #FEF3C7;
  color: #92400E;
}

/* Message list */
.whatsapp-message-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;        /* lets flex children shrink so overflow-y can take effect */
  overflow-y: auto;
}
.whatsapp-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* Bubble row — controls alignment via data-direction */
.whatsapp-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.whatsapp-bubble-row[data-direction="outbound"] {
  flex-direction: row-reverse;
}

/* Avatar (32px circle), placeholder keeps the gutter when avatar is omitted */
.whatsapp-bubble-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #94A3B8;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.whatsapp-bubble-avatar.inbound {
  background: #25D366;
}
.whatsapp-bubble-avatar.outbound {
  background: #5B5FC7;
}
.whatsapp-bubble-avatar.bot {
  background: #7C3AED;   /* violet — same hue we use for AI/sparkle accents */
}
.whatsapp-bubble-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.whatsapp-bubble-avatar-placeholder {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

/* Bubble */
.whatsapp-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #D1FAE5;
  color: var(--text);
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.04);
}
.whatsapp-bubble-row[data-direction="outbound"] .whatsapp-bubble {
  background: #DCFCE7;   /* familiar WA outbound green */
  border-color: #BBF7D0;
}
/* Bot bubble overrides the outbound green with a soft violet so the agent
   sees instantly that the message came from automation, not a teammate.
   Same right-alignment as outbound — bot speaks on behalf of the business. */
.whatsapp-bubble-row[data-bot="true"] .whatsapp-bubble {
  background: #EDE9FE;     /* violet-50 — soft, distinct from green */
  border-color: #C4B5FD;   /* violet-300 */
}
.whatsapp-bubble-sender.bot {
  color: #6D28D9;          /* violet-700 — matches the bot avatar accent */
  font-weight: 700;
}

.whatsapp-bubble-sender {
  font-size: 11px;
  font-weight: 600;
  color: #6B7280;
  margin-bottom: 2px;
}
.whatsapp-bubble-body {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.whatsapp-bubble-media {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.whatsapp-bubble-image {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  background: #F3F4F6;   /* placeholder colour while blob loads */
  min-height: 60px;
}
.whatsapp-bubble-video {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  display: block;
  background: #000;
}
.whatsapp-bubble-audio {
  display: block;
  width: 100%;
  max-width: 280px;
}
.whatsapp-bubble-file {
  display: inline-block;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #BBF7D0;
  border-radius: 6px;
  font-size: 12px;
  color: #166534;
  text-decoration: none;
}
.whatsapp-bubble-file:hover {
  background: #F0FDF4;
}

.whatsapp-bubble-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  color: #6B7280;
}
.whatsapp-bubble-status {
  display: inline-flex;
  align-items: center;
}
.whatsapp-bubble-status[data-status="delivered"] { color: #6B7280; }
.whatsapp-bubble-status[data-status="read"]      { color: #2563EB; }
.whatsapp-bubble-status[data-status="failed"]    { color: #DC2626; }
.whatsapp-bubble-status[data-status="queued"],
.whatsapp-bubble-status[data-status="sent"]      { color: #94A3B8; }

.whatsapp-panel-footer {
  padding: 8px 16px;
  border-top: 1px solid #D1FAE5;
  background: #fff;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
}

/* Compose area (Phase 3b) */
.whatsapp-compose {
  border-top: 1px solid #D1FAE5;
  background: #fff;
  padding: 10px 14px 12px;
  /* In the drawer the compose area sits at the bottom; flex-shrink:0 keeps
     it visible. iOS home-bar respect via safe-area-inset-bottom. */
  flex-shrink: 0;
  padding-bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
}
.whatsapp-compose[data-state="ready"] {
  /* Same as default — exists for symmetry with locked state. */
}
.whatsapp-compose[data-state="no-inbound"],
.whatsapp-compose[data-state="closed"] {
  background: #FEF3C7;
  padding: 12px 14px;
}
.whatsapp-compose-locked {
  font-size: 12px;
  color: #92400E;
  line-height: 1.5;
}
.whatsapp-compose-locked-hint {
  margin-top: 4px;
  font-size: 11px;
  color: #92400E;
  font-style: italic;
  opacity: 0.85;
}
.whatsapp-compose-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #BBF7D0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  background: #fff;
  color: var(--text);
  box-sizing: border-box;
}
.whatsapp-compose-textarea:focus {
  outline: none;
  border-color: #25D366;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}
.whatsapp-compose-textarea:disabled {
  background: #F9FAFB;
  color: var(--text-muted);
  cursor: wait;
}
.whatsapp-compose-actions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.whatsapp-compose-hint {
  font-size: 11px;
  color: var(--text-muted);
}
.whatsapp-compose-send {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  background: #25D366;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.whatsapp-compose-send:hover:not(:disabled) {
  background: #1FA855;
}
.whatsapp-compose-send:disabled {
  background: #94A3B8;
  cursor: wait;
}

/* Empty / error state */
.coverage-empty {
  padding: 48px 24px;
  text-align: center;
  background: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
}
.coverage-empty-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.coverage-empty-body {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Skeleton state (first paint while fetching) */
.coverage-card.is-skeleton {
  height: 280px;
  border-color: var(--border-color);
}
.coverage-card-header-skeleton {
  height: 56px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-hover) 50%, var(--bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: coverage-shimmer 1.4s ease-in-out infinite;
}
.coverage-card-body-skeleton {
  flex: 1;
  background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-hover) 50%, var(--bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: coverage-shimmer 1.4s ease-in-out infinite;
  animation-delay: 100ms;
  opacity: 0.5;
}
@keyframes coverage-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .coverage-card,
  .coverage-member,
  .section-tab { transition: none; }
  .coverage-card-header-skeleton,
  .coverage-card-body-skeleton { animation: none; }
}

/* Responsive — single column under 600px, tighter padding */
@media (max-width: 600px) {
  .coverage-grid { grid-template-columns: 1fr; gap: 12px; }
  .coverage-card-header { padding: 12px 14px 10px 16px; }
  .coverage-member { padding: 8px 14px; }
  .coverage-page-title { font-size: 20px; }
  .section-tab { padding: 10px 12px; font-size: 12.5px; }
}

/* ============================================================
   INBOUND CALL — incoming + live call modals (nexus-core.js)
   Mounted globally for ticketing-team members so calls can land
   on any page they're currently looking at.
   ============================================================ */
.nexus-call-modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 380px;
  width: calc(100vw - 32px);
  border-radius: 16px;
  color: var(--text-primary);
}
.nexus-call-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.nexus-call-modal-content {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.22),
    0 4px 12px rgba(15, 23, 42, 0.08);
  text-align: center;
  animation: nexusCallIn 220ms ease-out;
}
@keyframes nexusCallIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .nexus-call-modal-content { animation: none; }
}

.nexus-call-modal-icon,
.nexus-call-modal-pulse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 12px;
  background: var(--amt-green-light, rgba(93, 187, 99, 0.12));
  color: var(--amt-green, #5DBB63);
}
.nexus-call-modal-pulse {
  position: relative;
  animation: nexusCallPulse 1.6s ease-in-out infinite;
}
.nexus-call-modal-pulse::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: nexusCallPulseRing 1.6s ease-out infinite;
}
@keyframes nexusCallPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
@keyframes nexusCallPulseRing {
  0%   { opacity: 0.5; transform: scale(0.95); }
  100% { opacity: 0;   transform: scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  .nexus-call-modal-pulse,
  .nexus-call-modal-pulse::after { animation: none; }
}

.nexus-call-modal-title {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.nexus-call-modal-title-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}
.nexus-call-modal-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.nexus-call-modal-caller {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
}
.nexus-call-modal-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.nexus-call-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.nexus-call-modal-actions .btn { min-width: 130px; }

.nexus-call-accept {
  background: var(--amt-green, #5DBB63) !important;
  border-color: var(--amt-green, #5DBB63) !important;
  color: #fff !important;
}
.nexus-call-accept:hover {
  background: var(--amt-green-dark, #059669) !important;
  border-color: var(--amt-green-dark, #059669) !important;
}
.nexus-call-decline,
.nexus-call-hangup {
  background: #DC2626 !important;
  border-color: #DC2626 !important;
  color: #fff !important;
}
.nexus-call-decline:hover,
.nexus-call-hangup:hover {
  background: #B91C1C !important;
  border-color: #B91C1C !important;
}

/* "Open ticket" link inside the live call modal — styled as a button-shaped
   <a target="_blank">. Honoured by popup blockers because it's a direct
   user click (no JS popup). Hidden via .hidden until ticketId is present. */
.nexus-call-open-ticket {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.nexus-call-open-ticket:hover { text-decoration: none; }

/* ============================================================
   ▼ 2026-05-19 — Nexus Redesign Phase 0
   New design primitives per /DESIGN.md. Additive vocabulary that
   coexists with legacy classes. Migration is happening page by page;
   pages using these classes are the canonical look, everything else
   is legacy waiting to be brought in line.
   ============================================================ */

/* ── Spacing scale (4px base) ───────────────────────────────── */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Refined radii — slightly tighter than the legacy 6/10/14/18 so
     surfaces feel more professional, less consumer. */
  --radius-2026-sm: 6px;
  --radius-2026-md: 8px;
  --radius-2026-lg: 12px;
  --radius-2026-xl: 16px;
  --radius-full: 9999px;

  /* Type scale (fixed rem-based; product UI does not benefit from clamp). */
  --font-2xs: 11px;
  --font-xs:  12px;
  --font-sm:  13px;
  --font-base: 14px;
  --font-md:  15px;
  --font-lg:  17px;
  --font-xl:  22px;
  --font-2xl: 28px;

  /* Motion */
  --motion-fast:   120ms cubic-bezier(0.2, 0, 0.2, 1);
  --motion-normal: 200ms cubic-bezier(0.16, 1, 0.3, 1);
  --motion-slow:   320ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Severity palette aliases — single source of truth for status. */
  --sev-critical: var(--tech-red);
  --sev-warning:  var(--tech-orange);
  --sev-info:     var(--tech-blue);
  --sev-success:  var(--tech-green);
  --sev-muted:    var(--text-muted);
  --sev-progress: var(--tech-cyan);
  --sev-attention: var(--tech-purple);
}

/* ── Severity dot — the canonical "shape carries meaning" primitive ──
   Use alongside a text label; replaces all decorative left-stripe usage.
   Inline-block 6px circle; pairs with .pill / .badge to add severity
   carry without relying on color alone. */
.sev-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--sev-muted);
  vertical-align: baseline;
}
.sev-dot[data-sev="critical"] { background: var(--sev-critical); }
.sev-dot[data-sev="warning"]  { background: var(--sev-warning); }
.sev-dot[data-sev="info"]     { background: var(--sev-info); }
.sev-dot[data-sev="success"]  { background: var(--sev-success); }
.sev-dot[data-sev="muted"]    { background: var(--sev-muted); }
.sev-dot[data-sev="progress"] { background: var(--sev-progress); }
.sev-dot[data-sev="attention"]{ background: var(--sev-attention); }
.sev-dot--pulse {
  animation: sev-dot-pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes sev-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50%      { box-shadow: 0 0 0 4px transparent; opacity: 0.55; }
}
@media (prefers-reduced-motion: reduce) {
  .sev-dot--pulse { animation: none; }
}

/* ── Inline summary row — 2026-05-19 v2.
   Replaces stat-grid above tickets / coverage / similar lists. Each chip
   is a one-click filter shortcut.
   Visual treatment: solid pill background, framed group, larger number
   stands forward, clearer active state. The whole row is a card-shaped
   strip so it reads as a single unit rather than loose text. */
.inline-summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  margin: 0 0 var(--space-3);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: var(--font-sm);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  max-width: 100%;
}
.inline-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  height: 28px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  font-size: var(--font-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--motion-fast), color var(--motion-fast),
              border-color var(--motion-fast);
}
.inline-summary-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.inline-summary-item:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}
/* Active = the filter that is currently applied. Solid surface + strong text. */
.inline-summary-item.is-active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-on-accent, #fff);
}
.inline-summary-item.is-active .inline-summary-item-label,
.inline-summary-item.is-active .inline-summary-item-value {
  color: inherit;
}
.inline-summary-item.is-active:hover {
  background: var(--accent-secondary, var(--accent-primary));
  border-color: var(--accent-secondary, var(--accent-primary));
}
/* Severity colouring only kicks in when count > 0 (handled by JS setting
   data-sev). Otherwise the chip stays neutral. */
.inline-summary-item[data-sev="critical"]:not(.is-active) {
  color: var(--sev-critical);
  background: rgba(220, 38, 38, 0.08);
}
.inline-summary-item[data-sev="critical"]:not(.is-active):hover {
  background: rgba(220, 38, 38, 0.14);
}
.inline-summary-item[data-sev="warning"]:not(.is-active) {
  color: var(--sev-warning);
  background: rgba(234, 88, 12, 0.08);
}
.inline-summary-item[data-sev="success"]:not(.is-active) .inline-summary-item-value {
  color: var(--sev-success);
}
.inline-summary-item-value {
  font-weight: 700;
  font-size: var(--font-base);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.inline-summary-item-label {
  color: inherit;
  font-weight: 500;
}
.inline-summary-sep {
  width: 1px;
  height: 18px;
  background: var(--border-light);
  display: inline-block;
  margin: 0 4px;
  flex-shrink: 0;
}
html[data-theme="dark"] .inline-summary {
  background: rgba(255, 255, 255, 0.025);
}
@media (max-width: 768px) {
  .inline-summary { width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .inline-summary::-webkit-scrollbar { display: none; }
}

/* ── Refined badge primitive (2026) — single component, six semantics ─
   Always: optional dot + text label. Use over the legacy .badge-* classes
   as pages migrate. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  height: 20px;
  border-radius: var(--radius-full);
  font: 500 var(--font-2xs)/16px inherit;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  white-space: nowrap;
  vertical-align: middle;
}
.pill > .sev-dot { width: 6px; height: 6px; }
.pill[data-sev="critical"] { background: rgba(220, 38, 38, 0.10); color: var(--sev-critical); }
.pill[data-sev="warning"]  { background: rgba(234, 88, 12, 0.10); color: var(--sev-warning); }
.pill[data-sev="info"]     { background: rgba(59, 130, 246, 0.10); color: var(--sev-info); }
.pill[data-sev="success"]  { background: rgba(5, 150, 105, 0.10); color: var(--sev-success); }
.pill[data-sev="progress"] { background: rgba(6, 182, 212, 0.10); color: var(--sev-progress); }
.pill[data-sev="attention"]{ background: rgba(139, 92, 246, 0.10); color: var(--sev-attention); }
.pill[data-sev="muted"]    { background: var(--bg-tertiary); color: var(--text-muted); }
.pill--solid[data-sev="critical"] { background: var(--sev-critical); color: #fff; }
.pill--solid[data-sev="warning"]  { background: var(--sev-warning); color: #fff; }
.pill--solid[data-sev="info"]     { background: var(--sev-info); color: #fff; }
.pill--solid[data-sev="success"]  { background: var(--sev-success); color: #fff; }
.pill--solid[data-sev="progress"] { background: var(--sev-progress); color: #fff; }
.pill--solid[data-sev="attention"]{ background: var(--sev-attention); color: #fff; }
html[data-theme="dark"] .pill[data-sev="critical"] { background: rgba(248, 113, 113, 0.15); }
html[data-theme="dark"] .pill[data-sev="warning"]  { background: rgba(251, 146, 60, 0.15); }
html[data-theme="dark"] .pill[data-sev="info"]     { background: rgba(96, 165, 250, 0.15); }
html[data-theme="dark"] .pill[data-sev="success"]  { background: rgba(52, 211, 153, 0.15); }
html[data-theme="dark"] .pill[data-sev="progress"] { background: rgba(34, 211, 238, 0.15); }
html[data-theme="dark"] .pill[data-sev="attention"]{ background: rgba(167, 139, 250, 0.18); }

/* ── Side drawer (right-anchored slide-in panel) ────────────────
   Standard replacement for "decision modal" — preserves page context. */
.nx-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(420px, 100vw);
  background: var(--card-bg);
  border-left: 1px solid var(--border-medium);
  box-shadow: -10px 0 40px -10px rgba(15, 23, 42, 0.15);
  transform: translateX(100%);
  transition: transform var(--motion-normal);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.nx-drawer.is-open { transform: translateX(0); }
dialog.nx-drawer {
  margin: 0 0 0 auto;
  max-width: none;
  max-height: none;
  border: none;
  padding: 0;
}
dialog.nx-drawer::backdrop {
  background: rgba(15, 23, 42, 0.40);
}
.nx-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.40);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-normal);
  z-index: 8999;
}
.nx-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.nx-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.nx-drawer-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-primary);
}
.nx-drawer-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-2026-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nx-drawer-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.nx-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.nx-drawer-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
@media (max-width: 600px) {
  .nx-drawer {
    width: 100vw;
    inset: auto 0 0 0;
    height: min(85vh, 720px);
    border-left: none;
    border-top: 1px solid var(--border-medium);
    border-radius: var(--radius-2026-xl) var(--radius-2026-xl) 0 0;
    transform: translateY(100%);
  }
  .nx-drawer.is-open { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .nx-drawer, .nx-drawer-backdrop { transition: none; }
}

/* ── Popover (small floating panel anchored to a trigger) ──────
   Use for assign, status change, escalate — decisions that don't
   need full-modal focus. JS positions it; CSS owns the look. */
.nx-popover {
  position: absolute;
  z-index: 9500;
  min-width: 240px;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-2026-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--motion-fast), transform var(--motion-fast);
}
.nx-popover.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.nx-popover-header {
  padding: 8px 10px 6px;
  font-size: var(--font-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nx-popover-search {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-2026-sm);
  padding: 7px 10px;
  font: 400 var(--font-sm)/1.4 inherit;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.nx-popover-search:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: var(--bg-secondary);
}
.nx-popover-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nx-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-2026-sm);
  font-size: var(--font-sm);
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nx-popover-item:hover,
.nx-popover-item:focus-visible,
.nx-popover-item.is-active {
  background: var(--bg-tertiary);
  outline: none;
}
.nx-popover-item.is-selected {
  background: var(--bg-active);
  color: var(--accent-primary);
}
.nx-popover-item-meta {
  margin-left: auto;
  font-size: var(--font-2xs);
  color: var(--text-muted);
}
.nx-popover-empty {
  padding: 14px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}
.nx-popover-field {
  display: grid;
  gap: 6px;
  padding: 6px 2px 8px;
}
.nx-popover-label {
  color: var(--text-muted);
  font-size: var(--font-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nx-popover-textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 9px 10px;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-2026-sm);
  font: 400 var(--font-sm)/1.45 inherit;
}
.nx-popover-textarea:focus {
  outline: none;
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.nx-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 2px 2px;
}
@media (max-width: 640px) {
  .nx-popover {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: min(72vh, 560px);
    overflow: hidden;
    border-radius: var(--radius-2026-lg);
    transform: translateY(10px);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  }
  .nx-popover.is-open {
    transform: translateY(0);
  }
  .nx-popover-list {
    max-height: min(48vh, 360px);
  }
  .nx-popover-item,
  .nx-popover-search {
    min-height: 44px;
  }
  .nx-popover-actions {
    flex-direction: column-reverse;
  }
  .nx-popover-actions .btn,
  .nx-popover-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
}

/* In-place trigger button used inside property rows / detail cells.
   Looks like plain text/value until hovered; signals editability without
   adding visual noise to the read-only state. */
.property-edit-trigger {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: var(--radius-2026-sm, 6px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  max-width: 100%;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.property-edit-trigger:hover,
.property-edit-trigger:focus-visible {
  background: var(--bg-hover, var(--bg-secondary));
  border-color: var(--border-light);
  outline: none;
}
.property-edit-trigger:focus-visible {
  border-color: var(--accent-primary);
}

.ticket-badge-trigger {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px;
  margin: -2px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.ticket-badge-trigger:hover,
.ticket-badge-trigger:focus-visible {
  background: var(--bg-hover, var(--bg-secondary));
  border-color: var(--border-light);
  outline: none;
}
.ticket-badge-trigger:focus-visible {
  border-color: var(--accent-primary);
}

@media (prefers-reduced-motion: reduce) {
  .property-edit-trigger,
  .ticket-badge-trigger { transition: none; }
}

/* ── Command palette (Cmd/Ctrl+K) ─────────────────────────────── */
.nx-cmdk-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: rgba(8, 12, 20, 0.45);
  backdrop-filter: blur(6px);
}
.nx-cmdk-root.is-open { display: flex; }
.nx-cmdk-panel {
  width: 100%;
  max-width: 640px;
  background: var(--card-bg);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-2026-lg);
  box-shadow: 0 24px 80px -16px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 70vh;
  animation: nx-cmdk-in var(--motion-normal);
}
@keyframes nx-cmdk-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .nx-cmdk-panel { animation: none; }
}
.nx-cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.nx-cmdk-input {
  flex: 1;
  border: none;
  background: transparent;
  font: 400 16px/1.4 inherit;
  color: var(--text-primary);
  outline: none;
  caret-color: var(--accent-primary);
}
.nx-cmdk-input::placeholder { color: var(--text-muted); }
.nx-cmdk-mode {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: var(--font-2xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nx-cmdk-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.nx-cmdk-group-title {
  padding: 10px 12px 4px;
  font-size: var(--font-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nx-cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-2026-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-size: var(--font-sm);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nx-cmdk-item.is-active,
.nx-cmdk-item:hover {
  background: var(--bg-tertiary);
}
.nx-cmdk-item-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.nx-cmdk-item.is-active .nx-cmdk-item-icon { color: var(--text-primary); }
.nx-cmdk-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-cmdk-item-hint  { color: var(--text-muted); font-size: var(--font-2xs); }
.nx-cmdk-item-kbd {
  display: inline-flex;
  gap: 3px;
}
.nx-cmdk-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text-muted);
  font: 500 10px/1 var(--font-mono);
}
.nx-cmdk-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-secondary);
  font-size: var(--font-2xs);
  color: var(--text-muted);
}
.nx-cmdk-footer-kbds {
  display: inline-flex;
  gap: 12px;
}
.nx-cmdk-footer-kbds span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nx-cmdk-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}

/* ── First-run hint pill (bottom-right floating affordance) ──────────────
   Shown once per user (until dismissed). Surfaces the Cmd/Ctrl+K shortcut
   so new users discover the global palette. Compact, OS-aware, dismissible.
   Auto-hides after 8s. Polished but quiet — never blocks content. */
.nx-cmdk-hint {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px 9px 12px;
  background: var(--card-bg, #FFFFFF);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12),
              0 2px 6px rgba(15, 23, 42, 0.06);
  font-size: var(--font-sm, 13px);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: calc(100vw - 40px);
}
.nx-cmdk-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.nx-cmdk-hint:hover {
  border-color: var(--accent-primary);
}
.nx-cmdk-hint-text {
  color: var(--text-secondary);
  white-space: nowrap;
}
.nx-cmdk-hint-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
.nx-cmdk-hint-plus {
  color: var(--text-muted);
  font-size: 11px;
  margin: 0 1px;
}
.nx-cmdk-hint-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--motion-fast), color var(--motion-fast);
}
.nx-cmdk-hint-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
html[data-theme="dark"] .nx-cmdk-hint {
  background: var(--card-bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5),
              0 2px 6px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .nx-cmdk-hint-kbd {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}
@media (max-width: 640px) {
  .nx-cmdk-hint {
    bottom: 12px;
    right: 12px;
    left: 12px;
    justify-content: center;
  }
  .nx-cmdk-hint-text:last-of-type { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .nx-cmdk-hint { transition: opacity 120ms linear; transform: none; }
}

/* Hint trigger that lives in the global header (Cmd K shortcut affordance) */
.nx-cmdk-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--sidebar-text);
  border-radius: var(--radius-2026-md);
  padding: 6px 10px 6px 12px;
  font: 500 var(--font-sm)/1 inherit;
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}
.nx-cmdk-trigger:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--sidebar-text-bright);
}
.nx-cmdk-trigger .nx-cmdk-kbd {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--sidebar-text);
}
.nx-cmdk-trigger:hover .nx-cmdk-kbd { color: var(--sidebar-text-bright); }

/* ── Mobile ticket card list — phone-class replacement for the
   horizontal-scroll desktop table. JS renders <article.nx-tcard> rows
   when window width < 768px. */
.nx-tcard-list {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin: 0;
}
@media (max-width: 768px) {
  .nx-tcard-list.is-active { display: flex; }
}
.nx-tcard {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-2026-md);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "id  subj subj"
    "id  meta sla"
    "id  who  who";
  column-gap: 12px;
  row-gap: 4px;
  cursor: pointer;
  transition: border-color var(--motion-fast), background var(--motion-fast);
  -webkit-tap-highlight-color: transparent;
}
.nx-tcard:active { background: var(--bg-tertiary); }
.nx-tcard-id {
  grid-area: id;
  align-self: start;
  font: 600 var(--font-2xs)/1 var(--font-mono);
  color: var(--text-muted);
  padding: 4px 0;
  white-space: nowrap;
}
.nx-tcard-subject {
  grid-area: subj;
  font: 500 var(--font-base)/1.3 inherit;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.nx-tcard-meta {
  grid-area: meta;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-xs);
  color: var(--text-muted);
}
.nx-tcard-meta > * { flex-shrink: 0; }
.nx-tcard-sla {
  grid-area: sla;
  font-size: var(--font-2xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nx-tcard-sla[data-sev="critical"] { color: var(--sev-critical); }
.nx-tcard-sla[data-sev="warning"]  { color: var(--sev-warning); }
.nx-tcard-sla[data-sev="success"]  { color: var(--sev-success); }
.nx-tcard-who {
  grid-area: who;
  font-size: var(--font-xs);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nx-tcard.is-unassigned .nx-tcard-who { color: var(--sev-warning); }
.nx-tcard-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-sm);
}

/* Hide the legacy desktop ticket table on phones when card list is active */
@media (max-width: 768px) {
  .nx-table-hide-on-phone { display: none !important; }
}

/* ── Focus ring (universal) — visible on every interactive element ─ */
:where(button, a, input, select, textarea, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-2026-sm);
}

/* ============================================================
   ▲ End of 2026-05-19 Phase 0 additions
   ============================================================ */
