/* GridArb site and app. One type family (Public Sans, tabular figures). Teal and amber are
   used only for charge and sell. Mobile first; visible focus; reduced motion respected. */
:root {
  --paper: #FAFBFC;
  --ink: #14213D;
  --blue: #1D4E89;
  --blue-dark: #163C6A;
  --slate: #5C6B7A;
  --charge: #2A9D8F;
  --sell: #E9A23B;
  --grey: #8A94A0;       /* "default" tags */
  --grey-bg: #EEF1F4;
  --line: #DCE1E7;
  --just: #FFF4D6;       /* "just filled" highlight */
  --bad: #A23B2A;
  --white: #FFFFFF;
  --radius: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.55; font-variant-numeric: tabular-nums;
}
a { color: var(--blue); text-underline-offset: 2px; }
a:hover { color: var(--blue-dark); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--slate); }
.small { font-size: .875rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius); border: 1px solid var(--blue);
  background: var(--blue); color: var(--white); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--blue-dark); color: var(--white); }
.btn.secondary { background: var(--white); color: var(--blue); }
.btn.secondary:hover { background: var(--grey-bg); color: var(--blue-dark); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--blue); padding: 8px 10px; }
.btn.quiet:hover { background: var(--grey-bg); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.danger { background: var(--white); color: var(--bad); border-color: var(--bad); }

/* header / footer */
.site-head { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 30; }
.back-app { margin: 10px auto 0; max-width: 1080px; padding: 0 16px; }
.back-app a { color: var(--blue); text-decoration: none; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { font-weight: 800; color: var(--ink); text-decoration: none; font-size: 1.15rem; letter-spacing: -0.02em; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.site-nav a { padding: 8px 10px; text-decoration: none; color: var(--ink); border-radius: var(--radius); }
.site-nav a:hover { background: var(--grey-bg); }
.site-foot { border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0 40px; color: var(--slate); font-size: .9rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }
.site-foot nav { display: flex; gap: 16px; flex-wrap: wrap; }

/* landing */
.hero { position: relative; overflow: hidden; padding: 48px 0 40px; }
.hero-band { position: absolute; inset: auto 0 0 0; height: 150px; pointer-events: none; opacity: .55; }
.hero-band svg { width: 100%; height: 100%; display: block; }
.hero-inner { position: relative; max-width: 760px; margin: 0 auto; padding: 0 16px; text-align: center; }
.hero h1 { margin-bottom: .35em; }
.hero .sub { font-size: 1.1rem; color: var(--slate); max-width: 620px; margin: 0 auto 24px; }
.first-check { font-weight: 600; max-width: 680px; margin: 0 auto 14px; padding: 8px 14px; border: 1px solid var(--line, #d9dde3); border-radius: var(--radius, 8px); background: #fff; }
.band-legend { position: relative; text-align: center; font-size: .8rem; color: var(--slate); margin-top: 8px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin: 0 4px 0 10px; }
.key.charge { background: var(--charge); } .key.sell { background: var(--sell); }
section.block { padding: 40px 0; border-top: 1px solid var(--line); }
.live-strip { background: var(--white); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; font-size: .95rem; }
ol.steps3 { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 20px; }
ol.steps3 li { counter-increment: s; padding-left: 44px; position: relative; }
ol.steps3 li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--blue); color: var(--blue); font-weight: 700; display: grid; place-items: center; }
@media (min-width: 760px) { ol.steps3 { grid-template-columns: repeat(3, 1fr); gap: 28px; } }
.example { border-left: 3px solid var(--blue); padding: 4px 0 4px 18px; }
dl.figures { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
dl.figures div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
dl.figures dt { color: var(--slate); }
dl.figures dd { margin: 0; font-weight: 600; text-align: right; }
@media (min-width: 640px) { dl.figures.two { grid-template-columns: 1fr 1fr; column-gap: 32px; } }
table.plans { width: 100%; border-collapse: collapse; }
table.plans th, table.plans td { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.plans th { font-size: 1.05rem; }
.plan-price { font-size: 1.4rem; font-weight: 700; display: block; }
.plans-list { display: grid; gap: 0; border-top: 1px solid var(--line); }
.plan-row { display: grid; gap: 8px; padding: 20px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 760px) { .plan-row { grid-template-columns: 200px 1fr auto; align-items: start; gap: 24px; } }
.plan-row .what { color: var(--slate); }
.faq dt { font-weight: 700; margin-top: 18px; }
.faq dd { margin: 4px 0 0; color: var(--slate); }
.notice { background: var(--grey-bg); border-radius: var(--radius); padding: 12px 14px; }

/* forms */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=number], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--white);
  border: 1px solid #B9C2CC; border-radius: var(--radius); padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
.form-row { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .form-row.two { grid-template-columns: 1fr 1fr; } }
.ok-msg { color: var(--charge); font-weight: 600; } .err-msg { color: var(--bad); }
dialog { border: 1px solid var(--line); border-radius: 8px; padding: 20px; max-width: 520px; width: calc(100% - 32px); color: var(--ink); }
dialog::backdrop { background: rgba(20, 33, 61, .35); }

/* chat (shared by the landing hero and /app) */
.composer { display: flex; gap: 8px; align-items: flex-end; background: var(--white); border: 1px solid #B9C2CC; border-radius: 10px; padding: 8px; }
.composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29, 78, 137, .15); }
.composer textarea { border: 0; min-height: 44px; max-height: 180px; padding: 10px; resize: none; }
.composer textarea:focus { outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 0; }
.chip { font: inherit; font-size: .92rem; border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.thread { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--white); padding: 10px 14px; border-radius: 12px 12px 2px 12px; max-width: 85%; white-space: pre-wrap; }
.msg.assistant { align-self: stretch; }
.msg.assistant .text { white-space: pre-wrap; }
.msg.note .text { color: var(--slate); font-size: .95rem; }
.msg .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg .flag { font-size: .8rem; color: var(--slate); background: none; border: 0; cursor: pointer; padding: 4px 0; text-decoration: underline; }
.msg .inline-input { display: flex; gap: 8px; margin-top: 10px; max-width: 420px; }
.plan-card, .result-card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-top: 8px; }
.plan-card ol { margin: 8px 0 12px; padding-left: 20px; }
.plan-card li { padding: 3px 0; }
.plan-card label.step { font-weight: 400; display: inline; margin: 0; }
.result-card h3 { margin-bottom: 4px; }
.result-card .headline { font-size: 1.05rem; margin-bottom: 10px; }
.result-card .locked { color: var(--slate); font-size: .9rem; border-top: 1px dashed var(--line); padding-top: 8px; margin-top: 10px; }
.result-card .notes { color: var(--slate); font-size: .85rem; margin: 10px 0 0; padding-left: 18px; }
.progress { list-style: none; padding: 0; margin: 8px 0 0; font-size: .92rem; }
.progress li { padding: 4px 0 4px 26px; position: relative; color: var(--slate); }
.progress li::before { content: ""; position: absolute; left: 4px; top: 10px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--grey); }
.progress li.done::before, .progress li.kept::before { background: var(--blue); border-color: var(--blue); }
.progress li.running { color: var(--ink); font-weight: 600; }
.progress li.running::before { border-color: var(--blue); border-right-color: transparent; animation: spin 1s linear infinite; }
.progress li.skipped::before, .progress li.stopped::before { border-style: dashed; }
.progress li.error::before { border-color: var(--bad); background: var(--bad); }
.progress .why { display: block; font-weight: 400; color: var(--slate); font-size: .85rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing::after { content: "..."; animation: blink 1.2s steps(4) infinite; }
@keyframes blink { 0% { opacity: .2; } 50% { opacity: 1; } 100% { opacity: .2; } }

/* app layout */
.app { display: grid; grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
.app-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.sidebar { background: var(--white); border-right: 1px solid var(--line); padding: 14px; display: none; flex-direction: column; gap: 14px; overflow-y: auto; }
.sidebar.open { display: flex; position: fixed; inset: 0 25% 0 0; z-index: 20; box-shadow: 0 0 0 100vmax rgba(20, 33, 61, .3); }
.sidebar h2 { font-size: .9rem; color: var(--slate); margin: 8px 0 4px; font-weight: 600; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li a, .sidebar li button { display: block; width: 100%; text-align: left; padding: 7px 8px; border-radius: var(--radius); color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; }
.sidebar li a:hover, .sidebar li button:hover, .sidebar li .current { background: var(--grey-bg); }
.center { display: flex; flex-direction: column; min-width: 0; }
.center .thread { flex: 1; padding: 16px; overflow-y: auto; }
.center .composer-wrap { padding: 12px 16px 16px; border-top: 1px solid var(--line); background: var(--paper); position: sticky; bottom: 0; }
.panel { border-top: 1px solid var(--line); background: var(--white); min-width: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; font: inherit; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 8px; cursor: pointer; color: var(--slate); }
.tabs button[aria-selected=true] { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.tabpanel { padding: 14px 16px; }
.field { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.field .lbl { font-size: .9rem; color: var(--slate); }
.field .val { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.field .val input, .field .val select { min-height: 38px; padding: 6px 10px; }
.field.just { background: var(--just); transition: background 2s ease; }
.tag { font-size: .75rem; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.tag.you { background: #E3ECF6; color: var(--blue-dark); }
.tag.default { background: var(--grey-bg); color: var(--grey); }
.tag.calculated { background: #EAF0EA; color: #3C5A40; }
.figure-note { font-size: .8rem; color: var(--slate); }
.chart { margin: 14px 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); }
.chart text { font-size: 11px; fill: var(--slate); font-family: inherit; }
.chart-title { font-weight: 600; font-size: .95rem; margin: 0 0 4px; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--white); font-size: .8rem; padding: 6px 8px; border-radius: 4px; z-index: 50; display: none; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.charge { color: #1E7268; font-weight: 600; } table.data td.sell { color: #9A6514; font-weight: 600; }
.activity-item { border-bottom: 1px solid var(--line); padding: 10px 0; font-size: .9rem; }
.activity-item .meta { color: var(--slate); font-size: .8rem; }
.app-foot { padding: 10px 16px; font-size: .8rem; color: var(--slate); border-top: 1px solid var(--line); }
.role-pick { display: grid; gap: 12px; margin-top: 12px; }
.role-pick button { min-height: 72px; font-size: 1.05rem; }
.only-mobile { display: inline-flex; }
@media (min-width: 900px) {
  .app { grid-template-columns: 240px minmax(0, 1fr) 380px; grid-template-rows: auto 1fr; }
  .app-top { grid-column: 1 / -1; }
  .sidebar { display: flex; position: static; box-shadow: none; }
  .panel { border-top: 0; border-left: 1px solid var(--line); height: calc(100dvh - 58px); overflow-y: auto; position: sticky; top: 58px; }
  .center { height: calc(100dvh - 58px); }
  .only-mobile { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-head, .site-foot, .composer-wrap, .sidebar, .tabs { display: none; }
}
.hero-band .draw { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: draw 2.4s ease-out .2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .hero-band .draw { stroke-dashoffset: 0; } }
.hero .thread .msg.assistant { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.hero .thread .msg.note { background: transparent; border: 0; padding: 0 2px; }
.site-nav a.btn, .site-nav a.btn:hover { color: var(--white); background: var(--blue); }
.site-nav a.btn:hover { background: var(--blue-dark); }
.hero-inner { padding-bottom: 120px; }
.band-legend { position: absolute; left: 0; right: 0; bottom: 4px; margin: 0; }
.inline-input .btn { white-space: nowrap; }
.hero-band { bottom: 30px; }
.band-legend { bottom: 4px; padding: 0 16px; }
@media (max-width: 600px) {
  .site-nav a:not(.btn):not(:first-child) { display: none; }
  .hero { padding-top: 28px; }
}
