/* Argo CDS demo: mobile-first. Tokens: bg surface text muted line primary warn danger r gap. */
:root {
  --bg: #f1f4f3; --surface: #fff; --text: #0b1a17; --muted: #5f6d68; --line: #dde5e2;
  --primary: #0f766e; --warn: #8f5f00; --danger: #c62a3a;
  --r: 12px; --gap: 12px;
  /* Two control sizes only: --control (buttons, inputs, selects, tabs) and --chip (asset filters). */
  --control: 52px; --chip: 40px; --pad: 12px;
  --nav-h: calc(var(--control) + 13px + env(safe-area-inset-bottom));
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #090f0e; --surface: #111a18; --text: #e8f0ed; --muted: #a9b8b3; --line: #22302c; --primary: #2dd4bf; --warn: #eab308; --danger: #ff6c7b; }
}

/* Base: the page is exactly the viewport wide; nothing outside a scroller may widen it. */
* { box-sizing: border-box; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
html, body, button, input, select, label, nav { touch-action: manipulation; }
html { min-height: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text); overflow-x: clip; }
main { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
main.portfolio { max-width: 880px; }
h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); font-size: 14px; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.met { color: var(--primary); }
.waiting { color: var(--warn); }
[data-dimension] { text-transform: uppercase; }
/* T&C symbols: system symbol fonts first, so iPhone never shows missing-glyph boxes. */
.tc-icon, .tc-icons { font-family: 'Apple Symbols', 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'Noto Sans Symbols', system-ui, sans-serif; }
/* Every T&C symbol sits in the same fixed box, so the three read as one set. */
.tc-icon, .tc-icons i { display: inline-block; width: 1.25em; line-height: 1; vertical-align: middle; text-align: center; font-style: normal; font-weight: 400; }
.tc-icon { margin-right: 4px; }
.tc-icons { display: inline-flex; }
.tc-icons i.off { color: var(--muted); opacity: .3; }

/* Controls: one height (--control), one font size (17px, >= 16px stops iOS zoom), one inner padding (--pad). */
button, input, select { font: inherit; font-size: 17px; min-height: var(--control); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); }
button { padding: 10px var(--pad); background: var(--surface); cursor: pointer; }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--surface); font-weight: 600; }
button:disabled { opacity: .5; }
button.link { border: 0; background: none; min-width: 52px; padding: 0 var(--gap); font-size: 14px; color: var(--primary); text-transform: none; letter-spacing: 0; }
.sec-head .link { margin-right: calc(-1 * var(--gap)); }
.buttons { display: flex; gap: var(--gap); flex-wrap: wrap; }
.buttons button { flex: 1 1 auto; }
.trade-actions { flex: none; }
.confirm { border-color: var(--primary); }
/* Labels, notes and input contents share one left edge: the input's inner padding. */
input, select { width: 100%; min-width: 0; max-width: 100%; padding: 9px var(--pad); background: var(--bg); text-align: left; }
input[type="datetime-local"] { display: block; overflow: hidden; -webkit-appearance: none; appearance: none; }
input[type="datetime-local"]::-webkit-datetime-edit, input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper { padding: 0; min-width: 0; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; }
input.known { padding-right: 40px; background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f766e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E") no-repeat right 12px center / 20px; }
@media (prefers-color-scheme: dark) {
  input.known { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232dd4bf' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7'/%3E%3C/svg%3E"); }
}
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; padding-left: calc(var(--pad) + 1px); }
.available { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); padding-left: calc(var(--pad) + 1px); }
.condition-quantity { display: flex; gap: var(--gap); margin-top: var(--gap); }

/* Toast: small, at the top centre; never covers the header or the tabs. */
.toast { position: fixed; z-index: 4; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px); pointer-events: none; }
.toast.visible { background: var(--surface); border: 1px solid var(--primary); border-radius: 999px; padding: 2px 12px; font-size: 13px; overflow-wrap: anywhere; }
.toast.error { border-color: var(--danger); }

/* Header: ARGO at the left, the account at the right. */
header { display: flex; justify-content: space-between; align-items: center; gap: var(--gap); margin-bottom: 8px; min-width: 0; }
header.whoami { font-size: 17px; }
header.whoami b { color: var(--primary); }
header.whoami b.brand { letter-spacing: .08em; }
header.whoami + .sec-head { margin-top: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }

/* Bottom bar: fixed to the viewport, scrolls inside itself, never widens the page. */
nav#tabs { position: fixed; z-index: 1; left: 0; right: 0; bottom: 0; display: flex; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
nav#tabs[hidden] { display: none; }
nav#tabs button { flex: 1 0 auto; min-width: 84px; border: 0; background: none; font-size: 15px; color: var(--muted); }
nav#tabs button.on { color: var(--primary); font-weight: 700; }

/* One card / row grammar: States, Holdings, Events, Settings, offers. */
.card, .holdings-list .bar { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card { padding: var(--gap); margin-bottom: var(--gap); }
.card .card { border: 0; padding: 0; margin: var(--gap) 0 0; }
.row { display: flex; gap: var(--gap); align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > span, .st, .offer dd, .ev-detail, .holdings-list .bar small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row > span:first-child { flex: none; }
.st { padding: 4px 0; }
.st-role { display: inline-block; min-width: 3.5em; }
.holdings-list { display: flex; flex-direction: column; gap: var(--gap); }
.holdings-list .bar { display: flex; justify-content: space-between; align-items: center; gap: var(--gap); min-height: 68px; padding: 6px 14px; font-size: 17px; line-height: 1.2; text-align: left; overflow-wrap: anywhere; }
.holdings-list .bar > span:first-child, .ev-main { min-width: 0; }
.holdings-list .bar .holding-amount { flex: none; text-align: right; }
.holdings-list .bar .holding-amount small { white-space: nowrap; }
.holdings-list small, .ev-detail { display: block; font-size: 12px; color: var(--muted); }
.ev-main b { font-weight: 700; }
.ev-detail b { font-weight: 600; }

/* Offer cards */
.offer { overflow-wrap: anywhere; }
.offer-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--gap); font-size: 17px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.offer-heading b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer-heading span, .offer-heading .arrow { color: var(--muted); font-size: 15px; font-weight: 400; }
.offer-heading .target { text-align: right; }
.offer dt { color: var(--muted); font-size: 14px; }
.offer dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.offer-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px var(--gap); margin: 0 0 var(--gap); }

/* Tables: light, fit the viewport; intentional horizontal regions scroll inside themselves. */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 6px 4px; border-top: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
tr.me td { font-weight: 700; }
.scroll { overflow-x: auto; overscroll-behavior-x: contain; max-width: 100%; }
.preview-table { font-size: 15px; border-collapse: separate; border-spacing: 0; }
.preview-table th, .preview-table td { padding: 10px 8px; overflow-wrap: anywhere; }
.preview-table thead th { white-space: nowrap; overflow-wrap: normal; background: color-mix(in srgb, var(--text) 6%, transparent); }
.preview-table tbody td, .preview-table tbody th { border: 0; color: var(--text); }
.preview-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text) 3%, transparent); }
.preview-table .empty { color: var(--muted); }
.table-units { margin: 0 0 8px; }
/* Order books: four fixed columns. */
.order-book { table-layout: fixed; }
.order-book .c-side { width: 18%; }
.order-book .c-price, .order-book .c-size { width: 31%; }
.order-book .c-tc { width: 20%; }
.order-book th, .order-book td { padding-inline: 8px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order-book th:first-child, .order-book td:first-child { text-align: left; }
.order-book td:last-child .tc-icons { justify-content: flex-end; }
.order-book td.empty { white-space: normal; text-align: left; }
.order-book small { display: block; }
.order-book tbody tr[data-row] { cursor: pointer; }
.order-book tr.bid th { color: var(--primary); }
.order-book tr.ask th { color: var(--danger); }
/* Total supply */
.supply-table { --locus-width: 10rem; --symbol-width: 7rem; table-layout: fixed; width: calc(var(--locus-width) + var(--symbols) * var(--symbol-width)); }
.supply-table.fit { width: 100%; }
.supply-table col { width: var(--symbol-width); }
.supply-table col:first-child { width: var(--locus-width); }
.supply-table.fit col, .supply-table.fit col:first-child { width: auto; }
.supply-table th, .supply-table td { padding: 8px; text-align: right; }
.supply-table th:first-child, .supply-table td:first-child { text-align: left; font-weight: 600; }
.supply-table tbody tr:last-child > * { border-top: 1px solid var(--line); }
#supply { margin-top: 16px; }
.card > #supply-title { margin-top: 0; }

/* Workspace (Portfolio, Public, Private): exactly the screen above the bottom bar. The content scrolls inside
   a bounded area; the dock (T&C row, actions, asset filters) is anchored at the bottom and has a fixed height,
   so nothing in it moves when the content, the chosen action or the keyboard changes. */
main.portfolio { height: 100dvh; padding-bottom: var(--nav-h); display: flex; flex-direction: column; overflow: hidden; }
main.portfolio > header { flex: none; }
.portfolio-panes { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.workspace { flex: 1; min-height: 0; }
.workspace-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--gap); overflow-y: auto; overscroll-behavior-y: contain; }
.workspace-body > * { flex: none; }
.workspace .presets { margin-bottom: 0; }
.dock { flex: none; display: flex; flex-direction: column; gap: var(--gap); padding: 4px 0 var(--gap); }
.tab-row { display: flex; flex-wrap: nowrap; gap: 4px; flex: none; }
.tab-row button { flex: 1; min-width: 0; border: 0; border-radius: 0; background: none; color: var(--muted); padding: 4px 2px; font-size: 14px; white-space: nowrap; }
.tab-row button.on { color: var(--primary); font-weight: 700; box-shadow: inset 0 -3px 0 var(--primary); }
.tab-row button:active { background: var(--line); }
/* Pager height follows its tallest pane: shrinking inactive panes would show blank panes mid-swipe. */
.action-pager { display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; min-width: 0; }
.portfolio-action { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; scroll-snap-stop: always; overflow: clip; }
.action-fields { min-width: 0; }
.action-fields .card:last-child { margin-bottom: 0; }
.tc-line { display: block; min-height: 1.4em; margin-top: calc(4px - var(--gap)); font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-line:empty { display: none; }
.tc-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }

/* Asset filters: light chips that scroll inside themselves. The pair is always two rows tall
   (one asset leaves the second row empty), so the dock keeps one height for every action. */
.pair-sliders { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--chip) var(--chip); gap: 8px; flex: none; min-width: 0; }
.quick-assets { display: flex; gap: 8px; margin-top: var(--gap); overflow-x: auto; overscroll-behavior-x: contain; max-width: 100%; }
.pair-sliders .quick-assets { margin-top: 0; }
.quick-assets button { flex: none; min-width: 72px; min-height: var(--chip); padding: 0 var(--pad); font-size: 15px; font-weight: 500; color: var(--muted); background: none; }
.quick-assets button[aria-pressed="true"], .presets button.on { border-color: var(--primary); color: var(--primary); }
/* Public and Private have no action row: the spacer keeps their filters at Portfolio's height. */
.dock-spacer { flex: none; height: var(--control); }
.presets { display: flex; gap: var(--gap); margin-bottom: var(--gap); overflow: hidden; }
.presets button { white-space: nowrap; }
.presets button.on { font-weight: 700; }

/* Offer and Lost PIN sheets: light; transform and opacity only. Top-anchored and fixed; only the lower edge follows the visual viewport (set by JS). */
.sheet-back { position: fixed; inset: 0 0 auto; height: var(--vv-bottom, 100%); z-index: 3; display: flex; align-items: flex-start; padding: calc(8px + env(safe-area-inset-top)) 0 8px; box-sizing: border-box; background: #0006; opacity: 0; transition: opacity .2s; }
.sheet-back[hidden] { display: none; }
.sheet-back.open { opacity: 1; }
.sheet { width: 100%; max-width: 560px; max-height: 100%; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: var(--r); padding: 16px 16px 0; transform: translateY(-100%); transition: transform .2s ease-out; }
.sheet-back.open .sheet { transform: none; }
.sheet .buttons { position: sticky; bottom: 0; background: var(--surface); padding: var(--gap) 0 16px; }
.sheet .card { border: 0; padding: 0; margin: 0; }
/* Inline T&C editor: normal flow in the workspace body, in place of the action pane. */
.tc-editor { display: flex; flex-direction: column; gap: var(--gap); }
.tc-editor .card { margin: 0; }
.term-controls { display: flex; align-items: center; gap: var(--gap); margin-top: 4px; }
.term-controls .tab-row button, .term-controls .link { min-height: var(--chip); }

/* Login */
main.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding-bottom: 16px; }
.login-box { width: 100%; max-width: 360px; margin: 0 auto; }
.login-box h1 { text-align: center; margin-bottom: var(--gap); }
.login-box .muted { text-align: center; }
.login-box button.link { display: block; margin: 8px auto 0; }
