/* LSA-SCMS — supplemental styles.
   Tailwind covers layout and colour; this file holds what utilities cannot express:
   scrollbars, print rules, table ergonomics and a few state helpers. */

:root { color-scheme: light; }

html, body { height: 100%; }
body { -webkit-font-smoothing: antialiased; }

/* ── Scrollbars ────────────────────────────────────────────────── */
.thin-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }
.thin-scroll::-webkit-scrollbar-thumb { background: rgba(148,163,184,.45); border-radius: 4px; }
.thin-scroll::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.7); }
#sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.28); }

/* ── Enterprise table ergonomics ───────────────────────────────── */
/* min-width:0 is what actually makes the horizontal scroll work. A grid or flex
   child defaults to min-width:auto, so without this the wrapper grows to fit the
   widest row instead of scrolling, and the whole page overflows sideways on a
   narrow screen. The same reset is needed on the grid children that hold them. */
.dt-wrap { overflow-x: auto; min-width: 0; }
#view .grid > *, #view [class*="col-span"] { min-width: 0; }
.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8125rem; }
.dt thead th {
  position: sticky; top: 0; z-index: 1;
  background: #f8fafc; color: #475569;
  font-weight: 600; text-align: left; white-space: nowrap;
  padding: 0.5rem 0.75rem; border-bottom: 1px solid #e2e8f0;
  font-size: 0.6875rem; letter-spacing: .04em; text-transform: uppercase;
}
.dt thead th.sortable { cursor: pointer; user-select: none; }
.dt thead th.sortable:hover { background: #f1f5f9; color: #1e293b; }
.dt tbody td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.dt tbody tr:hover { background: #f8fafc; }
.dt tbody tr.row-click { cursor: pointer; }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dt .nowrap { white-space: nowrap; }

/* Numeric alignment anywhere */
.tnum { font-variant-numeric: tabular-nums; }

/* ── Forms ─────────────────────────────────────────────────────── */
.fld {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 0.375rem;
  padding: 0.4375rem 0.625rem; font-size: 0.8125rem; background: #fff; color: #0f172a;
  transition: border-color .12s, box-shadow .12s;
}
.fld:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.fld:disabled, .fld[readonly] { background: #f8fafc; color: #64748b; cursor: not-allowed; }
.fld.invalid { border-color: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.10); }
select.fld { appearance: none; background-image:
  url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3e%3cpath d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right .5rem center; background-size: 1rem; padding-right: 2rem; }
textarea.fld { min-height: 4.5rem; resize: vertical; }
.lbl { display:block; font-size: 0.75rem; font-weight: 600; color: #334155; margin-bottom: .25rem; }
.lbl .req { color: #dc2626; margin-left: .125rem; }
.hint { font-size: 0.6875rem; color: #64748b; margin-top: .25rem; }
.err { font-size: 0.6875rem; color: #b91c1c; margin-top: .25rem; display: none; }
.err.show { display: block; }

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display:inline-flex; align-items:center; gap:.375rem; justify-content:center;
  border-radius: .375rem; font-size: .8125rem; font-weight: 500;
  padding: .4375rem .75rem; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background:#2563eb; color:#fff; }
.btn-primary:not(:disabled):hover { background:#1d4ed8; }
.btn-default { background:#fff; color:#334155; border-color:#cbd5e1; }
.btn-default:not(:disabled):hover { background:#f8fafc; border-color:#94a3b8; }
.btn-ghost { background:transparent; color:#475569; }
.btn-ghost:not(:disabled):hover { background:#f1f5f9; color:#0f172a; }
.btn-ok { background:#059669; color:#fff; }
.btn-ok:not(:disabled):hover { background:#047857; }
.btn-warn { background:#d97706; color:#fff; }
.btn-warn:not(:disabled):hover { background:#b45309; }
.btn-bad { background:#dc2626; color:#fff; }
.btn-bad:not(:disabled):hover { background:#b91c1c; }
/* min-height keeps the compact variants on the 24px WCAG 2.2 target minimum
   without making the dense row actions look oversized. */
.btn-sm { padding: .25rem .5rem; font-size: .75rem; min-height: 1.75rem; }
.btn-xs { padding: .125rem .375rem; font-size: .6875rem; min-height: 1.5rem; }
.btn .lucide { width: 1rem; height: 1rem; }
.btn-sm .lucide, .btn-xs .lucide { width: .875rem; height: .875rem; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display:inline-flex; align-items:center; gap:.25rem;
  padding: .0625rem .4375rem; border-radius: .25rem;
  font-size: .6875rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.badge-neutral { background:#f1f5f9; color:#475569; border-color:#e2e8f0; }
.badge-info    { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.badge-ok      { background:#ecfdf5; color:#047857; border-color:#a7f3d0; }
.badge-warn    { background:#fffbeb; color:#b45309; border-color:#fde68a; }
.badge-bad     { background:#fef2f2; color:#b91c1c; border-color:#fecaca; }

/* ── Cards ─────────────────────────────────────────────────────── */
/* Panels sit flat on the workspace and are separated by a hairline, not a shadow.
   Elevation is reserved for things that genuinely float above the page — modals,
   dropdowns, toasts — so depth stays meaningful instead of decorative. */
.card { background:#fff; border:1px solid #e2e8f0; border-radius:.375rem; }
.card-head { padding:.75rem 1rem; border-bottom:1px solid #e2e8f0; display:flex; align-items:center; justify-content:space-between; gap:.75rem; flex-wrap:wrap; }
.card-title { font-size:.875rem; font-weight:600; color:#0f172a; }
.card-body { padding:1rem; }
.card-float { box-shadow:0 4px 12px rgba(16,24,40,.10), 0 1px 3px rgba(16,24,40,.08); }

/* ── Sign-in panel ─────────────────────────────────────────────── */
/* The backdrop is drawn here rather than loaded, so the sign-in screen has no
   external dependency and works offline from a plain folder. The motif is warehouse
   racking — uprights, beams, and a scattering of occupied slots — which is what this
   system actually manages, kept far enough back that it never competes with the type. */
.login-panel {
  position: relative;
  background-color: #111c34;
  background-image:
    radial-gradient(120% 90% at 12% 8%, rgba(37,99,235,.20) 0%, rgba(37,99,235,0) 55%),
    radial-gradient(90% 70% at 92% 96%, rgba(5,150,105,.13) 0%, rgba(5,150,105,0) 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.055' stroke-width='1'%3E%3Cpath d='M0 .5h120M0 40.5h120M0 80.5h120'/%3E%3Cpath d='M.5 0v120M60.5 0v120'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.032'%3E%3Crect x='6' y='46' width='22' height='28' rx='1'/%3E%3Crect x='32' y='52' width='22' height='22' rx='1'/%3E%3Crect x='66' y='8' width='22' height='26' rx='1'/%3E%3Crect x='92' y='14' width='20' height='20' rx='1'/%3E%3Crect x='66' y='88' width='22' height='24' rx='1'/%3E%3Crect x='8' y='90' width='20' height='22' rx='1'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat, repeat;
}
/* A hairline of light down the seam, so the panel meets the form like a real edge. */
.login-panel::after {
  content: ''; position: absolute; inset-block: 0; right: 0; width: 1px;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.14) 45%, rgba(255,255,255,0) 100%);
}

/* ── Metric ledger ─────────────────────────────────────────────── */
/* The figures a supervisor reads down, grouped by the part of the business they
   belong to. One bordered block with hairline cell dividers reads as a ledger;
   sixteen separate floating tiles read as a brochure. */
.ledger { background:#fff; border:1px solid #e2e8f0; border-radius:.375rem; overflow:hidden; }
.ledger-group + .ledger-group { border-top:1px solid #e2e8f0; }
.ledger-label {
  padding:.4375rem 1rem; background:#f8fafc; border-bottom:1px solid #eef2f7;
  font-size:.625rem; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:#64748b;
}
.ledger-cells { display:grid; }
.ledger-cell { padding:.625rem 1rem; border-left:1px solid #eef2f7; min-width:0; }
.ledger-cell:first-child { border-left:0; }
.ledger-cell.is-link { cursor:pointer; }
.ledger-cell.is-link:hover { background:#f8fafc; }
.ledger-term { font-size:.6875rem; color:#64748b; line-height:1.3; }
.ledger-figure {
  margin-top:.1875rem; font-size:1.0625rem; font-weight:600; color:#0f172a;
  font-variant-numeric: tabular-nums; letter-spacing:-.01em; line-height:1.2;
}
.ledger-note { margin-top:.0625rem; font-size:.625rem; color:#94a3b8; line-height:1.3; }
.ledger-figure.t-ok  { color:#047857; }
.ledger-figure.t-warn{ color:#b45309; }
.ledger-figure.t-bad { color:#b91c1c; }

/* ── Exception band ────────────────────────────────────────────── */
/* Only renders what is actually wrong, so the shape of the screen tells you
   whether anything needs doing before you have read a single number. */
.exceptions { border:1px solid #e2e8f0; border-radius:.375rem; overflow:hidden; background:#fff; }
.exception {
  display:flex; align-items:flex-start; gap:.625rem; padding:.5625rem 1rem;
  border-top:1px solid #f1f5f9; font-size:.8125rem; color:#334155; text-decoration:none;
}
.exception:first-of-type { border-top:0; }
.exception:hover { background:#f8fafc; }
.exception .lucide { width:1rem; height:1rem; flex:none; margin-top:.0625rem; }
.exception-count { font-variant-numeric: tabular-nums; font-weight:600; color:#0f172a; }
.exception-go { margin-left:auto; flex:none; color:#94a3b8; }
.exception:hover .exception-go { color:#2563eb; }
.ex-bad  .lucide { color:#dc2626; }
.ex-warn .lucide { color:#d97706; }
.ex-info .lucide { color:#2563eb; }
.exceptions-clear { display:flex; align-items:center; gap:.5rem; padding:.625rem 1rem; font-size:.8125rem; color:#475569; }
.exceptions-clear .lucide { width:1rem; height:1rem; color:#059669; flex:none; }

/* ── Sidebar nav ───────────────────────────────────────────────── */
.nav-item {
  display:flex; align-items:center; gap:.625rem; padding:.5rem .625rem;
  border-radius:.375rem; font-size:.8125rem; color:#cbd5e1; cursor:pointer;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { background:#1a2942; color:#fff; }
.nav-item.active { background:#2563eb; color:#fff; font-weight:500; }
.nav-item .lucide { width:1.125rem; height:1.125rem; flex:none; }
.nav-item .nav-label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-count { font-size:.625rem; font-weight:700; padding:.0625rem .3125rem; border-radius:.625rem; background:#dc2626; color:#fff; }

/* Collapsed sidebar */
body.nav-collapsed #sidebar { width: 4rem; }
body.nav-collapsed #shell  { padding-left: 4rem; }
body.nav-collapsed .nav-label,
body.nav-collapsed .nav-section-title,
body.nav-collapsed .brand-text,
body.nav-collapsed .nav-count { display:none; }
body.nav-collapsed .nav-item { justify-content:center; padding-inline:.5rem; }
@media (max-width: 1023px) {
  body.nav-collapsed #shell { padding-left: 0; }
  body.nav-collapsed #sidebar { width: 16rem; }
  body.nav-collapsed .nav-label, body.nav-collapsed .brand-text,
  body.nav-collapsed .nav-section-title, body.nav-collapsed .nav-count { display:revert; }
  body.nav-collapsed .nav-item { justify-content:flex-start; padding-inline:.625rem; }
}

/* ── Stepper / progress ────────────────────────────────────────── */
.step-dot { width:1.5rem; height:1.5rem; border-radius:9999px; display:flex; align-items:center; justify-content:center;
            font-size:.6875rem; font-weight:700; flex:none; }
.step-done    { background:#059669; color:#fff; }
.step-current { background:#2563eb; color:#fff; box-shadow:0 0 0 3px rgba(37,99,235,.18); }
.step-todo    { background:#e2e8f0; color:#64748b; }

/* ── Modal ─────────────────────────────────────────────────────── */
/* Genuinely floating, so this is where elevation is spent. */
#modal-root .modal-panel {
  max-height: calc(100vh - 3rem);
  box-shadow: 0 20px 40px rgba(15,23,42,.18), 0 2px 8px rgba(15,23,42,.10);
}
#toast-root > * { box-shadow: 0 6px 18px rgba(15,23,42,.14); }

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  body { background:#fff !important; }
  #sidebar, #topbar, #pagehead, #appfoot, #toast-root, #modal-root, #sidebar-scrim,
  .no-print { display:none !important; }
  #shell { padding-left:0 !important; }
  #view { padding:0 !important; }
  #print-root { display:block !important; }
  #print-root.hidden { display:block !important; }
  body.printing #view { display:none !important; }
  .card { border:1px solid #cbd5e1 !important; box-shadow:none !important; break-inside: avoid; }
  .dt thead th { background:#f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page-break { break-after: page; }
  @page { margin: 12mm; }
}

/* Document (printable) sheet styling */
.doc-sheet { background:#fff; color:#0f172a; font-size:.8125rem; }
.doc-sheet h1 { font-size:1.25rem; font-weight:700; }
.doc-sheet table { width:100%; border-collapse:collapse; }
.doc-sheet th { background:#f1f5f9; text-align:left; font-size:.6875rem; text-transform:uppercase;
                letter-spacing:.04em; padding:.375rem .5rem; border:1px solid #cbd5e1; }
.doc-sheet td { padding:.375rem .5rem; border:1px solid #e2e8f0; }

/* ── Misc ──────────────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg,#f1f5f9 25%,#e2e8f0 37%,#f1f5f9 63%); background-size:400% 100%; }
[data-tip] { position: relative; }
.truncate-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.tabs { display:flex; gap:.125rem; border-bottom:1px solid #e2e8f0; overflow-x:auto; }
.tab { padding:.5rem .75rem; font-size:.8125rem; color:#64748b; border-bottom:2px solid transparent;
       cursor:pointer; white-space:nowrap; margin-bottom:-1px; }
.tab:hover { color:#0f172a; }
.tab.active { color:#2563eb; border-bottom-color:#2563eb; font-weight:600; }
