/* ============================================================
   ATELIER — Diamond Trade Portal design system
   Themed to match the Eternal Radiance D2C site:
   navy #032658 primary · gold #c79a3a accent · ivory #fbfbfb
   Cormorant Garamond display · Jost UI · IBM Plex Mono
   ============================================================ */

/* ---- Fonts ---- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600&family=Jost:wght@300;400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ---- Tokens ---- */
:root {
  --bg:            #fcfbf8;
  --surface:       #FFFFFF;
  --surface-2:     #f8f6f1;
  --surface-3:     #f2ede3;

  --ink:           #26282d;
  --ink-soft:      #52493c;
  --muted:         #8a7d6b;
  --faint:         #b0a794;

  --hairline:      rgba(3,38,88,.10);
  --hairline-2:    rgba(3,38,88,.20);

  --sidebar-bg:    #032658;
  --sidebar-panel: #0b366e;
  --sidebar-ink:   #f2f1ec;              /* menu text: white at rest */
  --sidebar-dim:   rgba(252,251,248,.55); /* muted labels: dimmed white */
  --sidebar-line:  rgba(246,242,236,.14);

  /* brand navy is the working accent; gold is the garnish */
  --accent:        #032658;
  --accent-bright: #c79a3a;
  --accent-deep:   #021d42;
  --accent-soft:   #e8edf5;
  --accent-line:   #c9d3e3;

  --pos:    #4F7A5B;  --pos-bg:  #E8EFE7;  --pos-line:#CDDCC8;
  --warn:   #B0732A;  --warn-bg: #F5EAD7;  --warn-line:#E6D2AC;
  --neg:    #A8453A;  --neg-bg:  #F3E1DC;  --neg-line:#E5C6BD;
  --info:   #032658;  --info-bg: #e8edf5;  --info-line:#c9d3e3;

  --shadow-sm: 0 1px 2px rgba(3,38,88,.05), 0 1px 1px rgba(3,38,88,.04);
  --shadow:    0 4px 16px -6px rgba(3,38,88,.12), 0 1px 3px rgba(3,38,88,.06);
  --shadow-lg: 0 24px 60px -20px rgba(2,20,45,.30);

  --r-sm: 3px;
  --r:    6px;
  --r-lg: 10px;

  --sidebar-w: 252px;
  --topbar-h: 68px;

  --row-pad: 14px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Jost', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --heading-family: var(--font-display);
}

/* density */
[data-density="compact"]  { --row-pad: 9px; }
[data-density="comfy"]    { --row-pad: 20px; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  max-width: 100%;
  overflow-x: clip; /* nothing may widen the page — wide content scrolls inside its own wrapper */
}

img, video { max-width: 100%; }

html { scroll-behavior: smooth; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* numerals: tabular everywhere it matters */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============================================================
   APP SHELL
   ============================================================ */
#root { min-height: 100vh; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app.no-chrome { grid-template-columns: 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #021c40;
}
.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 20px;
  border-bottom: 1px solid var(--sidebar-line);
}
/* brand monogram (inline SVG from customer/_logo.php) */
.sb-mark {
  width: 44px; height: 44px;
  flex: none;
  display: block;
  object-fit: contain;
}
.la-mark { width: 60px; height: 60px; }
.sb-brand-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #fcfbf8;
  line-height: 1.25;
}
.sb-brand-sub {
  font-size: 10.5px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--sidebar-dim);
  margin-top: 3px;
}

.sb-nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.sb-section-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--sidebar-dim);
  padding: 14px 12px 8px;
}
.sb-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--sidebar-ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.sb-link .bi { font-size: 17px; width: 20px; text-align: center; color: var(--sidebar-dim); transition: color .15s; }
.sb-link:hover { background: var(--sidebar-panel); color: #fff; }
.sb-link:hover .bi { color: var(--sidebar-ink); }
.sb-link.active {
  background: linear-gradient(90deg, rgba(252,251,248,.16), rgba(252,251,248,.05));
  color: #fcfbf8;
  border-color: rgba(252,251,248,.28);
}
.sb-link.active .bi { color: #fcfbf8; }
.sb-badge {
  margin-left: auto;
  background: #C6493C;
  color: #FDF6F0;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: grid; place-items: center;
  animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(198,73,60,.55); }
  50%      { box-shadow: 0 0 0 5px rgba(198,73,60,0); }
}

.sb-foot {
  border-top: 1px solid var(--sidebar-line);
  padding: 14px;
}
.sb-user {
  display: flex; align-items: center; gap: 11px;
  padding: 8px; border-radius: var(--r-sm);
  cursor: pointer;
}
.sb-user:hover { background: var(--sidebar-panel); }
.sb-avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: transparent;
  color: #fcfbf8;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  border: 1px solid rgba(252,251,248,.55);
}
.sb-user-name { font-size: 13px; font-weight: 600; color: #EDEAE2; line-height: 1.2; }
.sb-user-meta { font-size: 11px; color: var(--sidebar-dim); }

/* ---- Main column ---- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: rgba(252,251,248,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center;
  gap: 18px;
  padding: 0 32px;
}
.tb-titles { min-width: 0; }
.tb-eyebrow {
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.tb-title {
  font-family: var(--heading-family);
  font-size: 27px; font-weight: 600;
  line-height: 1.05; color: var(--ink);
  letter-spacing: .2px;
}
.tb-title em { font-style: italic; color: var(--accent); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.tb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 13px;
  min-width: 220px;
}
.tb-search input { border: none; background: none; outline: none; font-family: inherit; font-size: 13px; color: var(--ink); width: 100%; }

.content { padding: 30px 32px 64px; max-width: 1240px; width: 100%; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.eyebrow {
  font-size: 11px; letter-spacing: 2.2px; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.display {
  font-family: var(--heading-family);
  font-weight: 600; color: var(--ink); letter-spacing: .2px;
}
.display em { font-style: italic; color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
}
.card-head h3 {
  margin: 0; font-size: 13px; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase; color: var(--ink-soft);
}
.card-head .bi { color: var(--accent); font-size: 15px; }
.card-head .head-action { margin-left: auto; }
.card-body { padding: 20px; }

/* buttons — Atelier style: square, uppercase, letter-spaced, navy */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 12px 20px; border-radius: 0;
  border: 1px solid transparent; cursor: pointer;
  transition: all .15s; white-space: nowrap; line-height: 1;
}
.btn .bi { font-size: 15px; }
.btn-primary { background: var(--accent); color: #fcfbf8; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-deep); }
.btn-accent { background: var(--accent); color: #fcfbf8; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-deep); color: #fcfbf8; }
.btn-ghost { background: transparent; color: var(--accent); border-color: rgba(3,38,88,.35); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-pos { background: var(--pos); color: #fff; }
.btn-pos:hover { filter: brightness(.92); }
.btn-danger-ghost { background: transparent; color: var(--neg); border-color: var(--neg-line); }
.btn-danger-ghost:hover { background: var(--neg-bg); }
.btn-sm { padding: 9px 14px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .2px;
  padding: 4px 11px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.no-dot::before { display: none; }
.pill-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
/* in-progress states — gold, as in the original Atelier palette */
.pill-info { background: #EFE5CF; color: #8A6529; border-color: #E0CFA4; }
.pill-pos  { background: var(--pos-bg);  color: var(--pos);  border-color: var(--pos-line); }
.pill-neg  { background: var(--neg-bg);  color: var(--neg);  border-color: var(--neg-line); }
.pill-neutral { background: var(--surface-3); color: var(--ink-soft); border-color: var(--hairline-2); }
.pill-accent { background: #EFE5CF; color: #8A6529; border-color: #E0CFA4; }

/* action-required pill — red + pulsing dot, used when the customer must respond */
.pill-action {
  background: var(--neg-bg); color: var(--neg); border-color: var(--neg-line);
  font-weight: 700;
}
.pill-action::before {
  background: var(--neg);
  animation: dot-pulse 1.6s ease-out infinite;
}
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(168,69,58,.45); }
  70%  { box-shadow: 0 0 0 6px rgba(168,69,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(168,69,58,0); }
}

/* attention halo for blocks that need the customer's action */
.needs-action {
  border-color: var(--neg-line) !important;
  animation: card-glow 2.2s ease-in-out infinite;
}
@keyframes card-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168,69,58,.30), var(--shadow-sm); }
  50%      { box-shadow: 0 0 0 6px rgba(168,69,58,0), var(--shadow-sm); }
}

@media (prefers-reduced-motion: reduce) {
  .pill-action::before, .needs-action, .sb-badge { animation: none !important; }
}

/* ============================================================
   TABLES
   ============================================================ */
.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.ledger thead th {
  text-align: left;
  font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase;
  font-weight: 700; color: var(--muted);
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline-2);
  background: var(--surface-2);
  white-space: nowrap;
}
.ledger tbody td {
  padding: var(--row-pad) 18px;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-soft);
  vertical-align: middle;
}
.ledger tbody tr:last-child td { border-bottom: none; }
.ledger tbody tr { transition: background .12s; }
.ledger tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.ledger tbody td.num { color: #6b6253; } /* prices — muted brown per the D2C spec */
.ledger .ordno { font-family: var(--font-mono); font-weight: 600; color: var(--ink); font-size: 13px; }
.ledger .sub { font-size: 11.5px; color: var(--faint); }
.ledger .strong { color: var(--ink); font-weight: 600; }

.table-wrap { overflow-x: auto; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.greet-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 26px;
}
.greet h1 {
  font-family: var(--heading-family);
  font-size: 38px; font-weight: 600; margin: 6px 0 0;
  line-height: 1.02; letter-spacing: .2px;
}
.greet h1 em { font-style: italic; color: var(--accent); }
.greet p { margin: 8px 0 0; color: var(--muted); font-size: 14px; max-width: 52ch; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi { min-width: 0; }
.kpi-value { overflow-wrap: anywhere; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content:""; position:absolute; left:0; top:0; bottom:0; width: 3px;
  background: var(--accent); opacity:.0; transition: opacity .2s;
}
.kpi:hover::before { opacity: .8; }
.kpi-label { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-family: var(--heading-family);
  font-size: 42px; font-weight: 600; line-height: 1; margin-top: 12px;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.kpi-value.accent { color: var(--accent); }
.kpi-value.neg { color: var(--neg); }
.kpi-foot { font-size: 12px; color: var(--muted); margin-top: 9px; display:flex; align-items:center; gap:6px; }
.kpi-foot .up { color: var(--pos); }
.kpi-foot .dn { color: var(--neg); }

/* action required strip */
.action-card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--accent-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 18px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.action-head { display:flex; align-items:center; gap:10px; margin-bottom: 14px; }
.action-head .bi { color: var(--accent); font-size: 18px; }
.action-head strong { font-size: 14px; color: var(--ink); }
.action-head .count { color: var(--muted); font-weight: 500; }
.quote-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.quote-chip {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm);
  padding: 11px 14px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.quote-chip:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.quote-chip .qc-no { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--ink); }
.quote-chip .qc-amt { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.quote-chip .qc-desc { font-size: 12px; color: var(--muted); }
.quote-chip .bi { color: var(--accent); }

.two-col { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(0,1fr); gap: 20px; align-items: start; }
.two-col > *, .detail-grid > * { min-width: 0; }

/* mini list */
.mini-row { display:flex; align-items:center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--hairline); }
.mini-row:last-child { border-bottom: none; }
.mini-ico {
  width: 34px; height: 34px; flex:none; border-radius: 8px;
  display:grid; place-items:center; background: var(--surface-3); color: var(--accent);
  border: 1px solid var(--hairline-2); font-size: 15px;
}
.mini-main { min-width:0; flex:1; }
.mini-main .t { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.mini-main .s { font-size: 12px; color: var(--muted); }
.mini-amt { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13.5px; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filterbar { display:flex; gap: 10px; flex-wrap: wrap; align-items:center; margin-bottom: 18px; }
.field {
  display:flex; align-items:center; gap: 8px;
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-sm); padding: 9px 13px; font-size: 13px; color: var(--muted);
}
.field input, .field select {
  border:none; background:none; outline:none; font-family: inherit; font-size: 13px; color: var(--ink);
}
.field input { width: 200px; }
.seg { display:flex; background: var(--surface); border:1px solid var(--hairline); border-radius: var(--r-sm); overflow:hidden; }
.seg button, .seg a {
  display: inline-block;
  border:none; background:none; padding: 9px 14px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); cursor:pointer; border-right: 1px solid var(--hairline);
  white-space: nowrap;
}
.seg button:last-child, .seg a:last-child { border-right: none; }
.seg button.on, .seg a.on { background: var(--accent); color: #fcfbf8; }

/* ============================================================
   ORDER DETAIL
   ============================================================ */

/* progress stepper — Confirmed → Design → Production → Dispatch → Delivered */
.stepper {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 20px 18px 16px;
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.step { flex: 1; min-width: 92px; position: relative; text-align: center; }
.step:not(:first-child)::before {
  content: ""; position: absolute;
  top: 13px; right: 50%; width: 100%; height: 2px;
  background: var(--hairline-2); z-index: 1;
}
.step.done:not(:first-child)::before,
.step.current:not(:first-child)::before { background: var(--accent); }
.step .dot {
  width: 27px; height: 27px; border-radius: 50%;
  margin: 0 auto 9px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 2px solid var(--hairline-2);
  color: var(--muted);
  font-size: 12px; font-weight: 600;
  position: relative; z-index: 2;
}
.step.done .dot { background: var(--accent); border-color: var(--accent); color: #fcfbf8; }
.step.current .dot {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.step .slbl {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; line-height: 1.35;
  padding: 0 4px;
}
.step.done .slbl, .step.current .slbl { color: var(--accent); font-weight: 600; }
.detail-head { display:flex; align-items:center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.back-btn {
  width: 40px; height: 40px; flex:none; border-radius: var(--r-sm);
  border: 1px solid var(--hairline-2); background: var(--surface);
  display:grid; place-items:center; cursor:pointer; color: var(--ink-soft); font-size: 17px;
}
.back-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.detail-head .dh-no { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--ink); }
.detail-head .dh-sub { font-size: 12.5px; color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(0,1fr); gap: 20px; align-items: start; }

/* estimate document */
.estimate {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--accent-bright);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.est-pad { padding: 34px 38px; }
.est-top { display:flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.est-biz-name { font-family: var(--heading-family); font-size: 26px; font-weight: 600; color: var(--ink); letter-spacing:.3px; line-height: 1.15; margin-bottom: 8px; max-width: 16ch; }
.est-biz-addr { font-size: 12px; color: var(--muted); line-height: 1.55; }
.est-top > div:first-child { min-width: 200px; }
.est-word { text-align: right; }
.est-word .w { font-family: var(--heading-family); font-size: 34px; font-weight: 600; letter-spacing: 6px; color: var(--accent-bright); text-transform: uppercase; }
.est-word .n { font-family: var(--font-mono); font-size: 13px; color: var(--muted); margin-top: 2px; }
.est-rule { height:1px; background: var(--accent-bright); opacity:.55; margin: 22px 0; }
.est-meta { display:grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-bottom: 26px; }
.est-meta .lbl { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); font-weight:600; }
.est-meta .val { font-weight: 600; color: var(--ink); margin-top: 4px; font-size: 14px; }
.est-line-title { font-family: var(--heading-family); font-size: 21px; font-weight: 600; color: var(--ink); margin: 0 0 14px; }
.est-line-title em { font-style: italic; }

.est-table { width:100%; border-collapse: collapse; font-size: 13.5px; }
.est-table thead th {
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 700;
  text-align: left; padding: 9px 12px; background: var(--surface-3); border-bottom: 1px solid var(--hairline-2);
}
.est-table thead th.r { text-align: right; }
.est-table tbody td { padding: 12px; border-bottom: 1px solid var(--hairline); color: var(--ink-soft); }
.est-table tbody td.r { text-align: right; font-variant-numeric: tabular-nums; }
.est-table tbody td .d-main { color: var(--ink); font-weight: 500; }
.est-table tbody td .d-spec { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.est-subtotal td { border-top: 2px solid var(--hairline-2); font-weight: 600; color: var(--ink); padding-top: 13px; }

.est-totals { display:flex; justify-content: flex-end; margin-top: 16px; }
.est-totals-inner { width: 290px; }
.est-totals-inner .row { display:flex; justify-content: space-between; padding: 7px 0; font-size: 13.5px; color: var(--ink-soft); }
.grand {
  display:flex; justify-content: space-between; align-items:center;
  flex-wrap: wrap; gap: 4px 12px;
  background: var(--accent); color: #f1ece3;
  padding: 16px 22px; margin-top: 16px; border-radius: 0;
}
.grand .gl { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 600; }
.grand .gv { font-family: var(--heading-family); font-size: 30px; font-weight: 600; color: var(--accent-bright); font-variant-numeric: tabular-nums; }

.est-notes { margin-top: 26px; }
.est-notes .nh { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent-bright); font-weight: 700; margin-bottom: 10px; }
.est-notes ul { margin: 0; padding-left: 18px; }
.est-notes li { font-size: 12px; color: var(--muted); line-height: 1.7; }

/* response bar */
.respond {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r); box-shadow: var(--shadow-sm); margin-top: 20px; overflow: hidden;
}
.respond-head {
  background: var(--neg-bg); color: var(--neg);
  padding: 13px 22px; font-size: 12px; letter-spacing: 1.4px; text-transform: uppercase; font-weight: 700;
  display:flex; align-items:center; gap: 8px; border-bottom: 1px solid var(--neg-line);
}
.respond-body { padding: 20px 22px; display:flex; gap: 12px; flex-wrap: wrap; }

/* CAD card — red: approval blocks production until the customer acts */
.cad-banner {
  background: var(--surface); border:1px solid var(--neg-line); border-left: 3px solid var(--neg);
  border-radius: var(--r); box-shadow: var(--shadow-sm); margin-bottom: 20px; overflow:hidden;
}
.cad-banner .ch { padding: 14px 22px; background: var(--neg-bg); color: var(--neg); font-weight: 700; font-size: 13px; letter-spacing:.4px; display:flex; align-items:center; gap:8px; border-bottom:1px solid var(--neg-line); }
.cad-banner .cb { padding: 22px; }

/* placeholder media */
.ph {
  position: relative; border-radius: var(--r-sm); overflow:hidden;
  background-color: var(--surface-3);
  background-image: repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(169,126,60,.07) 9px, rgba(169,126,60,.07) 18px);
  border: 1px dashed var(--hairline-2);
  display:grid; place-items:center;
}
.ph .ph-label { font-family: var(--font-mono); font-size: 11px; color: var(--faint); letter-spacing: .5px; text-align:center; padding: 8px; }

/* definition rows */
.dl { display: grid; grid-template-columns: 38% 1fr; }
.dl dt { padding: 11px 0; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--hairline); }
.dl dd { padding: 11px 0; margin: 0; font-size: 13.5px; color: var(--ink); border-bottom: 1px solid var(--hairline); }
.dl > dt:last-of-type, .dl > dd:last-of-type { border-bottom: none; }

/* timeline */
.timeline { position: relative; padding-left: 6px; }
.tl-item { position: relative; padding: 0 0 22px 28px; }
.tl-item::before {
  content:""; position:absolute; left: 5px; top: 16px; bottom: -6px; width: 1.5px; background: var(--hairline-2);
}
.tl-item:last-child::before { display:none; }
.tl-dot {
  position:absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--hairline-2);
}
.tl-item.done .tl-dot { background: var(--accent); border-color: var(--accent); }
.tl-item.current .tl-dot { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-status { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tl-note { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; background: var(--surface-2); border:1px solid var(--hairline); padding: 8px 11px; border-radius: var(--r-sm); }

/* invoice mini in detail */
.inv-mini { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 18px; }
.inv-mini .k { font-size: 11.5px; color: var(--muted); }
.inv-mini .v { font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ============================================================
   FORMS
   ============================================================ */
.form-card { max-width: 760px; }
.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.lbl { display:block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; letter-spacing:.2px; }
.lbl .req { color: var(--neg); }
.inp, .sel, .ta {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--hairline-2); border-radius: var(--r-sm);
  padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus, .sel:focus, .ta:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ta { resize: vertical; min-height: 96px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.check { display:flex; gap: 10px; align-items:flex-start; padding: 12px 14px; border:1px solid var(--hairline); border-radius: var(--r-sm); background: var(--surface-2); cursor:pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check .ct { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.check .cs { font-size: 12px; color: var(--muted); }

.dropzone {
  border: 1.5px dashed var(--hairline-2); border-radius: var(--r); background: var(--surface-2);
  padding: 30px; text-align:center; color: var(--muted);
}
.dropzone .bi { font-size: 28px; color: var(--accent); }
.dropzone .dz-t { font-weight: 600; color: var(--ink-soft); margin-top: 8px; font-size: 14px; }
.dropzone .dz-s { font-size: 12px; margin-top: 3px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-stage {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-art {
  background: var(--sidebar-bg);
  position: relative; overflow: hidden;
  display:flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  color: #EDEAE2;
}
.login-art::after {
  content:""; position:absolute; right:-120px; bottom:-120px; width: 420px; height: 420px;
  border: 1px solid rgba(252,251,248,.18); transform: rotate(45deg);
}
.login-art::before {
  content:""; position:absolute; right:-40px; bottom:-40px; width: 260px; height: 260px;
  border: 1px solid rgba(252,251,248,.12); transform: rotate(45deg);
}
.la-brand { display:flex; align-items:center; gap: 13px; position: relative; z-index:2; }
.la-quote { position: relative; z-index: 2; max-width: 30ch; }
.la-quote .q { font-family: var(--heading-family); font-size: 34px; line-height: 1.18; font-weight: 500; }
.la-quote .q em { font-style: italic; color: var(--accent-bright); }
.la-quote .by { margin-top: 16px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sidebar-dim); }
.la-badges { display:flex; gap: 18px; position:relative; z-index:2; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--sidebar-dim); }

.login-form-wrap { display:grid; place-items:center; padding: 40px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card.wide { max-width: 620px; }
.login-card h2 { font-family: var(--heading-family); font-size: 30px; font-weight: 600; margin: 0 0 6px; }
.login-card h2 em { font-style: italic; color: var(--accent); }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.field-group { margin-bottom: 18px; }
.field-row { display:grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.input-affix { display:flex; align-items:center; background: var(--surface); border: 1px solid var(--hairline-2); border-radius: var(--r-sm); padding: 0 13px; transition: border-color .15s, box-shadow .15s; }
.input-affix.affix-top { align-items: flex-start; }
.input-affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-affix .bi { color: var(--muted); }
.input-affix .bi.pt { margin-top: 13px; }
.input-affix input, .input-affix textarea { border:none; outline:none; background:none; padding: 12px; font-family: inherit; font-size: 14px; width: 100%; color: var(--ink); }
.input-affix textarea { resize: vertical; min-height: 66px; }
.input-affix button { border:none; background:none; color: var(--muted); cursor:pointer; padding: 6px; }
.field-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.form-switch-link { text-align:center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.form-switch-link a { color: var(--accent); font-weight: 600; text-decoration:none; }
.form-switch-link a:hover { text-decoration: underline; }

/* empty state */
.empty { text-align:center; padding: 60px 20px; color: var(--muted); }
.empty .bi { font-size: 40px; color: var(--hairline-2); }
.empty .et { font-size: 15px; margin-top: 10px; color: var(--ink-soft); }

/* misc */
.summary-strip { display:flex; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.summary-pill {
  background: var(--surface); border:1px solid var(--hairline); border-radius: var(--r);
  padding: 14px 20px; box-shadow: var(--shadow-sm); min-width: 180px;
}
.summary-pill .sl { font-size: 11px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); font-weight:600; }
.summary-pill .sv { font-family: var(--heading-family); font-size: 26px; font-weight:600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.summary-pill .sv.pos { color: var(--pos); }
.summary-pill .sv.neg { color: var(--neg); }

.section-title { display:flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.section-title h2 { font-family: var(--heading-family); font-size: 24px; font-weight: 600; margin: 0; }
.section-title .c { font-size: 13px; color: var(--muted); }

/* ============================================================
   MOBILE NAV (hamburger + off-canvas sidebar)
   ============================================================ */
.menu-btn {
  display: none;
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--hairline-2); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  place-items: center; font-size: 20px; cursor: pointer;
  padding: 0;
}
.nav-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(23,20,12,.45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .two-col, .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }

  /* sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    height: 100dvh; width: min(300px, 84vw);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .25s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: grid; }

  .topbar { padding: 8px 16px; gap: 12px; height: auto; min-height: 60px; }
  .tb-title { font-size: 20px; }
  .tb-eyebrow { font-size: 10px; letter-spacing: 1.5px; }
  .content { padding: 18px 16px 56px; }
  .flash-wrap { padding: 12px 16px 0 !important; }

  .greet h1 { font-size: 28px; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 30px; margin-top: 8px; }

  .filterbar .field { flex: 1 1 100%; }
  .filterbar .field input { width: 100%; flex: 1; }
  .seg { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  .ledger thead th, .ledger tbody td { padding-left: 12px; padding-right: 12px; }

  /* estimate / final bill document */
  .est-pad { padding: 20px 16px; }
  .est-word .w { font-size: 24px; letter-spacing: 3px; }
  .est-meta { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  /* the line-item table scrolls inside the document instead of widening the page */
  .est-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* order numbers wrap at their hyphens, not mid-token */
  .tb-title, .detail-head .dh-no { overflow-wrap: break-word; }
  .card, .estimate, .respond, .cad-banner, .action-card { min-width: 0; }
  .grand { padding: 13px 16px; }
  .grand .gv { font-size: 24px; }
  .est-totals-inner { width: 100%; }
  .respond-body { padding: 16px; }
  .respond-body .btn { flex: 1 1 auto; justify-content: center; }
  .cad-banner .cb { padding: 16px; }

  .form-grid { grid-template-columns: 1fr; }
  .card-body { padding: 16px; }

  .login-stage { grid-template-columns: 1fr; }
  .login-art { display:none; }
  .login-form-wrap { padding: 24px 18px; align-items: start; padding-top: 12vh; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}

/* columns that add little on a phone — hidden below 640px */
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
}

@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .summary-pill { min-width: 0; flex: 1 1 45%; padding: 12px 14px; }
  .summary-pill .sv { font-size: 20px; }
  .detail-head .dh-no { font-size: 18px; }

  /* definition rows stack */
  .dl { grid-template-columns: 1fr; }
  .dl dt { padding: 9px 0 0; border-bottom: none; font-size: 11.5px; }
  .dl dd { padding: 2px 0 9px; }
  .dl > dt:last-of-type { border-bottom: none; }

  .inv-mini { grid-template-columns: 1fr 1fr; }
  .est-meta { grid-template-columns: 1fr 1fr; }
  .quote-chip { flex: 1 1 100%; justify-content: space-between; }
}
