/* D&G Alterations
   A ledger, not a dashboard. Paper ground, near-black ink, one serif for the
   shop's own voice, hairline rules, square corners, numbers set tabular.
   Colour is used for meaning only: red for late, green for back, blue for
   out with a tailor. Nothing is decorated. Every control is 44px or taller. */

:root {
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --ink: #1b1a17;
  --ink-2: #44413b;
  --ink-3: #75716a;
  --ink-4: #a6a29a;
  --paper: #f7f5f0;
  --paper-2: #efece5;
  --white: #fffefc;
  --rule: #dcd8cf;
  --rule-2: #c6c1b6;
  --gold: #a9812a;
  --accent: #1f5b6e;
  --accent-wash: #e4eef1;
  --red: #9f2a1e;
  --red-wash: #f8e9e6;
  --green: #2c6a44;
  --green-wash: #e6f0ea;
  --blue: #2f5471;
  --blue-wash: #e6edf3;

  --side-w: 272px;
  --touch: 44px;
  --touch-lg: 52px;
  --r: 2px;
  --shadow: 0 24px 60px rgba(27,26,23,.28), 0 4px 14px rgba(27,26,23,.10);
}

* { box-sizing: border-box; }
/* A hidden element stays hidden whatever layout class it carries. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; width: 100%; overflow: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  grid-template-rows: 100%;
  overflow: hidden;
  font-feature-settings: "tnum" 1, "kern" 1;
}
/* The login page loads this same stylesheet but has no sidebar, so it has to
   opt out of the app's two-column grid. Without this the form is squeezed into
   the 272px sidebar column, pinned to the left edge and clipped. */
body.login {
  display: block;
  overflow: auto;
  padding: 0 20px max(env(safe-area-inset-bottom, 0px), 24px);
}
body.login main { margin: 0 auto; width: 100%; }

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
svg { display: block; flex: none; }
a { color: inherit; }
.spacer { flex: 1 1 auto; }

/* ================================ sidebar ================================ */

.side {
  background: var(--paper);
  border-inline-end: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.side-brand {
  padding: 26px 24px 20px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.side-brand .mark { font-family: var(--serif); font-size: 30px; line-height: 1; letter-spacing: .04em; }
.side-brand .word { font-size: 10px; letter-spacing: .28em; color: var(--ink-3); font-weight: 600; }

.side-actions { padding: 18px 16px 6px; display: grid; gap: 8px; }
.side-btn {
  display: flex; align-items: center; gap: 12px;
  height: 46px; padding: 0 14px;
  border-radius: var(--r);
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: 14.5px; font-weight: 600;
  text-align: start; width: 100%;
}
.side-btn svg { color: var(--ink-3); }
.side-btn:hover { background: var(--white); }
.side-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.side-btn.primary svg { color: #fff; }
.side-btn.primary:hover { background: #17495a; }
.side-btn .kbd { margin-inline-start: auto; font-size: 10.5px; color: var(--ink-4); letter-spacing: .06em; }
.side-btn.primary .kbd { color: rgba(255,255,255,.5); }

.side-section {
  padding: 22px 24px 6px;
  font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
}
.side-overview { flex: 1 1 auto; overflow: auto; padding: 0 16px 10px; }
.who {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 8px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}
.who:hover { background: var(--white); }
.who .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.who .late { font-size: 11.5px; font-weight: 700; color: var(--red); white-space: nowrap; }
.who .n {
  min-width: 34px; text-align: center; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 2px 8px; border-radius: 999px; background: var(--blue-wash); color: var(--blue);
}
.who[data-worker="none"] .n { background: var(--paper-2); color: var(--ink-2); }
.who[data-worker="ready"] .n { background: var(--green-wash); color: var(--green); }
.who[data-worker="all"] .n { background: var(--paper-2); color: var(--ink-3); }
.who.total .n { background: var(--ink); color: var(--paper); }
.who.total { margin-top: 8px; border-top: 1px solid var(--ink); border-bottom: 0; padding-top: 12px; }
.who.total .name { font-weight: 700; }

.side-foot { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--rule); }
.side-foot .side-btn { height: 40px; font-size: 13.5px; border-color: var(--rule-2); color: var(--ink-2); }

/* ================================ main ================================ */

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; background: var(--white); }

.page-head {
  display: flex; align-items: baseline; gap: 14px;
  padding: 22px 28px 12px;
  border-bottom: 1px solid var(--rule);
}
.page-head h1 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: .01em; }
.page-head .count { font-size: 13px; color: var(--ink-3); }

.search {
  margin-inline-start: auto;
  align-self: center;
  flex: 0 1 380px;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--white);
  color: var(--ink-4);
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 14px; height: 100%; }
.search input::placeholder { color: var(--ink-4); }
.search:focus-within { border-color: var(--ink); color: var(--ink); }

/* filters are text tabs, underlined when active */
.toolbar {
  display: flex; align-items: stretch; gap: 4px 22px; flex-wrap: wrap;
  padding: 0 28px;
  border-bottom: 1px solid var(--rule);
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; color: var(--ink-3);
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.chip:hover { color: var(--ink); }
.chip .n { font-size: 12px; font-weight: 500; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.chip.on { color: var(--accent); border-bottom-color: var(--accent); }
.chip.on .n { color: var(--ink-2); }
.chip.alert.on { color: var(--red); border-bottom-color: var(--red); }
.chip.alert .n { color: var(--red); }

/* ================================ list ================================ */

.listwrap { flex: 1 1 auto; overflow: auto; }
table.rows { width: 100%; border-collapse: separate; border-spacing: 0; }
table.rows th {
  position: sticky; top: 0; z-index: 3;
  background: var(--white);
  border-bottom: 1px solid var(--ink);
  padding: 10px 14px;
  text-align: start;
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); white-space: nowrap; cursor: pointer; user-select: none;
}
table.rows th:first-child { padding-inline-start: 28px; }
table.rows th:hover { color: var(--ink); }
table.rows th .caret { font-size: 8px; margin-inline-start: 4px; }
table.rows td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
table.rows td:first-child { padding-inline-start: 28px; }
table.rows tbody tr { cursor: pointer; }
table.rows tbody tr:hover td { background: var(--paper); }
table.rows tbody tr td:first-child { box-shadow: inset 3px 0 0 var(--rule); }
table.rows tbody tr.with_worker td:first-child { box-shadow: inset 3px 0 0 var(--blue); }
table.rows tbody tr.ready td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table.rows tbody tr.late td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.rows tbody tr.done td { color: var(--ink-3); }

.railno-cell {
  display: inline-block; min-width: 40px; text-align: center;
  font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1;
  border-bottom: 2px solid var(--accent); padding-bottom: 2px;
}
tr.done .railno-cell { border-bottom-color: var(--rule-2); }
.tno { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.cust { font-size: 15px; font-weight: 600; }
.sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.alt { max-width: 360px; color: var(--ink-2); }

/* status is set as text, never as a pill */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  white-space: nowrap;
  padding: 3px 9px; border-radius: 999px;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.waiting     { color: var(--ink-2);  background: var(--paper-2); }
.badge.with_worker { color: var(--blue);   background: var(--blue-wash); }
.badge.ready       { color: var(--green);  background: var(--green-wash); }
.badge.collected   { color: var(--ink-4);  background: transparent; }
.badge.late        { color: var(--red);    background: var(--red-wash); }

.letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: 1px solid var(--ink); border-radius: var(--r);
  font-weight: 700; font-size: 12px; vertical-align: middle;
}
.datecell { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.datecell .rel { display: block; font-size: 12px; font-weight: 500; color: var(--ink-3); }
.datecell.late, .datecell.late .rel { color: var(--red); }
.datecell.none { color: var(--ink-4); font-weight: 500; }
.empty { padding: 90px 20px; text-align: center; color: var(--ink-3); font-family: var(--serif); font-size: 18px; }

/* ================================ buttons ================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--r);
  border: 1px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  font-size: 13.5px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--paper); }
.btn:active { background: var(--paper-2); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.btn.primary, .btn.gold { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, .btn.gold:hover { background: #17495a; border-color: #17495a; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); font-weight: 500; }
.btn.quiet:hover { background: var(--paper); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red-wash); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.lg { height: var(--touch-lg); padding: 0 22px; font-size: 15px; }
.btn.touch { height: var(--touch); }
.btn.icon-only { width: 40px; padding: 0; }
.btn.block { width: 100%; }

/* ================================ choice groups ================================ */

.choice { display: flex; flex-wrap: wrap; gap: 6px; }
.choice.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.choice.cards.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.ch {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--touch);
  padding: 6px 14px;
  border-radius: var(--r);
  border: 1px solid var(--rule-2);
  background: var(--white);
  color: var(--ink);
  text-align: start;
  font-size: 14px; font-weight: 500;
}
.ch:hover { border-color: var(--ink); }
.ch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ch .ch-icon { color: var(--ink-4); }
.ch .ch-mark {
  flex: none; min-width: 26px; height: 26px; padding: 0 5px;
  border: 1px solid var(--ink); border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.ch .ch-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.ch .ch-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.choice:not(.cards) .ch .ch-body { flex-direction: row; align-items: baseline; gap: 8px; }
.choice.cards .ch { min-height: var(--touch-lg); padding: 8px 14px; }
.ch.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.ch.on .ch-icon { color: #fff; }
.ch.on .ch-mark { border-color: #fff; color: #fff; }
.ch.on .ch-sub { color: rgba(255,255,255,.6); }
.ch.off { opacity: .45; text-decoration: line-through; pointer-events: none; }

/* ================================ modal ================================ */

.overlay {
  position: fixed; inset: 0;
  background: rgba(27,26,23,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 28px 20px; overflow-y: auto; z-index: 50;
}
.overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 860px;
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.narrow { max-width: 540px; }
.modal.wide { max-width: 1080px; }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--ink);
  background: var(--white);
  position: sticky; top: 0; z-index: 2;
}
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 400; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  position: sticky; bottom: 0;
}
.x {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--ink-3);
}
.x:hover { border-color: var(--rule-2); color: var(--ink); }

/* ================================ forms ================================ */

.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > .lbl {
  display: block;
  font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}
.field .hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }

input[type=text], input[type=tel], input[type=date], input[type=time],
input[type=number], input[type=password], textarea {
  width: 100%; height: var(--touch);
  padding: 0 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r);
  background: var(--white); color: var(--ink);
  font-size: 15px;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.45; }
input:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
input:disabled { background: var(--paper); color: var(--ink-3); }

.grid { display: grid; gap: 0 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.rowflex { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.rowflex > .grow { flex: 1 1 180px; }

.gcard {
  border-top: 1px solid var(--ink);
  padding: 14px 0 4px;
  margin-bottom: 8px;
}
.gcard-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.gcard-head .n {
  font-family: var(--serif); font-size: 18px; font-weight: 700;
  width: 26px; text-align: center;
}
.gcard-head h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

.tabs { display: flex; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--rule); background: var(--white); overflow-x: auto; }
.tabs button {
  height: 44px; padding: 0; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font-size: 13.5px; font-weight: 600; color: var(--ink-3); white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

table.mini { width: 100%; border-collapse: collapse; }
table.mini th {
  text-align: start; font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--ink);
}
table.mini td { padding: 7px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini input { height: 38px; font-size: 14px; }

.note {
  border-radius: var(--r); padding: 10px 14px; margin-bottom: 12px;
  font-size: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.note.ok   { background: var(--green-wash); border-color: var(--green); color: var(--green); }
.note.err  { background: var(--red-wash);   border-color: var(--red);   color: var(--red); font-weight: 600; }
.note.warn { background: var(--paper-2);    border-color: var(--gold);  color: #6f5416; }
.note.info { background: var(--blue-wash);  border-color: var(--blue);  color: var(--blue); }

.scanbox {
  border: 1px solid var(--ink); border-radius: var(--r);
  padding: 14px 16px; background: var(--white); position: relative;
}
.scanbox input { height: 72px; font-size: 40px; font-weight: 700; text-align: center; letter-spacing: .1em; font-variant-numeric: tabular-nums; border-color: var(--ink); }
.scanbox.hot { background: var(--paper); }
.scanbox .live {
  position: absolute; inset-inline-end: 16px; top: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--green);
}
.scanbox .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

.taken { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.taken .tno { font-size: 18px; min-width: 60px; }
.bigcount { font-family: var(--serif); font-size: 44px; font-weight: 700; line-height: 1; }
.muted { color: var(--ink-3); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
h3.section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--ink-3); margin: 22px 0 8px; font-weight: 700; }

#toasts { position: fixed; inset-inline-end: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 440px; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--r); box-shadow: var(--shadow); font-size: 14px; }
.toast.ok  { box-shadow: inset 3px 0 0 var(--green), var(--shadow); }
.toast.err { box-shadow: inset 3px 0 0 var(--red), var(--shadow); }

/* ================================ responsive ================================ */

@media (max-width: 960px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; align-items: center; gap: 6px; padding: 8px 12px; border-inline-end: 0; border-bottom: 1px solid var(--rule); }
  .side-brand { padding: 0 10px 0 0; border: 0; }
  .side-brand .word { display: none; }
  .side-actions { display: flex; padding: 0; gap: 6px; flex: 1; }
  .side-btn { width: auto; height: 42px; padding: 0 12px; }
  .side-btn .kbd, .side-btn .lbl { display: none; }
  .side-section, .side-overview { display: none; }
  .side-foot { padding: 0; border: 0; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .search { flex-basis: 100%; margin: 0; }
  .page-head { flex-wrap: wrap; }
}
@media (max-width: 640px) {
  table.rows th:nth-child(n+5), table.rows td:nth-child(n+5) { display: none; }
  .overlay { padding: 0; }
  .modal { border: 0; min-height: 100%; max-width: none; }
}
@media print {
  .side, .page-head, .toolbar, .modal-head .x, .modal-foot, .noprint { display: none !important; }
  body { display: block; overflow: visible; }
  .overlay { position: static; background: none; padding: 0; overflow: visible; }
  .modal { box-shadow: none; border: 0; max-width: none; }
}
