/* ============================================================
   Dawn to Dusk — shared stylesheet (admin web app + mobile app)
   Palette, typography and elevation rules per the TRD.
   ============================================================ */
:root {
  --accent: #1A73E8;
  --accent-2: #3B82F6;
  --light: #F8FAFC;
  --muted: #94A3B8;
  --canvas: #090D16;
  --surface: #111827;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --amber: #F59E0B;
  --danger: #EF4444;
  --glow: 0 0 12px rgba(59, 130, 246, 0.15);
  --glow-strong: 0 0 18px rgba(59, 130, 246, 0.22);
  --radius: 10px;
  --sidebar-w: 264px;
  --font-head: 'Audiowide', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  background: var(--canvas);
  color: var(--light);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--canvas); }
::-webkit-scrollbar-thumb { background: #1f2937; border-radius: 3px; }
button, input, select, textarea { font-family: var(--font-body); }
button { cursor: pointer; }
a { color: var(--accent-2); text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ------------------------------------------------------------- app shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; z-index: 40;
  width: var(--sidebar-w); height: 100%;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 250ms ease;
}
.sidebar-spacer { width: var(--sidebar-w); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 17px 16px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--accent), #0d4ea6);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--glow);
}
.brand-mark svg { width: 18px; height: 18px; color: #fff; }
.brand-name { font-family: var(--font-head); font-size: 12.5px; letter-spacing: 0.04em; line-height: 1.15; }
.brand-sub { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; }

.nav { flex: 1; overflow-y: auto; padding: 10px; }
.nav-btn, .nav-link {
  width: 100%; display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; min-height: 42px;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 500; text-align: left;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}
.nav-btn:hover, .nav-link:hover, .sub-link:hover { background: rgba(148, 163, 184, 0.07); color: var(--light); }
.nav-btn.parent-active { color: var(--accent-2); }
.nav-link.active {
  background: rgba(26, 115, 232, 0.12); border-color: rgba(59, 130, 246, 0.35);
  color: var(--accent-2); box-shadow: var(--glow);
}
.nav-btn svg, .nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-btn .label { flex: 1; }
.nav-btn .chev { width: 13px; height: 13px; transition: transform 200ms ease; }
.nav-btn.open .chev { transform: rotate(90deg); }
.sub-nav { display: none; flex-direction: column; gap: 2px; margin: 2px 0 6px 26px; padding-left: 10px; border-left: 1px solid var(--border); }
.sub-nav.open { display: flex; }
.sub-link {
  width: 100%; padding: 9px 10px; min-height: 38px;
  border: none; background: none; border-radius: 8px;
  color: var(--muted); font-size: 13px; text-align: left;
  transition: background 180ms ease, color 180ms ease;
}
.sub-link.active { color: var(--accent-2); font-weight: 600; }
.sidebar-foot { padding: 13px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: rgba(26, 115, 232, 0.16); border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-2); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(9, 13, 22, 0.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; align-items: center; gap: 12px; padding: 12px 22px; }
.page-title { font-family: var(--font-head); font-size: 15px; letter-spacing: 0.03em; }
.crumb { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tabbar { display: flex; gap: 2px; padding: 0 22px; overflow-x: auto; border-top: 1px solid var(--border); scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 11px 15px; min-height: 42px;
  background: none; border: none; color: var(--muted);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: color 180ms ease;
}
.tab:hover { color: var(--light); }
.tab.active { color: var(--accent-2); }
.tab.active::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; box-shadow: var(--glow-strong);
}
.content { flex: 1; padding: 20px 22px 40px; }
.hamburger { display: none; background: none; border: none; color: var(--muted); padding: 8px; border-radius: 8px; }
.hamburger svg { width: 20px; height: 20px; }
.scrim { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 35; }
.scrim.open { display: block; }

/* ------------------------------------------------------------- primitives */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.card.accent { border-color: rgba(59, 130, 246, 0.35); box-shadow: var(--glow); }
.card-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 17px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 13.5px; font-weight: 600; }
.card-title .hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }
.card-body { padding: 17px; }
.card-foot { padding: 14px 17px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.section-stack { display: flex; flex-direction: column; gap: 16px; }
.section-num {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: rgba(26, 115, 232, 0.12); border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-2); font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 15px; min-height: 40px;
  border: 1px solid transparent; border-radius: 9px;
  font-size: 13px; font-weight: 500;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}
.btn svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover:not([disabled]) { background: #1668d4; box-shadow: var(--glow-strong); }
.btn-secondary { background: rgba(148, 163, 184, 0.08); color: var(--light); border-color: var(--border-strong); }
.btn-secondary:hover { background: rgba(148, 163, 184, 0.15); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--light); background: rgba(148, 163, 184, 0.08); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #F87171; border-color: rgba(239, 68, 68, 0.28); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: 12px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: rgba(148, 163, 184, 0.05); color: var(--muted);
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--accent-2); border-color: rgba(59, 130, 246, 0.35); background: rgba(26, 115, 232, 0.1); }
.icon-btn.danger:hover { color: #F87171; border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  border: 1px solid transparent; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-blue { background: rgba(26, 115, 232, 0.12); color: var(--accent-2); border-color: rgba(59, 130, 246, 0.3); }
.b-amber { background: rgba(245, 158, 11, 0.12); color: var(--amber); border-color: rgba(245, 158, 11, 0.3); }
.b-red { background: rgba(239, 68, 68, 0.12); color: #F87171; border-color: rgba(239, 68, 68, 0.3); }
.b-gray { background: rgba(148, 163, 184, 0.1); color: var(--muted); border-color: var(--border); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.push { margin-left: auto; }
.search {
  display: flex; align-items: center; gap: 8px; flex: 1;
  min-width: 190px; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
}
.search svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.search input { width: 100%; background: none; border: none; outline: none; color: var(--light); font-size: 13px; }
.search input::placeholder { color: #4b5a70; }

.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.subtab {
  padding: 8px 13px; min-height: 36px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(148, 163, 184, 0.05);
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  transition: all 180ms ease;
}
.subtab:hover { color: var(--light); }
.subtab.active { background: rgba(26, 115, 232, 0.12); color: var(--accent-2); border-color: rgba(59, 130, 246, 0.35); box-shadow: var(--glow); }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 15px; }
.kpi .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.kpi .v { font-family: var(--font-head); font-size: 20px; margin-top: 6px; }
.kpi .m { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi.ok { border-color: rgba(59, 130, 246, 0.3); box-shadow: var(--glow); }
.kpi.ok .v { color: var(--accent-2); }
.kpi.warn .v { color: var(--amber); }
.kpi.bad .v { color: #F87171; }

/* ------------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field .req { color: var(--accent-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 40px;
  background: var(--canvas); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; color: var(--light); font-size: 13px; outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.field input::placeholder, .field textarea::placeholder { color: #4b5a70; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(59, 130, 246, 0.5); box-shadow: var(--glow); }
.field input[readonly] { color: var(--muted); background: rgba(148, 163, 184, 0.04); cursor: not-allowed; }
.field select {
  cursor: pointer; appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.field select[multiple] { min-height: 120px; background-image: none; padding-right: 11px; }
.field textarea { min-height: 76px; resize: vertical; }
.field .help { font-size: 11px; color: #55647a; }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); padding-top: 20px; cursor: pointer; }
.check input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent); cursor: pointer; }
.repeater-row {
  position: relative;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 14px;
  padding: 14px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 11px; background: rgba(148, 163, 184, 0.03);
}
.repeater-row .remove { position: absolute; top: 8px; right: 8px; }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  padding: 11px 14px; text-align: left; white-space: nowrap;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border); background: var(--surface);
}
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background 160ms ease; }
table.data tbody tr:hover { background: rgba(59, 130, 246, 0.05); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.mono, table.data td .mono { font-variant-numeric: tabular-nums; }
table.data td.muted { color: var(--muted); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tfoot td { padding: 12px 14px; border-top: 1px solid var(--border-strong); font-weight: 600; white-space: nowrap; }
table.data tfoot td.label { color: var(--muted); font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* ----------------------------------------------------------- roster grid */
.filter-bar { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .field { min-width: 145px; }
.roster-wrap {
  overflow: auto; max-height: 66vh;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--glow);
}
table.roster { border-collapse: separate; border-spacing: 0; }
table.roster th, table.roster td {
  padding: 7px 9px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  white-space: nowrap; vertical-align: top;
}
table.roster thead th {
  position: sticky; top: 0; z-index: 3; background: #0d1424; text-align: left;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
}
table.roster thead th .dow { color: var(--light); }
table.roster thead th.today-col { color: var(--accent-2); box-shadow: inset 0 -2px 0 var(--accent); }
table.roster .col-a, table.roster .col-b { position: sticky; z-index: 2; background: var(--surface); }
table.roster .col-a { left: 0; min-width: 172px; max-width: 172px; }
table.roster .col-b { left: 172px; min-width: 152px; max-width: 152px; }
table.roster thead .col-a, table.roster thead .col-b { z-index: 4; background: #0d1424; }
table.roster tbody tr:hover .col-a, table.roster tbody tr:hover .col-b { background: #141d30; }
table.roster td.day { min-width: 146px; }
table.roster td.day.today-col { background: rgba(26, 115, 232, 0.05); }
table.roster td.weekend { background: rgba(148, 163, 184, 0.03); }
.row-label { font-size: 12.5px; font-weight: 500; white-space: normal; }
.row-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: normal; }

.shift-chip {
  display: block; width: 100%; text-align: left;
  padding: 6px 8px; margin-bottom: 4px; border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.3); background: rgba(26, 115, 232, 0.1);
  color: var(--light); font-size: 11.5px;
  transition: background 160ms ease, box-shadow 160ms ease;
}
.shift-chip:hover { background: rgba(26, 115, 232, 0.18); box-shadow: var(--glow); }
.shift-chip .who { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 128px; }
.shift-chip .when { color: var(--muted); font-variant-numeric: tabular-nums; }
.shift-chip.unconfirmed { border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.09); }
.shift-chip.unconfirmed .when { color: var(--amber); }
.shift-chip.unpaid { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.06); }
.shift-chip .live { color: var(--accent-2); font-weight: 600; }
.cell-add {
  width: 100%; padding: 5px; border-radius: 8px;
  border: 1px dashed var(--border-strong); background: transparent; color: #4b5a70;
  font-size: 11px; display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all 160ms ease;
}
.cell-add svg { width: 12px; height: 12px; }
.cell-add:hover { color: var(--accent-2); border-color: rgba(59, 130, 246, 0.5); background: rgba(26, 115, 232, 0.08); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; border: 1px solid; }

/* day-strip used by the mobile roster */
.day-strip { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.day-strip::-webkit-scrollbar { display: none; }
.day-pill {
  flex: 0 0 auto; min-width: 62px; padding: 8px 10px; border-radius: 11px; text-align: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  transition: all 180ms ease;
}
.day-pill .d { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.day-pill .n { font-family: var(--font-head); font-size: 15px; margin-top: 3px; color: var(--light); }
.day-pill.active { border-color: rgba(59, 130, 246, 0.4); background: rgba(26, 115, 232, 0.12); box-shadow: var(--glow); }
.day-pill.active .n, .day-pill.active .d { color: var(--accent-2); }
.day-pill .cnt { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* --------------------------------------------------------- misc utilities */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.detail-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--muted); min-width: 148px; }
.detail-row .v { font-weight: 500; word-break: break-word; }
.side-actions { display: flex; flex-direction: column; gap: 8px; }
.side-actions .btn { width: 100%; justify-content: flex-start; }
.lookup-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.lookup-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.lookup-item:last-child { border-bottom: none; }
.lookup-item .name { flex: 1; }
.matrix td.center, .matrix th.center { text-align: center; }
.matrix input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.note { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 12px; color: #55647a; }
.note svg { width: 14px; height: 14px; flex-shrink: 0; }

/* --------------------------------------------- expandable report sheets */
.sheet { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-bottom: 8px; overflow: hidden; }
.sheet-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 46px;
  background: none; border: none; color: var(--light); text-align: left;
  font-size: 13px; transition: background 160ms ease;
}
.sheet-head:hover { background: rgba(59, 130, 246, 0.06); }
.sheet-head .chev { width: 13px; height: 13px; flex-shrink: 0; color: var(--muted); transition: transform 200ms ease; }
.sheet-head.open { background: rgba(26, 115, 232, 0.08); }
.sheet-head.open .chev { transform: rotate(90deg); color: var(--accent-2); }
.sheet-head .s-date { font-weight: 600; min-width: 150px; }
.sheet-head .s-meta { color: var(--muted); font-size: 12px; flex: 1; font-variant-numeric: tabular-nums; }
.sheet-head .s-amt { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent-2); }
.sheet-body { border-top: 1px solid var(--border); }
.sheet-body table.data tbody tr:hover { background: rgba(59, 130, 246, 0.04); }
@media (max-width: 767px) {
  .sheet-head { flex-wrap: wrap; gap: 6px 10px; }
  .sheet-head .s-date { min-width: 0; flex: 1 1 auto; }
  .sheet-head .s-meta { flex: 1 1 100%; }
  .sheet-body { padding: 4px 8px 8px; }
}

/* invoice / report paper block */
.paper { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.paper-top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.paper-title { font-family: var(--font-head); font-size: 17px; letter-spacing: 0.04em; }
.paper-meta { font-size: 12px; color: var(--muted); line-height: 1.9; }
.paper-meta b { color: var(--light); font-weight: 500; }
.paper-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 18px 0; }
@media (max-width: 640px) { .paper-cols { grid-template-columns: 1fr; } }
.totals-box { margin-left: auto; max-width: 340px; width: 100%; margin-top: 16px; }
.totals-box .row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.totals-box .row:last-child { border-bottom: none; }
.totals-box .row.grand {
  margin-top: 6px; padding: 12px; border-radius: 10px;
  background: rgba(26, 115, 232, 0.12); border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: var(--glow); font-size: 15px; font-weight: 600; color: var(--accent-2);
}
.totals-box .row .k { color: var(--muted); }

/* client blocks in the income report */
.income-client { margin-bottom: 14px; }
.income-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.income-head .nm { font-size: 14px; font-weight: 600; flex: 1; min-width: 140px; }
.income-head .fig { font-variant-numeric: tabular-nums; font-size: 13px; }
.income-head .fig b { color: var(--accent-2); }

@media print {
  .sidebar, .sidebar-spacer, .topbar, .toolbar, .filter-bar, .subtabs, .note, .no-print, .toast-stack { display: none !important; }
  body, .content, .paper, .card, .sheet, .sheet-body { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .paper, .card, .sheet { border-color: #ccc !important; }
  table.data thead th { background: #f2f2f2 !important; color: #000 !important; border-color: #ccc !important; }
  table.data tbody td, table.data tfoot td, .detail-row, .totals-box .row { border-color: #ddd !important; color: #000 !important; }
  .paper-title, .card-title, .row-label, .sheet-head .s-amt, .totals-box .row.grand { color: #000 !important; }
  .totals-box .row.grand { background: #f2f2f2 !important; border-color: #999 !important; }
  .badge { border-color: #999 !important; color: #000 !important; background: transparent !important; }
  .content { padding: 0 !important; }
  a[href]::after { content: none !important; }
}

.toast-stack { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 36px); }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 15px; border-radius: 10px;
  background: var(--surface); border: 1px solid rgba(59, 130, 246, 0.35);
  box-shadow: var(--glow-strong); font-size: 13px;
  animation: slide-in 200ms ease;
}
.toast.err { border-color: rgba(239, 68, 68, 0.4); }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--accent-2); }
.toast.err svg { color: #F87171; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.loader { padding: 46px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 22px; height: 22px; margin: 0 auto 12px;
  border: 2px solid rgba(148, 163, 184, 0.25); border-top-color: var(--accent-2);
  border-radius: 50%; animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Responsive — tablet
   ============================================================ */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .lookup-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: 24px 0 60px rgba(0,0,0,.5); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-spacer { display: none; }
  .hamburger { display: inline-flex; }
  .topbar-row, .tabbar, .content { padding-left: 14px; padding-right: 14px; }
}

/* ============================================================
   Responsive — phone. Tables collapse into cards.
   ============================================================ */
@media (max-width: 767px) {
  body { font-size: 14px; }
  .content { padding: 14px 12px 34px; }
  .topbar-row { padding: 10px 12px; gap: 8px; }
  .tabbar { padding: 0 6px; }
  .tab { padding: 11px 12px; font-size: 12.5px; }
  .page-title { font-size: 13px; }
  .crumb { display: none; }
  .topbar-actions .search { display: none; }
  .sidebar { width: min(84vw, 300px); }

  .kpi-row { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 17px; }
  .kpi .m { display: none; }

  .form-grid { grid-template-columns: 1fr; gap: 13px; }
  .span-2 { grid-column: span 1; }
  .repeater-row { grid-template-columns: 1fr; padding: 13px; }
  .check { padding-top: 4px; }
  .card-foot .btn, .toolbar > .btn { flex: 1 1 auto; }
  .search { max-width: none; }

  /* table -> card list */
  .table-wrap { overflow: visible; }
  table.data { display: block; }
  table.data thead { display: none; }
  table.data tbody { display: block; }
  table.data tbody tr {
    display: block; margin: 0 0 10px;
    border: 1px solid var(--border); border-radius: 12px; background: rgba(148, 163, 184, 0.03);
    padding: 4px 0;
  }
  table.data tbody tr:hover { background: rgba(59, 130, 246, 0.05); }
  table.data tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 8px 13px; border-bottom: none; text-align: right; white-space: normal;
  }
  table.data tbody td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    text-align: left;
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted);
  }
  table.data tbody td.num { text-align: right; }
  table.data tbody td[data-label=""]::before, table.data tbody td.cell-actions::before { content: none; }
  table.data tbody td.cell-actions { justify-content: flex-start; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 4px; }
  table.data tbody td.cell-primary {
    font-size: 14px; font-weight: 600; padding-top: 11px;
  }
  table.data tbody td.cell-primary::before { color: #55647a; }
  table.data tfoot { display: block; border-top: 1px solid var(--border-strong); }
  table.data tfoot tr { display: block; padding: 6px 0; }
  table.data tfoot td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 13px; border: none; }
  table.data tfoot td::before { content: attr(data-label); color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.06em; }
  table.data tfoot td.label { display: none; }

  .roster-wrap { max-height: none; }
  .detail-row { flex-direction: column; gap: 3px; }
  .detail-row .k { min-width: 0; font-size: 11.5px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; }
  .toast { width: 100%; }
  .filter-bar .field { min-width: 0; flex: 1 1 130px; }
  .subtab { flex: 0 0 auto; }
  .subtabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
  .subtabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .card-head { padding: 12px 13px; }
  .card-body { padding: 13px; }
  .card-foot { padding: 12px 13px; }
}

/* ------------------------------------------------------------ sign-in gate */
/* The whole app is hidden until a session exists; the gate sits above it. */
body.locked .shell { display: none; }
body.locked .toast-stack { z-index: 210; }
.auth-gate {
  display: none; position: fixed; inset: 0; z-index: 200;
  background:
    radial-gradient(900px 480px at 18% -10%, rgba(26, 115, 232, 0.16), transparent 60%),
    radial-gradient(700px 420px at 96% 106%, rgba(59, 130, 246, 0.12), transparent 62%),
    var(--canvas);
  overflow: auto; padding: 24px;
}
body.locked .auth-gate { display: flex; align-items: center; justify-content: center; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), var(--glow);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 40px; height: 40px; flex-shrink: 0; }
.auth-brand .brand-mark svg { width: 21px; height: 21px; }
.auth-title { font-family: var(--font-head); font-size: 15px; letter-spacing: 0.06em; }
.auth-sub { font-size: 11.5px; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }
.auth-lead { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-msg {
  display: none; font-size: 12.5px; padding: 10px 12px; border-radius: 10px; margin-bottom: 16px;
  border: 1px solid rgba(239, 68, 68, 0.28); background: rgba(239, 68, 68, 0.1); color: #FCA5A5;
}
.auth-msg.show { display: block; }
.auth-msg.info { border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.1); color: #FCD34D; }
.auth-foot { margin-top: 18px; font-size: 11.5px; color: var(--muted); line-height: 1.6; }

/* idle warning bar */
.idle-bar {
  display: none; position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 190;
  align-items: center; gap: 12px; padding: 11px 16px; border-radius: 12px;
  background: var(--surface); border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); font-size: 12.5px;
}
.idle-bar.show { display: flex; }
.idle-bar .count { font-variant-numeric: tabular-nums; font-weight: 600; color: #FCD34D; }
@media (max-width: 640px) { .idle-bar { left: 12px; right: 12px; transform: none; } }

/* ------------------------------------------------------------ brand logo */
/* The badge artwork sits on a black square, so it is always clipped to a
   circle — that matches the emblem's outer ring and hides the corners. */
.logo-img {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #000;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.22), var(--glow);
}
.topbar-logo { width: 34px; height: 34px; }
.topbar-logo:hover { box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5), var(--glow-strong); }
.auth-logo { width: 62px; height: 62px; }
@media (max-width: 767px) {
  .topbar-logo { width: 30px; height: 30px; }
  .auth-logo { width: 54px; height: 54px; }
}
@media print { .topbar-logo { display: none; } }
.sidebar-logo { width: 34px; height: 34px; }
