/* BullQuote design system
   Navy carries structure, blue carries interaction, orange is reserved for the one
   primary action on a screen and for the profit target. Figures use DIN (macOS) or
   Bahnschrift (Windows): the typeface of engineering drawings and site signage. */
:root {
  --navy-950: #081428;
  --navy-900: #0B1C36;
  --navy-800: #13294B;
  --navy-700: #1F3A64;
  --navy-500: #4A6185;
  --blue-600: #1F56D0;
  --blue-500: #2E6BEB;
  --blue-100: #E3ECFD;
  --blue-50:  #F2F6FE;
  --orange-500: #FF6E00;   /* BullQuote orange: fills, buttons, accents. Pair with navy text (6.5:1), never white text */
  --orange-600: #E86400;   /* pressed */
  --orange-700: #B54800;   /* orange text on white (5.4:1) */
  --orange-100: #FFE9D9;
  --paper: #F4F6F9;
  --white: #FFFFFF;
  --ink: #0B1C36;
  --ink-2: #33445E;
  --muted: #56667E;   /* 4.97:1 on #E9EDF3 chips, 5.8:1 on white (WCAG AA) */
  --faint: #627188;   /* darkened from #8C99AD (2.9:1) to pass WCAG AA on white and paper */
  --line: #DFE5EE;
  --line-strong: #C9D2DF;
  --green-700: #116B3E; --green-100: #DDF3E6;
  --red-700: #B42A24;   --red-100: #FCE4E2;
  --amber-700: #8F5A0B; --amber-100: #FCEFD5;
  --violet-700: #4B3FB0; --violet-100: #ECEAFD;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-fig: "DIN Alternate", "Bahnschrift", "DIN 2014", "D-DIN", "Roboto Condensed", var(--font-ui);

  --r-sm: 6px; --r-md: 9px; --r-lg: 12px; --r-pill: 999px;
  --shadow-pop: 0 12px 32px -8px rgba(8, 20, 40, .28), 0 2px 6px rgba(8, 20, 40, .08);
  --shadow-panel: 0 1px 0 rgba(8, 20, 40, .04);
  --sidebar-w: 244px;
  --focus: 0 0 0 3px rgba(46, 107, 235, .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font-ui); color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; color: var(--ink); letter-spacing: -0.01em; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; }
h2 { font-size: 17px; line-height: 1.3; font-weight: 650; }
h3 { font-size: 14px; line-height: 1.35; font-weight: 650; }
p { margin: 0; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fig { font-family: var(--font-fig); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--navy-900); color: #C7D3E6; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; color: var(--white); font-weight: 750; font-size: 17px; letter-spacing: -0.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--orange-500); display: grid; place-items: center; color: var(--navy-900); }
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.4; }
.workspace { width: 100%; display: flex; align-items: center; gap: 10px; background: var(--navy-800); border: 1px solid #22406C; color: var(--white); border-radius: var(--r-md); padding: 8px 10px; cursor: pointer; text-align: left; margin-bottom: 18px; }
.workspace:hover { background: #18325A; }
.workspace .ws-avatar { width: 28px; height: 28px; border-radius: 7px; background: var(--blue-500); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.workspace .ws-name { font-weight: 600; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace .ws-sub { font-size: 11.5px; color: #9FB0CB; }
.workspace.demo .ws-avatar { background: var(--orange-500); color: var(--navy-900); }
.nav-group { margin-bottom: 14px; }
.nav-group-title { font-size: 11.5px; color: #7F92B2; padding: 0 10px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm); color: #C7D3E6; font-weight: 550; font-size: 13.5px; text-decoration: none; position: relative; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: var(--white); }
.nav a[aria-current="page"] { background: rgba(46, 107, 235, .22); color: var(--white); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--orange-500); }
.nav .count { margin-left: auto; font-size: 11.5px; color: #9FB0CB; font-variant-numeric: tabular-nums; }
.nav .count.alert { color: var(--navy-900); background: var(--orange-500); border-radius: var(--r-pill); padding: 0 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid #1C365D; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-md); color: var(--white); background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.user-chip:hover { background: rgba(255, 255, 255, .06); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #2A4877; color: var(--white); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.user-chip .u-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-chip .u-role { font-size: 11.5px; color: #9FB0CB; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.search-trigger { flex: 0 1 360px; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); color: var(--muted); cursor: pointer; }
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger kbd { margin-left: auto; font: 11px var(--font-ui); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; background: var(--white); }
.topbar .spacer { flex: 1; }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.lang-switch button { border: 0; background: var(--white); padding: 6px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang-switch button[aria-pressed="true"] { background: var(--navy-900); color: var(--white); }
.demo-banner { background: repeating-linear-gradient(135deg, var(--orange-100) 0 14px, #FFF4EC 14px 28px); border-bottom: 1px solid #FFC79E; color: #6B3209; padding: 8px 28px; font-size: 13px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.demo-banner strong { color: #4A2306; }
.demo-banner .btn { margin-left: auto; }
.page { padding: 28px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--white); color: var(--ink); font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--paper); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--orange-500); border-color: var(--orange-500); color: var(--navy-950); font-weight: 700; }
.btn.primary:hover { background: #FF8A33; border-color: #FF8A33; }
.btn.primary:active { background: var(--orange-600); border-color: var(--orange-600); }
.btn.dark { background: var(--navy-900); border-color: var(--navy-900); color: var(--white); }
.btn.dark:hover { background: var(--navy-800); }
.btn.blue { background: var(--blue-600); border-color: var(--blue-600); color: var(--white); }
.btn.blue:hover { background: var(--blue-500); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: rgba(11, 28, 54, .06); }
.btn.danger { color: var(--red-700); border-color: #EBC2BF; }
.btn.danger:hover { background: var(--red-100); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue-600); font-weight: 600; cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Panels, sections ---------- */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-panel); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.panel-body { padding: 18px; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* Stat strip: one panel split by rules, instead of a grid of identical cards */
.stat-strip { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); }
.stat { padding: 16px 20px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat .label { font-size: 12.5px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat .value { font-family: var(--font-fig); font-variant-numeric: tabular-nums; font-size: 27px; line-height: 1.15; margin-top: 6px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .value.alert { color: var(--red-700); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.grid-2 > *, .grid-halves > *, .stack > * { min-width: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #FAFBFD; white-space: nowrap; position: sticky; top: 0; }
table.data td { padding: 11px 14px; border-bottom: 1px solid #EDF1F6; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--blue-50); }
table.data .num { text-align: right; }
table.data .title { font-weight: 600; color: var(--ink); }
table.data .sub { font-size: 12.5px; color: var(--muted); }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty .empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--blue-50); color: var(--blue-600); display: grid; place-items: center; }
.empty h3 { color: var(--ink); }
.empty p { max-width: 46ch; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap; background: #EDF1F6; color: var(--ink-2); }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.blue { background: var(--blue-100); color: var(--blue-600); }
.pill.green { background: var(--green-100); color: var(--green-700); }
.pill.red { background: var(--red-100); color: var(--red-700); }
.pill.amber { background: var(--amber-100); color: var(--amber-700); }
.pill.violet { background: var(--violet-100); color: var(--violet-700); }
.pill.orange { background: var(--orange-100); color: #8A3606; }
.pill.navy { background: var(--navy-900); color: var(--white); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error-text { font-size: 12px; color: var(--red-700); }
.input, select.input, textarea.input { width: 100%; height: 38px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--white); padding: 0 11px; font-size: 14px; color: var(--ink); }
textarea.input { height: auto; min-height: 92px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: #AEB9C9; }
.input:focus { outline: none; border-color: var(--blue-500); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--red-700); }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .affix { position: absolute; color: var(--muted); font-size: 13px; pointer-events: none; }
.input-affix .affix.left { left: 11px; }
.input-affix .affix.right { right: 11px; }
.input-affix .input.has-left { padding-left: 24px; }
.input-affix .input.has-right { padding-right: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--blue-600); flex: none; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--blue-600); }
.switch input:checked::after { transform: translateX(16px); }
.segmented { display: inline-flex; background: #E9EDF3; border-radius: var(--r-md); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: none; white-space: nowrap; border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--white); color: var(--ink); box-shadow: 0 1px 2px rgba(8, 20, 40, .12); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 12px; font-weight: 600; font-size: 13.5px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--navy-900); }
.tabs .count { font-size: 11.5px; background: #E9EDF3; border-radius: 999px; padding: 0 6px; color: var(--muted); }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(8, 20, 40, .48); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; }
.dialog { background: var(--white); border-radius: 14px; box-shadow: var(--shadow-pop); width: min(560px, 100%); animation: pop .14s ease-out; }
.dialog.wide { width: min(880px, 100%); }
.dialog-head { padding: 18px 20px 6px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.dialog-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.dialog-body { padding: 14px 20px 18px; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes pop { from { transform: translateY(6px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-overlay { position: fixed; inset: 0; background: rgba(8, 20, 40, .4); z-index: 55; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--white); z-index: 56; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; animation: slide .18s ease-out; }
.drawer .dialog-body { flex: 1; overflow-y: auto; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.menu { position: absolute; z-index: 70; background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 5px; min-width: 210px; }
.menu button, .menu a { display: flex; width: 100%; gap: 9px; align-items: center; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font-size: 13.5px; color: var(--ink); cursor: pointer; text-align: left; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--paper); text-decoration: none; }
.menu .danger { color: var(--red-700); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: grid; gap: 8px; }
.toast { background: var(--navy-900); color: var(--white); padding: 11px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-pop); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; max-width: 420px; animation: pop .14s ease-out; }
.toast.error { background: #5C1714; }
.toast .t-icon { color: #7EE2A8; }
.toast.error .t-icon { color: #FFB4AE; }
.palette { width: min(620px, 100%); }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; height: 54px; font-size: 16px; padding: 0 18px; width: 100%; }
.palette input:focus { outline: none; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--ink); }
.palette-item[aria-selected="true"], .palette-item:hover { background: var(--blue-50); }
.palette-item .kind { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ---------- Skeleton & loading ---------- */
.skeleton { background: linear-gradient(90deg, #EBEFF4 0%, #F4F6F9 50%, #EBEFF4 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.page-loading { display: grid; gap: 14px; }
.page-loading .skeleton.h { height: 28px; width: 260px; }
.page-loading .skeleton.b { height: 120px; }

/* ---------- Signature: the margin strip ---------- */
.margin-strip { --target: 25%; display: grid; gap: 6px; }
.margin-strip .bar { position: relative; height: 14px; border-radius: 4px; background: #E7ECF3; overflow: visible; display: flex; }
.margin-strip .seg-cost { background: var(--navy-700); border-radius: 4px 0 0 4px; }
.margin-strip .seg-profit { background: var(--blue-500); }
.margin-strip .seg-profit.low { background: #D9480F; }
.margin-strip .seg-loss { background: repeating-linear-gradient(135deg, var(--red-700) 0 4px, #D9534F 4px 8px); }
.margin-strip .bar.unknown { background: repeating-linear-gradient(135deg, #E7ECF3 0 6px, #F3F5F9 6px 12px); }
.margin-strip .target { position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px; background: var(--orange-500); left: calc(100% - var(--target)); transform: translateX(-1px); }
.margin-strip .legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); gap: 8px; flex-wrap: wrap; }
.margin-strip .legend b { color: var(--ink); font-weight: 650; }
.margin-strip .key { display: inline-flex; align-items: center; gap: 5px; }
.margin-strip .key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.mini-strip { width: 92px; height: 7px; border-radius: 3px; background: #E7ECF3; display: inline-flex; overflow: hidden; vertical-align: middle; position: relative; }
.mini-strip span:first-child { background: var(--navy-700); }
.mini-strip span:last-child { background: var(--blue-500); }
.mini-strip.low span:last-child { background: #D9480F; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .axis text { font-size: 11px; fill: var(--muted); font-family: var(--font-ui); }
.chart .grid line { stroke: #EDF1F6; }
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- AI suggestion styling ---------- */
.ai-panel { border: 1px solid #CBD9F8; background: linear-gradient(180deg, var(--blue-50), var(--white) 120px); border-radius: var(--r-lg); }
.ai-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; color: var(--violet-700); background: var(--violet-100); border-radius: var(--r-pill); padding: 2px 8px; }
.ai-tag svg { width: 13px; height: 13px; }
.suggestion { border-left: 3px solid #9A8CF2; background: #FBFAFF; border-radius: 0 var(--r-md) var(--r-md) 0; padding: 10px 12px; display: grid; gap: 4px; }
.suggestion + .suggestion { margin-top: 8px; }
.suggestion .s-title { font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.suggestion .s-meta { font-size: 12.5px; color: var(--muted); }
.evidence { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.evidence span { font-size: 11.5px; padding: 1px 7px; border-radius: 4px; background: #EDF1F6; color: var(--ink-2); }
.finding { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 13px 0; border-top: 1px solid #EDF1F6; }
.finding:first-child { border-top: 0; padding-top: 2px; }
.finding .sev { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.finding .sev.high { background: var(--red-700); }
.finding .sev.medium { background: #D48A12; }
.finding .sev.low { background: var(--faint); }
.finding .f-title { font-weight: 650; display: flex; justify-content: space-between; gap: 10px; }
.finding .f-detail { grid-column: 2; color: var(--ink-2); font-size: 13.5px; }
.finding .f-rec { grid-column: 2; font-size: 13px; color: var(--muted); }
.finding .f-impact { font-family: var(--font-fig); color: var(--red-700); white-space: nowrap; }

/* ---------- Estimate editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.editor-side { position: sticky; top: 78px; display: grid; gap: 14px; }
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines th.num { text-align: right; }
.lines td { padding: 4px 4px; border-bottom: 1px solid #EDF1F6; vertical-align: top; }
.lines tr.review td { background: #FBFAFF; }
.lines tr.review td:first-child { box-shadow: inset 3px 0 0 #9A8CF2; }
.lines tr.zero td.amount { color: var(--red-700); }
.lines .cell { width: 100%; border: 1px solid transparent; background: transparent; border-radius: 6px; padding: 6px 7px; font-size: 13.5px; min-width: 0; }
.lines .cell:hover { border-color: var(--line); }
.lines .cell:focus { outline: none; border-color: var(--blue-500); background: var(--white); box-shadow: var(--focus); }
.lines .cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.lines textarea.cell { resize: none; overflow: hidden; line-height: 1.4; min-height: 32px; display: block; }
.lines .amount { text-align: right; padding: 10px 8px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.lines .line-meta { display: flex; gap: 6px; align-items: center; padding: 0 7px 6px; flex-wrap: wrap; }
.lines .row-actions { display: flex; gap: 2px; padding-top: 3px; }
.lines select.cell { padding: 6px 4px; min-width: 134px; }
.add-bar { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; position: relative; }
.pb-search { position: relative; flex: 1 1 280px; }
.pb-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; max-height: 320px; overflow-y: auto; }
.pb-results button .price { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.totals { display: grid; gap: 8px; font-size: 13.5px; }
.totals .t-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.totals .t-row .input { width: 84px; height: 30px; text-align: right; font-size: 13px; }
.totals .t-total { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; display: flex; justify-content: space-between; align-items: baseline; }
.totals .t-total .fig { font-size: 26px; }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state.dirty { color: #8A3606; }
.save-state.error { color: var(--red-700); }

/* ---------- Calendar ---------- */
.cal-week { display: grid; grid-template-columns: 56px repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.cal-week .day-head { padding: 8px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.cal-week .day-head.today { color: var(--blue-600); font-weight: 700; }
.cal-week .day-head b { display: block; font-size: 18px; color: var(--ink); font-family: var(--font-fig); }
.cal-week .day-head.today b { color: var(--blue-600); }
.cal-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(#EDF1F6 1px, transparent 1px); background-size: 100% 44px; }
.cal-hours div { height: 44px; font-size: 11px; color: var(--faint); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.cal-event { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 4px 6px; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 3px solid; background: var(--blue-100); border-color: var(--blue-600); color: var(--navy-900); }
.cal-event.estimate_visit { background: var(--orange-100); border-color: var(--orange-500); }
.cal-event.inspection { background: var(--violet-100); border-color: var(--violet-700); }
.cal-event.completed { opacity: .55; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-month .cell { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; font-size: 12px; }
.cal-month .cell.out { background: #FAFBFD; color: var(--faint); }
.cal-month .cell .d { font-weight: 600; margin-bottom: 4px; }
.cal-month .cell.today .d { color: var(--white); background: var(--blue-600); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; }
.cal-month .ev { background: var(--blue-100); border-radius: 4px; padding: 1px 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.agenda-day { padding: 10px 0; border-top: 1px solid var(--line); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--white); }
.auth-art { background: var(--navy-900); color: #C7D3E6; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .brand { padding: 0; font-size: 20px; }
.auth-art h1, .auth-art .auth-headline { color: var(--white); font-weight: 700; font-size: 34px; line-height: 1.15; max-width: 16ch; letter-spacing: -0.02em; }
.auth-art p { max-width: 44ch; margin-top: 14px; font-size: 15px; line-height: 1.6; }
.auth-sheet { background: var(--white); border-radius: var(--r-lg); padding: 18px 20px; color: var(--ink); width: min(420px, 100%); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .5); }
.auth-sheet .row-line { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid #EDF1F6; }
.auth-sheet .row-line:last-of-type { border-bottom: 0; }
.auth-grid-lines { position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px); background-size: 32px 32px; pointer-events: none; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form form { width: min(380px, 100%); display: grid; gap: 14px; }
.auth-form .switch-link { font-size: 13.5px; color: var(--muted); text-align: center; }
.form-error { background: var(--red-100); color: var(--red-700); border-radius: var(--r-md); padding: 10px 12px; font-size: 13.5px; }
.notice { border-radius: var(--r-md); padding: 11px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--blue-50); color: var(--navy-800); border: 1px solid #D3E0FA; }
.notice.warn { background: #FFF7EC; color: #6B3E05; border: 1px solid #F5DDB5; }
.notice.danger { background: var(--red-100); color: var(--red-700); border: 1px solid #F2C6C2; }
.notice.ok { background: var(--green-100); color: var(--green-700); border: 1px solid #BFE6CF; }

/* ---------- Misc components ---------- */
.list { display: grid; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-top: 1px solid #EDF1F6; }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow-wrap: anywhere; }
.list-item > .fig, .list-item > .num { flex: none; }
.list-item .sub { font-size: 12.5px; color: var(--muted); }
a.list-item { color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--blue-50); }
.checklist { display: grid; gap: 2px; }
.checklist a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 13.5px; }
.checklist a:hover { background: var(--paper); }
.checklist .tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); display: grid; place-items: center; flex: none; }
.checklist .done .tick { background: var(--green-700); border-color: var(--green-700); color: var(--white); }
.checklist .done span.text { color: var(--muted); text-decoration: line-through; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 26px; text-align: center; display: grid; gap: 8px; justify-items: center; color: var(--muted); cursor: pointer; background: #FAFBFD; }
.dropzone:hover, .dropzone.over { border-color: var(--blue-500); background: var(--blue-50); color: var(--ink); }
.dropzone input { display: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo { position: relative; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--paper); aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .p-actions { position: absolute; top: 6px; right: 6px; }
.photo .p-name { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(8, 20, 40, .7)); color: var(--white); font-size: 11.5px; padding: 14px 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: #E7ECF3; border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue-500); }
.progress.over span { background: var(--red-700); }
.cat-bars { display: grid; gap: 12px; }
.cat-bar .cb-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.cat-bar .cb-track { position: relative; height: 10px; background: #E7ECF3; border-radius: 4px; }
.cat-bar .cb-actual { position: absolute; left: 0; top: 0; bottom: 0; background: var(--navy-700); border-radius: 4px; }
.cat-bar .cb-actual.over { background: var(--red-700); }
.cat-bar .cb-budget { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--orange-500); }
.steps { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.steps .s { display: inline-flex; gap: 6px; align-items: center; }
.steps .s b { width: 22px; height: 22px; border-radius: 50%; background: #E9EDF3; display: grid; place-items: center; font-size: 12px; color: var(--ink-2); }
.steps .s.on { color: var(--ink); font-weight: 600; }
.steps .s.on b { background: var(--navy-900); color: var(--white); }
.steps .sep { width: 20px; height: 1px; background: var(--line-strong); }
.code-box { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; word-break: break-all; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 80; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-pop); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(8, 20, 40, .45); z-index: 79; }
  .topbar { padding: 0 14px; }
  .topbar .menu-btn { display: inline-flex; }
  .search-trigger kbd { display: none; }
  .page { padding: 18px 14px 40px; }
  .demo-banner { padding: 8px 14px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .grid-halves { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { padding: 28px 24px; }
  .auth-art .auth-sheet, .auth-art .hide-sm { display: none; }
  .auth-art h1 { font-size: 26px; }
  .cal-week { grid-template-columns: 44px repeat(7, minmax(84px, 1fr)); overflow-x: auto; }
}
@media (max-width: 640px) {
  h1 { font-size: 21px; }
  .search-trigger { flex: 1; }
  .search-trigger .label-text { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid #EDF1F6; }
  table.data.responsive td { padding: 0; border: 0; }
  table.data.responsive td.hide-sm { display: none; }
  table.data.responsive td.num { text-align: right; }
  .lines thead { display: none; }
  .lines tr.line-row { display: grid; grid-template-columns: 1fr 1fr 1fr; border-bottom: 1px solid var(--line); padding: 6px 0; }
  .lines tr.line-row td { border: 0; }
  .lines tr.line-row td.desc { grid-column: 1 / -1; }
  .lines tr.line-row td.amount { text-align: left; }
  .lines tr.line-row td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); padding: 2px 7px 0; }
  .lines tr.line-row .cell.num { text-align: left; }
  .stat .value { font-size: 22px; }
  .page-head .actions { width: 100%; }
  .toasts { left: 14px; right: 14px; bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .demo-banner, .page-head .actions { display: none !important; }
  .app { display: block; }
}

/* ---------- Quick calculator (top bar) ---------- */
.calc-trigger[aria-expanded="true"] { background: var(--paper); border-color: var(--line-strong); }
.calc { position: fixed; z-index: 75; background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-pop); padding: 10px; animation: pop .12s ease-out; }
.calc-screen { background: var(--navy-950); color: var(--white); border-radius: 10px; padding: 10px 8px 8px 14px; margin-bottom: 10px; }
.calc-expr { min-height: 18px; font: 12.5px/18px var(--font-fig); color: #9FB0C8; text-align: right; padding-right: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; unicode-bidi: plaintext; }
.calc-expr.err { color: #FFB27A; }
.calc-row { display: flex; align-items: center; gap: 6px; }
.calc-value { flex: 1; min-width: 0; font: 600 28px/36px var(--font-fig); font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; }
.calc-row .btn { color: #C9D5E6; border-color: transparent; }
.calc-row .btn:hover { background: var(--navy-800); color: var(--white); }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-key { height: 44px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--paper); color: var(--ink); font: 600 17px var(--font-fig); cursor: pointer; }
.calc-key:hover { background: #EEF2F7; }
.calc-key:active { transform: translateY(1px); }
.calc-key.fn { color: var(--ink-2); font-size: 15px; }
.calc-key.op { background: var(--white); color: var(--navy-900); font-size: 20px; }
.calc-key.op[aria-pressed="true"] { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }
.calc-key.eq { background: var(--orange-500); border-color: var(--orange-500); color: var(--navy-950); font-size: 20px; }
.calc-key.eq:hover { background: #FF8A33; }
.calc-key.zero { grid-column: span 2; }
.calc-key:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) { .calc { animation: none; } }

/* ---------- Billing ---------- */
.billing-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 28px; background: var(--red-100); color: #5C1714; border-bottom: 1px solid #EBC2BF; font-size: 13.5px; }
.billing-banner.warn { background: var(--amber-100); color: #5E3A05; border-bottom-color: #EBC98A; }
.billing-banner a { font-weight: 700; }
.plan-pick { display: grid; gap: 10px; }
.plan-option { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 12px 14px; cursor: pointer; }
.plan-option:has(input:checked) { border-color: var(--blue-600); background: var(--blue-50); }
.plan-option input, .check-line input { margin-top: 3px; accent-color: var(--blue-600); width: 18px; height: 18px; flex: none; }
.check-line { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.5; }
.table-wrap { overflow-x: auto; }

/* ---------- Onboarding, tour, help ---------- */
.welcome { max-width: 760px; margin: 0 auto; }
.welcome h1:focus { outline: none; }
.progress { height: 8px; border-radius: 999px; background: #E3E8EF; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--blue-600); border-radius: 999px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.choice { display: grid; gap: 6px; text-align: left; padding: 16px; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--white); color: var(--ink); cursor: pointer; text-decoration: none; font: inherit; }
.choice:hover { border-color: var(--blue-500); background: var(--blue-50); text-decoration: none; }
.choice svg.i { color: var(--blue-600); }
.tour { position: fixed; z-index: 95; width: 320px; max-width: calc(100vw - 24px); background: var(--white); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 16px; border-top: 4px solid var(--orange-500); display: grid; gap: 8px; }
.tour h2 { font-size: 16px; }
.tour-target { position: relative; z-index: 94; box-shadow: 0 0 0 3px var(--orange-500) !important; border-radius: 8px; }
.help-trigger { gap: 6px; }
.help-panel h3 { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.help-ask { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; background: var(--blue-50); display: grid; gap: 8px; }
.assistant-answer { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; display: grid; gap: 8px; }
.ai-label { display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 700; color: var(--violet-700); }
.help-hits { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.help-hits li { display: grid; gap: 2px; }
.help-article { border-top: 1px solid var(--line); padding-top: 12px; }
.prose-sm { font-size: 13.5px; line-height: 1.6; }
.prose-sm h1 { display: none; }
.prose-sm h2 { font-size: 14.5px; margin: 14px 0 6px; }
.prose-sm p, .prose-sm ul, .prose-sm ol { margin: 0 0 8px; }
.prose-sm ul, .prose-sm ol { padding-left: 18px; }
.prose-sm .note { background: var(--amber-100); padding: 8px 10px; border-radius: 8px; }
@media (max-width: 720px) { .help-trigger .label-text { display: none; } }

/* ---------- Two-factor ---------- */
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.qr { display: block; width: 200px; height: 200px; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.steps-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.plan-feats { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.brand-logo { display: block; height: auto; max-width: 100%; }
.auth-art .brand-logo { width: 181px; }
.auth-art .brand-home { display: inline-block; border-radius: 8px; }
.auth-art .brand-home:focus-visible { outline: 3px solid var(--orange-500); outline-offset: 4px; }
