:root {
  color-scheme: dark;
  --bg: oklch(15% 0.012 95);
  --surface: oklch(19% 0.014 92);
  --surface-raised: oklch(22% 0.017 91);
  --surface-deep: oklch(12% 0.011 94);
  --line: oklch(34% 0.018 88);
  --line-soft: oklch(28% 0.015 90);
  --text: oklch(92% 0.018 90);
  --muted: oklch(69% 0.022 88);
  --quiet: oklch(52% 0.018 88);
  --gold: oklch(78% 0.125 82);
  --gold-soft: oklch(87% 0.09 84);
  --olive: oklch(70% 0.075 122);
  --rust: oklch(66% 0.1 45);
  --green: oklch(73% 0.12 145);
  --red: oklch(68% 0.15 28);
  --amber: oklch(77% 0.12 80);
  --radius: 4px;
  font-family: Bahnschrift, "Segoe UI Variable", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 82% 0%, oklch(30% 0.045 81 / 0.13), transparent 30rem),
    linear-gradient(135deg, oklch(17% 0.014 95), var(--bg) 48rem);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
button, a { color: inherit; }
a { text-decoration: none; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.app-shell { width: min(1440px, 100%); margin-inline: auto; padding: 0 clamp(16px, 4vw, 58px) max(22px, env(safe-area-inset-bottom)); }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 27px; height: 27px; border: 1px solid var(--gold); display: flex; align-items: end; justify-content: center; gap: 3px; padding: 5px; transform: rotate(45deg); }
.brand-mark i { display: block; width: 3px; background: var(--gold); }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 6px; }
.brand-copy { display: grid; line-height: 1.15; gap: 4px; }
.brand-kicker, .brand-name, .eyebrow, .metric-index, .hero-foot-label, .hero-foot-value, .readout-label, .readout-bottom, .resource-index, .empty-mark, .footer {
  font-family: "Segoe UI", sans-serif;
  letter-spacing: .105em;
}
.brand-kicker { color: var(--quiet); font-size: 9px; font-weight: 700; }
.brand-name { color: var(--gold-soft); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.top-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.live-indicator, .readout-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px oklch(77% 0.12 80 / .11); }
.live-indicator.is-live { background: var(--green); box-shadow: 0 0 0 3px oklch(73% 0.12 145 / .12); }
.live-indicator.is-error { background: var(--red); box-shadow: 0 0 0 3px oklch(68% 0.15 28 / .12); }
.status-divider { width: 1px; height: 16px; background: var(--line); margin-inline: 4px; }
.last-seen-label { color: var(--quiet); }
#last-updated { color: var(--text); font-variant-numeric: tabular-nums; }

main { padding-top: clamp(18px, 3vw, 34px); }
.hero-panel {
  min-height: 260px;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  gap: 24px;
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid var(--line);
  background:
    linear-gradient(110deg, oklch(23% 0.019 86 / .98), oklch(18% 0.016 91 / .97) 62%, oklch(24% 0.028 80 / .9));
}
.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .2;
  background: repeating-linear-gradient(0deg, transparent 0 5px, oklch(82% 0.09 82 / .045) 6px, transparent 7px);
  mask-image: linear-gradient(90deg, #000, transparent 78%);
}
.hero-copy, .hero-readout { position: relative; z-index: 1; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--gold); font-size: 10px; font-weight: 700; }
.eyebrow-line { display: inline-block; width: 20px; height: 1px; background: currentColor; }
h1, h2, p { margin-top: 0; }
.hero-copy h1 { margin: 18px 0 10px; font-size: clamp(32px, 5vw, 55px); line-height: .98; letter-spacing: -.045em; font-weight: 650; }
.hero-copy h1 span { color: var(--gold); }
.hero-description { max-width: 430px; color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.hero-foot { display: flex; align-items: center; gap: 16px; padding-top: 12px; border-top: 1px solid var(--line-soft); width: min(440px, 100%); }
.hero-foot-label { color: var(--quiet); font-size: 9px; }
.hero-foot-value { color: var(--text); font-size: 9px; font-weight: 700; }
.hero-foot-value b { color: var(--gold); margin-inline: 4px; }
.hero-readout {
  align-self: stretch;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 16px 18px;
  border: 1px solid oklch(55% 0.08 80 / .35);
  background: linear-gradient(145deg, oklch(13% 0.014 91 / .7), oklch(18% 0.026 83 / .4));
}
.readout-top, .readout-bottom { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.readout-label, .readout-bottom { color: var(--muted); font-size: 9px; font-weight: 650; }
#server-clock { position: relative; z-index: 2; color: var(--gold-soft); font-size: clamp(30px, 4vw, 44px); line-height: 1; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.readout-date { position: relative; z-index: 2; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.readout-rule { position: relative; z-index: 2; height: 1px; background: linear-gradient(90deg, var(--gold), transparent 85%); }
.readout-bottom { font-size: 8px; color: var(--quiet); }
.radar-rings { position: absolute; width: 176px; height: 176px; right: 6%; top: 50%; transform: translateY(-50%); opacity: .17; }
.radar-rings i { position: absolute; inset: 0; border: 1px solid var(--gold); border-radius: 50%; }
.radar-rings i:nth-child(2) { inset: 24px; }
.radar-rings i:nth-child(3) { inset: 48px; }

.overview-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-top: 0; background: var(--surface-deep); }
.overview-cell { position: relative; min-height: 112px; padding: 18px clamp(14px, 2.2vw, 26px); border-right: 1px solid var(--line-soft); }
.overview-cell:last-child { border-right: 0; }
.metric-index { display: block; margin-bottom: 12px; color: var(--quiet); font-size: 8px; font-weight: 700; }
.overview-value { display: flex; align-items: baseline; gap: 7px; min-height: 36px; }
.overview-value strong { color: var(--text); font-size: clamp(22px, 3vw, 30px); line-height: 1; font-weight: 600; font-variant-numeric: tabular-nums; }
.overview-value > span:not(.state-mark) { color: var(--muted); font-size: 11px; }
.overview-caption { color: var(--muted); font-size: 10px; }
.overview-caption small { color: var(--quiet); font-size: inherit; }
.overview-profit .overview-value { align-items: center; min-height: 36px; }
.profit-breakdown { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.profit-token { display: inline-flex; align-items: baseline; gap: 5px; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.profit-token small { color: var(--muted); font-size: 9px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral { color: var(--muted) !important; }
.overview-state .overview-value { align-items: center; gap: 9px; }
.overview-state .overview-value strong { font-size: 18px; }
.state-mark { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px oklch(77% 0.12 80 / .1); }
.state-mark.good { background: var(--green); box-shadow: 0 0 0 4px oklch(73% 0.12 145 / .1); }
.state-mark.bad { background: var(--red); box-shadow: 0 0 0 4px oklch(68% 0.15 28 / .1); }

.host-section, .accounts-section { padding-top: clamp(30px, 5vw, 54px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-heading h2 { margin: 8px 0 0; font-size: clamp(20px, 2.6vw, 27px); line-height: 1.1; letter-spacing: -.025em; font-weight: 620; }
.section-note { color: var(--quiet); font-size: 10px; text-align: right; }
.host-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.resource-panel { min-width: 0; padding: 18px 20px 15px; border: 1px solid var(--line-soft); background: var(--surface); }
.resource-heading { display: flex; align-items: center; gap: 9px; }
.resource-symbol { min-width: 35px; padding: 3px 5px; border: 1px solid var(--line); color: var(--gold); font-family: "Segoe UI", sans-serif; font-size: 8px; text-align: center; letter-spacing: .08em; }
.ram-symbol { color: var(--olive); }
.disk-symbol { color: var(--rust); }
.resource-name { color: var(--muted); font-size: 11px; }
.resource-index { margin-left: auto; color: var(--quiet); font-size: 8px; }
.resource-reading { display: flex; align-items: baseline; gap: 8px; margin-top: 17px; }
.resource-reading strong { color: var(--text); font-size: clamp(25px, 3vw, 34px); line-height: 1; font-weight: 580; font-variant-numeric: tabular-nums; }
.resource-reading > span { color: var(--quiet); font-size: 10px; }
.meter-track { height: 4px; margin: 13px 0 12px; overflow: hidden; background: oklch(29% 0.013 91); }
.meter-fill { display: block; width: 0; height: 100%; background: var(--gold); transition: width .45s ease-out; }
.meter-fill.is-high { background: var(--red); }
.meter-olive { background: var(--olive); }
.meter-rust { background: var(--rust); }
.resource-foot { display: flex; justify-content: space-between; gap: 10px; color: var(--quiet); font-size: 9px; }
.resource-foot strong { color: var(--muted); font-weight: 550; font-variant-numeric: tabular-nums; text-align: right; }

.heading-count { margin-left: 5px; color: var(--quiet); font-family: "Segoe UI", sans-serif; font-size: 9px; letter-spacing: .12em; vertical-align: middle; }
.accounts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.account-card { min-width: 0; border: 1px solid var(--line-soft); background: var(--surface); }
.account-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 15px 17px 12px; border-bottom: 1px solid var(--line-soft); }
.account-name { display: flex; align-items: center; gap: 9px; }
.account-code { color: var(--gold); font-family: "Segoe UI", sans-serif; font-size: 11px; font-weight: 750; letter-spacing: .1em; }
.account-login { display: block; margin-top: 3px; color: var(--quiet); font-size: 9px; font-variant-numeric: tabular-nums; }
.account-state { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 9px; }
.account-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--quiet); }
.account-state.online::before { background: var(--green); box-shadow: 0 0 0 3px oklch(73% 0.12 145 / .1); }
.account-state.disconnected::before, .account-state.stale::before { background: var(--amber); }
.account-state.no-data { color: var(--quiet); }
.account-server { display: grid; justify-items: end; gap: 2px; min-width: 0; max-width: 190px; color: var(--quiet); text-align: right; }
.account-currency { overflow: hidden; max-width: 100%; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.account-time-note { color: var(--quiet); font-size: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.account-main { padding: 16px 17px 11px; }
.account-main-label { color: var(--quiet); font-family: "Segoe UI", sans-serif; font-size: 8px; letter-spacing: .1em; }
.account-pnl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 7px; }
.pnl-block { min-width: 0; }
.pnl-value { overflow-wrap: anywhere; display: block; color: var(--text); font-size: clamp(17px, 2.2vw, 21px); line-height: 1.15; font-weight: 620; font-variant-numeric: tabular-nums; }
.pnl-value.today { font-size: clamp(15px, 1.8vw, 18px); }
.pnl-currency { margin-left: 4px; color: var(--quiet); font-size: 8px; font-weight: 500; }
.account-balances { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 11px 17px 12px; border-top: 1px solid var(--line-soft); }
.balance-cell span { display: block; color: var(--quiet); font-family: "Segoe UI", sans-serif; font-size: 8px; letter-spacing: .08em; }
.balance-cell strong { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 550; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.positions-box { border-top: 1px solid var(--line-soft); }
.positions-box summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 17px; color: var(--muted); list-style: none; cursor: pointer; font-size: 10px; }
.positions-box summary::-webkit-details-marker { display: none; }
.positions-box summary::after { content: "+"; color: var(--gold); font-size: 15px; line-height: 1; }
.positions-box[open] summary::after { content: "−"; }
.position-count { color: var(--gold); font-variant-numeric: tabular-nums; }
.positions-list { display: grid; gap: 1px; border-top: 1px solid var(--line-soft); background: var(--line-soft); }
.position-row { display: grid; grid-template-columns: minmax(70px, 1.2fr) minmax(50px, .7fr) minmax(66px, .8fr) minmax(75px, 1fr); align-items: center; gap: 7px; padding: 9px 14px; background: var(--surface-deep); font-size: 9px; font-variant-numeric: tabular-nums; }
.position-symbol { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.position-side { color: var(--quiet); font-family: "Segoe UI", sans-serif; font-size: 8px; }
.position-volume { color: var(--muted); }
.position-profit { text-align: right; font-weight: 650; }
.empty-positions { padding: 13px 17px; color: var(--quiet); background: var(--surface-deep); font-size: 10px; }
.account-no-data { padding: 16px 17px 18px; color: var(--quiet); font-size: 10px; }
.account-no-data strong { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; font-weight: 550; }
.telemetry-age { display: block; margin-top: 6px; color: var(--quiet); font-size: 8px; }
.empty-state { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; min-height: 76px; padding: 16px 18px; border: 1px dashed var(--line); color: var(--muted); }
.empty-state p { margin: 0; font-size: 11px; }
.empty-mark { color: var(--gold); font-size: 8px; font-weight: 700; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding: 14px 0 2px; border-top: 1px solid var(--line-soft); color: var(--quiet); font-size: 8px; }
.footer b { color: var(--gold); font-weight: 600; }
.is-loading { opacity: .6; }

.logout-form { margin: 0; }
.logout-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--surface-deep);
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  cursor: pointer;
}
.logout-button:hover { border-color: var(--gold); color: var(--gold-soft); }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.login-shell { width: min(440px, 100%); }
.login-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(23px, 6vw, 42px);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--surface-raised), var(--surface-deep) 70%);
  box-shadow: 0 24px 90px oklch(0% 0 0 / .28);
}
.login-panel::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  right: -120px;
  top: -118px;
  border: 1px solid oklch(78% 0.125 82 / .34);
  border-radius: 50%;
  box-shadow: 0 0 0 22px oklch(78% 0.125 82 / .04), 0 0 0 44px oklch(78% 0.125 82 / .03);
  pointer-events: none;
}
.login-brand { margin-bottom: clamp(35px, 9vw, 58px); }
.login-panel h1 { margin: 12px 0 7px; font-size: clamp(29px, 8vw, 36px); letter-spacing: -.04em; }
.login-panel h1 span { color: var(--gold); }
.login-description { margin-bottom: 23px; color: var(--muted); font-size: 12px; }
.login-form { display: grid; gap: 9px; }
.login-form label { color: var(--muted); font-size: 10px; }
.login-form input {
  width: 100%;
  min-height: 47px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-deep);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.login-form input:focus-visible { border-color: var(--gold); outline: 2px solid oklch(78% 0.125 82 / .18); outline-offset: 2px; }
.login-form button {
  display: flex;
  min-height: 47px;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
  padding: 0 14px;
  border: 1px solid var(--gold);
  background: oklch(78% 0.125 82 / .11);
  color: var(--gold-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.login-form button:hover { background: oklch(78% 0.125 82 / .18); }
.login-error { margin: 0 0 14px; padding: 10px 12px; border-left: 2px solid var(--red); background: oklch(68% 0.15 28 / .08); color: var(--red); font-size: 11px; }
.login-error[hidden] { display: none; }
.login-foot { display: flex; align-items: center; gap: 9px; margin: 22px 0 0; color: var(--quiet); font-family: "Segoe UI", sans-serif; font-size: 8px; letter-spacing: .1em; }
.login-foot .live-indicator { width: 6px; height: 6px; }

@media (min-width: 1440px) {
  .accounts-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .app-shell { padding-inline: 24px; }
  .hero-panel { grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr); padding: 28px; }
  .accounts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-cell { min-height: 104px; }
}
@media (max-width: 700px) {
  .app-shell { padding-inline: 16px; }
  .topbar { min-height: 62px; gap: 8px; }
  .brand-mark { width: 23px; height: 23px; }
  .brand-kicker { font-size: 8px; }
  .brand-name { font-size: 10px; }
  .top-status { gap: 7px; font-size: 9px; }
  .logout-button { min-height: 30px; padding-inline: 7px; font-size: 9px; }
  .last-seen-label, .status-divider { display: none; }
  .hero-panel { grid-template-columns: 1fr; gap: 20px; min-height: auto; padding: 25px 20px 18px; }
  .hero-copy h1 { margin-top: 15px; font-size: clamp(34px, 11vw, 48px); }
  .hero-description { margin-bottom: 19px; font-size: 12px; }
  .hero-readout { min-height: 120px; padding: 13px 15px; }
  #server-clock { font-size: 31px; }
  .radar-rings { width: 135px; height: 135px; right: 7%; }
  .overview-strip { grid-template-columns: 1fr 1fr; }
  .overview-cell { min-height: 98px; padding: 14px; border-bottom: 1px solid var(--line-soft); }
  .overview-cell:nth-child(2) { border-right: 0; }
  .overview-cell:nth-child(3), .overview-cell:nth-child(4) { border-bottom: 0; }
  .metric-index { margin-bottom: 10px; }
  .overview-value strong { font-size: 25px; }
  .overview-state .overview-value strong { font-size: 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .section-note { text-align: left; }
  .host-grid { grid-template-columns: 1fr; gap: 8px; }
  .resource-panel { padding: 14px 16px 12px; }
  .resource-reading { margin-top: 13px; }
  .resource-reading strong { font-size: 28px; }
  .meter-track { margin: 10px 0; }
  .accounts-grid { grid-template-columns: 1fr; gap: 8px; }
  .account-server { max-width: min(42vw, 190px); }
  .position-row { grid-template-columns: minmax(74px, 1.1fr) 55px 58px minmax(70px, 1fr); padding-inline: 12px; }
  .footer { flex-direction: column; font-size: 7px; }
}
@media (max-width: 380px) {
  .app-shell { padding-inline: 11px; }
  .hero-panel { padding-inline: 16px; }
  .top-status { font-size: 8px; }
  .top-status #connection-label { display: none; }
  .logout-button { padding-inline: 6px; font-size: 8px; }
  .overview-caption { font-size: 9px; }
  .account-head, .account-main { padding-inline: 13px; }
  .account-balances { padding-inline: 13px; }
  .positions-box summary { padding-inline: 13px; }
  .position-row { grid-template-columns: minmax(65px, 1fr) 42px 48px minmax(58px, .9fr); gap: 5px; padding-inline: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
