/* webull-desk: dark only (Ruling R79), mobile-first (360-430 px), no external font or image (CSP 'self').
   Colours are tokens on :root; tests/web/test_theme.py checks their WCAG AA contrast. */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151b24;
  --surface-2: #1e2632;
  --border: #2a3441;
  --border-strong: #3a4657;
  --border-field: #66768c;
  --text: #e8edf3;
  --muted: #97a3b4;
  --accent: #82adff;
  --on-accent: #0b1526;
  --accent-bg: #172540;
  --up: #3fd498;
  --up-bg: #11281f;
  --down: #ff8080;
  --warn: #f2c55c;
  --on-warn: #1f1600;
  --warn-bg: #2b2311;
  --warn-line: #5c4a1c;
  --danger: #ff8a8a;
  --danger-bg: #361719;
  --danger-fill: #c4302b;
  --on-danger: #ffffff;
  --hero: #1b2636;
  /* chart series: categorical, in this fixed order (adjacent CVD and normal-vision separation and 3:1 on --surface checked) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #5d6878;
  --radius: 16px;
  --radius-sm: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --tabbar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.with-tabs { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--space-3)); }

::selection { background: var(--accent-bg); color: var(--text); }

a { color: var(--accent); text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4) var(--space-5);
}

h1 { font-size: 1.375rem; line-height: 1.35; font-weight: 700; margin: 0 0 var(--space-4); }

h2 { font-size: 1.0625rem; line-height: 1.4; font-weight: 650; margin: 0 0 var(--space-3); }

h3 { font-size: 1rem; line-height: 1.4; font-weight: 650; margin: var(--space-5) 0 var(--space-2); }

.card > h3 { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- banners, header, tab bar */

.uat-banner {
  background: var(--warn);
  color: var(--on-warn);
  padding: var(--space-2) var(--space-4);
  text-align: center;
  font-weight: 700;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.topbar {
  max-width: 480px;
  min-height: 56px;
  margin: 0 auto;
  padding: var(--space-1) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--accent);
}

.env-chip { /* prod only: real money, at a glance (UAT has its banner instead) */
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--warn);
  color: var(--on-warn);
}

.logout { margin: 0; }

.logout button {
  min-height: 44px;
  padding: 0 var(--space-4);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 0 var(--space-2) env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tab {
  position: relative;
  flex: 1 1 0;
  max-width: 120px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.tab svg { width: 24px; height: 24px; flex: none; }

.tab[aria-current="page"] { color: var(--accent); }

.tab[aria-current="page"]::before { /* not colour alone: a bar marks the current page too */
  content: "";
  position: absolute;
  top: 0;
  left: 28%;
  right: 28%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}

.kill-banner {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--danger-fill);
  border-left-width: 6px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}

.kill-banner a { color: inherit; white-space: nowrap; }

/* ---------------------------------------------------------------- cards, notices */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
}

.card + .card, .error + .card, .kill-banner + .card { margin-top: var(--space-3); }

.muted { color: var(--muted); margin: 0; }

.meta { color: var(--muted); font-size: 0.875rem; margin: var(--space-1) 0 0; }

.warn, .error, .ok {
  border: 1px solid;
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 0.9375rem;
}

.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-line);
  border-left-color: var(--warn);
  margin: var(--space-2) 0 0;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-fill);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.ok {
  background: var(--up-bg);
  color: var(--up);
  border-color: var(--up);
  margin: 0 0 var(--space-2);
}

.card > h1 + .warn, .card > h1 + .error { margin-top: 0; }

/* ---------------------------------------------------------------- dashboard */

.total {
  padding: var(--space-5) var(--space-4);
  background: linear-gradient(160deg, var(--hero) 0%, var(--surface) 75%);
  border-color: var(--border-strong);
}

.total-label { color: var(--muted); margin: 0; font-size: 0.9375rem; }

.total-big {
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: var(--space-1) 0 var(--space-2);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; /* a very large total wraps instead of scrolling the page sideways */
}

.total-none { font-size: 1.5rem; font-weight: 700; margin: var(--space-1) 0 var(--space-2); }

.rows { list-style: none; margin: 0; padding: 0; }

.rows > li { padding: var(--space-3) 0; border-top: 1px solid var(--border); }

.rows > li:first-child { border-top: 0; padding-top: 0; }

.rows > li:last-child { padding-bottom: 0; }

.line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.line > :first-child { min-width: 0; }

.line.sub { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }

.sym { font-weight: 700; letter-spacing: 0.02em; overflow-wrap: anywhere; }

.row-link { /* an order row's link: the whole line is the tap target */
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.35em;
  min-height: 44px;
  color: var(--accent);
  text-decoration: none;
}

.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.num { text-align: right; }

.holding > .line:first-child .money { font-weight: 650; font-size: 1.0625rem; }

.rows + .meta { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }

.gain { color: var(--up); }

.loss { color: var(--down); }

.flat { color: var(--muted); }

.arrow { font-size: 0.7em; margin-right: 0.3em; vertical-align: 0.1em; }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 1px 10px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text);
}

.badge.app, .badge.agent { background: var(--accent-bg); color: var(--accent); }

.badge.ext { background: var(--warn-bg); color: var(--warn); }

.status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: 0.8125rem;
}

.status > span { padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; }

/* ---------------------------------------------------------------- dashboard v2: the hero's P/L, sparkline */

.total-usd { margin: 0; color: var(--muted); font-size: 1.125rem; font-weight: 600; }

.pl, .change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-2);
  margin: var(--space-2) 0 0;
}

.pl { margin-top: var(--space-3); }

.pl .k, .change .k { flex: 0 0 6.5em; color: var(--muted); font-size: 0.875rem; }

.pl .v, .change .v { font-size: 1.125rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.pl .also { color: var(--muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.muted-inline { color: var(--muted); font-weight: 400; font-size: 0.9375rem; }

.spark { margin: var(--space-3) 0 0; }

.sparkline { display: block; width: 100%; max-width: 420px; height: auto; }

.spark-area { fill: var(--accent); fill-opacity: 0.1; stroke: none; }

.spark-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2px;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2px; vector-effect: non-scaling-stroke; }

.spark figcaption { margin-top: var(--space-1); }

/* ---------------------------------------------------------------- summary cards, estimates */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
}

.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-3); min-width: 0; }

.stat dt { color: var(--muted); font-size: 0.8125rem; line-height: 1.35; }

.stat dt small { display: block; font-size: 0.75rem; color: var(--warn); }

.stat dd { margin: var(--space-1) 0 0; }

.stat .money { display: block; font-size: 1.1875rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; white-space: normal; }

.subline { display: block; color: var(--muted); font-size: 0.8125rem; font-weight: 400; line-height: 1.4; }

.est { color: var(--warn); font-weight: 600; white-space: nowrap; }

.est-note {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-3);
  border-left: 3px solid var(--warn-line);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.more { margin: var(--space-1) 0 0; }

.refresh-box + .est-note { margin: 0 0 var(--space-3); } /* the dividend page's once-only note */

.more .row-link { justify-content: flex-end; font-weight: 600; }

/* ---------------------------------------------------------------- allocation bar (inline SVG, CSS colours) */

.alloc { display: block; border-radius: 6px; overflow: hidden; background: var(--surface-2); }

.seg { stroke: var(--surface); stroke-width: 2px; } /* the 2 px surface gap between segments */

.s1 { fill: var(--series-1); }
.s2 { fill: var(--series-2); }
.s3 { fill: var(--series-3); }
.s4 { fill: var(--series-4); }
.s5 { fill: var(--series-5); }
.s6 { fill: var(--series-6); }
.s7 { fill: var(--series-7); }
.s8 { fill: var(--series-8); }
.so { fill: var(--series-other); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  font-size: 0.9375rem;
}

.legend li { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

.legend .num { color: var(--muted); font-weight: 400; }

.swatch { flex: none; }

/* ---------------------------------------------------------------- positions: sort, cards, table */

.head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.head-row h2 { margin: 0; }

.sort { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--surface-2); }

.seg-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.seg-link[aria-current="true"] { background: var(--accent-bg); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.pos-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1) var(--space-4);
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
}

.pos-facts > div { display: flex; justify-content: space-between; gap: var(--space-2); min-width: 0; }

.pos-facts > .span-2 { grid-column: 1 / -1; }

.pos-facts dt { color: var(--muted); white-space: nowrap; }

.pos-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.pos-facts small, .positions small, .div-table small { color: var(--muted); }

.table-wrap { display: none; }

.positions, .div-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.positions th, .positions td, .div-table th, .div-table td {
  padding: var(--space-2) var(--space-2);
  border-top: 1px solid var(--border);
  text-align: right;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.positions thead th, .div-table thead th {
  border-top: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: normal;
}

.positions th:first-child, .div-table th:first-child { text-align: left; padding-left: 0; }

.positions td:last-child, .positions th:last-child, .div-table td:last-child, .div-table th:last-child { padding-right: 0; }

.positions tbody th, .div-table tbody th { font-weight: 400; }

.positions td.next { white-space: normal; min-width: 7.5em; }

/* ---------------------------------------------------------------- dividend page (every figure an estimate, R72) */

.est-chip {
  display: inline-block;
  vertical-align: middle;
  margin-left: var(--space-1);
  padding: 1px 10px;
  border: 1px solid var(--warn-line);
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
}

.card h2 .est { font-size: 0.75rem; margin-left: var(--space-1); }

.empty { margin: 0; font-size: 1.0625rem; }

.div-top + .card { margin-top: var(--space-3); }

.div-label { margin: 0; color: var(--muted); font-size: 0.875rem; }

.div-big { margin: 2px 0 var(--space-1); font-size: 2.25rem; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }

.breakdown { display: grid; gap: var(--space-1); margin: var(--space-3) 0 0; font-size: 0.9375rem; }

.breakdown > div { display: flex; justify-content: space-between; gap: var(--space-3); }

.breakdown dt { color: var(--muted); }

.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }

.breakdown .net { padding-top: var(--space-1); border-top: 1px solid var(--border); font-weight: 650; }

.breakdown .net dt { color: var(--text); }

.breakdown.minor { padding-top: var(--space-2); border-top: 1px solid var(--border); font-size: 0.875rem; }

.months { display: block; width: 100%; max-width: 420px; height: auto; margin-top: var(--space-2); overflow: visible; }

.months .axis { stroke: var(--border-strong); stroke-width: 1px; vector-effect: non-scaling-stroke; }

.months .hit { fill: transparent; }

.month:hover .hit { fill: var(--surface-2); }

.paid { fill: var(--series-1); }

.upcoming { /* still to come: the same hue as a wash with a dashed (projected) outline */
  fill: var(--series-1);
  fill-opacity: 0.25;
  stroke: var(--series-1);
  stroke-width: 1.5px;
  stroke-dasharray: 3 2;
  vector-effect: non-scaling-stroke;
}

.mlabel { fill: var(--muted); font-size: 14px; } /* viewBox units: >= 11 px on a 360 px phone */

.mlabel.alt { display: none; } /* every other month's label (this month's always shows) */

.month.current .mlabel { fill: var(--text); font-weight: 700; }

.peak { fill: var(--text); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.table-view { margin-top: var(--space-2); }

.table-view summary, .more-payments summary { padding: 10px 0; color: var(--accent); font-weight: 600; cursor: pointer; }

.more-payments { margin-top: var(--space-2); border-top: 1px solid var(--border); }

/* a payment's dates stay whole; its shares x amount drops to the next line (right-aligned) when both do not fit */
.payment .line.sub, .upcoming-pay .line.sub { flex-wrap: wrap; gap: 0 var(--space-3); }

.payment .line.sub > :first-child, .upcoming-pay .line.sub > :first-child { white-space: nowrap; }

.payment .line.sub > .num, .upcoming-pay .line.sub > .num { margin-left: auto; }

.months-table { max-width: 420px; }

.refresh-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 var(--space-3);
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.refresh-state { margin: 0; flex: 1 1 14rem; font-size: 0.9375rem; }

.refresh-box .meta { flex: 1 0 100%; margin: 0 0 var(--space-1); }

.spinner {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: var(--space-2);
  vertical-align: -0.1em;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.flash { margin: 0 0 var(--space-3); }

.badge.soon { background: var(--accent-bg); color: var(--accent); }

.badge.low { background: var(--warn-bg); color: var(--warn); }

/* ---------------------------------------------------------------- footer, links as buttons */

.foot {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4) var(--space-5);
  color: var(--muted);
  font-size: 0.8125rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  text-decoration: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: var(--space-2) 0 0; padding: 0; }

.field-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-1);
}

.field-foot .meta { margin: 0; flex: 1 1 12rem; }

.field-foot .chip { flex: none; margin-left: auto; }

.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- forms */

label {
  display: block;
  margin: var(--space-4) 0 var(--space-1);
  color: var(--muted);
  font-size: 0.9375rem;
}

input, select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1.0625rem; /* 16 px or more: iOS does not zoom into the field */
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border-field); /* 3:1 against --bg and the cards (WCAG 1.4.11) */
  border-radius: var(--radius-sm);
}

input::placeholder { color: var(--muted); }

input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 44px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

select option, select optgroup { background: var(--surface); color: var(--text); }

.symbol-select { min-height: 56px; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.02em; }

input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
}

fieldset { border: 0; margin: var(--space-4) 0 0; padding: 0; min-width: 0; }

legend { color: var(--muted); padding: 0; margin-bottom: var(--space-2); font-size: 0.9375rem; }

fieldset.group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-4) var(--space-4);
}

fieldset.group > legend { padding: 0 var(--space-2); margin-bottom: 0; font-weight: 650; color: var(--text); }

.choice { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.choice > legend { width: 100%; }

.choice label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  margin: 0;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-bg); }

button {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
}

button:disabled { opacity: 0.55; cursor: progress; }

button.primary, button.danger {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
  font-size: 1.0625rem;
  font-weight: 700;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}

button.danger { background: var(--danger-fill); color: var(--on-danger); }

button.plain {
  width: 100%;
  margin-top: var(--space-3);
  padding: 0 var(--space-4);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
}

button.small {
  padding: 0 var(--space-4);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

button.small.ack { color: var(--accent); } /* "รู้แล้ว" undoes nothing: not in the colour of a cancel */

form.inline { margin: 0; flex: none; }

.otp-row { margin-top: var(--space-2); }

.login { margin-top: var(--space-4); }

/* ---------------------------------------------------------------- order pages, settings */

.order-head { font-size: 1.125rem; margin: 0 0 var(--space-3); }

.facts { margin: 0; }

.facts dt { color: var(--muted); font-size: 0.875rem; margin-top: var(--space-3); }

.facts dt:first-child { margin-top: 0; }

.facts dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.facts dd.big { font-size: 1.75rem; font-weight: 700; line-height: 1.25; }

.token, .preflight { margin: 0; }

.limits { margin: 0; padding-left: 1.25rem; }

.limits li + li { margin-top: var(--space-2); }

/* ---------------------------------------------------------------- small phones, wide screens */

@media (max-width: 359px) {
  .total-big { font-size: 2.25rem; }
  .tab { font-size: 0.75rem; }
}

@media (hover: hover) {
  .tab:hover { color: var(--text); }
  .tab[aria-current="page"]:hover { color: var(--accent); }
  button.primary:hover, .button:hover, .chip:hover { filter: brightness(1.08); }
}

@media (min-width: 760px) {
  main, .topbar, .foot { max-width: 640px; }
  body.with-tabs { padding-bottom: 0; }
  .tabbar {
    position: static;
    max-width: 640px;
    margin: 0 auto var(--space-2);
    padding: 0 var(--space-4);
    justify-content: flex-start;
    gap: var(--space-1);
    background: none;
    border: 0;
  }
  .tab {
    flex: 0 0 auto;
    max-width: none;
    min-height: 44px;
    flex-direction: row;
    gap: var(--space-2);
    padding: 0 var(--space-4);
    border-radius: 999px;
    font-size: 0.9375rem;
  }
  .tab svg { width: 20px; height: 20px; }
  .tab[aria-current="page"] { background: var(--surface-2); }
  .tab[aria-current="page"]::before { display: none; }
}

@media (min-width: 760px) {
  body.page-wide main, body.page-wide .topbar, body.page-wide .tabbar, body.page-wide .foot { max-width: 1080px; }
  .page-wide .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pos-cards, .sym-cards { display: none; }
  .table-wrap { display: block; }
  .div-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
  .div-top > .card + .card { margin-top: 0; }
}

@media (min-width: 1000px) {
  .page-wide #portfolio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: var(--space-3);
  }
  .page-wide #portfolio > * { grid-column: 1 / -1; }
  .page-wide #portfolio > #total { grid-column: 1; }
  .page-wide #portfolio > #summary { grid-column: 2; margin-top: 0; }
  .page-wide #summary .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
