/* IRIS operator console — one stylesheet. Rules: docs/DESIGN.md.
   White ground, reference purple palette for accent/authority; green/red for signed money,
   red for faults, green for the running engine. Colours outside :root are tokens.
   Cards take the height of their content; only the page scrolls. */

/* ── tokens ────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #ffffff;
  --fill: #f7f4fb;
  --fill-2: #ede7f6;
  --line: #ede7f6;
  --line-2: #e3d9f6;
  --ink: #181526;
  --ink-2: #5f5b6d;
  --ink-3: #6f6a80;
  --p-50: #f8f6fc;
  --p-100: #efeaf9;
  --p-300: #cdbeea;
  --p-500: #8d72c6;
  --p-600: #6b53a8;
  --p-700: #4c3b7f;
  --approval-switch-off: #ede5fa;
  --approval-switch-on: #8d72c6;
  --gain: #12724a;
  --loss: #c0342e;
  --loss-soft: #fcefee;
  --on-accent: #ffffff;               /* text on --p-600 and --loss; switch knobs */
  --tile: rgba(255, 255, 255, .82);   /* figure tiles on a tinted card */
  --scrim: rgba(24, 21, 38, .28);     /* dialog backdrop: --ink at 28% */
  --led-halo: rgba(18, 114, 74, .16); /* running engine LED: --gain at 16% */

  --font: "Anthropic Sans", "anthropic-sans", ui-sans-serif, -apple-system, BlinkMacSystemFont,
          "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --w-title: 600;
  --t-badge: 11px;                    /* the alert badge digit only */
  --t-caption: 13px;
  --t-sub: 14px;                      /* secondary text, controls, notices */
  --t-body: 15px;
  --t-head: 17px;
  --t-title: 20px;
  --t-figure: 22px;                   /* 매매 summary, funnel stages, decision tiles, indices */
  --t-large: 34px;
  --t-hero: 44px;

  --r-ctl: 12px;                      /* inputs, segmented tracks, notice panels */
  --r-tile: 14px;                     /* figure tiles, menu, toast */
  --r-card: 22px;
  --r-sheet: 24px;                    /* dialogs, log sheet */
  --h-ctl: 44px;                      /* text inputs and buttons */
  --touch: 44px;                      /* minimum touch height */
  --shadow: 0 1px 2px rgba(24, 21, 38, .03), 0 10px 28px -14px rgba(76, 59, 127, .16);
  --shadow-float: 0 1px 2px rgba(24, 21, 38, .06), 0 18px 48px -12px rgba(24, 21, 38, .28);
  --shadow-on: 0 2px 6px rgba(107, 83, 168, .28);
  --shadow-knob: 0 2px 4px rgba(0, 0, 0, .15), 0 0 0 .5px rgba(0, 0, 0, .04);
  --glass: rgba(255, 255, 255, .84);
  --blur: saturate(180%) blur(20px);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --content: 1200px;                  /* the page box; gutters sit inside it */
  --gutter: 24px;
  --pad-l: max(var(--gutter), env(safe-area-inset-left));
  --pad-r: max(var(--gutter), env(safe-area-inset-right));
  --topbar-h: 64px;                   /* 119px while the tabs sit under the header */
}

/* ── base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) { html { touch-action: pan-x pan-y; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body)/1.45 var(--font);
  letter-spacing: -.01em;
  word-break: keep-all;          /* Korean wraps between words, never inside one */
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3, b, strong { font-weight: inherit; }
a { color: var(--p-600); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled, input:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--p-500); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--gain); }
.neg { color: var(--loss); }
.muted { color: var(--ink-2); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon-btn svg, .alert-close svg, .diff-row svg, .trow.ledger.day svg, .lrow.group svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ── controls ──────────────────────────────────────────────────── */
.btn {
  height: var(--h-ctl); padding: 0 18px; border-radius: 999px;
  background: var(--fill); color: var(--ink);
  transition: background .2s var(--ease);
}
.btn.primary { background: var(--p-600); color: var(--on-accent); }
.btn.wide { width: 100%; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%; color: var(--ink-2);
  transition: background .2s var(--ease), color .2s;
}
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 16px; height: 16px; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-ctl); background: var(--fill); }
.seg button {
  min-height: 32px; padding: 0 16px; border-radius: 9px;
  font-size: var(--t-sub); color: var(--ink-2); white-space: nowrap;
  transition: background .2s var(--ease), color .2s, box-shadow .2s;
}
.seg button.on { background: var(--p-600); color: var(--on-accent); box-shadow: var(--shadow-on); }
.seg.small button { min-height: 28px; padding: 0 12px; font-size: var(--t-caption); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 10px; }
.chips button {
  height: 34px; padding: 0 14px; border-radius: 999px;
  background: var(--fill); font-size: var(--t-sub); color: var(--ink-2);
  transition: background .2s var(--ease), color .2s;
}
.chips button.on { background: var(--p-600); color: var(--on-accent); box-shadow: var(--shadow-on); }

/* iOS switch: the knob position states on/off without colour. */
.switch {
  position: relative; flex: none; width: 51px; height: 31px; border-radius: 999px;
  background: var(--fill-2); transition: background .25s var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: var(--on-accent); box-shadow: var(--shadow-knob);
  transition: transform .25s var(--ease);
}
.switch[aria-checked="true"] { background: var(--p-500); }
#approvals .switch { background: var(--approval-switch-off); }
#approvals .switch[aria-checked="true"] { background: var(--approval-switch-on); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

input[type="text"], input[type="password"], input[type="number"] {
  height: var(--h-ctl); padding: 0 14px; border-radius: var(--r-ctl); border: 1px solid transparent;
  background: var(--fill); font: inherit; color: var(--ink);
}
/* Focus shows the shared :focus-visible ring; a changed limit keeps its tint inside it. */
input:focus { background: var(--bg); }
/* Autofill keeps the input colours: an inset shadow paints over the UA's own fill. */
input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  border-color: var(--fill); box-shadow: inset 0 0 0 100px var(--fill);
}
input:-webkit-autofill:focus { border-color: var(--bg); box-shadow: inset 0 0 0 100px var(--bg); }
input[type="checkbox"] { accent-color: var(--p-500); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.brand { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-head); letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }
.brand img { width: 24px; height: 24px; }

/* ── login ─────────────────────────────────────────────────────── */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--p-50), var(--bg) 60%);
}
.login-card {
  width: min(380px, 100%); display: grid; gap: 14px; padding: 32px;
  border-radius: 28px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.field { display: grid; gap: 6px; }
.field span { font-size: var(--t-caption); color: var(--ink-2); }
.form-error { min-height: 1.3em; color: var(--loss); font-size: var(--t-sub); }

/* ── top bar ───────────────────────────────────────────────────── */
/* Brand and controls line up with the page content at every width: the page
   box is --content wide with the gutter inside it. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px 16px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--pad-r), calc(50% - var(--content) / 2 + var(--gutter))) 0
    max(var(--pad-l), calc(50% - var(--content) / 2 + var(--gutter)));
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
}
.controls { justify-self: end; display: flex; align-items: center; gap: 4px; }

/* The pill carries no state words. The LED tells the state by shape: filled
   green while running, filled gray while stopped or not yet read, filled red on
   failure, a hollow green ring while starting, stopping or a request is in
   flight (the ring also pulses where motion is allowed). */
.engine {
  display: flex; align-items: center; gap: 8px; height: 36px; margin-right: 4px;
  padding: 0 4px 0 12px; border-radius: 999px; background: var(--fill); font-size: var(--t-sub);
}
.engine .led { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.engine-text { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
/* The state name stays for screen readers only. */
#engine-state { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.engine-btn {
  height: 28px; padding: 0 12px; border-radius: 999px;
  background: var(--p-600); color: var(--on-accent); font-size: var(--t-caption);
  transition: background .2s var(--ease);
}
.engine-btn.stop { background: var(--card); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }
.engine[data-state="running"], .engine[data-state="starting"] { background: var(--p-50); box-shadow: inset 0 0 0 1px var(--p-100); }
.engine[data-state="running"] .led { background: var(--gain); box-shadow: 0 0 0 3px var(--led-halo); }
.engine[data-state="running"] .led::after {
  content: ""; position: absolute; inset: -3px; border: 2px solid var(--gain);
  border-radius: 50%; opacity: 0; animation: led-wave 2.4s ease-out infinite;
}
@keyframes led-wave {
  0% { transform: scale(.95); opacity: .28; }
  70%, 100% { transform: scale(1.7); opacity: 0; }
}
.engine[data-state="failed"] .led { background: var(--loss); }
.engine[data-state="busy"] .led, .engine[data-state="starting"] .led, .engine[data-state="stopping"] .led {
  background: none; border: 2px solid var(--gain); animation: pulse 1.2s var(--ease) infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

.alert-btn { color: var(--loss); }
.alert-btn b {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--loss); color: var(--on-accent); font-size: var(--t-badge); line-height: 17px;
}

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 25; display: grid; min-width: 168px; padding: 6px;
  border-radius: var(--r-tile); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.menu button { height: 42px; padding: 0 12px; border-radius: 9px; text-align: left; }
.menu .danger { color: var(--loss); }

/* ── page ──────────────────────────────────────────────────────── */
.page { max-width: var(--content); margin: 0 auto; padding: 28px var(--pad-r) calc(72px + env(safe-area-inset-bottom)) var(--pad-l); }
.page-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 22px; }
.page-head h1 { font-size: var(--t-large); letter-spacing: -.035em; line-height: 1.1; font-weight: var(--w-title); }
.status-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: var(--t-sub); color: var(--ink-2); }
.status-line .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.status-line[data-tone="warn"] { color: var(--loss); }
.status-line[data-tone="warn"] .dot { background: var(--loss); }
.status-line span + span::before { content: "·"; margin-right: 8px; color: var(--ink-3); }

.view { display: grid; gap: 18px; animation: view-in .28s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } }
.view > .range { justify-self: start; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.col { display: grid; gap: 18px; align-content: start; min-width: 0; }

.card {
  min-width: 0; padding: 22px 24px; border-radius: var(--r-card);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.card.tint { background: linear-gradient(160deg, var(--p-50), var(--card) 72%); border-color: var(--p-100); }
.card-head { display: flex; align-items: center; gap: 12px; min-height: 32px; margin-bottom: 8px; }
.card-head h2 { margin-right: auto; font-size: var(--t-title); letter-spacing: -.03em; font-weight: var(--w-title); }

/* ── figures ───────────────────────────────────────────────────── */
.label { font-size: var(--t-caption); color: var(--ink-2); }
.hero { margin-top: 4px; font-size: var(--t-hero); letter-spacing: -.045em; line-height: 1.05; }
.hero small { margin-left: 4px; font-size: var(--t-title); letter-spacing: -.02em; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.metrics > div { min-width: 0; padding: 12px 14px; border-radius: var(--r-tile); background: var(--tile); border: 1px solid var(--p-100); }
.metric {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; margin-top: 2px;
  font-size: var(--t-head); letter-spacing: -.02em;
}
.metric small { font-size: var(--t-caption);}
.metric.near { color: var(--p-700); }
.metric.over { color: var(--loss); }
.metrics.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics.four { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0; }
.metrics.four .metric { font-size: var(--t-figure); }

/* 오늘 summary: the stock share of total assets; the tick is the exposure limit. */
.expo { margin-top: 18px; }
.expo.ticked { margin-top: 34px; }
.expo-track { position: relative; height: 10px; border-radius: 5px; background: var(--fill-2); }
.expo-track > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 5px; background: var(--p-500); }
.expo-track > em { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink-2); }
.expo-tick { position: absolute; bottom: calc(100% + 8px); translate: -50% 0; font-size: var(--t-caption); color: var(--ink-2); white-space: nowrap; }
.expo-tick.start { translate: 0 0; }
.expo-tick.end { translate: -100% 0; }
.expo-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-top: 10px; font-size: var(--t-sub); color: var(--ink-2); }
.expo-legend i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 1px; }
.expo-legend .k-stock { background: var(--p-500); }
.expo-legend .k-cash { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.expo.near .expo-track > i, .expo.near .k-stock { background: var(--p-700); }
.expo.over .expo-track > i, .expo.over .k-stock { background: var(--loss); }

.pair { display: grid; grid-template-columns: 1fr 1fr; }
.pair > div { display: grid; gap: 1px; min-width: 0; }
.pair > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.pair b { font-size: var(--t-figure); letter-spacing: -.03em; }
.market-observation { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.market-observation summary { cursor: pointer; min-height: 44px; padding-block: 10px; }
.market-observation summary .label { margin-left: 8px; }
.market-observation section { margin-top: 16px; }
.market-observation h3 { font-size: inherit; margin-bottom: 8px; }
.observation-metric { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding-block: 8px; border-bottom: 1px solid var(--line); }
.observation-metric small { grid-column: 1 / -1; color: var(--ink-3); overflow-wrap: anywhere; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tiles > div { display: grid; justify-items: center; gap: 2px; padding: 12px 4px; border-radius: var(--r-tile); background: var(--p-50); }
.tiles b { font-size: var(--t-figure); letter-spacing: -.03em; }
.tiles span { font-size: var(--t-caption); color: var(--ink-2); }

.bar { display: grid; grid-template-columns: minmax(72px, 30%) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; }
.bar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar s { display: block; height: 6px; border-radius: 3px; background: var(--fill-2); overflow: hidden; text-decoration: none; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--p-500); }
.bar b { min-width: 3em; text-align: right; }
.bar.near i { background: var(--p-700); }
.bar.near b { color: var(--p-700); }
.bar.over i { background: var(--loss); }
.bar.over b { color: var(--loss); }

.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stage {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 18px 8px;
  border-radius: var(--r-tile); background: var(--tile); border: 1px solid var(--p-100);
}
.stage b { font-size: var(--t-figure); letter-spacing: -.03em; }
.stage span { color: var(--ink-2); }

/* ── rows: one grid per kind, re-flowed on phones ─────────────── */
/* Every cell of a row sits on one text baseline; numbers are right-aligned
   under right-aligned heads, text is left-aligned under left-aligned heads. */
.table { display: grid; }
.trow {
  display: grid; align-items: baseline; column-gap: 16px; width: 100%; padding: 12px 0;
  border-top: 1px solid var(--line); text-align: left;
}
.trow.thead { padding: 2px 0 8px; border-top: 0; font-size: var(--t-caption); color: var(--ink-3); }
.trow > span { min-width: 0; }
.trow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name.link { text-align: left; }
.pnl, .rate, .val { text-align: right; white-space: nowrap; }
.alias { color: var(--ink-3); letter-spacing: .02em; white-space: nowrap; }
.strategy-note { margin-left: 6px; color: var(--ink-3); font-size: var(--t-caption); }

.trow.holdings { grid-template-columns: minmax(0, 1.4fr) minmax(0, .6fr) repeat(4, minmax(0, 1fr)) minmax(0, .8fr); }
.trow.holdings > :not(:first-child) { text-align: right; }

.trow.ledger { grid-template-columns: 48px 52px minmax(0, 1.4fr) minmax(0, .6fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr); }
#ledger { margin-top: 8px; }
.trow.ledger > :nth-child(n+4) { text-align: right; }
.trow.ledger .time { color: var(--ink-2); }
.trow.ledger.thead > :nth-child(2) { padding-left: 8px; }   /* over the pill text */
/* Day lines fold: a chevron, the date and the day total in the 손익 column. */
.trow.ledger.day { padding: 13px 0; }
.trow.ledger.day.open { padding-bottom: 6px; }
.trow.ledger.day .date { grid-column: 1 / 6; display: flex; align-items: center; gap: 6px; }
.trow.ledger.day .pnl { grid-column: 6; }
.trow.ledger.day svg, .lrow.group svg { flex: none; width: 14px; height: 14px; color: var(--ink-3); transition: transform .2s var(--ease); }
.trow.ledger.day.open svg, .lrow.group.open svg { transform: rotate(90deg); }

.trow.decisions { grid-template-columns: minmax(0, 1fr) 112px minmax(0, 2fr) 52px; }
.trow.decisions .reason { overflow: hidden; color: var(--ink-2); text-overflow: ellipsis; white-space: nowrap; }
.trow.decisions > :last-child { text-align: right; color: var(--ink-2); }
.trow.decisions.thead > :nth-child(2) { padding-left: 10px; }

.trow.approvals { grid-template-columns: minmax(0, 1fr) 80px 104px; align-items: center; }
.trow.approvals .cell { display: flex; align-items: center; gap: 4px; }
.trow.approvals .name { white-space: normal; }

/* Home fills: side, name and amount on the first line; time and rate below. */
.fill {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "side name pnl" "side time rate";
  align-items: baseline; column-gap: 12px; row-gap: 2px; padding: 12px 0; border-top: 1px solid var(--line);
}
.fill:first-child, .lrow:first-child { border-top: 0; }
.fill .sidecell { grid-area: side; }
.fill .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fill .pnl { grid-area: pnl; }
.fill .time { grid-area: time; font-size: var(--t-caption); color: var(--ink-3); }
.fill .rate { grid-area: rate; font-size: var(--t-caption); }

.lrow { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 12px 0; border-top: 1px solid var(--line); text-align: left; }
.lrow .main { flex: 1; min-width: 0; }
.lrow .main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow.group { align-items: center; margin-top: 6px; border-top-color: var(--line-2); }
.lrow.group .main, .lrow.retired { color: var(--ink-2); }
.lrow.retired { padding: 9px 0 9px 14px; font-size: var(--t-sub); }

.side, .pill {
  display: inline-block; font-style: normal; font-size: var(--t-caption);
  line-height: 1.3; white-space: nowrap;
}
.side { padding: 3px 8px; border-radius: 7px; }
.side.sell { background: var(--p-600); color: var(--on-accent); }
.side.stop { background: var(--p-700); color: var(--on-accent); }
.side.buy { background: var(--fill); color: var(--ink-2); }
.pill { padding: 3px 10px; border-radius: 999px; background: var(--fill); color: var(--ink-2); }
.pill.on { background: var(--p-100); color: var(--p-700); }
.pill.warn { background: var(--loss-soft); color: var(--loss); }

.detail { display: grid; gap: 8px; margin: 0 0 12px; padding: 14px 16px; border-radius: var(--r-ctl); background: var(--fill); }
.detail > div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; font-size: var(--t-sub); }
.detail dt { color: var(--ink-3); }

.empty { padding: 16px 0; color: var(--ink-3); }
.notice { margin-bottom: 12px; padding: 10px 14px; border-radius: var(--r-ctl); background: var(--loss-soft); color: var(--loss); font-size: var(--t-sub); }
.advice { display: grid; gap: 6px; margin-top: 14px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--fill); color: var(--ink-2); font-size: var(--t-sub); }
.note { margin-top: 12px; font-size: var(--t-caption); color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: var(--t-caption); word-break: break-all; }

/* ── limits ────────────────────────────────────────────────────── */
.field-row, .setting {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 58px; padding: 8px 0; border-top: 1px solid var(--line);
}
.field-row:first-child, .card-head + .setting { border-top: 0; }
.field-row .value { display: flex; align-items: center; gap: 8px; }
.field-row input { width: 100px; height: 38px; padding: 0 12px; border-radius: var(--r-ctl); text-align: right; }
.field-row em { width: 1em; font-style: normal; color: var(--ink-2); }
.field-row s { font-size: var(--t-sub); color: var(--ink-3); }
.field-row.changed input { background: var(--p-50); border-color: var(--p-300); color: var(--p-700); }

.save-bar {
  position: sticky; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 10; justify-self: center;
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.save-bar .btn { height: 36px; }

.diff-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.diff-row:first-child { border-top: 0; }
.diff-row .num { display: flex; align-items: center; gap: 6px; }
.diff-row s { color: var(--ink-3); }
.diff-row b { color: var(--p-700); }
.diff-row svg { width: 14px; height: 14px; color: var(--ink-3); }

/* ── log, toast, dialogs ───────────────────────────────────────── */
.log-sheet {
  position: fixed; z-index: 30; top: calc(var(--topbar-h) + 12px + env(safe-area-inset-top));
  right: calc(16px + env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(440px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  display: flex; flex-direction: column; padding: 16px 20px;
  border-radius: var(--r-sheet); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); box-shadow: var(--shadow-float); animation: sheet-in .3s var(--ease);
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } }
.log { flex: 1; overflow: auto; font-size: var(--t-caption); line-height: 1.5; overscroll-behavior: contain; }
.log-line { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 10px; padding: 3px 0; }
.log-line time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.log-line span { overflow-wrap: anywhere; }
.log-line.error span { color: var(--loss);}

/* Centred with `translate`, so the entry's transform only lifts it in place. */
.toast {
  position: fixed; z-index: 40; left: 50%; top: calc(var(--topbar-h) + 12px + env(safe-area-inset-top));
  translate: -50% 0; max-width: min(560px, calc(100vw - var(--pad-l) - var(--pad-r))); padding: 12px 18px;
  border-radius: var(--r-tile); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-float);
  cursor: pointer; animation: sheet-in .3s var(--ease);
}
.toast[data-tone="error"] { background: var(--loss-soft); border-color: var(--loss-soft); color: var(--loss); }

.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 22px 24px;
  border: 0; border-radius: var(--r-sheet); background: var(--card); color: var(--ink); box-shadow: var(--shadow-float);
}
.dialog.small { width: min(400px, calc(100vw - 32px)); }
.dialog::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog h2 { font-size: var(--t-title); letter-spacing: -.03em; font-weight: var(--w-title); }
.dialog > p, #info-body > p { margin-top: 8px; color: var(--ink-2); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dialog .check { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.alerts { display: grid; gap: 8px; }
.alerts .alert { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--loss-soft); color: var(--loss); }
.alerts .alert > span { flex: 1; min-width: 0; }
.alert-close { position: relative; display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; color: var(--ink-2); }
.alert-close.small { width: 24px; height: 24px; }
.alert-close.small svg { width: 14px; height: 14px; }
#alerts-title:focus { outline: none; }
.alert-close:focus-visible { outline-color: var(--ink-3); }
.facts, .axes { display: grid; margin-top: 14px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.facts dt { color: var(--ink-2); }
.axes > div { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); }
.axes > div:first-child { border-top: 0; }
.axes dt { font-size: var(--t-caption); color: var(--ink-3); }
.axes dd { display: grid; gap: 2px; }
.axes dd span { font-size: var(--t-sub); color: var(--ink-2); }
.axes .advice { margin-top: 4px; padding: 12px 14px; border-top: 0; }

/* ── pointer ───────────────────────────────────────────────────── */
/* Hover only where a pointer hovers, so a tap leaves nothing behind; a press
   looks the same on every pointer (web/app.js turns :active on for iOS). */
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--fill-2); }
  .btn.primary:hover:not(:disabled), .engine-btn:hover:not(:disabled) { background: var(--p-700); }
  .engine-btn.stop:hover:not(:disabled) { background: var(--fill); }
  .icon-btn:hover:not(:disabled) { background: var(--fill); color: var(--ink); }
  .alert-btn:hover:not(:disabled) { color: var(--loss); }
  .seg button:hover:not(.on):not(:disabled), .chips button:hover:not(.on):not(:disabled) { color: var(--ink); }
  .menu button:hover:not(:disabled) { background: var(--fill); }
  button.trow:hover .name, .name.link:hover, .lrow.link:hover b, .trow.ledger.day:hover .date, .lrow.group:hover .main { color: var(--p-600); }
}
.btn:active:not(:disabled) { background: var(--fill-2); }
.btn.primary:active:not(:disabled), .engine-btn:active:not(:disabled) { background: var(--p-700); }
.engine-btn.stop:active:not(:disabled) { background: var(--fill); }
.icon-btn:active:not(:disabled) { background: var(--fill); color: var(--ink); }
.alert-btn:active:not(:disabled) { color: var(--loss); }
.seg button:active:not(.on):not(:disabled), .chips button:active:not(.on):not(:disabled) { color: var(--ink); }
.menu button:active:not(:disabled) { background: var(--fill); }
button.trow:active .name, .name.link:active, .lrow.link:active b, .trow.ledger.day:active .date, .lrow.group:active .main { color: var(--p-600); }

/* ── responsive ────────────────────────────────────────────────── */
/* 매매: per-strategy results stay beside a long ledger while folded, and come
   first once the layout stacks. */
@media (min-width: 1021px) {
  .t-strategies:not(.expanded) { position: sticky; top: calc(var(--topbar-h) + 18px + env(safe-area-inset-top)); }
}
@media (max-width: 1020px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .t-strategies { order: -1; }
}

/* Two rows: brand and controls, then the tabs.
   119px = 10 + 36 + 12 + 50 (44px tabs in the track) + 10 + 1 (hairline). */
@media (max-width: 860px) {
  :root { --topbar-h: 119px; }
  .topbar { grid-template-columns: auto 1fr; padding-top: calc(env(safe-area-inset-top) + 10px); padding-bottom: 10px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; display: flex; }
  .tabs button { flex: 1; min-height: var(--touch); padding: 0 6px; }
}

/* Phones draw the tabs 36px high; they keep a --touch tall hit area below.
   111px = 10 + 36 + 12 + 42 (36px tabs in the track) + 10 + 1 (hairline). */
@media (max-width: 640px) {
  :root { --gutter: 16px; --t-large: 30px; --t-hero: 36px; --t-figure: 20px; --topbar-h: 111px; }
  .tabs button { min-height: 36px; font-size: var(--t-body); }
  .topbar { column-gap: 8px; }
  .topbar .brand { gap: 6px; font-size: var(--t-sub); }
  .controls { gap: 0; }
  .controls .icon-btn { width: 32px; height: 32px; }
  .engine { gap: 4px; margin-right: 0; padding-left: 8px; }
  .engine-btn { padding: 0 10px; }
  /* Touch areas: small controls keep their drawn size and reach --touch vertically
     only, so neighbours on one line never overlap (chip rows sit 10px apart). */
  .tabs button, .engine-btn, .seg.small button, .chips button, .save-bar .btn { position: relative; }
  .icon-btn::before, .alert-close::before, .tabs button::before, .engine-btn::before, .seg.small button::before, .chips button::before, .save-bar .btn::before {
    content: ""; position: absolute; inset: min(0px, calc((100% - var(--touch)) / 2)) 0;
  }
  .chips { row-gap: 10px; }
  .page { padding-top: 18px; }
  .card { padding: 18px; }
  /* Summary figures become a list: label left, value right. */
  .metrics:not(.four) { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 14px; }
  .metrics:not(.four) > div {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 11px 0; border: 0; border-top: 1px solid var(--p-100); border-radius: 0; background: none;
 }
  .metrics:not(.four) .label { font-size: var(--t-body); }
  .metrics.four > div { padding: 10px 12px; }
  .metrics.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .trow.thead:not(.approvals) { display: none; }
  /* Home: summary, market and fills before the long lists. */
  #view-home .split, #view-home .col { display: contents; }
  #view-home { grid-template-columns: minmax(0, 1fr); }
  .o-summary { order: 1; } .o-market { order: 2; } .o-holdings { order: 3; }
  .o-fills { order: 4; } .o-decisions { order: 5; }
  .trow .d { display: none; }
  .trow.holdings { grid-template-columns: minmax(0, 1fr) auto 4.5em; grid-template-areas: "name val val" ". pnl rate"; row-gap: 2px; }
  .trow.holdings .name { grid-area: name; }
  .trow.holdings .val { grid-area: val; }
  .trow.holdings .pnl { grid-area: pnl; font-size: var(--t-caption); }
  .trow.holdings .rate { grid-area: rate; font-size: var(--t-caption); }
  .trow.ledger { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "side name pnl" "side time rate"; row-gap: 2px; }
  .trow.ledger .sidecell { grid-area: side; }
  .trow.ledger .name { grid-area: name; }
  .trow.ledger .time { grid-area: time; font-size: var(--t-caption); color: var(--ink-3); }
  .trow.ledger .pnl { grid-area: pnl; }
  .trow.ledger .rate { grid-area: rate; font-size: var(--t-caption); }
  .trow.ledger.day { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: none; }
  .trow.ledger.day .date { grid-area: auto; grid-column: 1; }
  .trow.ledger.day .pnl { grid-area: auto; grid-column: 2; }
  .trow.decisions { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name pill" "reason reason"; row-gap: 4px; }
  .trow.decisions .name { grid-area: name; }
  .trow.decisions .pillcell { grid-area: pill; text-align: right; }
  .trow.decisions .reason { grid-area: reason; white-space: normal; font-size: var(--t-sub); }
  .trow.decisions > :last-child { display: none; }
  .trow.approvals { grid-template-columns: minmax(0, 1fr) 56px 90px; gap: 10px; }
  .detail > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .field-row input { width: 84px; }

  .log-sheet {
    top: auto; left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; height: 72vh;
    max-height: calc(100% - var(--topbar-h) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 350px) {
  :root { --topbar-h: 147px; }
  .topbar { grid-template-columns: minmax(0, 1fr); }
  .topbar .brand { grid-column: 1; grid-row: 1; }
  .controls { grid-column: 1; grid-row: 2; justify-self: stretch; justify-content: space-between; }
  .tabs { grid-row: 3; }
}

/* ── preferences ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .menu, .log-sheet, .save-bar, .toast { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (forced-colors: active) {
  .seg button.on, .chips button.on { outline: 2px solid Highlight; }
  .switch { border: 1px solid ButtonText; }
  .switch[aria-checked="true"] { background: Highlight; }
  #approvals .switch { background: Canvas; }
  #approvals .switch[aria-checked="true"] { background: Highlight; }
  .card, .dialog, .log-sheet { border: 1px solid CanvasText; }
}
