:root {
  --bg: #06100d;
  --bg-deep: #030907;
  --panel: rgba(13, 29, 24, .82);
  --panel-strong: #10271f;
  --line: rgba(166, 215, 194, .13);
  --line-strong: rgba(166, 215, 194, .22);
  --text: #f1f7f4;
  --muted: #94aaa1;
  --green: #44e29a;
  --green-2: #a9f4ce;
  --gold: #edc86d;
  --red: #ff7d76;
  --blue: #77bdfb;
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -5%, rgba(68, 226, 154, .13), transparent 34rem),
    radial-gradient(circle at -10% 25%, rgba(69, 127, 101, .11), transparent 30rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button, input { font: inherit; }
button { color: inherit; }
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(3, 9, 7, .74);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #06100d;
  background: linear-gradient(145deg, var(--green-2), var(--green));
  font-weight: 900;
  box-shadow: 0 8px 30px rgba(68, 226, 154, .18);
}
.brand strong { display: block; font-size: 14px; letter-spacing: .05em; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.topbar-status, .status-pill, .paper-badge { display: flex; align-items: center; }
.topbar-status { gap: 10px; }
.paper-badge {
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(237, 200, 109, .32);
  border-radius: 999px;
  color: var(--gold);
  background: rgba(237, 200, 109, .08);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.paper-badge.subtle { background: transparent; }
.status-pill {
  gap: 8px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(237, 200, 109, .09); }
.status-pill.fresh .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(68, 226, 154, .09); }
.status-pill.degraded .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 125, 118, .1); }

main { width: min(1460px, calc(100% - 40px)); margin: 0 auto; padding: 64px 0 80px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 54px; align-items: end; padding: 26px 4px 56px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, p { text-wrap: balance; }
h1 { margin: 0; max-width: 850px; font-size: clamp(43px, 6.2vw, 88px); line-height: .98; letter-spacing: -.055em; font-weight: 730; }
h1 span { color: var(--green-2); }
.hero-copy { max-width: 650px; margin: 25px 0 0; color: var(--muted); font-size: clamp(15px, 1.5vw, 18px); }
.hero-meta { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--line); box-shadow: var(--shadow); }
.hero-meta div { padding: 17px 19px; background: rgba(10, 24, 19, .94); }
.hero-meta span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.hero-meta strong { display: block; margin-top: 5px; font-size: 14px; font-variant-numeric: tabular-nums; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi, .panel {
  border: 1px solid var(--line);
  background: linear-gradient(150deg, rgba(18, 39, 31, .86), rgba(8, 20, 16, .9));
  box-shadow: var(--shadow);
}
.kpi { min-height: 156px; padding: 23px; border-radius: 18px; }
.kpi-primary { background: linear-gradient(145deg, rgba(29, 80, 60, .88), rgba(11, 31, 23, .92)); }
.kpi > span { display: block; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.kpi strong { display: block; margin: 20px 0 4px; font-size: clamp(22px, 2.5vw, 36px); line-height: 1; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.positive { color: var(--green-2) !important; }
.negative { color: var(--red) !important; }

.panel { border-radius: 20px; padding: clamp(20px, 2.5vw, 30px); }
.active-decision-panel { margin-bottom: 14px; border-color: rgba(237, 200, 109, .24); }
.active-decision-content { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 14px; }
.active-cash-strip { padding: 20px; border: 1px solid rgba(237, 200, 109, .2); border-radius: 15px; background: rgba(237, 200, 109, .055); }
.active-cash-strip span, .active-cash-strip small { display: block; color: var(--muted); font-size: 10px; }
.active-cash-strip span { text-transform: uppercase; letter-spacing: .08em; }
.active-cash-strip strong { display: block; margin: 14px 0 5px; color: var(--gold); font-size: 27px; letter-spacing: -.035em; }
.decision-cards { display: grid; gap: 12px; }
.decision-card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: rgba(2, 8, 6, .28); }
.decision-card.position-card { border-color: rgba(68, 226, 154, .24); }
.decision-card.no-trade-card { border-color: rgba(237, 200, 109, .18); }
.decision-card-head { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.decision-state { color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.position-card .decision-state { color: var(--green); }
.decision-card h3 { margin: 5px 0 0; font-size: 20px; line-height: 1.15; }
.decision-time { color: var(--muted); font-size: 10px; white-space: nowrap; }
.decision-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.decision-fact { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); }
.decision-fact.wide { grid-column: 1 / -1; }
.decision-fact span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; letter-spacing: .07em; text-transform: uppercase; }
.decision-fact p { margin: 0; font-size: 11px; white-space: pre-wrap; overflow-wrap: anywhere; }
.rank-panel { margin-bottom: 14px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading.compact { margin-bottom: 20px; }
h2 { margin: 0; font-size: clamp(21px, 2vw, 29px); line-height: 1.15; letter-spacing: -.03em; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.legend-dot.fresh { background: var(--green); }
.legend-dot.stale { background: var(--red); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th { padding: 0 13px 11px; color: #708a7e; font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: .1em; font-weight: 750; }
td { padding: 15px 13px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(169, 244, 206, .035); }
.active-account-row { cursor: pointer; outline: none; }
.active-account-row:hover { background: rgba(237, 200, 109, .055); }
.active-account-row:focus-visible { box-shadow: inset 0 0 0 2px var(--gold); background: rgba(237, 200, 109, .07); }
.account-open-hint { margin-left: auto; color: var(--gold); font-size: 9px; font-weight: 750; letter-spacing: .04em; white-space: nowrap; }
.rank { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: rgba(255,255,255,.04); font-weight: 750; }
.rank.top { color: #07120f; background: var(--green-2); }
.account-name { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.ticker { display: inline-flex; min-width: 43px; justify-content: center; padding: 3px 6px; border-radius: 7px; color: var(--green-2); background: rgba(68, 226, 154, .08); font-size: 10px; letter-spacing: .04em; }
.active-ticker { color: var(--gold); background: rgba(237, 200, 109, .09); }
.value { font-weight: 760; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.data-tag { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 8px; background: rgba(255,255,255,.035); color: var(--muted); font-size: 10px; white-space: nowrap; }
.data-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.data-tag.stale::before { background: var(--red); }
.loading-cell { padding: 40px; text-align: center; color: var(--muted); }

.split { display: grid; grid-template-columns: 1.25fr .75fr; gap: 14px; margin-bottom: 14px; }
.chart-note { color: var(--muted); font-size: 11px; }
.bar-chart { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 92px minmax(120px, 1fr) 88px; gap: 12px; align-items: center; }
.bar-label { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { width: 100%; height: 9px; border: 0; border-radius: 999px; background: rgba(255,255,255,.045); overflow: hidden; appearance: none; }
.bar-track::-webkit-progress-bar { border-radius: 999px; background: rgba(255,255,255,.045); }
.bar-track::-webkit-progress-value { min-width: 2px; border-radius: 999px; background: linear-gradient(90deg, #378866, var(--green)); }
.bar-track::-moz-progress-bar { min-width: 2px; border-radius: 999px; background: linear-gradient(90deg, #378866, var(--green)); }
.bar-track.negative-bar::-webkit-progress-value { background: linear-gradient(90deg, #783e3a, var(--red)); }
.bar-track.negative-bar::-moz-progress-bar { background: linear-gradient(90deg, #783e3a, var(--red)); }
.bar-value { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.health-list { display: grid; gap: 8px; }
.health-row { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(2, 8, 6, .24); }
.health-symbol { font-weight: 800; font-size: 12px; }
.health-source { min-width: 0; }
.health-source strong { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health-source small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.health-state { padding: 4px 7px; border-radius: 7px; color: var(--green-2); background: rgba(68,226,154,.08); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.health-state.stale { color: var(--red); background: rgba(255,125,118,.08); }

.rules-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rule { min-height: 108px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: rgba(2, 8, 6, .25); }
.rule-icon { display: grid; place-items: center; width: 29px; height: 29px; margin-bottom: 16px; border-radius: 9px; color: var(--green-2); background: rgba(68,226,154,.09); font-size: 13px; font-weight: 900; }
.rule strong { display: block; font-size: 13px; }
.rule small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

.timeline-panel { margin-top: 14px; }
.timeline-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 10px; cursor: pointer; }
.filter:hover, .filter.active { border-color: rgba(68,226,154,.34); color: var(--green-2); background: rgba(68,226,154,.07); }
.timeline { display: grid; }
.timeline-item { position: relative; display: grid; grid-template-columns: 125px 20px 1fr auto; gap: 14px; min-height: 91px; }
.timeline-time { padding-top: 17px; color: var(--muted); font-size: 10px; line-height: 1.45; text-align: right; font-variant-numeric: tabular-nums; }
.timeline-rail { position: relative; display: flex; justify-content: center; }
.timeline-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.timeline-dot { position: relative; z-index: 1; width: 9px; height: 9px; margin-top: 22px; border: 2px solid var(--bg); border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(68,226,154,.1); }
.timeline-dot.error { background: var(--red); box-shadow: 0 0 0 3px rgba(255,125,118,.1); }
.timeline-dot.info { background: var(--blue); box-shadow: 0 0 0 3px rgba(119,189,251,.1); }
.timeline-content { padding: 15px 0 18px; border-bottom: 1px solid var(--line); }
.timeline-content strong { display: block; font-size: 13px; }
.timeline-content p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.timeline-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.timeline-meta span { padding: 4px 7px; border-radius: 6px; background: rgba(255,255,255,.04); color: var(--muted); font-size: 9px; }
.detail-button { align-self: start; margin-top: 15px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.detail-button:hover { color: var(--green-2); border-color: rgba(68,226,154,.32); }
.empty { padding: 38px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; }

.method-note { display: flex; gap: 16px; align-items: flex-start; margin-top: 14px; padding: 20px 24px; border: 1px solid rgba(237,200,109,.2); border-radius: 16px; background: rgba(237,200,109,.045); }
.method-icon { display: grid; flex: 0 0 auto; place-items: center; width: 26px; height: 26px; border: 1px solid rgba(237,200,109,.35); border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-weight: 700; }
.method-note strong { font-size: 12px; }
.method-note p { margin: 5px 0 0; max-width: 960px; color: var(--muted); font-size: 11px; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(20px,5vw,72px); border-top: 1px solid var(--line); color: #61786e; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }

dialog { width: min(700px, calc(100% - 32px)); max-height: min(84vh, 820px); overflow: auto; padding: 0; border: 1px solid var(--line-strong); border-radius: 20px; color: var(--text); background: #0b1b16; box-shadow: 0 35px 100px rgba(0,0,0,.6); }
dialog.active-account-dialog { width: min(980px, calc(100% - 32px)); }
dialog.active-account-dialog, dialog.active-account-dialog * { min-width: 0; overflow-wrap: anywhere; }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; top: 14px; float: right; z-index: 2; width: 34px; height: 34px; margin: 14px; border: 1px solid var(--line); border-radius: 50%; background: #10271f; cursor: pointer; font-size: 20px; }
#dialog-content { padding: 34px; }
.dialog-kicker { color: var(--green); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
#dialog-content h3 { margin: 8px 45px 22px 0; font-size: 28px; line-height: 1.1; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.12); }
.detail-card.wide { grid-column: 1 / -1; }
.detail-card span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.detail-card p { margin: 0; font-size: 12px; white-space: pre-wrap; }
.active-dialog-summary { display: flex; align-items: baseline; gap: 12px; margin: -4px 0 18px; padding: 14px 16px; border: 1px solid rgba(237,200,109,.2); border-radius: 12px; background: rgba(237,200,109,.05); }
.active-dialog-summary span, .active-dialog-summary small { color: var(--muted); font-size: 10px; }
.active-dialog-summary strong { color: var(--gold); font-size: 22px; }
.active-dialog-summary small { margin-left: auto; }
.active-detail-list { display: grid; gap: 16px; }
.active-detail-position { padding: 18px; border: 1px solid rgba(68,226,154,.22); border-radius: 15px; background: rgba(0,0,0,.12); }
.active-detail-position-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.active-detail-position-head span { color: var(--green); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.active-detail-position-head h4 { margin: 4px 0 0; font-size: 20px; }
.active-detail-position-head > strong { color: var(--green-2); font-size: 18px; white-space: nowrap; }
.execution-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.execution-block > strong { display: block; margin-bottom: 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.active-empty { margin-bottom: 10px; }
.fatal { position: fixed; inset: auto 20px 20px; z-index: 50; max-width: 520px; padding: 18px; border: 1px solid rgba(255,125,118,.25); border-radius: 14px; background: #2b1412; box-shadow: var(--shadow); }
.fatal p { margin: 4px 0 0; color: #d6aaa6; font-size: 12px; }

@media (max-width: 1050px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .rules-grid { grid-template-columns: repeat(2, 1fr); }
  .active-decision-content { grid-template-columns: 1fr; }
}

@media (max-width: 740px) {
  .topbar { padding: 12px 16px; }
  .paper-badge:not(.subtle) { display: none; }
  .status-pill { padding: 0 8px; font-size: 10px; }
  main { width: min(100% - 24px, 1460px); padding: 34px 0 56px; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding: 12px 2px 36px; }
  h1 { font-size: clamp(42px, 14vw, 65px); }
  .hero-meta { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { min-height: 132px; padding: 17px; }
  .kpi strong { margin-top: 15px; font-size: 24px; }
  .panel { padding: 18px; border-radius: 16px; }
  .section-heading { align-items: flex-start; flex-direction: column; margin-bottom: 18px; }
  .legend { gap: 10px; }
  .rules-grid { grid-template-columns: 1fr 1fr; }
  .decision-card-head { flex-direction: column; gap: 7px; }
  .decision-time { white-space: normal; }
  .timeline-item { grid-template-columns: 18px 1fr auto; gap: 9px; }
  .timeline-time { grid-column: 2 / -1; grid-row: 1; padding: 12px 0 0; text-align: left; }
  .timeline-rail { grid-column: 1; grid-row: 1 / 3; }
  .timeline-content { grid-column: 2; grid-row: 2; padding-top: 4px; }
  .detail-button { grid-column: 3; grid-row: 2; margin-top: 3px; }
  .active-dialog-summary, .active-detail-position-head { align-items: flex-start; flex-direction: column; }
  .active-dialog-summary small { margin-left: 0; }
  footer { flex-direction: column; padding: 22px 16px; }
}

@media (max-width: 460px) {
  .brand small { display: none; }
  .kpis, .rules-grid { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 70px minmax(90px, 1fr) 72px; gap: 8px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card.wide { grid-column: auto; }
  .decision-summary { grid-template-columns: 1fr; }
  .decision-fact.wide { grid-column: auto; }
  #dialog-content { padding: 24px 18px; }
  #dialog-content h3 { font-size: 25px; overflow-wrap: normal; }
}
