/* Ratguard Ops – "dispatch desk" look.
   Paper = cool label stock. Ink = slate. Colour only means something: red late/critical,
   amber act soon, green done/primary. Numbers are set in condensed Archivo like a shipping label. */
@font-face {
  font-family: "Archivo"; src: url(/assets/fonts/archivo.woff2) format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
}
:root {
  --paper: #eef1f4; --surface: #ffffff; --ink: #1b2430; --ink-2: #5b6675; --ink-3: #8a94a3; --rule: #d5dbe2; --wash: #f5f7f9;
  --red: #d7263d; --red-wash: #fdecee; --amber: #c87a00; --amber-wash: #fff4de; --green: #1f8a4c; --green-wash: #e6f4ec; --blue: #2c5fa8;
  --bar-1: #1b2430; --bar-2: #47607e; --bar-3: #7f93ab; --bar-4: #aebccc; --bar-5: #cfd7e1;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-s: 6px; --r-m: 10px;
}
:root[data-theme="dark"] {
  --paper: #12171e; --surface: #1a212b; --ink: #e6eaf0; --ink-2: #a3adbb; --ink-3: #6f7a89; --rule: #2a3340; --wash: #202834;
  --red: #ff5a6a; --red-wash: #3a1d23; --amber: #f0a52a; --amber-wash: #3a2c14; --green: #3fbf74; --green-wash: #173826; --blue: #7aa7e8;
  --bar-1: #e6eaf0; --bar-2: #a9bbd1; --bar-3: #7487a0; --bar-4: #4d5d72; --bar-5: #36424f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12171e; --surface: #1a212b; --ink: #e6eaf0; --ink-2: #a3adbb; --ink-3: #6f7a89; --rule: #2a3340; --wash: #202834;
    --red: #ff5a6a; --red-wash: #3a1d23; --amber: #f0a52a; --amber-wash: #3a2c14; --green: #3fbf74; --green-wash: #173826; --blue: #7aa7e8;
    --bar-1: #e6eaf0; --bar-2: #a9bbd1; --bar-3: #7487a0; --bar-4: #4d5d72; --bar-5: #36424f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.5 var(--font); font-stretch: 100%; -webkit-text-size-adjust: 100%; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  padding-top: max(10px, env(safe-area-inset-top)); background: var(--paper); border-bottom: 1px solid var(--rule); }
.mark { width: 34px; height: 34px; border-radius: var(--r-s); background: var(--ink); color: var(--paper); display: grid; place-items: center;
  font-weight: 800; font-stretch: 75%; font-size: 15px; letter-spacing: .5px; flex: none; }
.bar-title { min-width: 0; flex: 1; }
.bar-title h1 { margin: 0; font-size: 18px; font-weight: 750; font-stretch: 85%; line-height: 1.15; }
.bar-title p { margin: 0; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-tools { display: flex; align-items: center; gap: 6px; }
.updated { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-right: 4px; }
.tool { width: 36px; height: 36px; border-radius: var(--r-s); border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; }
.tool:hover { border-color: var(--ink-3); }

.banners { display: grid; gap: 1px; }
.banner { background: var(--red); color: #fff; padding: 10px 20px; font-weight: 650; }
.banner small { font-weight: 400; opacity: .9; margin-left: 8px; }

/* ---------- desk layout ---------- */
.desk { max-width: 1240px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; align-items: start; }
@media (max-width: 980px) { .desk { grid-template-columns: 1fr; gap: 24px; padding: 14px; } }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
h2 { margin: 0; font-size: 22px; font-weight: 800; font-stretch: 80%; letter-spacing: -.2px; }
.strip { margin: 0; font-size: 14px; color: var(--ink-2); }
.strip b { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.strip .late { color: var(--red); } .strip .soon { color: var(--amber); }
.source { margin: 10px 0 0; font-size: 12px; color: var(--ink-3); }

/* ---------- tickets (problems) ---------- */
.ticket-list { display: grid; gap: 10px; }
.ticket { display: grid; grid-template-columns: minmax(0, 1fr) 112px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); overflow: hidden; }
.ticket.critical { border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); }
.t-main { padding: 12px 14px 12px 16px; border-left: 5px solid var(--amber); min-width: 0; }
.ticket.critical .t-main { border-left-color: var(--red); }
.ticket.claimed .t-main { border-left-color: var(--ink-3); }
.t-title { margin: 0; font-size: 15.5px; font-weight: 700; line-height: 1.3; cursor: pointer; }
.t-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.t-detail { margin: 3px 0 0; color: var(--ink-2); font-size: 13.5px; }
.t-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.t-facts b { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.t-facts .order { color: var(--blue); cursor: pointer; font-weight: 650; background: none; border: 0; padding: 0; font: inherit; font-weight: 650; }
.t-facts .order:hover { text-decoration: underline; }
.t-owner { margin-top: 6px; font-size: 12.5px; color: var(--ink-2); }
.t-owner .taken { color: var(--green); font-weight: 650; }
.t-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
/* the deadline stub, torn off along a perforation */
.t-stub { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 10px 8px;
  background: var(--wash); border-left: 2px dashed var(--rule); }
.t-stub::before, .t-stub::after { content: ""; position: absolute; left: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); border: 1px solid var(--rule); }
.t-stub::before { top: -9px; } .t-stub::after { bottom: -9px; }
.t-stub .when { font-size: 30px; font-weight: 800; font-stretch: 70%; line-height: 1; font-variant-numeric: tabular-nums; }
.t-stub .what { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; line-height: 1.2; }
.t-stub.late { background: var(--red-wash); } .t-stub.late .when, .t-stub.late .what { color: var(--red); }
.t-stub.soon { background: var(--amber-wash); } .t-stub.soon .when { color: var(--amber); }
@media (max-width: 420px) { .ticket { grid-template-columns: minmax(0, 1fr) 88px; } .t-stub .when { font-size: 24px; } }

.btn { border: 1px solid var(--rule); background: var(--surface); color: var(--ink); border-radius: var(--r-s); padding: 7px 14px; min-height: 38px;
  font: 600 14px/1 var(--font); cursor: pointer; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.go { background: var(--green); border-color: var(--green); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { color: var(--ink); border-color: var(--rule); }
.btn.small { min-height: 34px; padding: 6px 12px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: progress; }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--r-m); }
.empty.calm { border-style: solid; }
.empty b { display: block; color: var(--green); font-size: 16px; margin-bottom: 2px; }

/* ---------- order line (pipeline) ---------- */
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); overflow: hidden; }
.stage { padding: 14px 12px 12px; border-left: 1px solid var(--rule); position: relative; min-width: 0; }
.stage:first-child { border-left: 0; }
.stage:not(:last-child)::after { content: ""; position: absolute; top: 26px; right: -7px; width: 12px; height: 12px; background: var(--surface);
  border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); transform: rotate(45deg); z-index: 1; }
.stage-top { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.stage-top:disabled { cursor: default; }
.stage-n { display: block; font-size: 44px; font-weight: 800; font-stretch: 68%; line-height: .95; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stage-n.zero { color: var(--ink-3); }
.stage-l { display: block; font-size: 13px; font-weight: 650; color: var(--ink-2); margin-top: 4px; }
.lanes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 7px; }
.lane { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; cursor: pointer; border-radius: 4px; padding: 2px 3px; margin: 0 -3px; }
.lane:hover { background: var(--wash); }
.lane .name { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane .n { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lane .track { display: block; grid-column: 1 / -1; height: 5px; background: var(--wash); border-radius: 3px; overflow: hidden; }
.lane .fill { display: block; height: 100%; border-radius: 3px; background: var(--bar-2); }
.lane[data-c="SMILE"] .fill { background: var(--bar-1); } .lane[data-c="BDAT"] .fill { background: var(--bar-2); }
.lane[data-c="DLVY"] .fill { background: var(--bar-3); } .lane[data-c="INDPOST"] .fill { background: var(--bar-4); }
.lane[data-c="NONE"] .fill { background: var(--amber); }
.lane.none-left { color: var(--ink-3); font-size: 12px; cursor: default; }
@media (max-width: 760px) {
  .pipeline { grid-template-columns: 1fr; }
  .stage { border-left: 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: start; }
  .stage:first-child { border-top: 0; }
  .stage:not(:last-child)::after { top: auto; bottom: -7px; right: auto; left: 40px; transform: rotate(135deg); }
  .stage-n { font-size: 38px; }
  .lanes { margin-top: 2px; }
}

.find { display: flex; gap: 6px; }
.find input { width: 120px; }
input, select, textarea { font: 400 15px/1.3 var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-s); padding: 8px 10px; min-height: 38px; width: 100%; }
input:focus, select:focus { border-color: var(--blue); outline: none; }
label { display: grid; gap: 5px; font-weight: 650; font-size: 13.5px; margin-bottom: 12px; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(15, 20, 28, .45); display: flex; justify-content: flex-end; }
.sheet-card { width: min(560px, 100%); height: 100%; background: var(--paper); display: flex; flex-direction: column; animation: slide .16s ease-out; }
@keyframes slide { from { transform: translateX(24px); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--rule); background: var(--surface); }
.sheet-head h3 { flex: 1; margin: 0; font-size: 19px; font-weight: 800; font-stretch: 82%; }
.sheet-body { flex: 1; overflow: auto; padding: 16px; }
@media (max-width: 560px) { .sheet { align-items: flex-end; } .sheet-card { height: 94%; border-radius: 14px 14px 0 0; overflow: hidden; } }

.meta { font-size: 12.5px; color: var(--ink-3); margin: 0 0 12px; }
.list { display: grid; gap: 6px; }
.row { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-s); padding: 10px 12px; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; text-align: left; font: inherit; color: inherit; width: 100%; }
.row:hover { border-color: var(--ink-3); }
.row .a { font-weight: 650; } .row .b { color: var(--ink-2); font-size: 13px; }
.row .r { text-align: right; font-variant-numeric: tabular-nums; }
.row .flag { color: var(--red); font-weight: 650; font-size: 12.5px; } .row .flag.amber { color: var(--amber); }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); padding: 14px; margin-bottom: 14px; }
.status-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.status-line .state { font-size: 24px; font-weight: 800; font-stretch: 75%; }
.status-line .since { color: var(--ink-2); font-size: 13px; }
.kv { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; overflow-wrap: anywhere; }
h4 { margin: 18px 0 8px; font-size: 15px; font-weight: 750; font-stretch: 85%; }
.tagbtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tagbtn { text-align: left; border: 1px solid var(--rule); background: var(--surface); color: var(--ink); border-radius: var(--r-s); padding: 8px 10px; font: 600 13.5px/1.25 var(--font); cursor: pointer; min-height: 44px; }
.tagbtn:hover { border-color: var(--ink-3); }
.tagbtn.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tagbtn small { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-2); margin-top: 2px; }
.tagbtn.on small { color: inherit; opacity: .75; }
.syschips { display: flex; flex-wrap: wrap; gap: 6px; }
.syschip { font-size: 12px; padding: 2px 8px; border-radius: 4px; background: var(--wash); color: var(--ink-2); border: 1px solid var(--rule); }
.history { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--rule); display: grid; gap: 10px; }
.history li { font-size: 14px; } .history small { display: block; color: var(--ink-3); }

.toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: var(--r-s); font-weight: 650; max-width: 92vw; }
.toast.err { background: var(--red); color: #fff; }

.skeleton { height: 92px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--rule); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--wash), transparent); animation: sh 1.2s infinite; }
.skeleton.tall { height: 240px; }
@keyframes sh { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- login ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-m); padding: 24px; }
.login-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 800; font-stretch: 80%; }
.login-card p.sub { margin: 0; color: var(--ink-2); font-size: 13px; }
.err { background: var(--red-wash); color: var(--red); padding: 10px 12px; border-radius: var(--r-s); font-weight: 650; }
.hint { color: var(--ink-2); font-size: 13px; margin: 14px 0 0; }

@media (max-width: 560px) {
  .bar { padding-left: 14px; padding-right: 14px; }
  .updated { display: none; }
  h2 { font-size: 20px; }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
}
