/* Generic dashboard shell - workshop-industrial dark-first UI.
   No external resources. System font stack only. Data reads like an
   instrument readout: monospace for numbers, dates, and codes;
   one warm ember accent for emphasis. */

/* ---- Tokens: dark is the default, light is opt-in via prefers or toggle ---- */
:root {
  --bg:        #14161a;
  --surface:   #1c1f26;
  --surface-2: #242832;
  --surface-3: #2b303b;
  --line:      #2f343f;
  --line-soft: #23272f;
  --text:      #e8e6e1;
  --muted:     #9aa0ab;
  --faint:     #6b7280;

  --ember:      #f7811f;
  --ember-hot:  #ff9b3d;
  --ember-deep: #c25a12;
  --ember-glow: rgba(247, 129, 31, 0.18);

  /* Status hues - consistent across every view. Cool = early, hot = in
     the fire, green = finished, red = dead. */
  --st-prospect-fg:  #cdd3dc; --st-prospect-bg:  #2c313c;
  --st-quoted-fg:    #b8a6ff; --st-quoted-bg:    #2a2740;
  --st-approved-fg:  #ffcf8a; --st-approved-bg:  #3a2f1c;
  --st-production-fg:#ff9b3d; --st-production-bg:#3a2712;
  --st-awaiting-fg:  #ffd75e; --st-awaiting-bg:  #3a3312;
  --st-delivered-fg: #5fd0c4; --st-delivered-bg: #163430;
  --st-complete-fg:  #79d17f; --st-complete-bg:  #163420;
  --st-cancelled-fg: #d98b8b; --st-cancelled-bg: #35201f;

  --danger: #ff6a5a;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --tap: 44px;
  --maxw: 940px;

  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);

  --mono: ui-monospace, "Cascadia Code", "SF Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:        #eceae4;
  --surface:   #f7f5f0;
  --surface-2: #ffffff;
  --surface-3: #eeece5;
  --line:      #d9d5cb;
  --line-soft: #e4e0d6;
  --text:      #23262c;
  --muted:     #5f6672;
  --faint:     #8a909b;

  --ember:      #cf5f0a;
  --ember-hot:  #e6720f;
  --ember-deep: #a34a08;
  --ember-glow: rgba(207, 95, 10, 0.12);

  --st-prospect-fg:  #414a57; --st-prospect-bg:  #e3e1d8;
  --st-quoted-fg:    #5b45a8; --st-quoted-bg:    #e7e2f5;
  --st-approved-fg:  #8a5a10; --st-approved-bg:  #f4e6ce;
  --st-production-fg:#a8500c; --st-production-bg:#f6e0c8;
  --st-awaiting-fg:  #8a6a08; --st-awaiting-bg:  #f4ecc6;
  --st-delivered-fg: #0d6f64; --st-delivered-bg: #d3efe9;
  --st-complete-fg:  #1f7a34; --st-complete-bg:  #d5eed9;
  --st-cancelled-fg: #a33b34; --st-cancelled-bg: #f2dad7;

  --danger: #c23b2e;

  --shadow: 0 8px 30px rgba(60, 55, 45, 0.16);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg:        #eceae4;
    --surface:   #f7f5f0;
    --surface-2: #ffffff;
    --surface-3: #eeece5;
    --line:      #d9d5cb;
    --line-soft: #e4e0d6;
    --text:      #23262c;
    --muted:     #5f6672;
    --faint:     #8a909b;
    --ember:      #cf5f0a;
    --ember-hot:  #e6720f;
    --ember-deep: #a34a08;
    --ember-glow: rgba(207, 95, 10, 0.12);
    --st-prospect-fg:  #414a57; --st-prospect-bg:  #e3e1d8;
    --st-quoted-fg:    #5b45a8; --st-quoted-bg:    #e7e2f5;
    --st-approved-fg:  #8a5a10; --st-approved-bg:  #f4e6ce;
    --st-production-fg:#a8500c; --st-production-bg:#f6e0c8;
    --st-awaiting-fg:  #8a6a08; --st-awaiting-bg:  #f4ecc6;
    --st-delivered-fg: #0d6f64; --st-delivered-bg: #d3efe9;
    --st-complete-fg:  #1f7a34; --st-complete-bg:  #d5eed9;
    --st-cancelled-fg: #a33b34; --st-cancelled-bg: #f2dad7;
    --danger: #c23b2e;
    --shadow: 0 8px 30px rgba(60, 55, 45, 0.16);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Faint line texture on the page backdrop - very restrained. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 78px,
    rgba(255, 255, 255, 0.012) 78px,
    rgba(255, 255, 255, 0.012) 79px
  );
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ---- App shell ---- */
#app { position: relative; z-index: 1; }

.screen-lock,
.screen-app { min-height: 100dvh; }
.hidden { display: none !important; }

/* ---- Unlock screen ---- */
.screen-lock {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lock-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.lock-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  display: block;
}
.lock-brand {
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 15px;
  margin: 0 0 4px;
}
.lock-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0 0 30px;
}
.lock-form { display: flex; flex-direction: column; gap: 12px; }
.lock-input {
  width: 100%;
  height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 0 14px;
}
.lock-input:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: 0 0 0 3px var(--ember-glow);
}
.btn-primary {
  height: var(--tap);
  border: none;
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--ember-hot), var(--ember));
  color: #1a1206;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}
.btn-primary:active { transform: translateY(1px); }
.lock-msg {
  min-height: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
  letter-spacing: 0.02em;
}
.lock-hint {
  margin-top: 26px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.03em;
}

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
}
.brand svg { width: 26px; height: 26px; display: block; }
.brand-name {
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
}
.brand-name span { color: var(--ember); }
.icon-btn {
  width: var(--tap);
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line); }
.icon-btn svg { width: 20px; height: 20px; }
.header-tools { display: flex; align-items: center; gap: 4px; }

/* ---- Desktop top nav (hidden on mobile) ---- */
.top-nav { display: none; }

/* Orders renders as cards on mobile; the table is desktop-only. */
.orders-table { display: none; }
#orders-cards { display: block; }

/* ---- Main / views ---- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px 96px;
}
.view { animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 4px 2px 16px;
}
.view-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}
.view-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* Section label with the ember kerf line - the signature divider. */
.kerf-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 2px 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.kerf-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}
.kerf-label .cnt { color: var(--faint); }
.kerf-label[data-heat="overdue"] { color: var(--danger); }
.kerf-label[data-heat="overdue"]::after { background: linear-gradient(90deg, var(--danger), transparent); }
.kerf-label[data-heat="today"] { color: var(--ember); }
.kerf-label[data-heat="today"]::after {
  background: linear-gradient(90deg, var(--ember), transparent);
  box-shadow: 0 0 8px var(--ember-glow);
}
.kerf-label[data-heat="week"]::after { background: linear-gradient(90deg, var(--ember-deep), transparent); }

/* ---- Status pill ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.3;
}
.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill.prospect  { color: var(--st-prospect-fg);   background: var(--st-prospect-bg); }
.pill.quoted    { color: var(--st-quoted-fg);      background: var(--st-quoted-bg); }
.pill.approved  { color: var(--st-approved-fg);    background: var(--st-approved-bg); }
.pill.in-production { color: var(--st-production-fg); background: var(--st-production-bg); }
.pill.awaiting-final { color: var(--st-awaiting-fg); background: var(--st-awaiting-bg); }
.pill.delivered { color: var(--st-delivered-fg);   background: var(--st-delivered-bg); }
.pill.complete  { color: var(--st-complete-fg);    background: var(--st-complete-bg); }
.pill.cancelled { color: var(--st-cancelled-fg);   background: var(--st-cancelled-bg); }

/* ---- Up Next items ---- */
.unext-item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 0 12px;
  align-items: start;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 12px 14px 12px 0;
  margin-bottom: 8px;
  overflow: hidden;
  color: inherit;
}
.unext-item:hover { border-color: var(--line); background: var(--surface-2); }
.unext-item:active { transform: translateY(1px); }
.unext-bar { grid-row: 1 / 3; align-self: stretch; width: 4px; border-radius: 4px 0 0 4px; background: var(--faint); }
.unext-item[data-heat="overdue"] .unext-bar { background: linear-gradient(180deg, var(--danger), var(--ember-deep)); }
.unext-item[data-heat="today"]   .unext-bar { background: linear-gradient(180deg, var(--ember-hot), var(--ember)); box-shadow: 0 0 10px var(--ember-glow); }
.unext-item[data-heat="week"]    .unext-bar { background: var(--ember-deep); }
.unext-item[data-heat="month"]   .unext-bar { background: var(--st-prospect-fg); }

.unext-main { min-width: 0; }
.unext-cust { font-weight: 700; font-size: 15px; }
.unext-action { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.unext-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; padding-top: 1px; }
.date-chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 2px 7px;
  white-space: nowrap;
}
.date-chip.overdue { color: var(--danger); }
.date-chip.today { color: var(--ember); background: var(--ember-glow); }
.item-kind {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---- Filter chips + search (Orders) ---- */
.toolbar { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.search {
  width: 100%;
  height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  padding: 0 14px;
}
.search:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px var(--ember-glow); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chip .n { color: var(--faint); font-size: 11px; }
.chip[aria-pressed="true"] {
  color: #1a1206;
  background: var(--ember);
  border-color: var(--ember);
  font-weight: 700;
}
.chip[aria-pressed="true"] .n { color: #1a1206; opacity: 0.7; }

/* ---- Order cards ---- */
.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 10px;
  color: inherit;
}
.card:hover { border-color: var(--line); background: var(--surface-2); }
.card:active { transform: translateY(1px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-cust { font-weight: 700; font-size: 15.5px; min-width: 0; }
.card-product { color: var(--muted); font-size: 13.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-meta { display: flex; align-items: center; gap: 14px; margin-top: 11px; font-family: var(--mono); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card-total { color: var(--text); font-weight: 600; }
.card-total.tbd { color: var(--faint); font-weight: 400; }
.card-next { display: inline-flex; align-items: center; gap: 5px; }
.card-next::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--ember); }

.empty {
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

/* ---- Pipeline ---- */
.pipe-item {
  display: block;
  width: 100%;
  text-align: left;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.pipe-item:hover { background: var(--surface-2); }
.pipe-item.stale { border-left-color: var(--danger); }
.pipe-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pipe-cust { font-weight: 700; font-size: 15px; }
.pipe-val { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 600; }
.pipe-val.tbd { color: var(--faint); font-weight: 400; }
.pipe-product { color: var(--muted); font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.stale-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--danger); }
.age { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---- Reports ---- */
.month-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.month-select {
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 0 12px;
}
.month-select:focus { outline: none; border-color: var(--ember); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: 14px;
  position: relative;
  overflow: hidden;
}
.tile.accent { border-color: color-mix(in srgb, var(--ember) 40%, var(--line)); }
.tile.accent::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--ember-hot), var(--ember));
}
.tile-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.tile-value { font-family: var(--mono); font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -0.01em; }
.tile-value.tbd { color: var(--faint); }
.tile-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 3px; }
.tile-sub.warn { color: var(--st-awaiting-fg); }

.caveat {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--st-awaiting-fg);
  background: var(--st-awaiting-bg);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  line-height: 1.5;
}

/* Chart */
.chart-wrap { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); padding: 16px 14px 10px; margin-top: 6px; position: relative; }
.chart-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.chart { max-width: 560px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar-rect { transition: opacity 0.12s; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 9px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
}
.chart-tip .v { color: var(--ember); font-weight: 700; }

.alltime {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.alltime .at-cell { text-align: center; flex: 1; }
.alltime .at-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.alltime .at-value { font-family: var(--mono); font-size: 17px; font-weight: 700; margin-top: 3px; }

/* ---- Detail overlay ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 70%, rgba(0,0,0,0.6));
  backdrop-filter: blur(4px);
  overflow-y: auto;
  animation: fade 0.16s ease;
}
.sheet {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
.sheet-head {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px 0 8px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-md);
  color: var(--text); font-family: var(--mono); font-size: 12px;
}
.back-btn:hover { border-color: var(--ember); }
.sheet-body { padding: 18px 16px 60px; }
.sheet-cust { font-size: 21px; font-weight: 800; margin: 2px 0 4px; }
.sheet-sub { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-word; }
.sheet-product { margin: 14px 0 4px; font-size: 15px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow: hidden; margin-top: 14px; }
.field { background: var(--surface); padding: 10px 12px; }
.field.full { grid-column: 1 / -1; }
.field-k { font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field-v { font-family: var(--mono); font-size: 13.5px; margin-top: 3px; word-break: break-word; }
.field-v.tbd { color: var(--faint); }

.pay-summary { margin-top: 16px; border: 1px solid var(--line-soft); border-radius: var(--r-md); overflow: hidden; }
.pay-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 13px; background: var(--surface); border-bottom: 1px solid var(--line-soft); }
.pay-row:last-child { border-bottom: none; }
.pay-k { font-family: var(--mono); font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.pay-amt { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.pay-amt.tbd { color: var(--faint); font-weight: 400; }
.paid-check { color: var(--st-complete-fg); }
.paid-check.unpaid { color: var(--faint); }
.pay-date { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

.sq-link {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; height: 42px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--mono); font-size: 12px; color: var(--ember); text-decoration: none;
}
.sq-link:hover { border-color: var(--ember); }

.notes-list { list-style: none; padding: 0; margin: 12px 0 0; }
.notes-list li { position: relative; padding: 7px 0 7px 18px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--line-soft); white-space: pre-line; }
.notes-list li:last-child { border-bottom: none; }
.notes-list li::before { content: ""; position: absolute; left: 2px; top: 15px; width: 5px; height: 5px; border-radius: 50%; background: var(--ember-deep); }

.timeline { list-style: none; padding: 0; margin: 12px 0 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 1px solid var(--line); margin-left: 4px; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -4.5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 0 3px var(--bg); }
.tl-date { font-family: var(--mono); font-size: 11px; color: var(--ember); letter-spacing: 0.03em; }
.tl-text { font-size: 13.5px; color: var(--muted); margin-top: 3px; white-space: pre-line; }

/* ---- Bottom tab bar (mobile) ---- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1;
  min-height: 58px;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  position: relative;
}
.tab svg { width: 22px; height: 22px; }
.tab .tab-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; }
.tab[aria-selected="true"] { color: var(--ember); }
.tab[aria-selected="true"]::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 2px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  box-shadow: 0 0 8px var(--ember-glow);
}

.footer {
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  padding: 8px 0 4px;
  letter-spacing: 0.03em;
}

/* ---- Tablet grid niceties (still mobile chrome: bottom bar, cards, overlay) ---- */
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .pipe-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
}

@keyframes slideIn {
  from { transform: translateX(44px); opacity: 0.2; }
  to   { transform: none; opacity: 1; }
}

/* ==================== Desktop ops layout (>= 1024px) ==================== */
@media (min-width: 1024px) {
  .tabbar { display: none; }

  /* ---- Persistent left sidebar (repurposes the header) ---- */
  #main { padding-left: 248px; }
  .app-header {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 248px;
    background: var(--surface);
    border-bottom: none;
    border-right: 1px solid var(--line);
    backdrop-filter: none;
  }
  .header-inner {
    max-width: none;
    height: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 22px 14px 18px;
  }
  .brand { margin: 0 0 26px; padding: 0 10px; }
  .brand svg { width: 30px; height: 30px; }
  .brand-name { font-size: 14px; }

  .top-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
  }
  .nav-link {
    height: 44px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: transparent;
    border: none;
    border-radius: var(--r-md);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 13.5px;
    letter-spacing: 0.02em;
    position: relative;
    text-align: left;
  }
  .nav-link svg { width: 18px; height: 18px; flex: 0 0 auto; }
  .nav-link .nav-label { flex: 1; }
  .nav-link:hover { color: var(--text); background: var(--surface-2); }
  .nav-link[aria-selected="true"] {
    color: var(--ember);
    background: color-mix(in srgb, var(--ember) 13%, transparent);
  }
  .nav-count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--faint);
    background: var(--surface-3);
    border-radius: 999px;
    padding: 1px 8px;
    min-width: 24px;
    text-align: center;
  }
  .nav-link[aria-selected="true"] .nav-count { color: var(--ember); background: var(--ember-glow); }

  .header-tools {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
    gap: 6px;
  }
  .app-header .icon-btn { width: 44px; height: 40px; }

  /* ---- Content column ---- */
  main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 40px 60px;
  }
  .view-title { font-size: 26px; }
  .view-head { margin-bottom: 20px; }

  /* ---- Up Next: groups stack full-width; items balance in a grid ---- */
  .unext-group { margin-bottom: 22px; }
  .unext-group .kerf-label { margin: 4px 2px 10px; }
  .unext-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 10px 22px;
  }
  .unext-item { padding: 10px 12px 10px 0; margin-bottom: 0; }
  .unext-cust { font-size: 14px; }
  .unext-action { font-size: 13px; }

  /* ---- Orders: real table ---- */
  #orders-cards { display: none; }
  .orders-body {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    overflow: hidden;
    overflow-x: auto;
  }
  .orders-table {
    display: table;
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
  }
  .orders-table thead th {
    text-align: left;
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--muted);
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
  }
  .orders-table th.num { text-align: right; }
  .orders-table th .th-inner { display: inline-flex; align-items: center; gap: 6px; }
  .orders-table th.num .th-inner { flex-direction: row-reverse; }
  .orders-table th:hover { color: var(--text); }
  .orders-table th.sorted { color: var(--ember); }
  .sort-caret { display: inline-block; width: 0; height: 0; opacity: 0; }
  .orders-table th.sorted .sort-caret { opacity: 1; border-left: 4px solid transparent; border-right: 4px solid transparent; }
  .orders-table th.sorted.asc .sort-caret  { border-bottom: 5px solid currentColor; }
  .orders-table th.sorted.desc .sort-caret { border-top: 5px solid currentColor; }

  .orders-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13.5px;
    vertical-align: middle;
  }
  .orders-table tbody tr:last-child td { border-bottom: none; }
  .orow { cursor: pointer; }
  .orow:hover td { background: var(--surface-2); }
  .orders-table .c-cust { font-weight: 700; white-space: nowrap; }
  .orders-table .c-prod { color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .orders-table td.num { text-align: right; font-family: var(--mono); }
  .orders-table .c-total { color: var(--text); font-weight: 600; }
  .orders-table .c-total.tbd { color: var(--faint); font-weight: 400; }
  .orders-table .c-date { color: var(--muted); font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
  .orders-table .cell-muted { color: var(--faint); }
  .orders-table .c-next .date-chip { font-size: 10.5px; }
  .empty-cell { padding: 0 !important; }
  .empty-cell .empty { border: none; }

  /* ---- Pipeline: two columns ---- */
  .pipe-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
  .pipe-item { padding: 11px 13px; margin-bottom: 6px; }

  /* ---- Reports ---- */
  .tiles { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .report-lower {
    display: grid;
    grid-template-columns: 1.7fr 1fr;
    gap: 20px;
    align-items: start;
    margin-top: 16px;
  }
  .report-lower .chart-wrap { margin-top: 0; padding: 18px 18px 12px; }
  .report-lower .chart { max-width: 100%; }
  .report-lower .alltime {
    margin-top: 0;
    flex-direction: column;
    gap: 0;
    padding: 6px 16px;
  }
  .report-lower .alltime .at-cell {
    text-align: left;
    flex: none;
    padding: 13px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .report-lower .alltime .at-cell:last-child { border-bottom: none; }
  .report-lower .alltime .at-value { font-size: 20px; margin-top: 4px; }

  /* ---- Order detail: right-side sliding panel ---- */
  .overlay {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: flex-end;
    overflow: hidden;
  }
  .sheet {
    max-width: 460px;
    width: 460px;
    margin: 0;
    min-height: 0;
    height: 100dvh;
    border-left: 1px solid var(--line);
    border-right: none;
    overflow-y: auto;
    box-shadow: -14px 0 44px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
}

/* ---- Accessibility ---- */
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
