:root {
  --paper: #f4efe4;
  --paper-deep: #ebe3d4;
  --card: #fbf8f0;
  --ink: #27231d;
  --ink-soft: #4b453b;
  --muted: #837a6b;
  --line: rgba(39, 35, 29, .14);
  --line-strong: rgba(39, 35, 29, .24);
  --clay: #b85937;
  --clay-deep: #914329;
  --clay-soft: #f0dfd4;
  --sage: #68745c;
  --sage-soft: #e4e8db;
  --gold: #9a7a44;
  --danger: #a54434;
  --danger-soft: #f1dbd4;
  --rail: #211e19;
  --rail-ink: #e9e1d3;
  --rail-muted: #a49a89;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: "Avenir Next", "Gill Sans", "Century Gothic", "Trebuchet MS", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --shadow: 0 1px 0 rgba(39, 35, 29, .04), 0 18px 45px -38px rgba(39, 35, 29, .5);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 82% -10%, rgba(184, 89, 55, .10), transparent 62%),
    radial-gradient(900px 600px at -10% 40%, rgba(104, 116, 92, .08), transparent 55%),
    var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: 0;
  max-width: 100vw;
  pointer-events: none;
  z-index: 5;
  opacity: .20;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.19'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.shell {
  display: grid;
  grid-template-columns: clamp(246px, 13vw, 320px) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 24px 24px;
  background: var(--rail);
  color: var(--rail-ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rail::after {
  content: "";
  position: absolute;
  inset: auto -100px -180px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  border: 1px solid rgba(233, 225, 211, .12);
}

.brand { display: flex; align-items: center; gap: 13px; margin-bottom: 48px; }
.brand-mark {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(233, 225, 211, .40);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: -.06em;
  color: var(--rail-ink);
  white-space: nowrap;
}
.brand-mark span { color: var(--clay); }
.brand-copy { display: flex; flex-direction: column; line-height: 1.25; }
.brand-copy strong { font-family: var(--serif); font-size: 18px; font-weight: 500; }
.brand-copy span { color: var(--rail-muted); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 13px;
  padding: 10px 12px;
  margin-left: -12px;
  color: var(--rail-muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: .015em;
  border-left: 1px solid transparent;
  transition: color .25s ease, border-color .25s ease, background .25s ease;
}
.nav-link span {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  opacity: .62;
}
.nav-link:hover { color: var(--rail-ink); background: rgba(255, 255, 255, .035); }
.nav-link.active { color: var(--rail-ink); border-left-color: var(--clay); background: rgba(255, 255, 255, .045); }

.rail-foot {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding-top: 20px;
  border-top: 1px solid rgba(233, 225, 211, .13);
}
.live-dot { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 4px rgba(104, 116, 92, .15); flex: none; }
.live-dot.offline { background: var(--danger); box-shadow: 0 0 0 4px rgba(165, 68, 52, .15); }
.rail-label, .rail-note { display: block; }
.rail-label { color: var(--rail-muted); font-family: var(--mono); font-size: 9px; letter-spacing: .08em; }
.rail-note { color: var(--rail-ink); font-size: 10px; margin-top: 5px; line-height: 1.45; max-width: 150px; }

.main {
  width: 100%;
  min-width: 0;
  padding: 42px clamp(32px, 4.2vw, 96px) 38px;
}

.hero { padding: 8px 0 44px; border-bottom: 1px solid var(--line); animation: rise .65s ease both; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.eyebrow, .section-index, .panel-label {
  font-family: var(--mono);
  letter-spacing: .11em;
  text-transform: uppercase;
  font-size: 9px;
  color: var(--muted);
}
.eyebrow { color: var(--clay-deep); }
.as-of { color: var(--muted); font-family: var(--mono); font-size: 10px; }
.hero h1 {
  margin: 25px 0 18px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(45px, 6.2vw, 78px);
  line-height: .98;
  letter-spacing: -.045em;
}
.hero h1 em { color: var(--clay); font-weight: 400; }
.lede { max-width: 590px; color: var(--ink-soft); font-size: 16px; line-height: 1.75; margin: 0; }
.status-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 30px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--ink-soft);
  background: rgba(251, 248, 240, .55);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .035em;
  white-space: nowrap;
}
.chip::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--muted); }
.chip-ok { color: var(--sage); border-color: rgba(104, 116, 92, .28); background: var(--sage-soft); }
.chip-ok::before { background: var(--sage); }
.chip-warn { color: var(--gold); border-color: rgba(154, 122, 68, .28); background: #f1e8d6; }
.chip-warn::before { background: var(--gold); }
.chip-danger { color: var(--danger); border-color: rgba(165, 68, 52, .25); background: var(--danger-soft); }
.chip-danger::before { background: var(--danger); }
.chip-clay { color: var(--clay-deep); border-color: rgba(184, 89, 55, .25); background: var(--clay-soft); }
.chip-clay::before { background: var(--clay); }
.chip-neutral::before { background: var(--muted); }

.section { padding: 42px 0 18px; animation: rise .7s ease both; }
.section:nth-of-type(2) { animation-delay: .06s; }
.section:nth-of-type(3) { animation-delay: .10s; }
.section:nth-of-type(4) { animation-delay: .14s; }
.section:nth-of-type(5) { animation-delay: .18s; }
.section:nth-of-type(6) { animation-delay: .22s; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-index { display: block; margin-bottom: 7px; color: var(--clay-deep); }
.section h2 { margin: 0; font-family: var(--serif); font-size: clamp(27px, 3vw, 38px); font-weight: 400; letter-spacing: -.03em; }
.section-kicker { color: var(--muted); font-size: 11px; letter-spacing: .03em; padding-bottom: 4px; text-align: right; }

.kpi-grid { display: grid; grid-template-columns: 1.55fr 1fr 1fr 1fr; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kpi { min-height: 150px; padding: 22px 24px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.kpi:first-child { padding-left: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.kpi-value { margin-top: 22px; font-family: var(--serif); font-size: clamp(37px, 4.2vw, 57px); line-height: .95; font-weight: 400; letter-spacing: -.04em; }
.kpi-value.small { font-size: clamp(25px, 2.8vw, 36px); margin-top: 28px; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-top: auto; padding-top: 18px; font-size: 11px; }
.movement { color: var(--sage); font-family: var(--mono); }
.movement.down { color: var(--danger); }
.muted { color: var(--muted); font-size: 11px; }

.overview-grid { display: grid; grid-template-columns: 1.65fr .9fr; gap: 18px; margin-top: 18px; }
.panel {
  background: rgba(251, 248, 240, .72);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  padding: 21px 22px;
  min-width: 0;
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 17px; }
.panel-label { display: block; margin-bottom: 5px; color: var(--muted); }
.panel h3 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 400; letter-spacing: -.02em; }

.chart-panel { min-height: 328px; }
.chart-wrap { position: relative; min-height: 228px; }
#equity-chart { display: block; width: 100%; height: 228px; overflow: visible; }
.chart-empty { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); font-size: 12px; }
.chart-tooltip {
  position: absolute; display: none; pointer-events: none; padding: 6px 8px; border-radius: 6px;
  background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 10px; white-space: nowrap;
  transform: translate(-50%, -130%); z-index: 3;
}
.chart-legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; margin-top: 4px; }
.legend-line { width: 18px; height: 1px; background: var(--clay); display: inline-block; }
.chart-note { margin-left: auto; font-family: var(--mono); font-size: 9px; }

.risk-panel { background: #2a261f; color: var(--rail-ink); border-color: rgba(39, 35, 29, .3); }
.risk-panel .panel-label, .risk-panel .muted { color: var(--rail-muted); }
.risk-panel h3 { color: var(--rail-ink); }
.risk-panel .chip { background: rgba(255,255,255,.06); color: var(--rail-ink); border-color: rgba(255,255,255,.17); }
.risk-meter { padding-top: 4px; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid rgba(233,225,211,.10); font-size: 11px; color: var(--rail-muted); }
.meter-row strong { color: var(--rail-ink); font-family: var(--mono); font-size: 12px; font-weight: 400; }
.meter-track { height: 4px; background: rgba(233,225,211,.14); margin-top: 20px; border-radius: 9px; overflow: hidden; }
.meter-track span { display: block; width: 0; height: 100%; background: var(--clay); transition: width .8s ease; }
.meter-scale { display: flex; justify-content: space-between; color: var(--rail-muted); font-family: var(--mono); font-size: 8px; margin-top: 7px; }
.run-facts { margin: 20px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.run-facts div { border-top: 1px solid rgba(233,225,211,.10); padding-top: 8px; }
.run-facts dt { color: var(--rail-muted); font-size: 9px; letter-spacing: .03em; }
.run-facts dd { margin: 3px 0 0; color: var(--rail-ink); font-family: var(--mono); font-size: 10px; }

.book-grid, .memory-grid, .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.empty-state { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line-strong); border-radius: 9px; }
.position-row, .order-row {
  display: grid; grid-template-columns: 1.05fr .55fr .65fr .65fr; gap: 8px; align-items: center;
  padding: 11px 0; border-top: 1px solid var(--line); font-size: 11px;
}
.position-row:first-child, .order-row:first-child { border-top: 0; }
.position-symbol, .order-symbol { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.position-symbol small, .order-symbol small { display: block; font-family: var(--sans); color: var(--muted); font-size: 9px; margin-top: 2px; }
.position-value, .order-value { text-align: right; font-family: var(--mono); font-size: 10px; }
.position-value small, .order-value small { display: block; color: var(--muted); font-size: 9px; }
.order-status { justify-self: end; }
.order-meta { grid-column: 1 / -1; color: var(--muted); font-size: 9px; line-height: 1.4; margin-top: -3px; overflow-wrap: anywhere; }

.table-panel { padding-bottom: 9px; }
.filter-input {
  border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.3);
  padding: 7px 10px; font-family: var(--sans); font-size: 11px; color: var(--ink); outline: none; width: 175px;
}
.filter-input:focus { border-color: var(--clay); }
.filter-input::placeholder { color: var(--muted); }
.table-scroll { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 740px; }
.data-table th { text-align: left; font-family: var(--mono); font-size: 8px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 400; padding: 10px 9px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 12px 9px; border-bottom: 1px solid rgba(39,35,29,.08); font-size: 11px; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background .2s ease; }
.data-table tbody tr:hover { background: rgba(184, 89, 55, .045); }
.exp-id { font-family: var(--mono); color: var(--clay-deep); font-size: 10px; }
.num { font-family: var(--mono); font-size: 10px; }
.negative { color: var(--danger); }
.positive { color: var(--sage); }
.evidence-pill { display: inline-block; padding: 3px 7px; border-radius: 99px; font-size: 9px; border: 1px solid var(--line); color: var(--ink-soft); }
.evidence-ok { background: var(--sage-soft); color: var(--sage); border-color: rgba(104,116,92,.23); }
.evidence-fail { background: var(--danger-soft); color: var(--danger); border-color: rgba(165,68,52,.2); }
.evidence-warn { background: var(--clay-soft); color: var(--clay-deep); border-color: rgba(184,89,55,.2); }
.strategy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.strategy-card { border: 1px solid var(--line); border-radius: 11px; padding: 14px 15px; background: rgba(251,248,240,.48); }
.strategy-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.strategy-card h4 { margin: 0; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--ink); overflow-wrap: anywhere; }
.strategy-card p { margin: 10px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.strategy-metrics { display: flex; gap: 12px; margin-top: 12px; font-family: var(--mono); font-size: 9px; color: var(--ink-soft); }

.hypothesis-list { display: flex; flex-direction: column; }
.hypothesis { padding: 13px 0; border-top: 1px solid var(--line); }
.hypothesis:first-child { border-top: 0; padding-top: 0; }
.hypothesis-head { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; }
.hypothesis h4 { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 400; line-height: 1.3; }
.hypothesis-id { font-family: var(--mono); font-size: 9px; color: var(--clay-deep); }
.hypothesis p { color: var(--muted); font-size: 10px; line-height: 1.55; margin: 5px 0 0; }
.kv-list { margin: 0; }
.kv-list div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); }
.kv-list div:first-child { border-top: 0; padding-top: 0; }
.kv-list dt { color: var(--muted); font-size: 10px; }
.kv-list dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 10px; color: var(--ink-soft); overflow-wrap: anywhere; max-width: 68%; }
.provenance-panel { background: var(--clay-soft); border-color: rgba(184, 89, 55, .2); }
.provenance-panel .kv-list div { border-top-color: rgba(145, 67, 41, .14); }
.fine-print { color: var(--clay-deep); font-size: 10px; line-height: 1.55; margin: 16px 0 0; padding-top: 12px; border-top: 1px solid rgba(145,67,41,.14); overflow-wrap: anywhere; }

.log-panel { background: var(--rail); border-radius: 15px; overflow: hidden; color: var(--rail-ink); box-shadow: var(--shadow); }
.log-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 17px; border-bottom: 1px solid rgba(233,225,211,.12); }
.tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; color: var(--rail-muted); padding: 6px 9px; font-family: var(--sans); font-size: 10px; cursor: pointer; border-radius: 5px; }
.tab:hover { color: var(--rail-ink); background: rgba(255,255,255,.05); }
.tab.active { color: var(--rail-ink); background: rgba(255,255,255,.09); }
.log-actions { display: flex; gap: 7px; align-items: center; }
.filter-input.dark { background: rgba(255,255,255,.06); border-color: rgba(233,225,211,.16); color: var(--rail-ink); }
.filter-input.dark::placeholder { color: var(--rail-muted); }
.ghost-button { border: 1px solid rgba(233,225,211,.18); background: transparent; color: var(--rail-muted); padding: 6px 9px; border-radius: 6px; font-family: var(--mono); font-size: 9px; cursor: pointer; }
.ghost-button:hover { color: var(--rail-ink); border-color: rgba(233,225,211,.38); }
.log-meta { padding: 9px 18px 0; color: var(--rail-muted); font-family: var(--mono); font-size: 8px; }
.log-content { margin: 0; padding: 10px 18px 22px; min-height: 250px; max-height: 470px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 10px; line-height: 1.7; color: #d8d0c2; }
.log-content .hit { background: rgba(184, 89, 55, .35); color: #fff; }

.footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .02em; }
.toast { position: fixed; right: 22px; bottom: 22px; background: var(--ink); color: var(--paper); padding: 9px 12px; border-radius: 7px; font-size: 11px; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .25s, transform .25s; z-index: 10; }
.toast.show { opacity: 1; transform: translateY(0); }
.is-hidden { display: none !important; }
body.modal-open { overflow: hidden; }

.hero-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.auth-pill {
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 99px;
  color: var(--ink-soft); background: rgba(251,248,240,.55);
  font-family: var(--mono); font-size: 9px;
}
.auth-button, .rail-login, .primary-button, .danger-button {
  border: 1px solid var(--line-strong); border-radius: 7px; cursor: pointer;
  font-family: var(--sans); font-size: 11px; transition: background .2s, border-color .2s, color .2s;
}
.auth-button { background: transparent; color: var(--ink-soft); padding: 5px 9px; }
.auth-button:hover { border-color: var(--clay); color: var(--clay-deep); background: var(--clay-soft); }
.rail-auth { margin-top: 18px; padding: 14px 0 0; border-top: 1px solid rgba(233,225,211,.13); }
.rail-login { display: block; width: 100%; margin-top: 8px; padding: 8px 9px; color: var(--rail-ink); background: rgba(255,255,255,.055); border-color: rgba(233,225,211,.18); }
.rail-login:hover { border-color: var(--clay); color: #fff; }

.public-progress-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.public-progress-card {
  min-height: 150px; padding: 18px 19px; border: 1px solid var(--line); border-radius: 13px;
  background: rgba(251,248,240,.68); box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.public-progress-card span { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .06em; }
.public-progress-card strong { margin-top: auto; font-family: var(--serif); font-size: clamp(27px, 3vw, 40px); font-weight: 400; line-height: 1; letter-spacing: -.035em; }
.public-progress-card small { margin-top: 9px; color: var(--muted); font-size: 10px; }
.public-progress-card.accent { background: var(--clay-soft); border-color: rgba(184,89,55,.22); }
.public-progress-card.accent strong { font-family: var(--mono); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; }
.public-runline { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 12px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.public-runline div { padding: 12px 15px; border-left: 1px solid var(--line); min-width: 0; }
.public-runline div:first-child { border-left: 0; }
.public-runline span, .public-runline strong { display: block; }
.public-runline span { color: var(--muted); font-size: 9px; }
.public-runline strong { margin-top: 3px; font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--ink-soft); overflow-wrap: anywhere; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  padding: 20px; background: rgba(24,21,17,.72); backdrop-filter: blur(6px);
}
.auth-modal {
  position: relative; width: min(100%, 440px); padding: 30px; border: 1px solid rgba(233,225,211,.2);
  border-radius: 16px; background: var(--card); box-shadow: 0 30px 100px rgba(0,0,0,.35);
  animation: modalIn .34s cubic-bezier(.2,.78,.3,1) both;
}
.modal-backdrop:not(.is-hidden) { animation: backdropIn .22s ease both; }
.auth-modal h2 { margin: 9px 0 8px; font-family: var(--serif); font-size: 30px; font-weight: 400; letter-spacing: -.03em; }
.auth-modal > p { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 20px; }
.auth-modal label { display: block; margin-top: 13px; color: var(--ink-soft); font-size: 11px; }
.auth-modal input {
  display: block; width: 100%; margin-top: 6px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: rgba(255,255,255,.55); padding: 10px 11px; color: var(--ink); font: 12px var(--mono); outline: none;
}
.auth-modal input:focus { border-color: var(--clay); box-shadow: 0 0 0 3px rgba(184,89,55,.11); }
.modal-close { position: absolute; right: 13px; top: 10px; border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; }
.form-error { min-height: 20px; margin-top: 10px; color: var(--danger); font-size: 11px; }
.primary-button { padding: 9px 14px; background: var(--ink); color: var(--paper); border-color: var(--ink); }
.primary-button:hover { background: var(--clay-deep); border-color: var(--clay-deep); }
.primary-button:active, .danger-button:active, .auth-button:active, .rail-login:active { transform: translateY(1px) scale(.985); }
.primary-button:disabled { opacity: .5; cursor: wait; }
.compact-button { padding: 7px 11px; font-size: 10px; }
.danger-button { width: 100%; margin-top: 10px; padding: 8px 10px; background: rgba(165,68,52,.12); color: #ffd9cf; border-color: rgba(255,255,255,.16); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.confirm-modal code { color: var(--clay-deep); font-family: var(--mono); }
.ghost-button.light { color: var(--ink-soft); border-color: var(--line-strong); }
.captcha-field { margin-top: 14px; }
.captcha-controls { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 9px; align-items: stretch; margin-top: 6px; }
.captcha-controls input { margin: 0; }
.captcha-image-button {
  position: relative; display: block; width: 200px; height: 73px; padding: 0; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: 7px; background: var(--paper-deep); cursor: pointer;
}
.captcha-image-button::after {
  content: "↻"; position: absolute; right: 5px; bottom: 3px; color: var(--clay-deep);
  font: 13px var(--mono); opacity: 0; transform: rotate(-20deg); transition: opacity .2s, transform .3s;
}
.captcha-image-button:hover::after { opacity: 1; transform: rotate(0); }
.captcha-image-button img { display: block; width: 100%; height: 100%; object-fit: cover; }
.captcha-image-button img.is-refreshing { animation: captchaRefresh .22s ease both; }
.captcha-field small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.auth-modal.is-shaking { animation: shake .34s ease both; }

.control-section { position: relative; }
.control-risk-note {
  margin-bottom: 15px; padding: 12px 14px; border-left: 2px solid var(--clay);
  background: rgba(240,223,212,.55); color: var(--clay-deep); font-size: 11px; line-height: 1.6;
}
.control-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 18px; align-items: start; }
.control-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 13px; }
.control-toolbar h3 { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 400; }
.action-groups { display: flex; flex-direction: column; gap: 13px; }
.action-group { border: 1px solid var(--line); border-radius: 13px; background: rgba(251,248,240,.55); overflow: hidden; }
.action-group-head { display: flex; justify-content: space-between; padding: 12px 15px; border-bottom: 1px solid var(--line); color: var(--clay-deep); font-family: var(--mono); font-size: 10px; letter-spacing: .05em; }
.action-group-head small { color: var(--muted); }
.action-card { border-top: 1px solid rgba(39,35,29,.08); transition: background .24s ease, box-shadow .24s ease, transform .24s ease; }
.action-card:hover { background: rgba(240,223,212,.16); }
.action-card[open] { background: rgba(240,223,212,.24); box-shadow: inset 2px 0 0 var(--clay); }
.action-card:first-of-type { border-top: 0; }
.action-card summary { list-style: none; display: flex; justify-content: space-between; gap: 12px; padding: 13px 15px; cursor: pointer; }
.action-card summary::-webkit-details-marker { display: none; }
.action-card summary::before { content: "+"; color: var(--clay); font-family: var(--mono); font-size: 13px; }
.action-card[open] summary::before { content: "−"; }
.action-card summary > div { flex: 1; min-width: 0; }
.action-card summary strong, .action-card summary small { display: block; }
.action-card summary strong { font-family: var(--sans); font-size: 12px; font-weight: 500; }
.action-card summary small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.risk-badge { flex: none; align-self: flex-start; padding: 3px 6px; border-radius: 99px; font-family: var(--mono); font-size: 8px; text-transform: uppercase; border: 1px solid var(--line); }
.risk-low { color: var(--sage); background: var(--sage-soft); }
.risk-medium { color: var(--gold); background: #f1e8d6; }
.risk-high { color: var(--danger); background: var(--danger-soft); }
.action-card form { padding: 3px 15px 15px 32px; }
.action-card[open] form { animation: controlReveal .28s cubic-bezier(.2,.75,.3,1) both; }
.action-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-fields label { display: block; color: var(--ink-soft); font-size: 10px; }
.action-fields input, .action-fields select {
  display: block; width: 100%; margin-top: 5px; border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 8px; background: rgba(255,255,255,.45); color: var(--ink); font: 10px var(--mono); outline: none;
}
.action-fields input:focus, .action-fields select:focus { border-color: var(--clay); }
.action-fields small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.action-fields .check-field {
  grid-column: 1 / -1; display: grid; grid-template-columns: 16px 1fr; gap: 3px 7px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 7px;
}
.action-fields .check-field input { width: auto; margin: 0; }
.action-fields .check-field small { grid-column: 2; margin: 0; }
.command-preview { display: block; margin-top: 12px; padding: 9px 10px; border-radius: 6px; background: #2a261f; color: #d8d0c2; font-size: 9px; white-space: pre-wrap; overflow-wrap: anywhere; }
.action-submit-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 9px; }
.job-panel { position: sticky; top: 18px; min-width: 0; padding: 17px; border-radius: 14px; background: #28241e; color: var(--rail-ink); box-shadow: var(--shadow); }
.job-panel.is-running { animation: runningGlow 2.5s ease-in-out infinite; }
.job-panel.is-running #job-status { animation: statusPulse 1.4s ease-in-out infinite; }
.job-panel .panel-label { color: var(--rail-muted); }
.job-panel .control-toolbar h3 { color: var(--rail-ink); }
.job-panel .chip { background: rgba(255,255,255,.06); color: var(--rail-ink); border-color: rgba(255,255,255,.17); }
.job-summary { min-height: 56px; padding: 11px 0; border-top: 1px solid rgba(233,225,211,.12); border-bottom: 1px solid rgba(233,225,211,.12); }
.job-summary strong, .job-summary span { display: block; }
.job-summary strong { font-size: 12px; font-weight: 500; }
.job-summary span { margin-top: 5px; color: var(--rail-muted); font: 9px var(--mono); overflow-wrap: anywhere; }
.job-log {
  height: 260px; overflow: auto; margin: 11px 0 0; padding: 11px; border-radius: 8px;
  background: #1d1a16; color: #d8d0c2; font: 9px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.job-history-head { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(233,225,211,.12); }
.job-history-head .panel-label { color: var(--rail-muted); }
.job-history { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow: auto; margin-top: 8px; }
.job-history-item {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; width: 100%; padding: 7px; border: 1px solid rgba(233,225,211,.1);
  border-radius: 7px; background: transparent; color: var(--rail-ink); text-align: left; cursor: pointer;
}
.job-history-item:hover { border-color: rgba(233,225,211,.25); background: rgba(255,255,255,.035); }
.job-history-item strong { font-size: 10px; font-weight: 500; }
.job-history-item small { grid-column: 2; color: var(--rail-muted); font: 8px var(--mono); }
.empty-state.tiny { padding: 14px 10px; border-color: rgba(233,225,211,.16); color: var(--rail-muted); }
body.admin [data-admin-only]:not(.is-hidden) { animation: roleReveal .42s cubic-bezier(.2,.75,.3,1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes backdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(.965); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes controlReveal {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes captchaRefresh {
  from { opacity: .25; transform: scale(.98); filter: blur(1px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-6px); }
  44% { transform: translateX(5px); }
  66% { transform: translateX(-3px); }
  82% { transform: translateX(2px); }
}

@keyframes roleReveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes runningGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(184,89,55,.12), var(--shadow); }
  50% { box-shadow: 0 0 0 1px rgba(184,89,55,.42), 0 18px 50px -28px rgba(184,89,55,.55); }
}

@keyframes statusPulse {
  0%, 100% { transform: scale(1); opacity: .82; }
  50% { transform: scale(1.035); opacity: 1; }
}

@media (min-width: 1500px) {
  .rail { padding: 34px 28px 28px; }
  .brand { margin-bottom: 36px; }
  .nav { gap: 5px; }
  .nav-link { padding: 11px 13px; font-size: 14px; }
  .rail-auth { margin-top: 20px; }
  .rail-foot { padding-top: 24px; }
  .main { padding-top: 50px; padding-bottom: 44px; }
  .hero { padding-bottom: 52px; }
  .hero h1 { max-width: 1180px; font-size: clamp(76px, 4.35vw, 112px); }
  .lede { max-width: 780px; font-size: 17px; }
  .status-strip { margin-top: 34px; }
  .chip { padding: 6px 10px; font-size: 10px; }
  .section { padding-top: 52px; padding-bottom: 22px; }
  .section-head { margin-bottom: 24px; }
  .section h2 { font-size: clamp(36px, 2.45vw, 52px); }
  .public-progress-grid { gap: 16px; }
  .public-progress-card { min-height: 178px; padding: 23px 24px; }
  .public-progress-card strong { font-size: clamp(38px, 2.85vw, 58px); }
  .public-progress-card.accent strong { font-size: 18px; }
  .public-runline div { padding: 15px 18px; }
  .kpi { min-height: 176px; padding: 25px 28px 23px; }
  .kpi-value { font-size: clamp(50px, 3.8vw, 70px); }
  .kpi-value.small { font-size: clamp(30px, 2.25vw, 40px); }
  .overview-grid { grid-template-columns: 1.75fr .8fr; gap: 20px; }
  .book-grid { grid-template-columns: 1.15fr .85fr; }
  .memory-grid { grid-template-columns: 1.18fr .82fr; }
  .panel { padding: 24px 26px; }
  .table-scroll { margin: 0 -26px; padding: 0 26px; }
  .data-table th { font-size: 9px; padding: 12px 11px; }
  .data-table td { font-size: 12px; padding: 14px 11px; }
  .strategy-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
  .control-grid { grid-template-columns: minmax(0, 1.55fr) minmax(390px, .45fr); gap: 22px; }
  .action-groups { gap: 16px; }
  .job-log { height: 330px; }
}

@media (min-width: 2100px) {
  .main { padding-left: clamp(56px, 4.6vw, 128px); padding-right: clamp(56px, 4.6vw, 128px); }
  .hero-top { align-items: flex-start; }
  .hero h1 { max-width: 1320px; font-size: clamp(88px, 4.45vw, 124px); }
  .hero-meta { padding-top: 3px; }
  .public-progress-grid { gap: 20px; }
  .public-progress-card { min-height: 196px; }
  .overview-grid { grid-template-columns: 1.9fr .76fr; }
  .chart-panel { min-height: 370px; }
  .chart-wrap { min-height: 260px; }
  #equity-chart { height: 260px; }
  .action-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .action-group { min-width: 0; }
  .action-card form { padding-left: 18px; }
  .job-panel { max-width: 520px; justify-self: end; width: 100%; }
}

@media (max-width: 1080px) {
  .shell { grid-template-columns: 204px minmax(0, 1fr); }
  .rail { padding-left: 18px; padding-right: 18px; }
  .main { padding-left: 30px; padding-right: 30px; }
  .kpi-grid { grid-template-columns: 1.5fr 1fr 1fr; }
  .kpi:nth-child(4) { border-top: 1px solid var(--line); }
  .kpi:nth-child(3) { border-right: 0; }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .rail { position: relative; height: auto; padding: 18px 20px 15px; }
  .brand { margin-bottom: 18px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; width: 100%; min-width: 0; max-width: 100%; }
  .nav-link { padding: 7px 9px; margin-left: 0; white-space: nowrap; border-left: 0; border-bottom: 1px solid transparent; }
  .nav-link.active { border-left: 0; border-bottom-color: var(--clay); background: transparent; }
  .nav-link span { display: none; }
  .rail-auth { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; }
  .rail-auth .rail-label { flex: 1; }
  .rail-login { width: auto; min-width: 116px; margin-top: 0; }
  .rail-foot { display: none; }
  .main { padding: 28px 18px 24px; }
  .hero h1 { font-size: 46px; }
  .hero-top { align-items: flex-start; flex-direction: column; gap: 8px; }
  .hero-meta { justify-content: flex-start; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 6px; }
  .section-kicker { text-align: left; padding: 0; }
  .desktop-only { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { min-height: 122px; padding: 16px 14px; }
  .kpi:nth-child(odd) { padding-left: 0; }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(3), .kpi:nth-child(4) { border-top: 1px solid var(--line); }
  .kpi-value { margin-top: 16px; font-size: 34px; }
  .kpi-value.small { font-size: 24px; margin-top: 20px; }
  .book-grid, .memory-grid, .settings-grid { grid-template-columns: 1fr; }
  .public-progress-grid { grid-template-columns: 1fr 1fr; }
  .public-runline { grid-template-columns: 1fr 1fr; }
  .public-runline div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .public-runline div:nth-child(4) { border-top: 1px solid var(--line); }
  .control-grid { grid-template-columns: 1fr; }
  .action-fields { grid-template-columns: 1fr; }
  .job-panel { position: relative; top: auto; }
  .table-scroll { width: 100%; margin: 0; padding: 0; }
  .log-toolbar { flex-direction: column; align-items: stretch; }
  .log-actions { justify-content: space-between; }
  .filter-input { width: 100%; }
  .footer { flex-direction: column; gap: 5px; }
  .captcha-controls { grid-template-columns: 1fr; }
  .captcha-image-button { width: 100%; height: 82px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
