/* Marathon Printing – GoMake Orders Dashboard
   Shared stylesheet for every tab. Look and tokens follow the Printer's Plan dashboard. */
:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --critical: #d03b3b;
  --critical-ink: #b42828;
  --critical-soft: #fbe5e5;
  --warning: #fab219;
  --warning-ink: #8a5a00;
  --warning-soft: #fdf1d6;
  --good: #0ca30c;
  --good-ink: #0a7a0a;
  --good-soft: #e0f3e0;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --td: 22px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
    --accent: #3987e5; --accent-soft: #184f95;
    --critical-ink: #ff8a8a; --critical-soft: #3a1c1c;
    --warning-ink: #fab219; --warning-soft: #3a2e12;
    --good-ink: #6fdc6f; --good-soft: #15301a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #3987e5; --accent-soft: #184f95;
  --critical-ink: #ff8a8a; --critical-soft: #3a1c1c;
  --warning-ink: #fab219; --warning-soft: #3a2e12;
  --good-ink: #6fdc6f; --good-soft: #15301a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }

/* ---------- header + nav ---------- */
header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
header .header-left { display: flex; align-items: center; gap: 16px; }
header img.logo { height: 56px; width: auto; border-radius: 8px; }
header h1 { font-size: 30px; font-weight: 650; letter-spacing: -0.01em; }
.status-bar { font-size: 20px; color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 4px 16px; text-align: right; }
nav { background: var(--surface); border-bottom: 1px solid var(--border); display: flex; gap: 2px; padding: 0 20px; overflow-x: auto; }
nav a { color: var(--text-2); text-decoration: none; font-size: 22px; font-weight: 600; padding: 12px 18px; display: inline-block; white-space: nowrap; border-bottom: 3px solid transparent; transition: color 0.15s, border-color 0.15s; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- layout + cards ---------- */
main { width: 100%; padding: 20px 28px 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 20px; min-width: 0; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.toolbar-left { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.toolbar strong { font-size: 27px; font-weight: 650; letter-spacing: -0.01em; }
.badge { display: inline-block; vertical-align: 2px; margin-left: 8px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 12px; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */
.field-sm { display: flex; flex-direction: column; gap: 4px; font-size: 18px; color: var(--text-2); }
.field-sm label { font-size: 18px; font-weight: 600; color: var(--text-2); }
.field-sm select, .search-box { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 7px 12px; font-size: 20px; outline: none; }
.search-box { width: 240px; }
.search-box:focus, .field-sm select:focus { border-color: var(--accent); }
button { padding: 8px 18px; border-radius: 8px; font-size: 20px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, opacity 0.15s, border-color 0.15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-green { background: var(--good); color: #fff; }
.btn-green:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.sync-status { font-size: 18px; color: var(--muted); align-self: center; }

/* ---------- KPI tiles (Orders summary) ---------- */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius); padding: 14px 20px; min-width: 0; }
.stat-card.created { border-left-color: var(--accent); }
.stat-card.due { border-left-color: var(--warning); }
.stat-card.done { border-left-color: var(--good); }
.stat-label { font-size: 20px; color: var(--text-2); font-weight: 600; }
.stat-value { font-size: 43px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card.created .stat-value { color: var(--accent); }
.stat-card.due .stat-value { color: var(--warning-ink); }
.stat-card.done .stat-value { color: var(--good-ink); }
.stat-sub { font-size: 20px; color: var(--muted); margin-top: 2px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- table ---------- */
table { width: 100%; border-collapse: collapse; font-size: var(--td); }
th { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 20px; font-weight: 600; white-space: nowrap; cursor: pointer; user-select: none; }
th:hover { color: var(--text); }
th.no-sort, th.no-sort:hover { cursor: default; color: var(--text-2); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover td { background: var(--surface-2); }
.order-num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.due-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 20px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.due-overdue { background: var(--critical-soft); color: var(--critical-ink); }
.due-soon    { background: var(--warning-soft);  color: var(--warning-ink); }
.due-ok      { background: var(--good-soft);     color: var(--good-ink); }
.due-none    { background: var(--surface-2);     color: var(--muted); }

/* section headers: Late / Due Today / Upcoming */
.section-header td { font-size: 20px; font-weight: 700; padding: 9px 14px; letter-spacing: 0.03em; text-transform: uppercase; border-bottom: none; }
tbody tr.section-header:hover td { background: inherit; }
.section-overdue td { background: var(--critical-soft); color: var(--critical-ink); box-shadow: inset 5px 0 0 var(--critical); }
.section-today   td { background: var(--warning-soft);  color: var(--warning-ink);  box-shadow: inset 5px 0 0 var(--warning); }
.section-future  td { background: var(--surface-2);     color: var(--text-2);       box-shadow: inset 5px 0 0 var(--good); }
tbody tr.section-overdue:hover td { background: var(--critical-soft); }
tbody tr.section-today:hover td   { background: var(--warning-soft); }
tbody tr.section-future:hover td  { background: var(--surface-2); }

/* job status chips (colours come from the department rules in each page) */
.job-status-badge { display: inline-block; padding: 1px 9px; border-radius: 6px; font-size: 19px; font-weight: 650; margin: 0 4px 3px 0; }
.job-item { margin-bottom: 8px; }
.job-item:last-child { margin-bottom: 0; }
.job-item strong { display: block; font-size: 21px; font-weight: 650; color: var(--text); margin-bottom: 3px; }
.status-loading { color: var(--muted); font-size: 19px; font-style: italic; }

/* ---------- states ---------- */
.state { text-align: center; padding: 48px 24px; color: var(--muted); font-size: 25px; }
.state .icon { font-size: 29px; margin-bottom: 8px; }
.error-msg { color: var(--critical-ink); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.legend { margin-top: 14px; font-size: 19px; color: var(--muted); }

/* ---------- Completed tab ---------- */
.tracking-link { color: var(--accent); text-decoration: none; font-weight: 650; }
.tracking-link:hover { text-decoration: underline; }
.cost-cell { font-weight: 650; color: var(--good-ink); font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  header { padding: 10px 16px; }
  header h1 { font-size: 22px; }
  main { padding: 14px 14px 32px; }
  .search-box { width: 100%; }
}

/* Need By chips */
.nb-chip { display:inline-flex; align-items:center; gap:4px; padding:2px 10px; border-radius:999px; font-size:.85em; font-weight:600; white-space:nowrap; background:rgba(128,128,128,.15); color:var(--text-2); }
.nb-chip svg { width:.8em; height:.8em; }
.nb-hot  { background: var(--warning-soft); color: var(--warning-ink); box-shadow: inset 0 0 0 1px var(--warning); }
.nb-late { background:#fde2e2; color:#a11; box-shadow: inset 0 0 0 1px #e66; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nb-late { background:#3a1717; color:#ff9a9a; } }
:root[data-theme="dark"] .nb-late { background:#3a1717; color:#ff9a9a; }
.nb-rest { color: var(--text-2); }
