/* ============================================================================
   TradeOS — Field Operations Platform
   Design system: "Operations console for a piping crew"
   Industrial / utilitarian with craft. Hand-crafted, no framework.
   Built with frontend-design + emil-design-eng principles.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. Tokens
---------------------------------------------------------------------------- */
:root {
  /* Brand — marine blue chrome */
  --brand-900: #081a2e;
  --brand-800: #0a2138;
  --brand-700: #0e2a47;
  --brand-600: #14385c;
  --brand-500: #1d4a76;
  --brand-glow: #2b6cab;

  /* Accent — copper (piping heritage) */
  --accent: #b86a3e;
  --accent-700: #a05530;
  --accent-300: #e7b48f;
  --accent-tint: #f6eadf;

  /* Water — teal highlight */
  --aqua: #0ea5a5;
  --aqua-700: #0c8888;
  --aqua-tint: #e1f4f4;

  /* Neutrals — slate */
  --ink-900: #0f1e2e;
  --ink-800: #1c2f42;
  --ink-700: #33475b;
  --ink-600: #4a5f74;
  --ink-500: #647a8e;
  --ink-400: #8497a9;
  --ink-300: #aabcca;
  --ink-200: #cdd8e2;

  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --surface-3: #eaf0f5;
  --surface-sunken: #eef3f7;
  --line: #e3e9f0;
  --line-strong: #d2dbe4;
  --line-faint: #eef2f6;

  /* Semantic (tinted badge pattern) */
  --ok: #1f9254;        --ok-bg: #e6f5ec;     --ok-ink: #157347;
  --warn: #c97a16;      --warn-bg: #fbefdc;   --warn-ink: #9a5a0c;
  --danger: #d23b3b;    --danger-bg: #fbe8e8; --danger-ink: #b22323;
  --info: #2f6bd6;      --info-bg: #e8effb;   --info-ink: #2256b3;
  --neutral-bg: #eef2f6; --neutral-ink: #51647a;

  /* Production stage legend (their real 4-stage process) */
  --stage-protect: #5e718a;  --stage-protect-bg: #eaeef3;
  --stage-repipe: #b86a3e;   --stage-repipe-bg: #f6eadf;
  --stage-restore: #7c5ccb;  --stage-restore-bg: #ece6fa;
  --stage-certify: #2e9e6b;  --stage-certify-bg: #e3f5ec;
  --stage-scheduled: #9aabbd; --stage-scheduled-bg: #f1f4f8;
  --stage-hold: #d23b3b;     --stage-hold-bg: #fbe8e8;

  /* Type */
  --font-display: 'Archivo', system-ui, sans-serif;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;

  /* Spacing scale (4px base) */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px; --s9: 48px; --s10: 64px;

  /* Radii */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(11,33,56,.06), 0 1px 1px rgba(11,33,56,.04);
  --shadow-md: 0 6px 18px -6px rgba(11,33,56,.16), 0 2px 6px -2px rgba(11,33,56,.08);
  --shadow-lg: 0 22px 48px -16px rgba(11,33,56,.28), 0 8px 18px -10px rgba(11,33,56,.14);
  --shadow-pop: 0 12px 32px -8px rgba(11,33,56,.24);

  /* Motion — Emil's strong custom curves */
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;
}

/* ----------------------------------------------------------------------------
   2. Reset & base
---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-800);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "cv05" 1;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.015em; color: var(--ink-900); margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent-tint); color: var(--accent-700); }

/* Tabular figures + mono helpers */
.num, .mono, td .num, .kpi-card__value, .money { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1; letter-spacing: -.01em; }
.muted { color: var(--ink-500); }
.faint { color: var(--ink-400); }
.eyebrow {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-400); font-family: var(--font-sans);
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-300); background-clip: content-box; }

/* ----------------------------------------------------------------------------
   3. Layout shell
---------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* Subtle film-grain overlay for atmosphere */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: .025; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Sidebar */
.sidebar {
  background: linear-gradient(180deg, var(--brand-700) 0%, var(--brand-800) 60%, var(--brand-900) 100%);
  color: #d8e3ef; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid rgba(0,0,0,.2);
}
.sidebar::before { /* blueprint grid */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
          mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px;
  position: relative; z-index: 1;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-700) 100%);
  display: grid; place-items: center; color: #fff; font-family: var(--font-display);
  font-weight: 800; font-size: 17px; letter-spacing: -.04em;
  box-shadow: 0 4px 12px -2px rgba(184,106,62,.5), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark::after { content: ""; position: absolute; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: #fff; letter-spacing: -.02em; line-height: 1; }
.brand-sub { font-size: 9.5px; text-transform: uppercase; letter-spacing: .15em; color: #7d97b3; margin-top: 3px; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 6px 12px 16px; position: relative; z-index: 1; }
.nav-section { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: #607a93; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 8.5px 10px; border-radius: 8px;
  color: #c0d0e0; font-size: 13px; font-weight: 500; position: relative;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.is-active { background: rgba(184,106,62,.16); color: #fff; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item.is-active .nav-icon { color: var(--accent-300); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; color: #8aa1b8; }
.nav-item:hover .nav-icon { color: #cfe0f0; }
.nav-badge { margin-left: auto; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: rgba(255,255,255,.1); color: #d8e6f2; font-variant-numeric: tabular-nums; }
.nav-badge--accent { background: var(--accent); color: #fff; }

.sidebar__foot { padding: 12px; position: relative; z-index: 1; border-top: 1px solid rgba(255,255,255,.07); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; transition: background-color .15s ease; }
.user-chip:hover { background: rgba(255,255,255,.06); }
.user-chip__name { font-size: 12.5px; font-weight: 600; color: #fff; line-height: 1.2; }
.user-chip__role { font-size: 10.5px; color: #7d97b3; }

/* Main column */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  height: var(--topbar-h); flex: 0 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 0 24px; background: rgba(255,255,255,.82); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
}
.topbar__search {
  flex: 1; max-width: 440px; display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; color: var(--ink-400); transition: border-color .15s ease, box-shadow .15s ease;
}
.topbar__search:hover { border-color: var(--line-strong); }
.topbar__search:focus-within { border-color: var(--accent-300); box-shadow: 0 0 0 3px var(--accent-tint); }
.topbar__search input { border: 0; background: transparent; outline: none; flex: 1; font: inherit; font-size: 13px; color: var(--ink-800); }
.topbar__search kbd { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-400); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.office-switcher {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-700);
  transition: border-color .15s ease, transform .12s var(--ease-out);
}
.office-switcher:hover { border-color: var(--line-strong); }
.office-switcher:active { transform: scale(.98); }
.office-switcher .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 3px var(--aqua-tint); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink-600); position: relative;
  transition: border-color .15s ease, color .15s ease, transform .12s var(--ease-out);
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink-900); }
.icon-btn:active { transform: scale(.95); }
.icon-btn .dot-count { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }

.content { flex: 1; padding: 26px 28px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* ----------------------------------------------------------------------------
   4. Page header
---------------------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 25px; line-height: 1.1; }
.page-sub { color: var(--ink-500); font-size: 13.5px; margin-top: 5px; }
.page-head__actions { display: flex; gap: 10px; align-items: center; }
.breadcrumb { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-400); margin-bottom: 9px; }
.breadcrumb a:hover { color: var(--accent-700); }
.breadcrumb .sep { opacity: .5; }

/* ----------------------------------------------------------------------------
   5. Buttons
---------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-800); font-size: 13px; font-weight: 600;
  transition: transform .12s var(--ease-out), border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-300); background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn svg { width: 16px; height: 16px; }
.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-700) 100%);
  border-color: var(--accent-700); color: #fff;
  box-shadow: 0 2px 8px -2px rgba(184,106,62,.5), inset 0 1px 0 rgba(255,255,255,.2);
}
.btn--primary:hover { background: linear-gradient(180deg, #c1764a 0%, var(--accent-700) 100%); border-color: var(--accent-700); }
.btn--dark { background: var(--brand-700); border-color: var(--brand-800); color: #fff; }
.btn--dark:hover { background: var(--brand-600); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-600); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink-900); }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn--block { width: 100%; }

/* ----------------------------------------------------------------------------
   6. Badges / chips / pills
---------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-ink);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--danger { background: var(--danger-bg); color: var(--danger-ink); }
.badge--info { background: var(--info-bg); color: var(--info-ink); }
.badge--accent { background: var(--accent-tint); color: var(--accent-700); }
.badge--aqua { background: var(--aqua-tint); color: var(--aqua-700); }
.badge.no-dot::before { display: none; }
.badge--lg { height: 26px; font-size: 12.5px; padding: 0 11px; }

/* Stage pills (shared legend everywhere) */
.stage { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1; }
.stage::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.stage-protect { background: var(--stage-protect-bg); color: var(--stage-protect); }
.stage-repipe { background: var(--stage-repipe-bg); color: var(--stage-repipe); }
.stage-restore { background: var(--stage-restore-bg); color: var(--stage-restore); }
.stage-certify { background: var(--stage-certify-bg); color: var(--stage-certify); }
.stage-scheduled { background: var(--stage-scheduled-bg); color: #6a7d90; }
.stage-hold { background: var(--stage-hold-bg); color: var(--stage-hold); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; color: var(--ink-600); }
.chip svg { width: 13px; height: 13px; }
.chip--source { background: var(--surface); }
.tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); }

/* ----------------------------------------------------------------------------
   7. Cards & surfaces
---------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-faint); }
.card__title { font-size: 14px; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; color: var(--ink-900); }
.card__body { padding: 18px; }
.card--pad { padding: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.section-gap { margin-top: 22px; }

/* Generic grid helpers */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------------------
   8. KPI cards
---------------------------------------------------------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi-card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-sm); overflow: hidden;
}
.kpi-card::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: 0; transition: opacity .2s ease; }
.kpi-card:hover::after { opacity: .8; }
.kpi-card__label { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: var(--ink-500); }
.kpi-card__icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-600); margin-bottom: 12px; }
.kpi-card__icon svg { width: 16px; height: 16px; }
.kpi-card__icon.is-accent { background: var(--accent-tint); color: var(--accent-700); }
.kpi-card__icon.is-aqua { background: var(--aqua-tint); color: var(--aqua-700); }
.kpi-card__icon.is-ok { background: var(--ok-bg); color: var(--ok-ink); }
.kpi-card__value { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: -.02em; color: var(--ink-900); line-height: 1.05; margin-top: 10px; }
.kpi-card__foot { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 12px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: 11.5px; }
.delta svg { width: 13px; height: 13px; }
.delta--up { color: var(--ok-ink); }
.delta--down { color: var(--danger-ink); }

/* ----------------------------------------------------------------------------
   9. Tables
---------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-400); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
}
table.data tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-faint); color: var(--ink-700); vertical-align: middle; }
table.data tbody tr { transition: background-color .12s ease; }
table.data tbody tr:hover { background: var(--surface-2); cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .td-strong { font-weight: 600; color: var(--ink-900); }
table.data th.r, table.data td.r { text-align: right; }

/* ----------------------------------------------------------------------------
   10. Avatars
---------------------------------------------------------------------------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: 0 0 auto; font-family: var(--font-display); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.avatar--sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--lg { width: 46px; height: 46px; font-size: 16px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }
.a-blue { background: linear-gradient(135deg,#2e6cb0,#1d4a76); }
.a-copper { background: linear-gradient(135deg,#c8794d,#a05530); }
.a-teal { background: linear-gradient(135deg,#1bb3b3,#0c8888); }
.a-violet { background: linear-gradient(135deg,#8f6fd6,#6f4fc0); }
.a-slate { background: linear-gradient(135deg,#6c7f93,#4a5f74); }
.a-green { background: linear-gradient(135deg,#3aab74,#1f8a57); }

/* ----------------------------------------------------------------------------
   11. Progress
---------------------------------------------------------------------------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress__bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #cf8a5f); transition: width .6s var(--ease-out); }
.progress__bar.is-aqua { background: linear-gradient(90deg, var(--aqua), #38c3c3); }
.progress__bar.is-green { background: linear-gradient(90deg, var(--ok), #3fbf78); }
.progress--thin { height: 5px; }

/* ----------------------------------------------------------------------------
   12. Timeline
---------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline__item { position: relative; padding-bottom: 18px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { position: absolute; left: -26px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); display: grid; place-items: center; }
.timeline__dot svg { width: 10px; height: 10px; color: var(--ink-400); }
.timeline__dot.is-accent { border-color: var(--accent); background: var(--accent-tint); }
.timeline__dot.is-accent svg { color: var(--accent-700); }
.timeline__dot.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.timeline__dot.is-ok svg { color: var(--ok-ink); }
.timeline__time { font-size: 11px; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.timeline__title { font-size: 13px; font-weight: 600; color: var(--ink-800); }
.timeline__body { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }

/* ----------------------------------------------------------------------------
   13. Tabs
---------------------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 2px; background: var(--surface-3); padding: 4px; border-radius: 10px; }
.tab { padding: 7px 14px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-500); border: 0; background: transparent; transition: color .15s ease, background-color .15s ease; }
.tab:hover { color: var(--ink-800); }
.tab.is-active { background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-sm); }

/* ----------------------------------------------------------------------------
   14. Forms
---------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 11.5px; font-weight: 600; color: var(--ink-600); }
.input, .select { height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); font: inherit; font-size: 13px; color: var(--ink-800); transition: border-color .15s ease, box-shadow .15s ease; width: 100%; }
.input:focus, .select:focus { outline: none; border-color: var(--accent-300); box-shadow: 0 0 0 3px var(--accent-tint); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 84px; line-height: 1.5; }
.checkline { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); transition: border-color .15s ease, background-color .15s ease; }
.checkline + .checkline { margin-top: 8px; }
.check-ico { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; flex: 0 0 auto; }
.check-ico.on { background: var(--ok-bg); color: var(--ok-ink); }
.check-ico.off { background: var(--surface-3); color: var(--ink-300); }
.check-ico.flag { background: var(--warn-bg); color: var(--warn-ink); }
.check-ico svg { width: 13px; height: 13px; }

/* ----------------------------------------------------------------------------
   15. Skeleton / empty / toast
---------------------------------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, #e9eef3 25%, #dde5ec 37%, #e9eef3 63%); background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 48px 24px; }
.empty-state__icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-300); margin-bottom: 14px; }
.empty-state__icon svg { width: 26px; height: 26px; }
.empty-state h3 { font-size: 15px; margin-bottom: 4px; }
.empty-state p { color: var(--ink-500); font-size: 13px; max-width: 320px; }

.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 9000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 12px;
  background: var(--brand-700); color: #fff; box-shadow: var(--shadow-lg); min-width: 300px; max-width: 380px;
  opacity: 1; transform: translateY(0) scale(1); transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.toast[data-leaving="true"] { opacity: 0; transform: translateY(8px) scale(.98); }
.toast__icon { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.14); display: grid; place-items: center; flex: 0 0 auto; color: #8fe6c9; }
.toast__icon svg { width: 16px; height: 16px; }
.toast__title { font-size: 13px; font-weight: 600; }
.toast__body { font-size: 12px; color: #b9cbdc; margin-top: 1px; }
@starting-style { .toast { opacity: 0; transform: translateY(12px) scale(.97); } }

/* ----------------------------------------------------------------------------
   16. Stagger reveal (page load)
---------------------------------------------------------------------------- */
.reveal > * { opacity: 0; transform: translateY(10px); animation: reveal .5s var(--ease-out) forwards; }
.reveal > *:nth-child(1) { animation-delay: 0ms; }
.reveal > *:nth-child(2) { animation-delay: 45ms; }
.reveal > *:nth-child(3) { animation-delay: 90ms; }
.reveal > *:nth-child(4) { animation-delay: 135ms; }
.reveal > *:nth-child(5) { animation-delay: 180ms; }
.reveal > *:nth-child(6) { animation-delay: 225ms; }
.reveal > *:nth-child(7) { animation-delay: 270ms; }
.reveal > *:nth-child(8) { animation-delay: 315ms; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* ----------------------------------------------------------------------------
   17. Module: Kanban (Leads & CRM)
---------------------------------------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 13px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.kanban__col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; min-height: 220px; transition: background-color .15s ease, border-color .15s ease; }
.kanban__col.drop-on { background: var(--accent-tint); border-color: var(--accent-300); border-style: dashed; }
.kanban__head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 10px; }
.kanban__head .dot { width: 8px; height: 8px; border-radius: 50%; }
.kanban__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-600); }
.kanban__count { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--ink-400); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.kanban__body { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 9px; }
.kanban__sum { padding: 0 14px 12px; font-size: 11.5px; color: var(--ink-400); font-weight: 600; }
.lead-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px;
  box-shadow: var(--shadow-sm); cursor: grab; transition: transform .14s var(--ease-out), box-shadow .15s ease, border-color .15s ease;
}
.lead-card:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); transform: translateY(-1px); }
.lead-card:active { cursor: grabbing; }
.lead-card.dragging { opacity: .45; }
.lead-card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.lead-card__name { font-size: 13px; font-weight: 700; color: var(--ink-900); line-height: 1.25; }
.lead-card__addr { font-size: 11.5px; color: var(--ink-500); margin-top: 2px; }
.lead-card__meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.lead-card__val { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--ink-900); }
.lead-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line-faint); }

/* ----------------------------------------------------------------------------
   18. Module: Projects — unit matrix + stepper
---------------------------------------------------------------------------- */
.unit-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.unit-cell {
  border-radius: 11px; padding: 11px 12px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; position: relative; overflow: hidden; transition: transform .14s var(--ease-out), box-shadow .15s ease;
  text-align: left;
}
.unit-cell:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.unit-cell:active { transform: translateY(0) scale(.98); }
.unit-cell::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c, var(--line-strong)); }
.unit-cell__no { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--ink-900); }
.unit-cell__type { font-size: 10.5px; color: var(--ink-400); margin-top: 1px; }
.unit-cell__stage { margin-top: 10px; font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 5px; color: var(--c, var(--ink-500)); }
.unit-cell__stage .d { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-300)); }
.unit-cell[data-stage="protect"] { --c: var(--stage-protect); }
.unit-cell[data-stage="repipe"] { --c: var(--stage-repipe); }
.unit-cell[data-stage="restore"] { --c: var(--stage-restore); }
.unit-cell[data-stage="certify"] { --c: var(--stage-certify); }
.unit-cell[data-stage="scheduled"] { --c: var(--stage-scheduled); }
.unit-cell[data-stage="certify"] { background: linear-gradient(180deg,#fff, #f3faf5); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.legend__item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; color: var(--ink-600); }
.legend__item .d { width: 9px; height: 9px; border-radius: 3px; }

/* Stepper (single-unit 4-stage) */
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; position: relative; }
.step { position: relative; padding: 0 10px; text-align: center; }
.step::before { content: ""; position: absolute; top: 17px; left: -50%; width: 100%; height: 2px; background: var(--line-strong); z-index: 0; }
.step:first-child::before { display: none; }
.step.done::before { background: var(--stage-certify); }
.step__dot { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-strong); color: var(--ink-400); }
.step__dot svg { width: 17px; height: 17px; }
.step.done .step__dot { background: var(--stage-certify); border-color: var(--stage-certify); color: #fff; }
.step.active .step__dot { border-color: var(--accent); color: var(--accent-700); background: var(--accent-tint); box-shadow: 0 0 0 5px var(--accent-tint); }
.step__name { font-size: 12.5px; font-weight: 700; color: var(--ink-800); }
.step__meta { font-size: 11px; color: var(--ink-400); margin-top: 2px; }

.photo-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo { border-radius: 11px; overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4/3; position: relative; background: var(--surface-3); }
.photo .ph-label { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: rgba(15,30,46,.7); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(4px); }
.photo img { width: 100%; height: 100%; object-fit: cover; }

/* mini list rows */
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-faint); }
.row-item:last-child { border-bottom: 0; }

/* ----------------------------------------------------------------------------
   19. Module: Dispatch (swimlanes)
---------------------------------------------------------------------------- */
.dispatch { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.dispatch__grid { display: grid; grid-template-columns: 132px repeat(5, 1fr); }
.dispatch__corner { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface-2); }
.dispatch__dayhead { padding: 10px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-faint); background: var(--surface-2); text-align: center; }
.dispatch__dayhead:last-child { border-right: 0; }
.dispatch__dayhead .dow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); }
.dispatch__dayhead .date { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--ink-900); }
.dispatch__dayhead.today .date { color: var(--accent-700); }
.lane-label { padding: 14px 12px; border-bottom: 1px solid var(--line-faint); border-right: 1px solid var(--line); background: var(--surface-2); display: flex; align-items: center; gap: 9px; }
.lane-label__name { font-size: 12px; font-weight: 700; color: var(--ink-800); line-height: 1.15; }
.lane-label__role { font-size: 10.5px; color: var(--ink-400); }
.lane-cell { border-bottom: 1px solid var(--line-faint); border-right: 1px solid var(--line-faint); padding: 7px; min-height: 78px; display: flex; flex-direction: column; gap: 6px; }
.lane-cell:nth-child(6n) { border-right: 0; }
.job-block {
  border-radius: 9px; padding: 8px 9px; font-size: 11.5px; cursor: pointer; border-left: 3px solid var(--c, var(--ink-300));
  background: var(--cb, var(--surface-2)); transition: transform .12s var(--ease-out), box-shadow .15s ease;
}
.job-block:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.job-block:active { transform: scale(.98); }
.job-block[data-stage="repipe"] { --c: var(--stage-repipe); --cb: var(--stage-repipe-bg); }
.job-block[data-stage="restore"] { --c: var(--stage-restore); --cb: var(--stage-restore-bg); }
.job-block[data-stage="certify"] { --c: var(--stage-certify); --cb: var(--stage-certify-bg); }
.job-block[data-stage="protect"] { --c: var(--stage-protect); --cb: var(--stage-protect-bg); }
.job-block__t { font-weight: 700; color: var(--ink-900); line-height: 1.2; }
.job-block__sub { color: var(--ink-600); margin-top: 2px; }
.job-block__water { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 10.5px; font-weight: 600; color: var(--aqua-700); }
.job-block__water svg { width: 12px; height: 12px; }

/* ----------------------------------------------------------------------------
   20. Module: Estimates — Good/Better/Best
---------------------------------------------------------------------------- */
.gbb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.gbb-card { position: relative; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); padding: 20px; transition: transform .16s var(--ease-out), box-shadow .2s ease, border-color .2s ease; }
.gbb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.gbb-card--featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-md); }
.gbb-card--featured::before { content: "Recommended"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg,var(--accent),var(--accent-700)); color: #fff; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 12px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.gbb-card__tier { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); }
.gbb-card__name { font-family: var(--font-display); font-weight: 800; font-size: 19px; color: var(--ink-900); margin-top: 2px; }
.gbb-card__price { font-family: var(--font-display); font-weight: 800; font-size: 34px; letter-spacing: -.02em; color: var(--ink-900); margin: 12px 0 2px; }
.gbb-card__price .cents { font-size: 16px; color: var(--ink-400); }
.gbb-feature { display: flex; align-items: flex-start; gap: 9px; padding: 8px 0; font-size: 12.5px; color: var(--ink-700); border-top: 1px solid var(--line-faint); }
.gbb-feature svg { width: 15px; height: 15px; color: var(--ok); flex: 0 0 auto; margin-top: 1px; }
.gbb-feature.off { color: var(--ink-300); }
.gbb-feature.off svg { color: var(--ink-200); }

.lineitems { width: 100%; border-collapse: collapse; font-size: 13px; }
.lineitems th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.lineitems td { padding: 11px 12px; border-bottom: 1px solid var(--line-faint); }
.lineitems tr.group td { background: var(--surface-2); font-weight: 700; color: var(--ink-700); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.lineitems .r { text-align: right; font-variant-numeric: tabular-nums; }
.lineitems tfoot td { padding: 10px 12px; font-weight: 700; }
.lineitems tfoot tr.total td { font-family: var(--font-display); font-size: 16px; color: var(--ink-900); border-top: 2px solid var(--line-strong); }

/* ----------------------------------------------------------------------------
   21. Module: Customer Portal
---------------------------------------------------------------------------- */
.portal-frame { border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-md); }
.portal-top { background: linear-gradient(135deg, var(--brand-700), var(--brand-800)); color: #fff; padding: 22px 24px; position: relative; overflow: hidden; }
.portal-top::after { content: ""; position: absolute; inset: 0; opacity: .4; background-image: linear-gradient(rgba(255,255,255,.05) 1px,transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px,transparent 1px); background-size: 22px 22px; -webkit-mask-image: radial-gradient(circle at 80% 20%, #000, transparent 70%); mask-image: radial-gradient(circle at 80% 20%, #000, transparent 70%); }
.portal-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #9fd5d5; }

/* ----------------------------------------------------------------------------
   22. Module: Inventory / stock bar
---------------------------------------------------------------------------- */
.stock-bar { width: 88px; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; display: inline-block; vertical-align: middle; }
.stock-bar > span { display: block; height: 100%; border-radius: 999px; }
.stock-ok > span { background: var(--ok); }
.stock-low > span { background: var(--warn); }
.stock-crit > span { background: var(--danger); }

/* ----------------------------------------------------------------------------
   23. Misc helpers
---------------------------------------------------------------------------- */
.divider { height: 1px; background: var(--line-faint); margin: 16px 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.dl dt { color: var(--ink-500); }
.dl dd { margin: 0; color: var(--ink-900); font-weight: 600; text-align: right; }
.notice { display: flex; gap: 11px; padding: 13px 15px; border-radius: 11px; background: var(--warn-bg); border: 1px solid #f0dcb6; color: var(--warn-ink); font-size: 12.5px; }
.notice svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.notice--info { background: var(--info-bg); border-color: #c9d9f5; color: var(--info-ink); }
.notice--accent { background: var(--accent-tint); border-color: var(--accent-300); color: var(--accent-700); }
.dot-sep { color: var(--ink-300); }
.attn-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-faint); }
.attn-item:last-child { border-bottom: 0; }
.attn-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto; }
.attn-ico svg { width: 16px; height: 16px; }

.util-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.util-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--aqua), #34c0c0); border-radius: 999px; }
.util-bar.high > span { background: linear-gradient(90deg, var(--warn), #e09a3c); }

/* ----------------------------------------------------------------------------
   24. Responsive
---------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  :root { --sidebar-w: 70px; }
  .brand-name, .brand-sub, .nav-item span, .nav-section, .nav-badge, .user-chip__name, .user-chip__role { display: none; }
  .sidebar__brand { justify-content: center; padding: 16px 0; }
  .nav-item { justify-content: center; padding: 11px; }
  .nav-item.is-active::before { display: none; }
  .g-4, .g-3, .g-2 { grid-template-columns: 1fr 1fr; }
  .gbb-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .content { padding: 18px 14px 50px; }
  .g-4, .g-3, .g-2, .grid { grid-template-columns: 1fr; }
  .topbar__search { display: none; }
  .stepper { grid-template-columns: 1fr 1fr; gap: 18px 0; }
}

/* Responsive column layouts (avoid inline grid so collapse works) */
.cols { display: grid; gap: 18px; align-items: start; }
.cols-21 { grid-template-columns: 2fr 1fr; }
.cols-32 { grid-template-columns: 1.55fr 1fr; }
.cols-11 { grid-template-columns: 1fr 1fr; }
.cols-side { grid-template-columns: 1fr 330px; }
.cols-side-l { grid-template-columns: 300px 1fr; }
@media (max-width: 1100px) { .cols-21, .cols-32, .cols-11, .cols-side, .cols-side-l { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .reveal > * { opacity: 1; transform: none; }
}
