/* SparkSheet shell styles.
   Brand: "Spark" bold + "Sheet" light, red maple-leaf accent, letterspaced
   tagline. Palette = ink navy + white/near-white surfaces, red reserved for
   the leaf and small active accents. Dark is default; light applies via
   body[data-theme="light"]. */

:root, body[data-theme="dark"] {
  --bg:            #12161e;
  --surface:       #1a1f29;
  --surface-2:     #222834;
  --border:        #2b3240;
  --border-strong: #3a4252;
  --text:          #dfe4ec;
  --text-strong:   #f5f7fa;
  --text-muted:    #97a1b2;
  --ink:           #F4F5F6;   /* brand dark-bg text */
  --ink-btn:       #e8ebf0;   /* primary button bg (inverted in dark) */
  --ink-btn-text:  #232833;
  --accent:        #D92D20;   /* brand red - active accents only */
  --tagline:       #9AA3B0;   /* brand dark tagline gray */
  --focus:         #8fa0b8;   /* focus/interactive borders */
  --radius:        10px;
  --maxw:          960px;
}
body[data-theme="light"] {
  --bg:            #f3f5f8;
  --surface:       #ffffff;
  --surface-2:     #eef1f5;
  --border:        #dde2ea;
  --border-strong: #c6cdd8;
  --text:          #2a3240;
  --text-strong:   #232833;
  --text-muted:    #5f6b7d;
  --ink:           #232833;   /* brand ink */
  --ink-btn:       #232833;
  --ink-btn-text:  #ffffff;
  --tagline:       #828A96;   /* brand tagline gray */
  --focus:         #232833;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14.5px/1.5 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  min-height: 100vh;
}

/* ── shell: QBO/CRM-style left nav on desktop, top bar on mobile ─────────── */
.shell { display: flex; min-height: 100vh; align-items: stretch; }
.side {
  width: 228px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.side-brand { padding: 20px 18px 16px; border-bottom: 1px solid var(--border); }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.wordmark { margin: 0; line-height: 1; }
.wordmark img { height: 24px; }
/* theme-swapped brand images (sidebar + login) */
.wm-light, .wm-dark { display: none; }
body:not([data-theme="light"]) .wm-dark { display: block; }
body[data-theme="light"] .wm-light { display: block; }
.tagline {
  margin: 6px 0 0; font-size: 8px; font-weight: 500;
  font-family: Poppins, -apple-system, 'Segoe UI', sans-serif;
  color: var(--tagline); text-transform: uppercase; letter-spacing: 0.2em;
}

.app-header {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 16px; padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { color: var(--text-strong); border-color: var(--border-strong); }

/* vertical nav (desktop) */
.tab-bar { display: flex; flex-direction: column; padding: 12px 0; gap: 2px; }
.tab {
  background: transparent; border: none; color: var(--text-muted);
  padding: 10px 18px 10px 15px; font-size: 14px; font-weight: 500; cursor: pointer;
  border-left: 3px solid transparent; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; text-align: left;
}
.tab:hover { color: var(--text-strong); background: var(--surface-2); }
.tab.active { color: var(--text-strong); border-left-color: var(--accent); background: var(--surface-2); }
.tab-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-2); color: var(--text-muted);
  padding: 1px 6px; border-radius: 2px;
}
.tab.active .tab-badge, .tab:hover .tab-badge { background: var(--bg); }
/* nav subcategories (QBO-style) */
.tab-sub {
  background: transparent; border: none; color: var(--text-muted);
  padding: 6px 18px 6px 34px; font-size: 13px; cursor: pointer;
  border-left: 3px solid transparent; text-align: left; white-space: nowrap;
  display: flex; align-items: center;
}
.tab-sub:hover { color: var(--text-strong); }
.tab-sub.active { color: var(--text-strong); border-left-color: var(--accent); font-weight: 600; }
/* desktop: the nav owns subcategory switching — hide the in-view pill row */
@media (min-width: 901px) { body .qc-pills { display: none; } }

.tool-host {
  flex: 1; width: 100%;
  padding: 24px 30px;
}

/* mobile / narrow: brand bar + horizontal tabs on top, no sidebar */
@media (max-width: 900px) {
  .shell { display: block; }
  .side {
    width: auto; position: static; height: auto; overflow: visible;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .side-brand { padding: 14px 16px 12px; border-bottom: none; }
  .tab-bar {
    flex-direction: row; overflow-x: auto; padding: 0 10px; gap: 4px;
    border-top: 1px solid var(--border);
  }
  .tab {
    border-left: none; border-bottom: 2px solid transparent;
    padding: 12px 14px;
  }
  .tab.active { border-left: none; border-bottom-color: var(--accent); background: transparent; }
  .tab:hover { background: transparent; }
  /* mobile: the in-view pills handle subcategories — hide nav children */
  .tab-sub { display: none; }
}
.tool-placeholder {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px;
}
.tool-placeholder h2 { margin: 0 0 8px; color: var(--text-strong); }
.muted { color: var(--text-muted); }

.app-footer {
  padding: 14px 20px; font-size: 12px; color: var(--text-muted);
  border-top: 1px solid var(--border); background: var(--surface);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.app-footer .dot { opacity: 0.5; }
#footer-brand { color: var(--text); font-weight: 600; }
#footer-feedback { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
#footer-feedback:hover { color: var(--text-strong); }

@media (max-width: 560px) {
  .app-header { padding: 12px 14px; }
  .header-actions .btn-ghost { padding: 6px 9px; }
  .tool-host { padding: 18px 14px; }
  .wordmark { font-size: 21px; }
}

/* --- tool views: compatibility with the ported views' CSS variables ---
   LITERALS per theme, never var() chains (a custom property that references
   another resolves at the element it's DEFINED on - :root = html - so it
   freezes and ignores the body[data-theme] override).
   The old blue accents are remapped to the brand ink/steel family. */
:root, body[data-theme="dark"] {
  --panel:         #1a1f29;
  --panel-2:       #222834;
  --panel-3:       #141922;
  --border-subtle: #242b38;
  --radius-md:     10px;
  --blue:          #46536a;                 /* interactive borders / filled buttons in tools */
  --blue-bright:   #aab8cd;                 /* section labels / emphasized values */
  --blue-soft:     rgba(170, 184, 205, 0.12);
  --text-soft:     #dfe4ec;
  --text-subtle:   #97a1b2;
  --green:         #22c55e;
  --green-text:    #34d399;
  --amber:         #f59e0b;
  --amber-text:    #fbbf24;
  --red:           #ef4444;
  --red-bright:    #f87171;
  --shadow-card:   0 4px 16px rgba(0, 0, 0, 0.28);
}
body[data-theme="light"] {
  --panel:         #ffffff;
  --panel-2:       #f0f2f6;
  --panel-3:       #eef1f5;
  --border-subtle: #e6eaf0;
  --blue:          #232833;
  --blue-bright:   #232833;
  --blue-soft:     rgba(35, 40, 51, 0.07);
  --text-soft:     #2a3240;
  --text-subtle:   #5f6b7d;
  --green:         #16a34a;
  --green-text:    #059669;
  --amber-text:    #b45309;
  --red-bright:    #dc2626;
  --shadow-card:   0 4px 16px rgba(23, 29, 38, 0.08);
}
/* legacy aliases some views reference */
:root { --primary: var(--focus); --accent-soft: var(--blue-soft); --danger: #ef4444; --primary-hover: var(--focus); }

/* ── flat spec-sheet structure ─────────────────────────────────────────────
   Overrides for the tool views' injected styles (body-prefix wins the
   specificity tie without touching the mirrored tool files). Kills the
   floating rounded-card grid: sections become ruled headers on one surface;
   the results column is a summary block with an accent rule. */
body .lc-card, body .qc-card, body .pnl-card, body .pm-card {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 0 8px;
  margin-bottom: 2px;
}
body .lc-inputs .lc-card:first-child, body #qc-form .qc-card:first-child,
body .pnl-wrap .pnl-card:first-child, body .pm-wrap .pm-card:first-child { border-top: none; padding-top: 4px; }
body .lc-seclabel, body .qc-seclabel, body .pnl-seclabel {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-strong);
  border-bottom: none; padding-bottom: 0; margin-bottom: 12px;
  letter-spacing: 0.11em;
}
body .lc-seclabel::before, body .qc-seclabel::before, body .pnl-seclabel::before {
  content: ''; width: 3px; height: 11px; background: var(--accent); flex-shrink: 0;
}
body .lc-badge {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-strong); border-radius: 2px;
}
/* the results / summary column stays a distinct block */
body .lc-results .lc-card, body #qc-result .qc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 0;
  padding: 16px 18px;
}
body .lc-results .lc-card .lc-seclabel::before, body #qc-result .qc-seclabel::before { display: none; }
/* square the controls */
body .lc-num, body .qc-num, body .lc-select, body .qc-select, body .lc-ftxt, body .pnl-in,
body .auth-input, body .cp-grid input, body .fb-ta { border-radius: 3px; }
body .lc-btn, body .qc-btn, body .pnl-btn, body .pm-btn, body .cp-btn, body .btn-ghost,
body .lc-add, body .qc-add, body .lc-rm, body .qc-rm, body .pnl-tool, body .pm-tool { border-radius: 3px; }
body .lc-item { border-radius: 0; background: transparent; border: 1px solid var(--border); }
body .lc-note { border-radius: 0; }
body .lc-service, body .qc-verdict { border-radius: 0; }
body .lc-gcell { border-radius: 0; }
body .lc-modal, body .cp-modal { border-radius: 4px; }
body .auth-card { border-radius: 6px; }
body .tool-placeholder { border-radius: 0; border: none; border-top: 1px solid var(--border); background: transparent; padding: 24px 0; }
/* selection states: ink outline instead of tinted pills */
body .lc-type, body .lc-chip, body .qc-pill { border-radius: 3px; }
body .lc-type.on, body .lc-chip.on, body .qc-pill.on {
  background: transparent;
  border-color: var(--text-strong);
  color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--text-strong);
}
body .tab-badge { border-radius: 2px; }
/* content sits beside the nav at a readable cap, left-aligned (QBO-style) */
body .lc-wrap, body .qc-wrap, body .pnl-wrap, body .pm-wrap { max-width: 1240px; margin: 0; }

/* ── panel schedule: brand retheme (drafting-grid, red accents) ──────────── */
body .pnl-grid { border: 1px solid var(--border-strong); }
body .pnl-grid td.num { background: var(--panel-2); color: var(--text-subtle); font-weight: 500; }
body .pnl-cell.sel { outline: 2px solid var(--accent); outline-offset: -2px; background: rgba(217, 45, 32, 0.08); }
body .pnl-cell.empty:hover { background: rgba(217, 45, 32, 0.05); }
body .pnl-badge {
  background: transparent; border: 1px solid var(--accent); color: var(--accent);
  border-radius: 2px; font-size: 8.5px; letter-spacing: 0.03em;
}
body .pnl-tool:not(:disabled):hover { border-color: var(--text-strong); color: var(--text-strong); background: transparent; }
body .pnl-count { font-family: inherit; }
body .pnl-in:focus { border-color: var(--focus); }
/* keep the reading column sane inside wide layouts: results stay a fixed rail */
@media (min-width: 921px) {
  body .lc-layout { grid-template-columns: 1fr 400px; }
  body .qc-layout { grid-template-columns: 1fr 400px; }
}

/* ── phone layout (same app, different rendering) ────────────────────────── */
@media (max-width: 720px) {
  .tool-host { padding: 14px 12px; }
  .tab { padding: 13px 15px; font-size: 14.5px; }
  /* results first, then the form — matches how you use it standing at a panel */
  body #qc-result { order: -1; }
  /* 16px inputs stop iOS zoom-on-focus; bigger touch targets everywhere */
  body .lc-num, body .qc-num, body .lc-select, body .qc-select, body .lc-ftxt,
  body .pnl-in, body .pnl-cell input, body .auth-input, body .cp-grid input { font-size: 16px; }
  body .lc-btn, body .qc-btn, body .pnl-btn, body .pm-btn, body .lc-add, body .qc-add,
  body .pnl-tool, body .pm-tool, body .qc-pill, body .lc-type, body .lc-chip { padding-top: 10px; padding-bottom: 10px; }
  body .pnl-grid td.num { width: 26px; font-size: 10.5px; }
  body .pnl-grid td { height: 40px; }
  body .lc-results { position: static; }
}

/* --- auth --- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  overflow-y: auto;
}
.auth-card {
  width: min(430px, 94vw);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 38px 36px 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
}
.auth-mark { width: 58px; height: 58px; border-radius: 14px; margin: 0 auto 14px; display: block; }
.auth-wordmark { margin: 0 auto 4px; }
.auth-wordmark img { height: 30px; margin: 0 auto; }
body:not([data-theme="light"]) .auth-wordmark .wm-dark { display: block; }
body[data-theme="light"] .auth-wordmark .wm-light { display: block; }
.auth-tagline {
  margin: 0 0 22px; font-size: 8.5px; font-weight: 500;
  font-family: Poppins, -apple-system, 'Segoe UI', sans-serif;
  color: var(--tagline); text-transform: uppercase; letter-spacing: 0.24em;
}
.auth-sub { margin: 0 0 18px; font-size: 13.5px; color: var(--text-muted); }
.auth-devbadge {
  margin: 0 0 14px; padding: 6px 10px; border-radius: 7px; font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-strong);
}
.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-strong); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.auth-google:hover { border-color: var(--focus); }
.auth-or {
  display: flex; align-items: center; gap: 12px; margin: 16px 0;
  color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
}
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-label { display: block; text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text); margin: 12px 0 5px; }
.auth-input {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-strong); font: inherit; font-size: 14px;
}
.auth-input:focus { outline: none; border-color: var(--focus); }
.auth-err { min-height: 18px; margin: 10px 0 2px; font-size: 12.5px; color: var(--red-bright); text-align: left; }
.auth-primary {
  width: 100%; padding: 12px 14px; border-radius: 10px; margin-top: 4px;
  border: none; background: var(--ink-btn); color: var(--ink-btn-text);
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
}
.auth-primary:hover { opacity: 0.92; }
.auth-primary:disabled, .auth-google:disabled { opacity: 0.6; cursor: default; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; font-size: 12.5px; flex-wrap: wrap; }
.auth-links a { color: var(--text); text-decoration: none; }
.auth-links a:hover { color: var(--accent); }
.auth-links span { color: var(--text-muted); }
.auth-chip { display: inline-flex; align-items: center; gap: 8px; }
.auth-chip-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 560px) { .auth-chip-name { display: none; } }

/* --- company profile modal --- */
.cp-backdrop {
  position: fixed; inset: 0; z-index: 400; background: rgba(10, 13, 18, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.cp-modal {
  width: min(560px, 94vw); max-height: 88vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 22px 24px;
}
.cp-modal h3 { margin: 0 0 4px; font-size: 17px; color: var(--text-strong); }
.cp-modal .sub { margin: 0 0 16px; font-size: 12.5px; color: var(--text-muted); }
.cp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cp-grid .full { grid-column: 1 / -1; }
.cp-grid label { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cp-grid input {
  width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-strong); font: inherit; font-size: 13.5px;
}
.cp-grid input:focus { outline: none; border-color: var(--focus); }
.cp-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.cp-btn {
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer;
}
.cp-btn.primary { background: var(--ink-btn); border-color: var(--ink-btn); color: var(--ink-btn-text); }
.cp-btn:disabled { opacity: 0.5; cursor: default; }
@media (max-width: 480px) { .cp-grid { grid-template-columns: 1fr; } }

/* --- feedback modal (shares the company-profile shell) --- */
.fb-lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
.fb-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
/* Squared, and selected = ink outline rather than a tinted pill — same house
   rule as .lc-chip / .qc-pill further down this file. */
.fb-chip {
  padding: 7px 12px; border-radius: 3px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
  font: inherit; font-size: 12.5px; cursor: pointer;
}
.fb-chip:hover { border-color: var(--border-strong); color: var(--text); }
.fb-chip.on {
  background: transparent; border-color: var(--text-strong); color: var(--text-strong);
  box-shadow: inset 0 0 0 1px var(--text-strong);
}
.fb-ta {
  width: 100%; min-height: 132px; resize: vertical; padding: 10px 11px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-strong); font: inherit; font-size: 13.5px; line-height: 1.5;
}
.fb-ta:focus { outline: none; border-color: var(--focus); }
.fb-under { display: flex; gap: 10px; align-items: baseline; margin-top: 6px; }
.fb-hint { flex: 1; font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }
.fb-count { font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-check {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  font-size: 12.5px; color: var(--text); cursor: pointer;
}
/* --focus, not --ink-btn: in dark mode --ink-btn is near-white, which would put
   a white checkmark on a white box. */
.fb-check input { width: 15px; height: 15px; accent-color: var(--focus); }
/* Phones: 16px stops iOS zooming the whole page on focus. */
@media (max-width: 560px) { body .fb-ta { font-size: 16px; } }
