/* ============================================================
   NPW Labor Console — Enterprise Design System
   Brand red #DC2626 · Navy #0F1554 — matches npwdirect.com
   ============================================================ */

/* ── Light mode (default) ───────────────────────────────── */
:root {
  --navy:     #0F1554;
  --navy-d:   #0a0f3d;
  --red:      #DC2626;
  --red-l:    #ef4444;
  --bg:       #F0F2F7;
  --panel:    #ffffff;
  --panel-r:  #f7f8fc;
  --hover-bg: #eef1fa;
  --ink:      #1a2036;
  --muted:    #64748b;
  --line:     #dde3ef;
  --shadow:   rgba(0,0,0,0.08);
  --blue:     #1d4ed8;
  --green:    #15803d;
  --amber:    #b45309;
  --danger:   #b91c1c;
  --row-risk: #fef2f2;
  --row-good: #f0fdf4;
  --chart-inventory: #1d4ed8;
  --chart-stocking:  #3b0764;
  --chart-shipping:  #ea580c;
  --chart-picking:   #7e22ce;
}

/* ── Dark mode ──────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:       #0d1021;
  --panel:    #141828;
  --panel-r:  #1a1f35;
  --hover-bg: #1e2440;
  --ink:      #e2e8f6;
  --muted:    #8892aa;
  --line:     #252c45;
  --shadow:   rgba(0,0,0,0.35);
  --row-risk: rgba(185,28,28,0.12);
  --row-good: rgba(21,128,61,0.10);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p  { color: var(--muted); margin: 4px 0 0; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  background: var(--navy);
  border-bottom: 2px solid var(--red);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
}
.brand-sub {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.65);
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 10px;
}

/* Hamburger — hidden on desktop, shown at the mobile breakpoint */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  border: none;
  border-radius: 8px;
  background: none;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover { background: rgba(255,255,255,0.12); }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(15, 21, 84, 0.45);
}

.top-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.top-nav-link {
  color: rgba(255,255,255,0.65);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.top-nav-link:hover,
.top-nav-link.active {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
}

/* User dropdown */
.user-area { margin-left: auto; }
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  position: relative;
  transition: background 0.15s;
}
.user-menu:hover,
.user-menu:focus-within {
  background: rgba(255,255,255,0.1);
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-name {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 600;
}
.chevron { color: rgba(255,255,255,0.5); }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  z-index: 200;
  overflow: hidden;
}
.user-menu:focus-within .user-dropdown { display: block; }
.dropdown-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-r);
}
.dropdown-name { font-weight: 700; font-size: 14px; }
.dropdown-email { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.dropdown-item:hover { background: var(--hover-bg); }
.dropdown-item svg { color: var(--muted); flex-shrink: 0; }
.dropdown-signout { color: var(--danger); }
.dropdown-signout svg { color: var(--danger); }

/* ── Page body ──────────────────────────────────────────── */
.page-body {
  padding: 0 0 40px;
}

/* ── Alert ──────────────────────────────────────────────── */
.alert {
  padding: 12px 20px;
  margin: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
  border-left: 4px solid #3b82f6;
}
.alert.error {
  background: #fef2f2;
  color: var(--danger);
  border-left-color: var(--danger);
}
.alert.success {
  background: #f0fdf4;
  color: var(--green);
  border-left-color: var(--green);
}

/* ── Filter bar ─────────────────────────────────────────── */
.filter-bar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
}
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-form.inline {
  flex-wrap: nowrap;
  gap: 8px;
}
.filter-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.filter-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.filter-select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  min-width: 140px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-select:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15,21,84,0.1);
}
input.filter-select { min-width: 120px; }
.hidden { display: none !important; }

/* ── Multi-select checkbox dropdown ─────────────────────── */
.ms-wrap {
  position: relative;
  display: inline-block;
}
.ms-trigger {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 28px 0 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  min-width: 160px;
  cursor: pointer;
  display: flex;
  align-items: center;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  overflow: hidden;
}
.ms-trigger::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  margin-top: 1px;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-top: 5px solid var(--muted);
  border-bottom: none;
  pointer-events: none;
}
.ms-wrap.open .ms-trigger {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(15,21,84,0.10);
}
.ms-wrap.open .ms-trigger::after {
  border-top: none;
  border-bottom: 5px solid var(--navy);
  margin-top: -4px;
}
.ms-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  min-width: 100%;
  width: max-content;
  max-height: 280px;
  overflow-y: auto;
}
.ms-wrap.open .ms-dropdown { display: block; }
.ms-option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 13px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  transition: background 0.1s;
}
.ms-option:hover { background: var(--bg); }
.ms-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}
.ms-option.ms-all {
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  color: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── KPI strip ──────────────────────────────────────────── */
.kpi-strip {
  display: flex;
  gap: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  overflow-x: auto;
}
.kpi-card {
  flex: 1;
  min-width: 140px;
  padding: 16px 20px;
  border-right: 1px solid var(--line);
}
.kpi-card:last-child { border-right: 0; }
.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--ink);
}
.kpi-value.navy  { color: var(--navy); }
.kpi-value.red   { color: var(--danger); }
.kpi-value.green { color: var(--green); }
.kpi-value.amber { color: var(--amber); }
.red   { color: var(--danger) !important; font-weight: 600; }
.green { color: var(--green)  !important; font-weight: 600; }
.amber { color: var(--amber)  !important; font-weight: 600; }
.kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* ── Tab bar ────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  padding: 14px 24px 0;
  border-bottom: 2px solid var(--line);
  background: var(--panel);
}
.tab-btn {
  padding: 9px 20px;
  background: none;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  bottom: -2px;
  transition: color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--ink); background: var(--hover-bg); }
.tab-btn.active {
  background: var(--bg);
  color: var(--navy);
  border-color: var(--line);
  border-bottom-color: var(--bg);
}

/* ── Tab panels ─────────────────────────────────────────── */
.tab-panel {
  display: none;
  padding: 20px 24px;
}
.tab-panel.active { display: block; }

/* ── Panels / cards ─────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; }
.panel-grid { display: grid; gap: 18px; }
.panel-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.chart-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.chart-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }

.period-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--line); text-align: left; }
th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--panel-r);
  white-space: nowrap;
}
td.num, th.num { text-align: right; }
td.bold { font-weight: 700; }
td.muted { color: var(--muted); }
td.mono { font-family: "Fira Code", "Consolas", monospace; font-size: 12px; }
td.small, .small { font-size: 12px; }
td.empty { color: var(--muted); text-align: center; padding: 24px; font-style: italic; }

table.dense th,
table.dense td { padding: 7px 8px; font-size: 12px; }

/* Matrix table */
.matrix th.sticky-col,
.matrix td.sticky-col {
  position: sticky;
  left: 0;
  background: var(--navy);
  color: #fff;
  z-index: 2;
  font-size: 12px;
  min-width: 140px;
}
.matrix td.metric-label { font-weight: 600; }
.matrix th:first-child { background: var(--navy); color: #fff; }
.matrix th.forecast-col { opacity: 0.65; font-style: italic; }
.matrix td.forecast-col { opacity: 0.65; font-style: italic; }
.proj-tag {
  font-size: 9px;
  font-weight: 600;
  opacity: 0.8;
  letter-spacing: 0.02em;
  display: block;
}

/* Labor table */
.labor-table th, .labor-table td { padding: 7px 8px; font-size: 12px; white-space: nowrap; }
.labor-table .col-name { min-width: 180px; }
.assoc-link {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}
.assoc-link:hover { text-decoration: underline; color: var(--blue); }
.pay-type { text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }

.row-risk { background: var(--row-risk); }
.row-risk .attain-cell { color: var(--danger); font-weight: 700; }
.row-good { background: var(--row-good); }

.attain-cell { font-weight: 700; }
.attain-good { color: var(--green); }
.attain-mid  { color: var(--amber); }
.attain-bad  { color: var(--danger); }

.cell-warn { color: var(--amber); font-weight: 600; }
.cell-pos  { color: var(--green); font-weight: 600; }
.cell-neg  { color: var(--danger); font-weight: 600; }

.bonus-yes { color: var(--green); font-weight: 700; font-size: 14px; }
.bonus-no  { color: var(--danger); font-weight: 700; font-size: 14px; }

.total-row td {
  background: var(--bg);
  border-top: 2px solid var(--navy);
  font-weight: 600;
}

.row-forecast td { color: #94a3b8; font-style: italic; }
.forecast-tag {
  display: inline-block;
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--line);
  color: var(--muted);
  vertical-align: middle;
  margin-left: 4px;
}

/* ── Labor toolbar ──────────────────────────────────────── */
.labor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.labor-meta { font-size: 13px; color: var(--muted); }
.export-btns { display: flex; gap: 8px; }

/* Labor tab client-side filters (search / department / attainment group) */
.labor-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.labor-filters .filter-select { min-width: 160px; height: 34px; }
.labor-filters input[type="search"] { flex: 1; min-width: 200px; }

/* Overtime tab: Site / Weekly view toggle */
.util-toggle { display: flex; align-items: center; gap: 6px; }
.util-toggle-btn {
  padding: 4px 12px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.util-toggle-btn:hover { background: var(--hover-bg); }
.util-toggle-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-export:hover { background: var(--hover-bg); border-color: var(--navy); }

/* Excluded section */
.excluded-section {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.excluded-section summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.excluded-section[open] summary {
  border-bottom: 1px solid var(--line);
}

/* ── Department badges ──────────────────────────────────── */
.dept-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.dept-leadership { background: #ede9fe; color: #5b21b6; }
.dept-corporate  { background: #f1f5f9; color: #475569; }
.dept-picking    { background: #fdf4ff; color: #86198f; }
.dept-ecommerce  { background: #fff7ed; color: #c2410c; }
.dept-shipping   { background: #fef3c7; color: #92400e; }
.dept-stocking   { background: #dbeafe; color: #1e40af; }
.dept-inventory  { background: #f3e8ff; color: #7c3aed; }
.dept-returns    { background: #ccfbf1; color: #0f766e; }
.dept-willcall   { background: #ffe4e6; color: #be123c; }
.dept-support    { background: #f0fdf4; color: #166534; }
.dept-none       { background: #f1f5f9; color: #94a3b8; }

/* ── Source badges ──────────────────────────────────────── */
.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.source-clickhouse { background: #e0f2fe; color: #075985; }
.source-manual     { background: #fef3c7; color: #92400e; }

/* ── Buttons ────────────────────────────────────────────── */
.btn-primary {
  height: 36px;
  padding: 0 18px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--navy-d); }
.btn-primary.btn-lg { height: 44px; padding: 0 28px; font-size: 15px; }
.btn-primary.btn-full { width: 100%; height: 42px; }
.btn-primary-sm {
  height: 28px;
  padding: 0 12px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost {
  height: 36px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--hover-bg); }
.btn-ghost-sm {
  height: 28px;
  padding: 0 10px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger-sm {
  height: 28px;
  padding: 0 10px;
  background: var(--row-risk);
  color: var(--danger);
  border: 1px solid rgba(185,28,28,0.25);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-danger-sm:hover { background: #fee2e2; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.badge-blue  { background: #dbeafe; color: #1e40af; }
.badge-red   { background: #fee2e2; color: var(--danger); }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray  { background: #f1f5f9; color: #475569; }

.required { color: var(--red); }

/* ── Auth pages ─────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-logo {
  text-align: center;
  line-height: 1;
  margin-bottom: 6px;
}
.auth-logo-img {
  height: 52px;
  width: auto;
  object-fit: contain;
}
.auth-title {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 28px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Classify page ──────────────────────────────────────── */
.classify-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
}
.classify-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
.classify-icon { color: var(--red); flex-shrink: 0; margin-top: 2px; }
.classify-header h1 { font-size: 20px; margin-bottom: 4px; }
.classify-header p { margin: 0; }
.classify-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}
.classify-table th, .classify-table td { padding: 11px 14px; }
.classify-select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  min-width: 150px;
}
.classify-actions {
  text-align: center;
  padding: 4px 0;
}
.classify-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Data-freshness stamp in the top bar */
.data-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  flex-shrink: 0;
}
.data-refresh svg { opacity: 0.7; }

/* ── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
  margin-left: 8px;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
}
/* Hide the icon for the inactive mode */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ── Auto-logout modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(15,21,84,0.50);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px 44px 36px;
  width: 380px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { transform: translateY(-14px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.modal-icon-wrap {
  color: var(--amber);
  margin-bottom: 14px;
}
.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 10px;
}
.modal-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin: 0 0 26px;
}
.modal-body strong { color: var(--ink); }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.btn-ghost {
  height: 38px;
  padding: 0 20px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover {
  border-color: var(--navy);
  color: var(--navy);
}

/* ── Associate detail page ──────────────────────────────── */
.assoc-page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px 24px;
}
.assoc-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}
.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 4px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--navy); }
.assoc-title-block h1 { font-size: 22px; margin-bottom: 8px; }
.assoc-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Admin page ─────────────────────────────────────────── */
.admin-page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px 24px;
}
.page-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.access-list { display: grid; }
.access-row {
  display: grid;
  grid-template-columns: 220px 1fr 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.access-row:last-child { border-bottom: 0; }
.access-user { padding-top: 2px; }
.access-fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  display: grid;
  gap: 6px;
  margin: 0;
}
.access-fieldset legend {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 4px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.check-label input { width: 14px; height: 14px; cursor: pointer; }

.row-actions { display: flex; gap: 6px; }

/* ── Goals form ─────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.goal-form .form-row .filter-select { min-width: 120px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 24px;
  width: 420px;
  max-width: 95vw;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: var(--ink); }

/* ── Charts ─────────────────────────────────────────────── */
/* touch-action: manipulation keeps scroll/pinch but stops accidental
   double-tap-to-zoom when a tap lands on a chart */
canvas { width: 100%; display: block; touch-action: manipulation; }

/* ── Misc utility ───────────────────────────────────────── */
.bold { font-weight: 700; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; text-align: center; padding: 24px; }
.goals-layout { display: grid; gap: 18px; }

/* ── Activity accordion ─────────────────────────────────── */
.act-parent-row {
  cursor: pointer;
  background: var(--panel-r);
  user-select: none;
}
.act-parent-row:hover { background: var(--hover-bg); }
.act-parent-row.act-expanded { background: var(--hover-bg); }
.act-parent-label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.act-expand-icon {
  display: inline-block;
  font-size: 9px;
  color: var(--muted);
  width: 12px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.act-parent-row:hover .act-expand-icon,
.act-parent-row.act-expanded .act-expand-icon { color: var(--navy); }
.act-child-row td { font-size: 12.5px; background: var(--panel); }
.act-child-label {
  padding-left: 28px;
  color: var(--muted);
}
[data-theme="dark"] .act-child-row td { background: var(--panel); }
/* Transaction rows on the Activity tab double as a filter for the employee drill table. */
.act-child-drill { cursor: pointer; }
.act-child-drill:hover td { background: var(--hover-bg); }
.act-child-row.act-child-selected td { background: rgba(15, 21, 84, 0.10); font-weight: 600; }
[data-theme="dark"] .act-child-row.act-child-selected td { background: rgba(255, 255, 255, 0.10); }
/* Employee drill-down panel nested under an expanded parent type. */
.act-emp-cell { padding: 10px 14px 14px 28px; background: var(--hover-bg); }
.act-emp-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.act-emp-table { width: 100%; background: var(--panel); }
.act-emp-table th { position: static; }
/* Returns tab — site → channel → writer accordion (days across the columns). */
.ret-site, .ret-channel { cursor: pointer; }
.ret-site:hover td, .ret-channel:hover td { background: var(--hover-bg); }
.ret-site:hover .act-expand-icon, .ret-site.ret-expanded .act-expand-icon,
.ret-channel:hover .act-expand-icon, .ret-channel.ret-expanded .act-expand-icon { color: var(--navy); }
.ret-expandable { display: flex; align-items: center; gap: 8px; }
.ret-channel td, .ret-writer td { font-size: 12.5px; }
.ret-writer td { background: var(--panel); }
[data-theme="dark"] .ret-writer td { background: var(--panel); }
.ret-writer-label { padding-left: 52px; color: var(--muted); }
.cmp-loc-head { background: var(--navy); color: #fff; font-size: 11px; letter-spacing: .03em; text-align: center; }
.activity-accordion[style*="table-layout"] td:first-child,
.activity-accordion[style*="table-layout"] th:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Daily Hours Plan grid ───────────────────────────────── */
.plan-grid th, .plan-grid td { white-space: nowrap; }
.plan-grid .plan-rowhead { text-align: left; }
.plan-grid .plan-day-head { border-left: 2px solid var(--border); }
.plan-grid .plan-sub { border-left: 1px solid var(--border); }
.plan-grid .plan-total-head { border-left: 2px solid var(--border); background: var(--hover-bg); }
/* FTE (headcount-equivalent = hours ÷ 8) column, one per day — light left divider. */
.plan-grid .plan-fte { border-left: 1px solid var(--border); }
/* Projected (future) day columns are visually de-emphasised. */
.plan-grid .plan-fc { background: rgba(15, 21, 84, 0.05); color: var(--muted); font-style: italic; }
[data-theme="dark"] .plan-grid .plan-fc { background: rgba(255, 255, 255, 0.04); }
/* The "/ projected" (or "/ target") baseline shown next to the actual, kept small. */
.plan-grid .plan-proj { font-size: 9px; color: var(--muted); font-weight: 400; margin-left: 1px; }

/* ── Impersonation bar ───────────────────────────────────── */
.impersonate-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background: #92400e;
  color: #fef3c7;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid #b45309;
}
[data-theme="dark"] .impersonate-bar {
  background: #78350f;
  border-bottom-color: #92400e;
}
.impersonate-bar strong { color: #ffffff; }
.impersonate-stop {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fef3c7;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.impersonate-stop:hover {
  background: rgba(255,255,255,0.25);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 960px) {
  /* Backstop: nothing may widen the document past the screen — a wider layout
     makes mobile browsers zoom out to fit it. `clip` (unlike `hidden`) doesn't
     create a scroll container, so the sticky topbar keeps working. */
  html, body { overflow-x: clip; }

  .topbar { gap: 12px; padding: 0 16px; }
  .nav-toggle { display: inline-flex; }
  .data-refresh { display: none; }

  /* Top nav becomes a slide-in drawer */
  .top-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    max-width: 82vw;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 14px 12px;
    background: var(--navy);
    box-shadow: 2px 0 20px rgba(0,0,0,0.35);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 100;
    overflow-y: auto;
  }
  .top-nav-link { font-size: 15px; padding: 12px 14px; border-radius: 8px; }
  body.nav-open .top-nav { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }
  body.nav-open { overflow: hidden; }

  .user-name { display: none; }

  /* Tab bars (Dashboard has 10 tabs) become swipe-scrollable instead of
     overflowing the screen. The -2px border-merge trick is dropped here —
     inside a scroll container it would just clip. */
  .tab-bar {
    overflow-x: auto;
    padding: 14px 16px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; white-space: nowrap; bottom: 0; }

  /* Multi-select must never exceed its filter bar / the screen */
  .ms-wrap, .ms-trigger { max-width: 100%; }
  .ms-dropdown { max-width: calc(100vw - 40px); }

  /* Pin the first column of dense tables so row labels stay visible while
     the numeric columns scroll horizontally */
  table.dense th:first-child,
  table.dense td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--panel);
  }
  table.dense thead th:first-child { z-index: 2; background: var(--panel-r); }
  table.dense .total-row td:first-child { background: var(--bg); }

  /* iOS zooms any focused input under 16px — keep form controls at 16px */
  .filter-select,
  input.filter-select,
  select,
  textarea,
  input[type="text"],
  input[type="search"],
  input[type="number"],
  input[type="date"] { font-size: 16px; }

  .kpi-strip { flex-wrap: wrap; }
  .kpi-card { min-width: 45%; }
  .chart-grid.two,
  .panel-grid.two { grid-template-columns: 1fr; }
  .tab-panel { padding: 14px 16px; }
  .filter-bar { padding: 10px 16px; }
  .labor-toolbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .access-row { grid-template-columns: 1fr; }
  .assoc-header { flex-direction: column; }
  .form-row { flex-direction: column; }
}

/* Narrow phones: the topbar's fixed-width items (hamburger + logo + brand +
   toggle + avatar) don't all fit, and none of them can shrink — trim the brand
   down to the gearbox mark so the header can't overflow the screen. */
@media (max-width: 520px) {
  .topbar { gap: 10px; }
  .brand-logo, .brand-tag { display: none; }
  .brand-mark { border-left: none; padding-left: 0; }
}

/* ── NPW Gearbox brand mark ─────────────────────────────── */
.brand-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  border-left: 1px solid rgba(255,255,255,0.2);
  padding-left: 12px;
  color: #fff;               /* shift-gate strokes pick this up */
}
.gearbox-icon { width: 30px; height: 30px; display: block; flex-shrink: 0; }
.gearbox-icon .gear-ring {
  transform-origin: 24px 24px;
  transition: transform 0.5s ease;
}
.brand:hover .gearbox-icon .gear-ring { transform: rotate(45deg); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-size: 15px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}
.brand-tag {
  font-size: 8.5px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

/* Login-card variant */
.auth-brandmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 0 2px;
  color: var(--ink);         /* shift-gate strokes pick this up */
}
.auth-brandmark .gearbox-icon { width: 34px; height: 34px; }
.auth-brandmark .auth-title {
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
.auth-tagline {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  font-style: italic;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 26px;
}

/* ── Gearbox loading overlay ────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(15, 21, 84, 0.55);
  backdrop-filter: blur(2px);
}
.loading-overlay.active { display: flex; }
.gearset { position: relative; width: 104px; height: 78px; }
.gearset .gear { position: absolute; display: block; }
.gearset .gear-big {
  width: 64px; height: 64px;
  left: 0; top: 14px;
  animation: gear-spin 2.4s linear infinite;
}
.gearset .gear-small {
  width: 42px; height: 42px;
  left: 60px; top: 0;
  animation: gear-spin-rev 1.575s linear infinite; /* 42/64 of the big gear's period — meshed ratio */
}
@keyframes gear-spin     { to { transform: rotate(360deg); } }
@keyframes gear-spin-rev { from { transform: rotate(22.5deg); } to { transform: rotate(-337.5deg); } }
.loading-text {
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #fff;
}

/* ── Task boards (supervisor editor) ────────────────────── */
.board-step-btn {
  background: none;
  border: 0;
  padding: 0 2px;
  cursor: pointer;
  color: inherit;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.65;
}
.board-step-btn:hover:not(:disabled) { opacity: 1; }
.board-step-btn:disabled { opacity: 0.2; cursor: default; }

.cadence-row { display: flex; gap: 8px; align-items: center; }
.cadence-seq {
  min-width: 22px;
  text-align: right;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
}
.cadence-zone    { max-width: 180px; }
.cadence-type    { max-width: 120px; }
.cadence-num     { max-width: 200px; }
.cadence-optzone { max-width: 150px; }

/* Handheld editors (Zebra TC52 etc.): cadence rows must fit a ~400px screen and
   the per-step controls need real touch targets. */
@media (max-width: 960px) {
  .cadence-row { flex-wrap: wrap; }
  .cadence-zone    { flex: 1 1 140px; max-width: none; }
  .cadence-type    { flex: 0 1 110px; }
  .cadence-num     { flex: 1 1 130px; max-width: none; }
  .cadence-optzone { flex: 1 1 110px; max-width: none; }
  .board-step-btn {
    font-size: 17px;
    padding: 6px 9px;
    min-width: 34px;
    min-height: 34px;
  }
}
