  :root {
    --blue: #0057B8;
    --blue-dark: #003d82;
    --blue-light: #e8f0fb;
    --teal: #00A3A3;
    --orange: #FF6B2B;
    --green: #22C55E;
    --red: #EF4444;
    --yellow: #F59E0B;
    --purple: #8B5CF6;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --sidebar-w: 220px;
    --header-h: 60px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-100); color: var(--gray-800); height: 100vh; overflow: hidden; }

  /* ── LOGIN ──────────────────────────────── */
  #login-screen {
    position: fixed; inset: 0; background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 50%, var(--teal) 100%);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    padding: 20px; overflow-y: auto;
  }
  .login-card {
    background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 400px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3); text-align: center;
  }
  .login-logo { font-size: 42px; margin-bottom: 8px; }
  .login-title { font-size: 26px; font-weight: 800; color: var(--blue); margin-bottom: 4px; }
  .login-subtitle { font-size: 13px; color: var(--gray-400); margin-bottom: 32px; }
  .login-card label { display: block; text-align: left; font-size: 12px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
  .login-card select, .login-card input {
    width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: 8px;
    font-size: 14px; margin-bottom: 16px; outline: none; transition: border-color .2s;
  }
  .login-card select:focus, .login-card input:focus { border-color: var(--blue); }
  .btn-login {
    width: 100%; padding: 12px; background: var(--blue); color: white; border: none;
    border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; transition: background .2s;
  }
  .btn-login:hover { background: var(--blue-dark); }

  /* ── LAYOUT ──────────────────────────────── */
  #app { display: none; height: 100vh; overflow: hidden; }
  #app.visible { display: flex; }

  .sidebar {
    width: var(--sidebar-w); background: #ffffff; color: #334155;
    border-right: 1px solid #e8edf3;
    display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
  }
  .sidebar-brand {
    padding: 18px 16px 14px; border-bottom: 1px solid #eef2f7;
    display: flex; align-items: center; gap: 11px;
  }
  .sidebar-brand .logo {
    width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--teal) 100%);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px; font-weight: 800; letter-spacing: -.5px;
    box-shadow: 0 2px 6px rgba(0,87,184,.25);
  }
  .sidebar-brand .brand-text { font-size: 15px; font-weight: 800; line-height: 1.15; color: #0f172a; letter-spacing: -.2px; }
  .sidebar-brand .brand-sub { font-size: 10px; color: #94a3b8; font-weight: 500; }
  .sidebar-user { padding: 12px 16px; border-bottom: 1px solid #eef2f7; }
  .sidebar-user .user-name { font-size: 13px; font-weight: 700; color: #1e293b; }
  .sidebar-user .user-role { font-size: 11px; color: #94a3b8; }
  .sidebar-nav { padding: 10px 8px; flex: 1; }
  /* Section headers are highlighted "chips": orange on white by default, bigger
     than the tabs beneath. Admin can recolor them (✏️ → inline style wins). */
  .sidebar .nav-section { margin: 12px 6px 6px; padding: 8px 12px; font-size: 14px; font-weight: 800; color: var(--orange); background: #FFFFFF; border-radius: 9px; text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
  /* Collapsible nav groups — header toggles the items beneath it */
  .nav-section[data-navgroup] { cursor: pointer; user-select: none; }
  .sidebar .nav-section[data-navgroup]:hover { filter: brightness(.93); }
  .nav-section[data-navgroup]::after { content: '▾'; margin-left: auto; font-size: 9px; opacity: .75; }
  .nav-section[data-navgroup].collapsed::after { content: '▸'; }
  .nav-item.nav-collapsed { display: none !important; }
  .nav-group-dot { margin-left: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); display: none; flex-shrink: 0; }
  .nav-section.collapsed .nav-group-dot.on { display: inline-block; }
  /* Drag-to-arrange: ⠿ grab dots on sidebar tabs (js/dragsort.js) */
  .nav-drag { margin-left: auto; padding: 2px 0 2px 8px; font-size: 12px; color: #94a3b8; opacity: 0; cursor: grab; touch-action: none; user-select: none; flex-shrink: 0; }
  .nav-badge ~ .nav-drag { margin-left: 6px; }
  .nav-item:hover .nav-drag { opacity: .6; }
  @media (hover: none) { .nav-drag { opacity: .35; } }
  /* Admin-only group controls: ✏️ rename + ⠿ move whole group */
  .nav-sec-edit { margin-left: auto; padding: 0 2px 0 8px; font-size: 10px; opacity: 0; cursor: pointer; user-select: none; flex-shrink: 0; }
  .nav-section:hover .nav-sec-edit { opacity: .7; }
  .nav-section .nav-sec-drag { margin-left: 4px; opacity: 0; }
  .nav-section:hover .nav-sec-drag { opacity: .6; }
  @media (hover: none) { .nav-sec-edit, .nav-section .nav-sec-drag { opacity: .35; } }
  /* keep the collapse chevron at the far right after the injected controls */
  .nav-section[data-navgroup]::after { order: 99; }
  .kb-dragging { opacity: .55; background: rgba(0,87,184,.08); outline: 2px dashed var(--blue); border-radius: 10px; }
  body.kb-drag-live { user-select: none; -webkit-user-select: none; }
  /* Dashboard 🧩 Rearrange mode: dashed boxes, grab anywhere, clicks paused */
  body.dash-arrange .dash-block { outline: 2px dashed var(--blue); outline-offset: 4px; border-radius: 12px; cursor: grab; touch-action: none; margin-bottom: 18px; min-height: 34px; }
  body.dash-arrange .dash-block * { pointer-events: none !important; }
  .nav-item {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin: 1px 0;
    font-size: 13px; font-weight: 500; color: #475569; cursor: pointer;
    transition: background .15s, color .15s, transform .16s ease, box-shadow .16s ease;
    border-radius: 9px;
    position: relative;
  }
  /* Sub-tabs sit indented under their section chip so the hierarchy reads instantly,
     and they "pop" toward you on hover — slide right, lift, soft glow. */
  .sidebar .nav-item { margin-left: 18px; margin-right: 6px; }
  .sidebar .nav-item:hover {
    transform: translateX(5px) scale(1.03);
    box-shadow: 0 4px 14px rgba(0,0,0,.28);
    background: rgba(255,255,255,.10);
  }
  .sidebar .nav-item:active { transform: translateX(5px) scale(.98); }
  .nav-item:hover { background: #f1f5f9; color: #1e293b; }
  .nav-item.active { background: var(--blue-light); color: var(--blue); font-weight: 700; }
  .nav-item.active::before { content: none; }
  .nav-icon { font-size: 16px; width: 20px; text-align: center; opacity: .9; }
  .nav-badge { margin-left: auto; background: var(--blue); color: white; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }

  .main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
  .topbar {
    height: var(--header-h); background: white; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0;
  }
  .topbar-title { font-size: 18px; font-weight: 700; color: var(--gray-800); flex: 1; }
  .topbar-location {
    display: flex; align-items: center; gap: 6px; background: var(--blue-light);
    padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--blue); cursor: pointer;
  }
  .topbar-date { font-size: 12px; color: var(--gray-400); }
  .topbar-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--blue);
    display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: white; cursor: pointer;
  }

  .content { flex: 1; overflow-y: auto; padding: 24px; }

  /* Horizontal-scroll wrapper auto-applied to every table (mobile-friendly; no-op when it fits) */
  .tbl-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── PAGES ──────────────────────────────── */
  .page { display: none; }
  .page.active { display: block; }
  .page-monday-flex.active { display: flex; flex-direction: column; }

  /* ── HAMBURGER BUTTON ────────────────────── */
  .hamburger-btn {
    display: none; background: none; border: none; cursor: pointer;
    padding: 6px; border-radius: 8px; color: var(--gray-700); flex-shrink: 0;
    transition: background .15s;
  }
  .hamburger-btn:hover { background: var(--gray-100); }
  .hamburger-btn svg { display: block; }

  /* ── SIDEBAR OVERLAY (mobile) ─────────────── */
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
    z-index: 198; animation: fade-in .2s ease;
  }
  .sidebar-overlay.open { display: block; }

  /* ── MOBILE RESPONSIVE ───────────────────── */
  @media (max-width: 768px) {
    :root { --sidebar-w: 240px; --header-h: 56px; }

    body { overflow: hidden; }

    .sidebar {
      position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
      transform: translateX(-100%); transition: transform .25s ease;
      box-shadow: 4px 0 24px rgba(0,0,0,.25);
    }
    .sidebar.mobile-open { transform: translateX(0); }

    .hamburger-btn { display: flex; align-items: center; justify-content: center; }

    .topbar { padding: 0 14px; gap: 10px; }
    .topbar-location { font-size: 11px; padding: 5px 10px; }
    .topbar-date { display: none; }
    .dr-range-wrap { display: none; }

    .content { padding: 16px 14px; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-value { font-size: 24px; }

    .charts-row { grid-template-columns: 1fr; }
    .health-scores-row { grid-template-columns: 1fr; }
    .fin-grid { grid-template-columns: 1fr; }

    .pipeline-cols { grid-template-columns: repeat(2, 1fr); }
    .ms-report-body { grid-template-columns: repeat(2, 1fr); }

    .form-grid { grid-template-columns: 1fr; }
    .form-full { grid-column: 1; }

    .modal { width: 95vw !important; padding: 20px; }

    .btn-sm { min-height: 36px; padding: 7px 14px; }

    table { font-size: 12px; }
    thead th, tbody td { padding: 10px 12px; }

    /* Scheduler mobile */
    .sched-grid.weekly { min-width: 600px; }
    .sched-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sched-toolbar { flex-wrap: wrap; gap: 8px; }

    /* Tab bars: scroll sideways instead of overflowing the screen */
    .tabs { width: auto; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tabs::-webkit-scrollbar { height: 0; }
    .tabs .tab { flex-shrink: 0; white-space: nowrap; }
    /* NOTE: grid-stacking & Monday-board mobile rules live in mobile.css (loaded last)
       because their base styles are defined in components.css / pages.css. */
  }

  @media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-card { padding: 14px; }
    .page-title { font-size: 18px; }
    .topbar-title { font-size: 15px; }
  }

  /* ── PRINT ───────────────────────────────── */
  @media print {
    body { overflow: visible; background: white; }
    #login-screen, .sidebar, .topbar, .tabs, .sched-toolbar,
    #sched-week-summary, #sched-content-open, #sched-content-timeoff,
    #sched-content-reports, #sched-content-quarterly,
    .shift-add-btn, .nav-badge, button { display: none !important; }
    #app { display: flex !important; height: auto; overflow: visible; }
    .main-area { overflow: visible; }
    .content { overflow: visible; padding: 0; }
    .page { display: none !important; }
    .page#page-scheduler { display: block !important; }
    .sched-grid-wrap { overflow: visible; }
    .sched-grid.weekly { font-size: 10px; }
    .shift-block { page-break-inside: avoid; }
  }

