:root {
  --bg: #090b10;
  --surface: #10141d;
  --surface-2: #151b26;
  --surface-3: #1c2430;
  --ink: #edf2f7;
  --muted: #8f9bab;
  --line: #273140;
  --accent: #d7a84d;
  --accent-2: #48b6a5;
  --ok: #4fc28b;
  --watch: #e2a94f;
  --action: #ef6776;
  --info: #6ea8fe;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

body[data-theme="light"] {
  --bg: #f3f5f0;
  --surface: #fffdf8;
  --surface-2: #f8faf4;
  --surface-3: #eef3ea;
  --ink: #161a1f;
  --muted: #65717d;
  --line: #d9dfd3;
  --accent: #a96f1d;
  --accent-2: #167761;
  --ok: #167761;
  --watch: #a96a00;
  --action: #ba2f3a;
  --info: #2a6f9f;
  --shadow: 0 18px 42px rgba(31, 37, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 0%, rgba(215, 168, 77, 0.15), transparent 28%),
    linear-gradient(180deg, rgba(72, 182, 165, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.12;
  font-weight: 760;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 760;
}

p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel,
.panel,
.hero-panel {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(470px, 100%);
  padding: 28px;
}

.brandline,
.identity {
  display: flex;
  align-items: center;
  gap: 13px;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.25);
}

.avatar.compact {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.auth-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-form input {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.auth-form button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
}

.auth-form button {
  background: var(--accent);
  color: #14100a;
  border-color: transparent;
}

.ghost-button:hover,
.tabbar button:hover,
.segmented button:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.error-line {
  color: var(--action);
  min-height: 18px;
  margin-top: 12px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  min-height: 72px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timestamp {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.state-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.state-pill.ok,
.badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 38%, var(--line));
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.state-pill.watch,
.badge.watch,
.badge.warning {
  color: var(--watch);
  border-color: color-mix(in srgb, var(--watch) 38%, var(--line));
  background: color-mix(in srgb, var(--watch) 12%, transparent);
}

.state-pill.action,
.badge.action,
.badge.error,
.badge.critical {
  color: var(--action);
  border-color: color-mix(in srgb, var(--action) 38%, var(--line));
  background: color-mix(in srgb, var(--action) 12%, transparent);
}

.tabbar {
  padding: 12px 22px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabbar button,
.segmented button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 13px;
  font-size: 12px;
  font-weight: 780;
}

.tabbar button.active,
.segmented button.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

body[data-theme="dark"] .tabbar button.active,
body[data-theme="dark"] .segmented button.active {
  background: var(--accent);
  color: #15100a;
  border-color: var(--accent);
}

.dashboard {
  padding: 16px 22px 32px;
}

.tab-panel {
  display: grid;
  gap: 16px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 16px;
}

.hero-panel {
  min-height: 252px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(220px, 0.78fr) minmax(0, 1.22fr);
  gap: 16px;
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.hero-window-head {
  display: grid;
  gap: 10px;
  align-content: start;
}

.hero-copy h2 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 0.98;
  font-weight: 820;
}

.hero-pnl {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hero-chart {
  min-height: 216px;
}

.manager-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tile,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.tile {
  display: grid;
  align-content: space-between;
  min-height: 118px;
  gap: 12px;
}

.tile span,
.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.tile strong,
.metric-value {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 820;
  overflow-wrap: anywhere;
}

.tile p,
.metric-detail {
  min-height: 17px;
}

.workspace {
  display: grid;
  gap: 16px;
}

.two-col {
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
}

.panel {
  padding: 14px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chart {
  width: 100%;
  min-height: 240px;
}

.chart svg,
.hero-chart svg {
  width: 100%;
  height: 100%;
  min-height: 216px;
  display: block;
}

.bridge {
  display: grid;
  gap: 12px;
}

.bridge-summary,
.book-shape {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.mini-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.mini-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.value-flash {
  animation: valueFlash 720ms ease-out;
}

@keyframes valueFlash {
  0% {
    color: var(--accent);
    text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  100% {
    text-shadow: none;
  }
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover,
.heartbeat-row:hover,
.order-row:hover,
.sleeve-row:hover,
.projected-row:hover,
.metric-card:hover {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background: var(--surface-2);
}

.num-positive {
  color: var(--ok);
}

.num-negative {
  color: var(--action);
}

.muted {
  color: var(--muted);
}

.sleeve-grid,
.projected-list,
.heartbeat-list,
.order-list,
.metrics-grid {
  display: grid;
  gap: 9px;
}

.metrics-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  text-align: left;
  color: var(--ink);
}

.metric-detail {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.metric-group {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sleeve-row,
.projected-row,
.heartbeat-row,
.order-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  display: grid;
  gap: 7px;
}

.sleeve-row,
.projected-row,
.heartbeat-row,
.order-row {
  cursor: pointer;
}

.row-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.row-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.row-sub {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exposure-bar {
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--long, 50%) var(--short, 50%);
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.exposure-bar i:first-child {
  background: var(--ok);
}

.exposure-bar i:last-child {
  background: var(--action);
}

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: min(760px, 100%);
  min-height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-left: 1px solid var(--line);
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.drawer-body {
  overflow: auto;
  padding-top: 14px;
  display: grid;
  gap: 14px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.kv {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

.kv span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.kv strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
}

@media (max-width: 1120px) {
  .hero-grid,
  .hero-panel,
  .two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .dashboard,
  .tabbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar,
  .topbar-right,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manager-tiles,
  .bridge-summary,
  .book-shape,
  .metrics-grid.compact,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .hero-copy h2 {
    font-size: 34px;
  }
}
