/* The component library for Leads from Open sources, REL-3, round 2 (memory/product/design/README.md § Layout direction, 05, 06).
   From Siamwise: the colour tokens and the logo only (RUL-2026-11-21-49, -50). Light theme only.
   Round 2 (2026-11-21): a calm type scale (14 · 16 · 21 · 32), a 1240 px frame that uses the screen's width in two
   working columns, the trimmed logo at its natural shape, and the toast at the top of the screen. */
@font-face { font-family: "Bai Jamjuree"; font-weight: 500; font-style: normal; font-display: swap; src: url("/static/fonts/BaiJamjuree-Medium.ttf") format("truetype"); }
@font-face { font-family: "Bai Jamjuree"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/BaiJamjuree-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Bai Jamjuree"; font-weight: 700; font-style: normal; font-display: swap; src: url("/static/fonts/BaiJamjuree-Bold.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans Thai Looped"; font-weight: 400; font-style: normal; font-display: swap; src: url("/static/fonts/IBMPlexSansThaiLooped-Regular.ttf") format("truetype"); }
@font-face { font-family: "IBM Plex Sans Thai Looped"; font-weight: 600; font-style: normal; font-display: swap; src: url("/static/fonts/IBMPlexSansThaiLooped-SemiBold.ttf") format("truetype"); }

:root {
  /* Siamwise colour tokens (knowledge/research/ui.md § REL-3) */
  --blue: #2B6CB0;
  --blue-dark: #1A4F8A;
  --blue-deep: #0F2744;
  --blue-tint: #EFF6FF;
  --navy: #1A2744;
  --text: #0F172A;
  --muted: #475569;
  --gray-50: #F8FAFC;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-500: #64748B;       /* field edges: 4.76:1 on white */
  --red: #B91C1C;
  --red-bg: #FDF3F3;
  --green-text: #047857;
  --white: #FFFFFF;
  --ring: rgba(43, 108, 176, 0.35);

  /* this product's own scale: four sizes */
  --f-head: "Bai Jamjuree", "Thonburi", "Leelawadee UI", system-ui, sans-serif;
  --f-text: "IBM Plex Sans Thai Looped", "Thonburi", "Leelawadee UI", system-ui, sans-serif;
  --s-small: 14px;
  --s-body: 16px;
  --s-head: 21px;
  --s-title: 32px;
  --frame: 1240px;
  --gutter: 32px;
  --gap: 64px;
  --measure: 36em;           /* about 70 Thai characters at 16 px */
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--white);
  color: var(--text);
  font-family: var(--f-text);
  font-size: var(--s-body);
  line-height: 1.6;
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
h1, h2, h3 { font-family: var(--f-head); color: var(--navy); font-weight: 600; }
h1 { font-size: var(--s-title); line-height: 1.3; }
h2 { font-size: var(--s-head); line-height: 1.4; }
h3 { font-size: var(--s-body); line-height: 1.5; }
p, dd, li { max-width: var(--measure); }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-dark); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--ring); outline-offset: 2px;
}
strong { font-weight: 600; white-space: nowrap; }
[hidden] { display: none !important; }
.nw { white-space: nowrap; }
.small { font-size: var(--s-small); color: var(--muted); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── the frame: one width for the bar, the page and the foot ── */
.frame { width: 100%; max-width: calc(var(--frame) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.page { padding-top: 48px; padding-bottom: 72px; }
.page-head { margin-bottom: 32px; }
.page-head p { margin-top: 8px; color: var(--muted); }
.page > .back { margin-top: 32px; }

/* two working columns; one column under 900 px */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px var(--gap); align-items: start; }
.split.wide-left { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.stack > * + * { margin-top: 16px; }

/* ── the bar ── */
.site-bar { border-bottom: 1px solid var(--gray-200); background: var(--white); }
.site-bar .frame { display: flex; align-items: center; gap: 28px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 14px; margin-right: auto; text-decoration: none; color: var(--navy); }
.brand img { display: block; height: 36px; width: auto; }
.brand-name { font-family: var(--f-head); font-weight: 600; font-size: var(--s-body); padding-left: 14px; border-left: 1px solid var(--gray-300); white-space: nowrap; }
.bar-link { color: var(--navy); text-decoration: none; font-weight: 600; font-size: var(--s-small); padding: 6px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.bar-nav { display: flex; align-items: center; gap: 28px; }
.bar-link:hover { color: var(--blue); }
.bar-link[aria-current="page"] { border-bottom-color: var(--blue); color: var(--blue-dark); }

/* ── the foot ── */
.site-foot { border-top: 1px solid var(--gray-200); font-size: var(--s-small); color: var(--muted); }
.site-foot .frame { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-top: 20px; padding-bottom: 20px; }

/* ── buttons: one filled button per view ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 20px;
  font: 600 var(--s-body)/1.4 var(--f-text);
  color: var(--white); background: var(--blue);
  border: 1px solid var(--blue); border-radius: 6px;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: var(--white); }
.btn:active { background: var(--blue-deep); border-color: var(--blue-deep); }
.btn:disabled { background: var(--gray-200); border-color: var(--gray-200); color: var(--muted); cursor: not-allowed; }
.btn-second { background: var(--white); color: var(--navy); border-color: var(--gray-500); }
.btn-second:hover { background: var(--gray-50); color: var(--navy); border-color: var(--navy); }
.btn-second:active { background: var(--gray-200); border-color: var(--navy); }
.btn-second:disabled { background: var(--white); color: var(--gray-500); border-color: var(--gray-300); }
.btn-stop { background: var(--red); border-color: var(--red); }
.btn-stop:hover, .btn-stop:active { background: #991B1B; border-color: #991B1B; }
.btn-small { min-height: 36px; padding: 4px 14px; font-size: var(--s-small); }
.btn-quiet { background: none; border-color: transparent; color: var(--blue); padding: 4px 10px; min-height: 36px; font-size: var(--s-small); }
.btn-quiet:hover, .btn-quiet:active { background: var(--blue-tint); border-color: transparent; color: var(--blue-dark); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; }

/* ── forms ── */
.form { max-width: 480px; }
.form > * + * { margin-top: 20px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 6px; }
.field .rule { display: block; font-size: var(--s-small); color: var(--muted); margin: -2px 0 6px; }
.input, .textarea {
  display: block; width: 100%; min-height: 44px; padding: 9px 12px;
  font: 400 var(--s-body)/1.5 var(--f-text); color: var(--text);
  background: var(--white); border: 1px solid var(--gray-500); border-radius: 6px;
}
.textarea { resize: vertical; min-height: 104px; }
.input[readonly] { background: var(--white); font-family: var(--f-head); font-weight: 500; font-size: 15px; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.with-toggle { position: relative; }
.with-toggle .input { padding-right: 72px; }
.with-toggle .btn-quiet { position: absolute; right: 4px; top: 4px; }
.field-error { color: var(--red); font-size: var(--s-small); margin-top: 6px; }
.field-error:empty, .msg:empty { display: none; }
.msg { font-size: var(--s-small); }
.msg.error { color: var(--red); }
.msg.wait { color: var(--text); }
.tick { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.tick input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--blue); }
.tick label { font-weight: 400; margin: 0; }
.error-summary { border: 1px solid var(--red); border-left-width: 4px; background: var(--red-bg); padding: 14px 18px; margin-bottom: 24px; max-width: 480px; }
.error-summary h2 { font-size: var(--s-body); color: var(--red); }
.error-summary ul { margin-top: 6px; padding-left: 20px; }
.error-summary a { color: var(--red); }

/* a form's own panel, where it sits beside what it is for */
.panel { border: 1px solid var(--gray-300); border-radius: 8px; padding: 28px; }
.panel .form { max-width: none; }

/* ── the slip: what a person copies and takes away, or reads before agreeing ── */
.slip { background: var(--blue-tint); border-left: 3px solid var(--blue); padding: 18px 20px; }
.slip > * + * { margin-top: 10px; }
.slip h2, .slip h3 { font-size: var(--s-body); }
.slip .small { max-width: none; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { flex: 1 1 auto; min-width: 0; }

/* ── the home page ── */
.opening { padding: 56px 0 64px; align-items: center; }
.opening h1 { font-size: 34px; }
.opening .lead { margin-top: 16px; font-size: 18px; }
.opening .actions { margin-top: 28px; }
.opening h1 { text-wrap: balance; }
.trust { list-style: none; padding: 0; margin-top: 28px; display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: var(--s-small); color: var(--muted); }
.trust li { max-width: none; padding-left: 18px; position: relative; }
.trust li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 8px; height: 8px; background: var(--blue); }
.band { padding: 48px 0; border-top: 1px solid var(--gray-200); }
.band > h2 { margin-bottom: 8px; }
.band > .intro { color: var(--muted); margin-bottom: 28px; }
.band > h2 + :not(.intro) { margin-top: 24px; }

/* the sample exchange: two plain turns, the product answering */
.exchange { border: 1px solid var(--gray-300); border-radius: 8px; overflow: hidden; }
.turn { padding: 18px 24px; }
.turn + .turn { border-top: 1px solid var(--gray-200); }
.turn.asks { background: var(--gray-50); }
.turn .who { font-size: var(--s-small); font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.turn .said { font-family: var(--f-head); font-weight: 600; color: var(--navy); font-size: 18px; line-height: 1.5; }
.reply > * + * { margin-top: 12px; }
.bands { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.bands th { text-align: left; font-weight: 400; }
.bands td { text-align: right; font-family: var(--f-head); font-weight: 600; color: var(--navy); }
.bands th, .bands td { padding: 7px 0; border-bottom: 1px solid var(--gray-200); }
.bands tr:first-child th, .bands tr:first-child td { border-top: 1px solid var(--gray-200); }
.exchange figcaption { padding: 10px 24px; border-top: 1px solid var(--gray-200); font-size: var(--s-small); color: var(--muted); }

/* facts: a term and what it means, in as many columns as fit */
.facts { display: grid; gap: 28px 40px; }
.facts.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.facts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px var(--gap); }
.facts dt { font-family: var(--f-head); font-weight: 600; color: var(--navy); margin-bottom: 6px; }

/* what one lead holds: a plain table of its parts */
.fields { width: 100%; border-collapse: collapse; margin-top: 20px; }
.fields th, .fields td { text-align: left; vertical-align: top; padding: 14px 0; border-top: 1px solid var(--gray-200); }
.fields tr:last-child th, .fields tr:last-child td { border-bottom: 1px solid var(--gray-200); }
.fields th { width: 11em; padding-right: 24px; font-family: var(--f-head); font-weight: 600; color: var(--navy); white-space: nowrap; }
.rules { border-left: 3px solid var(--navy); padding-left: 28px; }
.rules > div + div { margin-top: 24px; }
.rules dt { font-family: var(--f-head); font-weight: 600; font-size: var(--s-head); color: var(--navy); margin-bottom: 4px; }

/* how to connect: the steps beside the address */
.connect { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px var(--gap); align-items: start;
  grid-template-areas: "steps slip" "steps notes"; grid-template-rows: auto 1fr; }
.connect .steps { grid-area: steps; }
.connect .slip { grid-area: slip; }
.connect .notes { grid-area: notes; }
.steps { list-style: none; padding: 0; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gray-200); max-width: none; }
.steps li:first-child { padding-top: 0; }
.steps p { max-width: none; }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(step); font-family: var(--f-head); font-weight: 700; color: var(--blue); width: 28px; height: 28px; border: 1px solid var(--blue); border-radius: 50%; display: grid; place-items: center; font-size: var(--s-small); line-height: 1; }
.notes > * + * { margin-top: 12px; }
.notes ul { padding-left: 20px; }
.notes li + li { margin-top: 8px; }

/* the way in, as a sequence: request, approval, password, connect */
.path { list-style: none; padding: 0; counter-reset: step; }
.path li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gray-200); color: var(--muted); }
.path li:last-child { border-bottom: 0; }
.path li::before { content: counter(step); font-family: var(--f-head); font-weight: 700; width: 28px; height: 28px; border: 1px solid var(--gray-500); border-radius: 50%; display: grid; place-items: center; font-size: var(--s-small); line-height: 1; }
.path li.done { color: var(--text); }
.path li.done::before { border-color: var(--green-text); color: var(--green-text); }
.path li.now { color: var(--navy); font-weight: 600; }
.path li.now::before { background: var(--blue); border-color: var(--blue); color: var(--white); }
.path .at { display: block; font-size: var(--s-small); font-weight: 400; color: var(--muted); }

/* ── the sign-in page (opened from Claude) ── */
.connect-line { display: flex; align-items: center; gap: 14px; font-family: var(--f-head); font-weight: 600; color: var(--navy); margin-bottom: 28px; }
.connect-line .wire { flex: 0 0 56px; height: 0; border-top: 2px dotted var(--gray-500); }
.connect-line .product { display: flex; align-items: center; gap: 10px; }
.connect-line .product img { display: block; height: 28px; width: 28px; }
.may-do { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--gray-200); }
.may-do h2 { font-size: var(--s-body); }
.may-do ul { margin-top: 8px; padding-left: 20px; }
.ask p { margin-top: 10px; color: var(--muted); }
.notice > * + * { margin-top: 10px; }
.equal { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── the admin's lists ── */
.list-head { margin: 32px 0 0; padding-bottom: 10px; border-bottom: 2px solid var(--navy); }
.page-head + section .list-head { margin-top: 0; }
.req { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 5fr) minmax(0, 2fr) auto; gap: 8px 32px; align-items: start; padding: 18px 0; border-bottom: 1px solid var(--gray-200); }
.req .person strong, .users .person strong { display: block; font-weight: 600; color: var(--navy); }
.req .person span, .users .person span { font-size: var(--s-small); color: var(--muted); overflow-wrap: anywhere; }
.req .what p { max-width: none; }
.req .when { font-size: var(--s-small); color: var(--muted); white-space: nowrap; padding-top: 2px; }
.req .actions { justify-content: flex-end; flex-wrap: nowrap; gap: 8px; min-width: 168px; }
.req .slip, .req .row-note { grid-column: 1 / -1; }
.row-note { color: var(--green-text); max-width: none; }
.row-note .who-now { color: var(--text); }
.empty-line { padding: 18px 0; color: var(--muted); }

.users { width: 100%; border-collapse: collapse; }
.users th { text-align: left; font: 600 var(--s-small)/1.5 var(--f-text); color: var(--muted); padding: 0 16px 10px 0; border-bottom: 2px solid var(--navy); white-space: nowrap; }
.users td { padding: 16px 16px 16px 0; border-bottom: 1px solid var(--gray-200); vertical-align: top; }
.users th:last-child, .users td:last-child { padding-right: 0; }
.users tr.has-slip td { border-bottom: 0; }
.users .acts .actions { justify-content: flex-end; flex-wrap: nowrap; gap: 8px; }
.users .slip-cell { padding-top: 0; }
.state { white-space: nowrap; font-weight: 600; }
.state::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 8px; border: 1.5px solid var(--gray-500); }
.state.active { color: var(--green-text); }
.state.active::before { background: var(--green-text); border-color: var(--green-text); }
.state.off { color: var(--muted); }
.state.off::before { background: var(--gray-500); }
.state.waiting { color: var(--navy); }
.use { min-width: 190px; }
.use .num { font-family: var(--f-head); font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.use .bar { height: 6px; background: var(--gray-200); margin-top: 6px; max-width: 200px; }
.use .bar i { display: block; height: 100%; background: var(--blue); }
.use.full .bar i { background: var(--navy); }

/* ── the confirm and the toast ── */
.confirm { border: 1px solid var(--gray-300); border-radius: 8px; padding: 28px; width: min(440px, calc(100vw - 32px)); color: var(--text); box-shadow: 0 16px 40px rgba(15, 39, 68, 0.22); }
.confirm::backdrop { background: rgba(15, 39, 68, 0.45); }
.confirm h2 { font-size: var(--s-head); text-wrap: balance; }
.confirm p { margin-top: 8px; }
.confirm .actions { margin-top: 24px; justify-content: flex-end; flex-direction: row-reverse; }
.toast { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 10; width: max-content; max-width: calc(100vw - 32px);
  background: var(--navy); color: var(--white); padding: 10px 18px; border-radius: 6px; font-size: var(--s-small); text-align: center; }
.toast:empty { display: none; }

/* ── medium: the four facts go two by two ── */
@media (max-width: 1100px) {
  :root { --gap: 40px; }
  .facts.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .req { grid-template-columns: minmax(0, 3fr) minmax(0, 5fr) auto; }
  .req .when { grid-column: 2; grid-row: 2; }
  .req .actions { grid-column: 3; grid-row: 1; }
}

/* ── narrow: one column ── */
@media (max-width: 900px) {
  :root { --s-title: 26px; --gutter: 16px; }
  .page { padding-top: 32px; padding-bottom: 48px; }
  .split, .split.wide-left { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .opening { padding: 32px 0 40px; }
  .opening h1 { font-size: 26px; }
  .band { padding: 36px 0; }
  .facts.four, .facts.three, .facts.two { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .connect { grid-template-columns: minmax(0, 1fr); grid-template-areas: "slip" "steps" "notes"; grid-template-rows: auto; }
  .site-bar .frame { gap: 16px; min-height: 60px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .brand img { height: 32px; }
  .wide-only { display: none; }
  .opening .lead { font-size: var(--s-body); }
  .fields th { width: 8.5em; padding-right: 12px; white-space: normal; }
  .rules { padding-left: 16px; }
  .bar-nav { width: 100%; gap: 24px; }
  .panel { padding: 20px; }

  .req { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .req .when, .req .actions { grid-column: 1; grid-row: auto; }
  .req .actions { justify-content: flex-start; margin-top: 4px; }

  .users, .users tbody, .users tr, .users td { display: block; }
  .users thead { display: none; }
  .users tr { padding: 16px 0; border-bottom: 1px solid var(--gray-200); }
  .users tr.has-slip { border-bottom: 0; padding-bottom: 8px; }
  .users td { padding: 0; border: 0; }
  .users td + td { margin-top: 8px; }
  .users td[data-label] { display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; }
  .users td[data-label]::before { content: attr(data-label); font-size: var(--s-small); color: var(--muted); padding-top: 2px; }
  .users .acts .actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 6px; }
  .users .slip-row { padding-top: 0; }
}
@media (max-width: 480px) {
  .brand-name { font-size: var(--s-small); padding-left: 10px; }
  .brand { gap: 10px; }
  .copy-row { flex-direction: column; align-items: stretch; }
  .opening .actions .btn, .form .actions .btn, .closing .btn { width: 100%; }
  .confirm .actions { flex-direction: column; align-items: stretch; }
  .connect-line { flex-wrap: wrap; gap: 10px; }
  .connect-line .wire { flex-basis: 28px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color 120ms, border-color 120ms; }
}

/* ── served only (ST-11.3): the admin bar's Sign out is a form's button, not the prototype's link, because it ends the
   session and carries the CSRF token (ADR-0006 § 3): its form does not break the bar's row, and its button looks as
   the prototype's link ── */
.bar-form { display: contents; }
button.bar-link { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; margin: 0; font: inherit; font-weight: 600; font-size: var(--s-small); line-height: inherit; cursor: pointer; }
