/* ============================================================================
   QuickCart — Shared Design System
   One stylesheet, linked by every document. Print-first: A4, page breaks,
   and a light chart surface. Data-viz colors are the validated, CVD-safe
   palette from the dataviz skill; brand chrome is indigo→violet.
   ========================================================================== */

:root {
  /* ---- Brand chrome ---- */
  --brand-1:        #4f46e5;   /* indigo  */
  --brand-2:        #7c3aed;   /* violet  */
  --brand-ink:      #2e1065;   /* deep violet ink for headings-on-tint */
  --accent-quick:   #16a34a;   /* "quick/fresh" green */
  --accent-warm:    #f59e0b;   /* highlight amber */

  /* ---- Surfaces & ink ---- */
  --surface-0:      #ffffff;   /* card surface */
  --surface-1:      #fcfcfb;   /* chart surface */
  --surface-page:   #f6f6f4;   /* page plane */
  --surface-tint:   #f4f2ff;   /* faint brand wash */
  --surface-code:   #0f1222;   /* code block bg */

  --ink-1:          #0b0b0b;   /* primary text */
  --ink-2:          #45443f;   /* secondary text */
  --ink-3:          #6f6d66;   /* muted text */
  --hairline:       #e6e5df;   /* borders */
  --hairline-soft:  #efeee9;

  /* ---- Validated categorical data palette (light) ---- */
  --series-1:       #2a78d6;   /* blue    */
  --series-2:       #eb6834;   /* orange  */
  --series-3:       #1baf7a;   /* aqua    */
  --series-4:       #eda100;   /* yellow  */
  --series-5:       #e87ba4;   /* magenta */
  --series-6:       #008300;   /* green   */
  --series-7:       #4a3aa7;   /* violet  */
  --series-8:       #e34948;   /* red     */

  /* ---- Status ---- */
  --good:           #0ca30c;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  /* chart chrome */
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --axis-label:     #898781;

  --radius:         14px;
  --radius-sm:      9px;
  --shadow:         0 1px 2px rgba(16,18,40,.05), 0 8px 24px rgba(16,18,40,.06);
  --shadow-lg:      0 12px 40px rgba(16,18,40,.12);
  --maxw:           1040px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-1);
  background: var(--surface-page);
  line-height: 1.6;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 48px 72px;
}

/* ---------------------------------------------------------------- Typography */
h1, h2, h3, h4 { line-height: 1.2; color: var(--ink-1); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2.05rem; margin: .2em 0 .35em; letter-spacing: -.02em; }
h2 { font-size: 1.5rem; margin: 2.2em 0 .6em; padding-top: .3em; }
h3 { font-size: 1.16rem; margin: 1.6em 0 .5em; color: var(--ink-1); }
h4 { font-size: .97rem; margin: 1.2em 0 .35em; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
p  { margin: .55em 0; color: var(--ink-2); }
a  { color: var(--brand-1); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { color: var(--ink-1); font-weight: 650; }
small { color: var(--ink-3); }
ul, ol { color: var(--ink-2); padding-left: 1.25em; }
li { margin: .3em 0; }
hr { border: none; border-top: 1px solid var(--hairline); margin: 2.4em 0; }

.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 68ch; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 700; color: var(--brand-2);
}
.muted { color: var(--ink-3); }
.center { text-align: center; }

/* Section number chips before h2 */
.numbered { counter-reset: h2; }
.numbered h2 { counter-increment: h2; position: relative; }
.numbered h2::before {
  content: counter(h2);
  display: inline-grid; place-items: center;
  width: 1.7em; height: 1.7em; margin-right: .55em;
  border-radius: 8px; font-size: .72em; vertical-align: 2px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; font-weight: 700;
}

/* --------------------------------------------------------------------- Header */
.doc-header {
  background: linear-gradient(120deg, var(--brand-1) 0%, var(--brand-2) 55%, #9333ea 100%);
  color: #fff; border-radius: 0;
}
.doc-header .page { padding-top: 30px; padding-bottom: 30px; }
.doc-header .kicker { color: #e9e4ff; font-weight: 600; letter-spacing: .04em; }
.doc-header h1 { color: #fff; margin-top: .1em; }
.doc-header p { color: #ece9ff; }
.doc-header .crumbs { font-size: .8rem; color: #d9d2ff; }
.doc-header .crumbs a { color: #fff; }

.brandmark { display: inline-flex; align-items: center; gap: .55em; font-weight: 800; letter-spacing: -.02em; }
.brandmark .logo {
  width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center;
  background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}

/* --------------------------------------------------------------------- Cards */
.card {
  background: var(--surface-0); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card h3:first-child, .card h4:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* KPI / stat tiles */
.kpi { background: var(--surface-0); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi .val { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink-1); }
.kpi .lbl { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.kpi .val small { font-size: .55em; font-weight: 700; color: var(--good); letter-spacing: 0; }
.kpi.accent { background: var(--surface-tint); border-color: #ddd6fe; }

/* Feature/step blocks */
.feature { display: flex; gap: 14px; align-items: flex-start; }
.feature .ico {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-tint); color: var(--brand-2); font-size: 1.1rem;
  box-shadow: inset 0 0 0 1px #e7e1ff;
}
.feature h4 { margin: .1em 0 .2em; text-transform: none; letter-spacing: -.01em; font-size: 1rem; color: var(--ink-1); }
.feature p { margin: 0; font-size: .92rem; }

/* ------------------------------------------------------------------- Badges */
.badge {
  display: inline-flex; align-items: center; gap: .4em; font-size: .72rem; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap;
  background: var(--surface-tint); color: var(--brand-2); border: 1px solid #e2dbff;
}
.badge.g  { background: #e8f7ee; color: #0a7d33; border-color: #bfe8cd; }
.badge.a  { background: #fef4e2; color: #9a6400; border-color: #f7e0b0; }
.badge.r  { background: #fdeaea; color: #b4262a; border-color: #f6c9ca; }
.badge.b  { background: #e8f0fc; color: #1d5fb3; border-color: #c9dcf6; }
.badge.n  { background: #f1f0ec; color: #55534d; border-color: #e2e1da; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------- Tables */
table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .9rem; }
thead th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--hairline);
  background: var(--surface-1);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--hairline-soft); color: var(--ink-2); vertical-align: top; }
tbody tr:nth-child(even) td { background: #fafaf8; }
table.tight td, table.tight th { padding: 7px 10px; }
table code { font-size: .84em; }
td .yes { color: var(--good); font-weight: 700; }
td .no  { color: var(--critical); font-weight: 700; }
td .partial { color: #9a6400; font-weight: 700; }

/* ------------------------------------------------------------------ Callouts */
.callout {
  border-radius: var(--radius-sm); padding: 14px 16px 14px 18px; margin: 1.1em 0;
  border-left: 4px solid var(--brand-1); background: var(--surface-tint); color: var(--ink-2);
  font-size: .92rem;
}
.callout .t { font-weight: 700; color: var(--ink-1); display: block; margin-bottom: 2px; }
.callout.warn { border-color: var(--warning); background: #fff8e9; }
.callout.danger { border-color: var(--critical); background: #fdeeee; }
.callout.ok { border-color: var(--good); background: #ecf8ef; }
.callout.note { border-color: var(--series-1); background: #eef4fd; }

/* --------------------------------------------------------------------- Code */
pre, code { font-family: var(--mono); }
code { background: #f0eff9; color: #4c1d95; padding: .12em .38em; border-radius: 5px; font-size: .85em; }
pre {
  background: var(--surface-code); color: #e5e7f0; border-radius: var(--radius-sm);
  padding: 16px 18px; overflow-x: auto; font-size: .82rem; line-height: 1.55; margin: 1em 0;
  box-shadow: var(--shadow); border: 1px solid #1e2138;
}
pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
pre .c { color: #7f8bb0; }      /* comment */
pre .k { color: #c792ea; }      /* keyword */
pre .s { color: #a5e075; }      /* string  */
pre .n { color: #f5c07a; }      /* number/const */
pre .fn{ color: #82d2ff; }      /* function */
pre .p { color: #8b93b3; }      /* punctuation */

.filetab {
  display: inline-block; font-family: var(--mono); font-size: .74rem; color: #b9c0e0;
  background: #1a1d33; border: 1px solid #262a45; border-bottom: none;
  padding: 5px 12px; border-radius: 8px 8px 0 0; margin-bottom: -8px; position: relative; z-index: 1;
}
.filetab + pre { border-top-left-radius: 0; }

/* --------------------------------------------------------------- Diagrams */
.diagram {
  background: var(--surface-1); border: 1px solid var(--hairline); border-radius: var(--radius);
  padding: 18px; margin: 1.2em 0; box-shadow: var(--shadow); text-align: center; overflow-x: auto;
}
.diagram .cap { font-size: .8rem; color: var(--ink-3); margin-top: 8px; }
.mermaid { display: flex; justify-content: center; }
figure { margin: 1.2em 0; }
figcaption { font-size: .8rem; color: var(--ink-3); text-align: center; margin-top: 8px; }

/* --------------------------------------------------------- Phone mockups */
.devices { display: flex; gap: 26px; flex-wrap: wrap; justify-content: center; }
.phone {
  width: 300px; background: #0b0b12; border-radius: 34px; padding: 12px;
  box-shadow: var(--shadow-lg); flex: 0 0 auto;
}
.phone .screen {
  background: #fff; border-radius: 24px; overflow: hidden; position: relative;
  height: 620px; display: flex; flex-direction: column;
}
.phone .notch {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; background: #0b0b12; border-radius: 12px; z-index: 5;
}
.phone-label { text-align: center; font-weight: 700; margin-top: 12px; color: var(--ink-1); }
.phone-sub { text-align: center; font-size: .82rem; color: var(--ink-3); }

/* mini UI kit used inside phone screens */
.ui-statusbar { height: 34px; display: flex; align-items: flex-end; justify-content: space-between; padding: 0 16px 4px; font-size: .68rem; font-weight: 700; color: #0b0b0b; }
.ui-appbar { padding: 8px 14px 12px; display: flex; align-items: center; gap: 10px; }
.ui-appbar .loc { font-size: .66rem; color: var(--ink-3); }
.ui-appbar .loc b { color: var(--ink-1); font-size: .82rem; display: block; }
.ui-search { flex: 1; background: #f1f1ee; border-radius: 10px; padding: 9px 12px; font-size: .78rem; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.ui-body { flex: 1; overflow: hidden; padding: 0 14px; }
.ui-hero { background: linear-gradient(120deg,var(--brand-1),var(--brand-2)); color: #fff; border-radius: 14px; padding: 14px; font-size: .8rem; margin: 4px 0 12px; }
.ui-hero .big { font-size: 1.1rem; font-weight: 800; }
.ui-chips { display: flex; gap: 7px; overflow: hidden; margin-bottom: 12px; }
.ui-chip { background: #f1f1ee; border-radius: 999px; padding: 5px 11px; font-size: .68rem; white-space: nowrap; color: var(--ink-2); font-weight: 600; }
.ui-chip.on { background: var(--brand-1); color: #fff; }
.ui-cats { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px 6px; }
.ui-cat { text-align: center; font-size: .6rem; color: var(--ink-2); }
.ui-cat .thumb { height: 46px; border-radius: 12px; background: var(--surface-tint); margin-bottom: 3px; display: grid; place-items: center; font-size: 1.1rem; }
.ui-section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 8px; }
.ui-section-h b { font-size: .82rem; }
.ui-section-h span { font-size: .64rem; color: var(--brand-1); font-weight: 700; }
.ui-prod-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 9px; }
.ui-card { border: 1px solid var(--hairline); border-radius: 12px; padding: 8px; }
.ui-card .thumb { height: 66px; border-radius: 9px; background: #f4f4f1; margin-bottom: 6px; display: grid; place-items: center; font-size: 1.4rem; position: relative; }
.ui-card .eta { position: absolute; top: 5px; left: 5px; background: #fff; border-radius: 6px; font-size: .54rem; font-weight: 700; padding: 2px 5px; color: var(--accent-quick); box-shadow: var(--shadow); }
.ui-card .nm { font-size: .68rem; color: var(--ink-1); font-weight: 600; line-height: 1.25; height: 2.4em; overflow: hidden; }
.ui-card .qty { font-size: .58rem; color: var(--ink-3); }
.ui-card .pr { font-size: .76rem; font-weight: 800; margin-top: 3px; }
.ui-card .pr s { color: var(--ink-3); font-weight: 500; font-size: .82em; }
.ui-card .src { font-size: .55rem; color: var(--series-1); font-weight: 700; margin-top: 1px; }
.ui-add { border: 1px solid var(--brand-1); color: var(--brand-1); border-radius: 8px; text-align: center; font-size: .66rem; font-weight: 800; padding: 4px; margin-top: 5px; }
.ui-tabbar { height: 52px; border-top: 1px solid var(--hairline); display: flex; justify-content: space-around; align-items: center; font-size: .55rem; color: var(--ink-3); }
.ui-tabbar .on { color: var(--brand-1); font-weight: 700; }
.ui-tabbar div { text-align: center; }
.ui-tabbar .ic { font-size: 1rem; display: block; }

/* comparison / source rows */
.srcrow { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; border: 1px solid var(--hairline); border-radius: 11px; margin: 7px 0; font-size: .74rem; }
.srcrow.best { border-color: var(--accent-quick); background: #f0faf3; }
.srcrow .left { display: flex; align-items: center; gap: 9px; }
.srcrow .logo2 { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .62rem; }
.srcrow .price { font-weight: 800; font-size: .9rem; }
.srcrow .meta { color: var(--ink-3); font-size: .62rem; }

/* ---------------------------------------------------------------- Toolbar */
.docnav {
  position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--hairline);
}
.docnav .inner { max-width: var(--maxw); margin: 0 auto; padding: 10px 48px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.docnav a { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.docnav a.here { color: var(--brand-1); }
.docnav .sp { flex: 1; }

.footer { border-top: 1px solid var(--hairline); margin-top: 40px; }
.footer .page { padding: 22px 48px; display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-3); flex-wrap: wrap; gap: 8px; }

/* legend for charts */
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .8rem; color: var(--ink-2); margin: 6px 0 2px; }
.legend .it { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }

/* Table of contents (cover) */
.toc { display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; margin-top: 8px; }
.toc a.tile {
  display: block; border: 1px solid var(--hairline); border-radius: var(--radius); padding: 18px 20px;
  background: var(--surface-0); box-shadow: var(--shadow); color: inherit; transition: transform .1s ease;
}
.toc a.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.toc a.tile .n { font-size: .72rem; font-weight: 800; color: var(--brand-2); letter-spacing: .05em; }
.toc a.tile .t { font-weight: 700; font-size: 1.05rem; margin: 4px 0 4px; color: var(--ink-1); }
.toc a.tile .d { font-size: .85rem; color: var(--ink-3); }

/* =============================================================== PRINT / PDF */
@page { size: A4; margin: 14mm 12mm 16mm; }

@media print {
  :root { --maxw: 100%; }
  body { background: #fff; font-size: 10.6pt; }
  .page { padding: 0 4mm; max-width: 100%; }
  .docnav { display: none !important; }
  .doc-header { border-radius: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-header .page { padding: 14px 4mm; }
  a { color: var(--ink-1); text-decoration: none; }

  /* keep color fills in print */
  .doc-header, .kpi, .card, .callout, .badge, pre, .ui-hero, .numbered h2::before,
  .toc a.tile, .srcrow, .phone, .feature .ico, .diagram, thead th, .legend .sw,
  .srcrow .logo2, .ui-chip.on, .ui-tabbar .on, .phone .screen, .phone .notch, svg {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  h2, h3, h4 { break-after: avoid; }
  table, figure, .diagram, .card, .kpi, .phone, .callout, .feature { break-inside: avoid; }
  tr { break-inside: avoid; }

  /* Long code/JSON must WRAP in print — screens scroll horizontally, paper cannot,
     so overflow:auto would silently clip data at the right margin. Allow tall blocks
     to flow across pages rather than force a phantom blank page. */
  pre, pre code { white-space: pre-wrap !important; word-break: break-word; overflow: visible !important; }

  /* A tall Mermaid diagram that is taller than the printable page makes
     break-inside:avoid impossible and leaves a phantom blank page before it.
     Cap the rendered SVG to comfortably fit one A4 page so it never fragments. */
  .mermaid { max-width: 100%; }
  .mermaid svg {
    max-height: 228mm !important;
    height: auto !important;
    width: auto !important;
    max-width: 100% !important;
  }
  .grid.cols-3, .grid.cols-4 { gap: 10px; }
  .page-break { break-before: page; }
  .avoid-break { break-inside: avoid; }
  .footer { break-inside: avoid; }
}
