/* Layout: corporate-services ticket ledger — header + SLA tally strip, filter bar, wide ledger (cards on phones), side drawer for ticket + SLA table */
:root {
  --bg: #f3f5f7; --surface: #ffffff; --sunk: #e9edf1; --line: #d6dde4; --fg: #17212b; --muted: #5b6874;
  --accent: #23628f; --accent-ink: #ffffff; --accent-soft: #dfeaf3; --cream: #fff6e0;
  --ok: #1f7a4d; --ok-soft: #dcf0e5; --warn: #9a5b00; --warn-soft: #fbecd2; --bad: #b3261e; --bad-soft: #fbe0de;
  --shadow: 0 10px 40px rgba(20,35,50,.18);
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root {
  --bg: #11171d; --surface: #182029; --sunk: #1f2933; --line: #2c3946; --fg: #e4eaf0; --muted: #94a3b1;
  --accent: #6fb0e0; --accent-ink: #0c1620; --accent-soft: #1c3346; --cream: #2a2618;
  --ok: #6fd19c; --ok-soft: #173426; --warn: #f0b860; --warn-soft: #3a2b12; --bad: #f38b83; --bad-soft: #3d1a18;
  --shadow: 0 10px 40px rgba(0,0,0,.5); color-scheme: dark; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14px; line-height: 1.5; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.wrap { max-width: 1320px; margin: 0 auto; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: grid; gap: 20px; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap > * { min-width: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.eyebrow { font-family: var(--f-mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-family: var(--f-display); font-weight: 700; font-size: clamp(26px, 4vw, 34px); line-height: 1.1; margin: 4px 0 0; letter-spacing: -.01em; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.me { color: var(--muted); font-size: 12.5px; margin-right: 4px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger.confirm { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }

/* sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 26px; }
.auth-card p { margin: 0; color: var(--muted); }

.tally { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.tally > * { padding: 14px 18px; border-right: 1px solid var(--line); display: grid; gap: 2px; }
.tally > *:last-child { border-right: 0; }
.tally button { all: unset; cursor: pointer; padding: 14px 18px; border-right: 1px solid var(--line); display: grid; gap: 2px; }
.tally button:hover { background: var(--sunk); }
.tally button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tally button[aria-pressed="true"] { background: var(--accent-soft); }
.tally .n { font-family: var(--f-display); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tally .l { font-size: 12.5px; color: var(--muted); }
.tally .n.bad { color: var(--bad); } .tally .n.ok { color: var(--ok); }
@media (max-width: 760px) { .tally { grid-template-columns: repeat(2, minmax(0,1fr)); } .tally > * { border-bottom: 1px solid var(--line); } .tally > *:nth-child(2n) { border-right: 0; } .tally > *:last-child { grid-column: 1 / -1; border-bottom: 0; } }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { flex: 1 1 220px; min-width: 0; }
.field { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.filters .count { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.ledger { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow-x: auto; }
table.main { width: 100%; border-collapse: collapse; min-width: 1240px; }
th { text-align: left; font-family: var(--f-mono); font-weight: 500; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px; border-bottom: 1px solid var(--line); background: var(--sunk); white-space: nowrap; }
th.calc { color: var(--accent); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.main tbody tr { cursor: pointer; }
table.main tbody tr:hover { background: var(--sunk); }
tbody tr:last-child td { border-bottom: 0; }
tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.ref { font-family: var(--f-mono); font-size: 12px; font-weight: 500; white-space: nowrap; }
.desc { max-width: 260px; }
.sub { color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; font-family: var(--f-mono); font-size: 12px; }
.due-bad { color: var(--bad); font-weight: 600; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.s-Open { background: var(--accent-soft); color: var(--accent); }
.s-Overdue { background: var(--bad-soft); color: var(--bad); }
.s-Closed { background: var(--ok-soft); color: var(--ok); }
.sla-Yes { color: var(--ok); font-weight: 600; } .sla-No { color: var(--bad); font-weight: 600; }
.prio { font-size: 12.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.prio i { width: 8px; height: 8px; border-radius: 2px; background: var(--line); display: inline-block; }
.p-Critical i { background: var(--bad); } .p-High i { background: var(--warn); } .p-Medium i { background: var(--accent); } .p-Low i { background: var(--muted); opacity: .5; }
.p-Critical { color: var(--bad); font-weight: 600; }
.stars { color: var(--warn); letter-spacing: 1px; white-space: nowrap; }
.stars span { color: var(--line); }

.cards { display: none; gap: 10px; }
.card { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; cursor: pointer; text-align: left; width: 100%; }
.card.overdue { box-shadow: inset 3px 0 0 var(--bad); }
.card .row { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
@media (max-width: 760px) { .ledger { display: none; } .cards { display: grid; } }

.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 40px 20px; text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; background: var(--surface); }
.empty h2 { font-family: var(--f-display); font-size: 20px; color: var(--fg); margin: 0; }
.empty p { margin: 0; max-width: 52ch; }
.banner { border-radius: 8px; padding: 10px 14px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }

.scrim { position: fixed; inset: 0; background: rgba(10,18,26,.4); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 21; box-shadow: var(--shadow); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); padding-right: env(safe-area-inset-right, 0px); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--f-display); font-size: 20px; margin: 0; }
.drawer-body { overflow-y: auto; padding: 18px 20px 28px; display: grid; gap: 14px; align-content: start; flex: 1; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.drawer-foot .left { margin-right: auto; }
.x { all: unset; cursor: pointer; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; font-size: 20px; color: var(--muted); }
.x:hover { background: var(--sunk); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .grid2 { grid-template-columns: 1fr; } }
label.f { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; }
label.f .field { font-weight: 400; color: var(--fg); width: 100%; background: var(--cream); }
.inline { display: flex; gap: 6px; } .inline .field { flex: 1; }
textarea.field { resize: vertical; min-height: 76px; }
.err { color: var(--bad); font-size: 13px; min-height: 0; }
.okmsg { color: var(--ok); font-size: 13px; }
.calcbox { background: var(--sunk); border-radius: 8px; padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 16px; }
.calcbox .k { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.calcbox .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.calcbox .cap { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.history { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
.history h3 { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; font-weight: 500; }
#histList { display: grid; gap: 10px; }
.hist-item { font-size: 13px; display: grid; gap: 1px; border-left: 2px solid var(--line); padding-left: 10px; }
.hist-item .meta { color: var(--muted); font-size: 12px; }
.note-row { display: flex; gap: 8px; } .note-row input { flex: 1; min-width: 0; }

.slatab { width: 100%; border-collapse: collapse; }
.slatab th, .slatab td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.slatab input, .slatab select { width: 100%; padding: 6px 8px; }
.slatab td.n input { width: 70px; }
.slawrap { overflow-x: auto; }
.slawrap table { min-width: 480px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px; z-index: 40; font-size: 13px; }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } }
