:root {
  --blue: #0F034E;
  --blue-light: #ede9f8;
  --blue-mid: #2a1878;
  --gold: #9C7E0F;
  --gold-light: #f9f4e3;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #d97706;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --sidebar-w: 220px;
  font-family: system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { background: var(--gray-100); color: var(--gray-900); }

/* ── Auth screen ──────────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}

.login-box {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.login-box h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.login-box p { color: var(--gray-500); margin-bottom: 2rem; }

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 7px;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--gray-900);
  cursor: pointer;
  transition: background 0.15s;
}

.btn-google:hover { background: var(--gray-50); }

/* ── App shell ────────────────────────────────────────────────────────────── */

#app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--blue);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-logo-img {
  display: block;
  width: 100%;
  max-width: 160px;
  height: auto;
  margin-bottom: 0.6rem;
}

.nav-logo {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

.nav-user-name {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-links {
  list-style: none;
  padding: 0.75rem 0;
  flex: 1;
}

.nav-link {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: color 0.1s;
}

.nav-link:hover { color: #fff; }
.nav-link.active { color: #fff; border-left-color: var(--gold); background: rgba(255,255,255,0.07); }

/* ── Nav groups (collapsible) ─────────────────────────────────────────────── */

.nav-group { list-style: none; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 1.25rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: rgba(255,255,255,0.6);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  transition: color 0.1s;
}

.nav-group-toggle:hover { color: #fff; }

.nav-group-toggle.open { color: #fff; }

.nav-arrow {
  font-size: 0.65rem;
  transition: transform 0.18s ease;
  opacity: 0.6;
}

.nav-group-toggle.open .nav-arrow { transform: rotate(90deg); opacity: 1; }

.nav-group-items {
  list-style: none;
  display: none;
  background: rgba(0,0,0,0.15);
}

.nav-group-items.open { display: block; }

.nav-link.nav-sub {
  padding-left: 2rem;
  font-size: 0.875rem;
}

.nav-subgroup { list-style: none; }

.nav-subgroup-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.45rem 1.25rem 0.45rem 2rem;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: rgba(255,255,255,0.45);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-align: left;
  transition: color 0.1s;
}

.nav-subgroup-toggle:hover { color: rgba(255,255,255,0.8); }
.nav-subgroup-toggle.open  { color: rgba(255,255,255,0.85); }

.nav-subgroup-toggle.open .nav-arrow { transform: rotate(90deg); opacity: 1; }

.nav-subgroup-items {
  list-style: none;
  display: none;
}

.nav-subgroup-items.open { display: block; }

.nav-link.nav-deep {
  padding-left: 2.75rem;
  font-size: 0.84rem;
}

.btn-logout {
  margin: 1rem 1.25rem;
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--gray-400);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}

.btn-logout:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

/* ── Main content ─────────────────────────────────────────────────────────── */

#main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 1100px;
}

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; }
.page-header p { color: var(--gray-500); font-size: 0.9rem; margin-top: 0.2rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin-bottom: 1rem;
}

/* ── Stat tiles ───────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-tile {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
}

.stat-tile .stat-label { font-size: 0.78rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .stat-value { font-size: 2rem; font-weight: 700; margin-top: 0.2rem; }
.stat-tile.blue .stat-value { color: var(--blue); }
.stat-tile.amber .stat-value { color: var(--amber); }
.stat-tile.red .stat-value { color: var(--red); }
.stat-tile.green .stat-value { color: var(--green); }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
}

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ── Status badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-accepted  { background: var(--blue-light); color: var(--blue); }
.badge-review    { background: #fef3c7; color: var(--amber); }
.badge-quarantine { background: #fee2e2; color: var(--red); }
.badge-approved  { background: #dcfce7; color: var(--green); }
.badge-revised   { background: #f3e8ff; color: #7c3aed; }
.badge-conflict  { background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.badge-flag      { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-gray      { background: #f3f4f6; color: #6b7280; }
.badge-yellow    { background: #fef3c7; color: #92400e; }
.badge-green     { background: #dcfce7; color: #166534; }
.badge-red       { background: #fee2e2; color: #991b1b; }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

.field-group { display: flex; flex-direction: column; }
.field-group.full-width { grid-column: 1 / -1; }

.field-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
}

input[type="text"], input[type="date"], input[type="number"],
input[type="email"], select, textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--gray-50);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn { border: none; border-radius: 7px; padding: 0.5rem 1.1rem;
  font-size: 0.88rem; font-weight: 600; cursor: pointer; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-mid); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-success:disabled { background: var(--gray-300); color: var(--gray-500); cursor: not-allowed; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-ghost { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-200); }

.btn-row { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Detail panel ─────────────────────────────────────────────────────────── */

.detail-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  box-shadow: -4px 0 20px rgba(0,0,0,0.08);
  z-index: 50;
  display: none;
  flex-direction: column;
}

.detail-panel.open { display: flex; }

.panel-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
}

.panel-body {
  overflow-y: auto;
  flex: 1;
  padding: 1.25rem 1.5rem;
}

.panel-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gray-400);
  padding: 0;
  line-height: 1;
}

.panel-close:hover { color: var(--gray-900); }

.dl { display: grid; grid-template-columns: 140px 1fr; gap: 0.4rem 1rem; font-size: 0.88rem; margin-bottom: 1rem; }
.dl dt { color: var(--gray-500); font-weight: 500; }
.dl dd { color: var(--gray-900); }

/* ── Filter bar ───────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar select, .filter-bar input { max-width: 200px; }

.filter-bar label { font-size: 0.82rem; font-weight: 600; color: var(--gray-700); }

/* ── Misc ─────────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
  font-size: 0.95rem;
}

.section-divider {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin: 1.25rem 0 0.5rem;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.25rem;
}

/* ── Staff directory ───────────────────────────────────────────────────────── */

.alias-tag {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin: 0.1rem 0.15rem 0.1rem 0;
  white-space: nowrap;
}

.code-tag {
  display: inline-block;
  background: var(--gold-light);
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin: 0.1rem 0.15rem 0.1rem 0;
  white-space: nowrap;
  font-family: monospace;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
  display: block;
}

.multi-select {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0.25rem;
  font-size: 0.9rem;
}

/* ── Staff wizard ──────────────────────────────────────────────────────────── */

.wizard-step-indicator {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.wizard-warning {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #92400e;
  margin-bottom: 1rem;
}

.wizard-clear {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #166534;
  margin-bottom: 1rem;
}

/* ── Read-only staff fields ─────────────────────────────────────────────────── */

.readonly-section {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-top: 1.25rem;
  background: var(--gray-50);
}

.readonly-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.readonly-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.65rem;
}

.readonly-field:last-child { margin-bottom: 0; }

.readonly-field-label {
  font-size: 0.78rem;
  color: var(--gray-400);
  font-weight: 600;
}

.readonly-field-value {
  font-size: 0.875rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

/* ── Staff name resolution ─────────────────────────────────────────────────── */

.staff-match-card {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface);
}

.staff-match-card:hover {
  border-color: var(--blue);
  background: #f8f7ff;
}

.staff-match-selected {
  border-color: var(--blue) !important;
  background: #eeecff !important;
}

.match-score {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

/* ── Review Flags ──────────────────────────────────────────────────────────── */

.flag-item {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.45rem;
}

.flag-dismissed { opacity: 0.45; }

.flag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}

.flag-type-badge {
  background: #fff7ed;
  color: #c2410c;
  font-size: 0.68rem;
  border: 1px solid #fed7aa;
}

.flag-desc {
  margin: 0;
  font-size: 0.83rem;
  color: var(--gray-600);
}

/* ── Edit form ─────────────────────────────────────────────────────────────── */

.edit-section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  margin: 1.25rem 0 0.5rem;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.edit-add-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  text-transform: none;
  letter-spacing: 0;
}

.edit-list-row {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--gray-50);
  position: relative;
}

.edit-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
}

.edit-row-grid .edit-full { grid-column: 1 / -1; }

.edit-lbl {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.15rem;
}

.edit-list-row input[type="text"],
.edit-list-row input[type="number"],
.edit-list-row input[type="date"],
.edit-list-row select {
  width: 100%;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #fff;
}

.edit-row-del {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}

.edit-row-del:hover { color: var(--red); }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

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

/* ── Token rows ───────────────────────────────────────────────────────────── */

.token-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.85rem;
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  width: min(540px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h3 { margin: 0; font-size: 1rem; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  color: var(--gray-500, #64748b);
}

/* Location active toggle */
.loc-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.loc-toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.loc-toggle-track {
  display: inline-block;
  width: 32px;
  height: 18px;
  background: var(--gray-300, #cbd5e1);
  border-radius: 9px;
  position: relative;
  transition: background 0.15s;
}

.loc-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.loc-toggle input:checked + .loc-toggle-track {
  background: var(--blue);
}

.loc-toggle input:checked + .loc-toggle-track::after {
  transform: translateX(14px);
}

/* ── Pay Period Summary Cards ─────────────────────────────────────────────── */

.pp-summary-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pp-summary-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(15,3,78,0.08);
}

.pp-summary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.pp-period-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  margin-bottom: 0.2rem;
}

.pp-date-range {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.pp-metrics {
  display: flex;
  gap: 1.5rem;
}

.pp-metric { text-align: center; }
.pp-metric-val { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.pp-metric-lbl { font-size: 0.72rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.15rem; }
.pp-metric-warn .pp-metric-val { color: var(--amber); }
.pp-metric-danger .pp-metric-val { color: var(--red); }

/* ── Pay Period Detail ────────────────────────────────────────────────────── */

.pp-detail-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.pp-detail-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pp-detail-title h1 { margin: 0; font-size: 1.2rem; }

.pp-tab-bar {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.25rem;
  gap: 0;
}

.pp-tab {
  background: none;
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.1s;
}

.pp-tab:hover { color: var(--gray-700); }
.pp-tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 1.25rem;
  gap: 0;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.1s;
}

.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Pay Period Spreadsheet ───────────────────────────────────────────────── */

.pp-client-section { margin-bottom: 1.25rem; }

.pp-client-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.pp-client-name { font-weight: 700; font-size: 1rem; }
.pp-client-code { color: var(--gray-400); font-size: 0.85rem; }

.pp-billing-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pp-billing-badge.hourly { background: #dbeafe; color: var(--blue); }
.pp-billing-badge.daily  { background: #dcfce7; color: var(--green); }

.pp-ot-label {
  font-size: 0.78rem;
  color: var(--gray-400);
}

.pp-sheet-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}

.pp-sheet {
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 600px;
  width: 100%;
  table-layout: auto;
}

.pp-sheet th {
  background: #f1f5f9;
  border: 1px solid var(--gray-200);
  padding: 0.3rem 0.4rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-700);
  white-space: nowrap;
}

.pp-col-emp   { text-align: left !important; width: 140px; min-width: 120px; }
.pp-col-client { text-align: left !important; width: 100px; min-width: 80px; }
.pp-col-date  { width: 42px; min-width: 38px; }
.pp-col-total { width: 56px; min-width: 50px; background: #e9ecef !important; }

.pp-emp-name {
  border: 1px solid var(--gray-200);
  padding: 0.3rem 0.5rem;
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  background: #fafafa;
}

.pp-cell {
  border: 1px solid var(--gray-200);
  padding: 0.25rem 0.3rem;
  text-align: center;
  vertical-align: middle;
  font-size: 0.82rem;
  color: var(--gray-700);
}

.pp-cell-total {
  border: 1px solid var(--gray-200);
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.82rem;
  background: #f1f5f9;
  white-space: nowrap;
}

.pp-client-cell {
  text-align: left;
  padding-left: 0.5rem;
  font-size: 0.8rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.pp-footer-row td { background: #f1f5f9; font-weight: 600; }
.pp-footer-lbl { text-align: left !important; font-size: 0.75rem !important; color: var(--gray-500) !important; }

.pp-summary-row td { background: #fafafa; font-size: 0.78rem; }
.pp-summary-lbl { font-size: 0.75rem !important; color: var(--gray-500) !important; font-style: italic; }
.pp-ot-row { background: #fafafa; }

/* Week break column — slightly thicker left border */
.week-break { border-left: 2px solid var(--gray-400) !important; }

/* OT cell coloring */
.cell-st    { background: #f0fdf4; }
.cell-mixed { background: #fef9c3; }
.cell-ot    { background: #fff1e6; }

.ot-val { color: #c2410c; font-weight: 600; }

/* ── DFT View Grid ────────────────────────────────────────────────────────── */

.pp-dft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.pp-dft-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.pp-dft-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(15,3,78,0.07);
}

.pp-dft-card-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.pp-dft-card-head code {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gray-900);
}

.pp-dft-meta {
  font-size: 0.82rem;
  color: var(--gray-700);
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.3rem;
}

.pp-dft-counts {
  display: flex;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--gray-500);
  flex-wrap: wrap;
}

/* Legend */
.pp-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
}

.pp-legend-item {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  color: var(--gray-700);
}

/* ── Logistics Centre ────────────────────────────────────────────────────── */

.lc-type-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.lc-type-flight      { background: #dbeafe; color: #1d4ed8; }
.lc-type-hotel       { background: #ede9fe; color: #6d28d9; }
.lc-type-rental_truck { background: #fef3c7; color: #92400e; }

.lc-status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.lc-status-incomplete { background: var(--gray-100); color: var(--gray-500); }
.lc-status-unmatched  { background: #fee2e2; color: #991b1b; }
.lc-status-partial    { background: #fef9c3; color: #854d0e; }
.lc-status-matched    { background: #dcfce7; color: #166534; }

/* Calendar */

.lc-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.lc-cal-dow {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-400);
  padding: 0.25rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lc-cal-cell {
  min-height: 72px;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--gray-100);
  border-radius: 4px;
  background: #fff;
  position: relative;
  vertical-align: top;
}

.lc-cal-empty { background: var(--gray-50); border-color: transparent; }

.lc-cal-today {
  border-color: var(--blue);
  background: #eff6ff;
}

.lc-cal-has-events { background: #fafafa; }
.lc-cal-today.lc-cal-has-events { background: #eff6ff; }

.lc-cal-day-num {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.2rem;
}

.lc-cal-today .lc-cal-day-num {
  color: var(--blue);
}

.lc-cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 0.2rem;
}

.lc-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.lc-dot-unmatched  { background: #ef4444; }
.lc-dot-partial    { background: #f59e0b; }
.lc-dot-matched    { background: #22c55e; }
.lc-dot-incomplete { background: var(--gray-300); }

.lc-cal-chips {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.lc-chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  white-space: nowrap;
  line-height: 1.5;
}

.lc-chip-flight     { background: #dbeafe; color: #1d4ed8; }
.lc-chip-hotel      { background: #ede9fe; color: #6d28d9; }
.lc-chip-truck      { background: #fef3c7; color: #92400e; }
.lc-chip-unmatched  { background: #fee2e2; color: #991b1b; }
.lc-chip-partial    { background: #fef9c3; color: #854d0e; }
.lc-chip-matched    { background: #dcfce7; color: #166534; }
.lc-chip-incomplete { background: var(--gray-100); color: var(--gray-500); }

/* Per-diem logistics warning banner */

.lc-perdiem-banner {
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 6px;
  color: #713f12;
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}

/* ── Project Planning Gantt ──────────────────────────────────────────────── */

.plan-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
}

.plan-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  white-space: nowrap;
  width: 100%;
}

/* Sticky left: role column */
.plan-role-col {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  padding: 0.3rem 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 2px solid var(--gray-200);
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
}

/* Sticky right: staff column */
.plan-staff-col {
  position: sticky;
  right: 0;
  z-index: 3;
  background: #fff;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid var(--gray-200);
  cursor: pointer;
  font-weight: 500;
  color: var(--gray-700);
}

.plan-staff-col:hover,
.plan-role-col:hover { background: var(--gray-50); }

.plan-staff-unassigned { color: var(--gray-400); font-style: italic; font-weight: 400; }

/* Header corner cells */
.plan-th-corner {
  background: var(--gray-50) !important;
  border-bottom: 2px solid var(--gray-200) !important;
}

/* Month header */
.plan-month-th {
  background: var(--gray-100);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-600);
  padding: 0.25rem 0;
  text-align: center;
  border-bottom: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
}

/* Week day-of-month label */
.plan-week-th {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  font-size: 0.66rem;
  font-weight: 400;
  color: var(--gray-400);
  text-align: center;
  padding: 0.15rem 0;
  border-bottom: 2px solid var(--gray-200);
  border-right: 1px solid var(--gray-100);
}

/* Project header spanning row */
.plan-project-header td {
  padding: 0.35rem 0.75rem;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

/* Data rows */
.plan-data-row { height: 30px; }

.plan-data-row td {
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

/* Week cells */
.plan-week-cell {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  padding: 0;
  border-right: 1px solid rgba(0,0,0,0.06);
  position: relative;
  vertical-align: middle;
}

.plan-week-empty { background: var(--gray-50); border-right-color: var(--gray-100); }

.plan-week-filled { border-right: 1px solid rgba(255,255,255,0.18); }

/* Actuals dot */
.plan-actual-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.88);
  margin: auto;
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Context menu */
.plan-ctx-menu {
  position: fixed;
  z-index: 2000;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.14);
  min-width: 160px;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}

.plan-ctx-item {
  padding: 0.45rem 1rem;
  cursor: pointer;
  color: var(--gray-700);
  user-select: none;
}

.plan-ctx-item:hover { background: var(--gray-50); }

.plan-ctx-danger { color: var(--red); }

.plan-ctx-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0.25rem 0;
}

/* Legend */
.plan-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  margin-top: 0.75rem;
  color: var(--gray-600);
}

.plan-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.plan-legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Payroll Export ───────────────────────────────────────────────────────── */

.payroll-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 0;
}

.payroll-tab {
  padding: 0.55rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--gray-500);
  transition: color 0.12s;
}

.payroll-tab:hover  { color: var(--gray-700); }

.payroll-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.payroll-table-wrap {
  max-height: 280px;
  overflow-y: auto;
}

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

.payroll-table thead th {
  position: sticky;
  top: 0;
  background: var(--gray-50);
  z-index: 1;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.payroll-table tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900);
}

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

.payroll-table tbody tr:hover td { background: var(--gray-50); }

.payroll-num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Invoicing ─────────────────────────────────────────────────────────────── */

.inv-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.inv-section {
  padding: 0;
}

.inv-section-inactive {
  opacity: 0.6;
  pointer-events: none;
}

.inv-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
}

.inv-step-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.inv-step-done {
  background: #2e7d32;
}

.inv-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.inv-section-body {
  padding: 1.25rem;
}

.inv-placeholder {
  color: var(--gray-400);
  font-size: 0.875rem;
  font-style: italic;
}

.inv-loading-inline {
  color: var(--gray-500);
  font-size: 0.875rem;
}

.inv-error {
  color: #c62828;
  font-size: 0.875rem;
}

/* Selection section */
.inv-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inv-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.inv-field-btn {
  flex-shrink: 0;
}

.inv-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.inv-select,
.inv-date-input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--gray-900);
  background: #fff;
  min-width: 180px;
}

.inv-select { min-width: 260px; }

.inv-note {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* Health checks */
.inv-health-checks {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inv-check {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.inv-check-ok {
  background: #f0faf4;
  border-color: #a8d5b5;
}

.inv-check-warn {
  background: #fffbeb;
  border-color: #fcd34d;
}

.inv-check-block {
  background: #fff5f5;
  border-color: #fca5a5;
}

.inv-check-icon {
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.inv-check-approval {
  background: #eff6ff;
  border-color: #60a5fa;
}

.inv-check-ok .inv-check-icon         { color: #2e7d32; }
.inv-check-warn .inv-check-icon       { color: #b45309; }
.inv-check-block .inv-check-icon      { color: #c62828; }
.inv-check-approval .inv-check-icon   { color: #1e40af; }

.inv-check-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.inv-check-body strong { font-size: 0.875rem; }

.inv-check-sub {
  font-size: 0.78rem;
  color: var(--gray-500);
}

/* Blocker list */
.inv-blocker-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 0 0.5rem;
}

.inv-blocker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.85rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}

.inv-blocker-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.inv-blocker-date { font-variant-numeric: tabular-nums; color: var(--gray-700); }
.inv-blocker-code { font-family: monospace; font-size: 0.8rem; color: var(--gray-600); }
.inv-blocker-techs { color: var(--gray-700); }

.inv-blocker-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Badges */
.inv-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.inv-badge-review    { background: #fff3cd; color: #7c5700; }
.inv-badge-accepted  { background: #bfdbfe; color: #1e3a8a; }
.inv-badge-current   { background: #d4edda; color: #155724; }

/* Preview section */
.inv-preview-meta {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.inv-meta-pair {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.inv-meta-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
}

.inv-meta-value {
  font-size: 0.95rem;
  color: var(--gray-900);
}

.inv-meta-mono { font-family: monospace; font-size: 0.9rem; }

.inv-table-wrap {
  overflow-x: auto;
}

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

.inv-table thead th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  background: var(--gray-50);
  white-space: nowrap;
}

.inv-table tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900);
}

.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table tbody tr:hover td { background: var(--gray-50); }

.inv-table tfoot td {
  padding: 0.5rem 0.75rem;
  border-top: 2px solid var(--gray-200);
  background: var(--gray-50);
}

.inv-num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Actions section */
.inv-block-msg {
  padding: 0.65rem 1rem;
  background: #fff5f5;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #c62828;
  margin-bottom: 1rem;
}

.inv-actions-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.inv-generate-btn {
  font-size: 0.95rem;
  padding: 0.65rem 1.5rem;
}

.inv-actions-note {
  font-size: 0.8rem;
  color: var(--gray-500);
}

/* Generated panel */
.inv-revision-alert {
  padding: 0.75rem 1rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #7c5700;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.inv-generated-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.inv-gen-number {
  font-size: 1.35rem;
  font-weight: 700;
  font-family: monospace;
  color: var(--gray-900);
}

.inv-gen-period {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.2rem;
}

.inv-gen-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.inv-vh-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
}

.inv-vh-table tbody tr { font-size: 0.875rem; }

.inv-version-current td { font-weight: 500; }

/* Calendar modal */
.inv-cal-modal {
  max-width: 860px;
  width: 95vw;
}

.inv-cal-body {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.inv-cal-main { flex: 1; min-width: 0; }

#inv-cal-main { flex: 1; }

.inv-cal-months {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.inv-cal-month {
  flex: 1;
  min-width: 200px;
}

.inv-cal-month-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
  text-align: center;
}

.inv-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.inv-cal-dayname {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-400);
  padding: 0.2rem 0;
}

.inv-cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: 4px;
}

.inv-cal-empty  { background: transparent; }
.inv-cal-outside { background: var(--gray-100); color: var(--gray-300); }
.inv-cal-present { background: #d4edda; color: #155724; font-weight: 500; }
.inv-cal-missing { background: #fff3cd; color: #7c5700; }
.inv-cal-review  { background: #fde8e8; color: #c62828; font-weight: 600;
                   border: 1px solid #fca5a5; }

.inv-cal-review:hover { background: #fca5a5; }

.inv-cal-needs-approval { background: #bfdbfe; color: #1e3a8a; font-weight: 600;
                          border: 1px solid #60a5fa; cursor: pointer; }

.inv-cal-needs-approval:hover { background: #93c5fd; }

.inv-cal-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

.inv-cal-leg-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--gray-600);
}

.inv-cal-dot {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.inv-cal-dot.inv-cal-outside { background: var(--gray-200); }
.inv-cal-dot.inv-cal-present { background: #d4edda; border: 1px solid #a8d5b5; }
.inv-cal-dot.inv-cal-missing { background: #fff3cd; border: 1px solid #fcd34d; }
.inv-cal-dot.inv-cal-review  { background: #fde8e8; border: 1px solid #fca5a5; }
.inv-cal-dot.inv-cal-needs-approval { background: #bfdbfe; border: 1px solid #60a5fa; }

/* DFT side panel inside calendar modal */
.inv-cal-dft-panel {
  width: 260px;
  flex-shrink: 0;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  background: var(--gray-50);
}

.inv-cal-dft-detail { display: flex; flex-direction: column; gap: 0.5rem; }

.inv-cal-dft-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inv-cal-dft-date  { font-size: 0.85rem; color: var(--gray-600); }
.inv-cal-dft-techs { font-size: 0.85rem; color: var(--gray-700); line-height: 1.5; }

.inv-cal-dft-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

/* ──────────────────────────────────────────────────────────────────────────
   Mobile menu (slide-in drawer with push-content behavior)
   ──────────────────────────────────────────────────────────────────────────
   Breakpoint chosen as 840px:
   - sidebar is 220px; with ~600px of useful content the layout starts to crowd
     anywhere below ~820px. 840 gives a touch of slack and is a common
     tablet-portrait threshold.
   - Landscape phones (852+) deliberately fall on the desktop side. If that
     proves cramped in practice, bump to a larger value here.

   Orthogonal to the @media (max-width: 600px) rule above, which only adjusts
   .form-grid columns and shares no selectors with this block.

   Push, not overlay: when the drawer opens, #main-content translates right by
   the sidebar width with the same timing as the drawer slide-in. There is no
   scrim. The drawer closes via the X icon, Escape, or tapping any nav link.

   Deferred: full keyboard focus management (focus-trap inside the drawer,
   restore focus to the toggle on close). Basics are in: semantic <button>,
   aria-label, aria-expanded, Escape-to-close.
   ────────────────────────────────────────────────────────────────────────── */

#topbar-toggle .icon-close { display: none; }

@media (max-width: 839px) {
  /* Top bar: shows above the content, fixed to the viewport. */
  #topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    padding: 0 0.5rem;
    background: var(--blue);
    color: #fff;
    z-index: 110;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  }

  #topbar[hidden] { display: flex; } /* override the hidden attr below breakpoint */

  #topbar-toggle {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
  }
  #topbar-toggle:hover  { background: rgba(255,255,255,0.08); }
  #topbar-toggle:active { background: rgba(255,255,255,0.16); }

  .topbar-logo { height: 32px; width: auto; display: block; }

  /* Swap hamburger ↔ X based on body state. */
  body.menu-open #topbar-toggle .icon-menu  { display: none; }
  body.menu-open #topbar-toggle .icon-close { display: block; }

  /* Drawer: fixed-position so it doesn't shift the flex layout; transformed
     offscreen by default; transitions in when body has .menu-open. */
  #sidebar {
    position: fixed;
    top: 56px; left: 0;
    width: var(--sidebar-w);
    height: calc(100vh - 56px);
    transform: translateX(-100%);
    transition: transform 240ms ease-out;
    box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    z-index: 100;
  }

  body.menu-open #sidebar { transform: translateX(0); }

  /* Main content: clear the fixed top bar; push right (not cover) when drawer
     is open. Same timing as the drawer so the motion looks coordinated. */
  #main-content {
    padding-top: calc(56px + 1rem);
    transform: translateX(0);
    transition: transform 240ms ease-out;
  }

  body.menu-open #main-content { transform: translateX(var(--sidebar-w)); }

  /* Touch-target floor for menu items inside the drawer. */
  #sidebar .nav-link,
  #sidebar .nav-group-toggle,
  #sidebar .nav-subgroup-toggle {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Logo already lives in the top bar — don't show it twice. */
  #sidebar .nav-logo-img { display: none; }

  /* Right-side slide-in detail panels must layer above the top bar so their
     close button at the top stays tappable. Desktop is unchanged. */
  .detail-panel { z-index: 120; }
}
