:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-2: #0b1420;
  --panel: #101b27;
  --panel-2: #142232;
  --panel-3: #0e1824;
  --line: rgba(143, 181, 205, 0.18);
  --line-strong: rgba(115, 231, 255, 0.34);
  --text: #eef7fb;
  --muted: #8fa4b3;
  --muted-2: #607586;
  --accent: #22d3ee;
  --accent-2: #60a5fa;
  --good: #4ade80;
  --bad: #fb7185;
  --warn: #fbbf24;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --bottom-nav-h: 74px;
}

* { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; overflow-x: hidden; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 0%, rgba(34, 211, 238, 0.14), transparent 34rem),
    radial-gradient(circle at 95% 10%, rgba(96, 165, 250, 0.15), transparent 28rem),
    linear-gradient(180deg, var(--bg), #05090f 72%);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.6; }

img, svg { max-width: 100%; }

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

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.login-card {
  width: min(100%, 430px);
  display: grid;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(16, 27, 39, 0.96), rgba(10, 18, 27, 0.96));
  box-shadow: var(--shadow);
}

.brand-stack, .brand-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-stack { align-items: flex-start; margin-bottom: 4px; }
.brand-inline.compact { gap: 10px; }

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  filter: drop-shadow(0 8px 20px rgba(34, 211, 238, 0.16));
}

.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 7vw, 34px); letter-spacing: -0.04em; }
h2 { font-size: clamp(24px, 6vw, 36px); letter-spacing: -0.04em; }
h3 { font-size: 17px; letter-spacing: -0.02em; }

.brand-stack p, .brand-copy p, .section-head p, .card-head p, .menu-head span, small, .state-line, .meta {
  color: var(--muted);
}

label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; }

input, select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 19, 29, 0.92);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus, select:focus, button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
}

button {
  min-height: 42px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(18, 33, 48, 0.92);
  color: var(--text);
  padding: 9px 12px;
}

button:active { transform: translateY(1px); }

.primary-button {
  border-color: rgba(34, 211, 238, 0.6);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #031018;
  font-weight: 800;
}

.ghost-button { background: transparent; }

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  place-content: center;
  gap: 5px;
  padding: 0;
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 99px;
  background: var(--text);
}

.dashboard {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(var(--bottom-nav-h) + max(18px, env(safe-area-inset-bottom)));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -1px -12px 10px;
  padding: 10px 12px;
  background: rgba(7, 16, 24, 0.88);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(143, 181, 205, 0.08);
}

.brand-copy { min-width: 0; }
.brand-copy h1 { font-size: 22px; }
.brand-copy p { max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.48);
}

.menu-panel {
  width: min(340px, calc(100% - 26px));
  height: calc(100dvh - 26px);
  margin: 13px 13px 13px auto;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(10, 18, 27, 0.98);
  box-shadow: var(--shadow);
}

.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.menu-head .brand-inline div { display: grid; min-width: 0; }
.menu-nav, .menu-actions { display: grid; gap: 9px; align-content: start; }
.menu-link { text-align: left; min-height: 48px; }
.menu-link.active { border-color: var(--line-strong); background: rgba(34, 211, 238, 0.12); }

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  min-height: var(--bottom-nav-h);
  background: rgba(7, 16, 24, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav-item {
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 4px 2px;
  border-radius: 18px;
  background: transparent;
}

.nav-item span { font-size: 16px; line-height: 1; color: var(--muted); }
.nav-item strong { font-size: 11px; font-weight: 750; color: var(--muted); }
.nav-item.active { background: rgba(34, 211, 238, 0.13); border-color: rgba(34, 211, 238, 0.24); }
.nav-item.active span, .nav-item.active strong { color: var(--accent); }

.tab-panel { display: none; gap: 14px; }
.tab-panel.active { display: grid; }

.section-head, .card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.chip-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; min-width: 0; }

.card, .portfolio-card, .metric, .symbol-row, .node-row, .alert-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(16, 27, 39, 0.96), rgba(11, 20, 32, 0.96));
  box-shadow: 0 12px 28px rgba(0,0,0,0.15);
}

.card, .portfolio-card { padding: 14px; display: grid; gap: 14px; min-width: 0; }

.portfolio-card { border-color: rgba(34, 211, 238, 0.22); background: linear-gradient(145deg, rgba(12, 31, 44, 0.98), rgba(14, 24, 36, 0.98)); }

.portfolio-main {
  display: grid;
  gap: 2px;
  padding: 4px 2px 8px;
  min-width: 0;
}

.portfolio-main span { color: var(--muted); font-weight: 700; }
.portfolio-main strong { font-size: clamp(31px, 10vw, 54px); letter-spacing: -0.06em; overflow-wrap: anywhere; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; min-width: 0; }
.metric-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.metric {
  min-height: 88px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
}

.metric span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.03em; }
.metric strong { font-size: 21px; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.metric small { font-size: 12px; }

.chart-card { overflow: hidden; }
.range-tabs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.range { min-height: 34px; padding: 6px 9px; border-radius: 999px; font-size: 13px; }
.range.active { border-color: var(--line-strong); color: var(--accent); background: rgba(34, 211, 238, 0.12); }

.chart-box {
  width: 100%;
  min-height: 190px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 181, 205, 0.12);
  border-radius: 16px;
  background: rgba(5, 10, 16, 0.48);
  overflow: hidden;
}

.chart-box svg { width: 100%; height: 210px; display: block; }

.filters-card { grid-template-columns: 1fr; }

.symbol-list, .node-list, .alert-list { display: grid; gap: 10px; min-width: 0; }

.symbol-row, .node-row, .alert-row {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  text-align: left;
}

button.symbol-row { color: inherit; }

.row-main, .symbol-main, .node-main, .alert-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.symbol-title, .node-title, .alert-title { min-width: 0; display: grid; gap: 2px; }
.symbol-name, .node-name, .alert-title strong { font-weight: 850; overflow-wrap: anywhere; }
.symbol-sub, .node-sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 25px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.chip.good { color: var(--good); border-color: rgba(74, 222, 128, 0.34); background: rgba(74, 222, 128, 0.08); }
.chip.bad { color: var(--bad); border-color: rgba(251, 113, 133, 0.34); background: rgba(251, 113, 133, 0.08); }
.chip.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.34); background: rgba(251, 191, 36, 0.08); }
.chip.neutral { color: var(--muted); }

.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 7px 9px;
  min-width: 0;
}

.kv span { color: var(--muted); min-width: 0; }
.kv strong { text-align: right; font-weight: 760; min-width: 0; overflow-wrap: anywhere; }

.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.muted { color: var(--muted); }

.state-banner {
  position: sticky;
  top: 68px;
  z-index: 10;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 16px;
  background: rgba(251, 191, 36, 0.08);
  color: var(--warn);
}

.state-line { min-height: 20px; font-size: 13px; }
.error-line { color: var(--bad); }
.empty-state { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.55); }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(92dvh, 820px);
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 26px 26px 0 0;
  background: #08121c;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 23px; }
.sheet-head p { color: var(--muted); overflow-wrap: anywhere; }
.sheet-body { display: grid; gap: 12px; padding: 14px; overflow-y: auto; min-width: 0; }

.detail-grid { display: grid; gap: 10px; }
details { border: 1px solid var(--line); border-radius: 16px; padding: 10px; background: rgba(16, 27, 39, 0.7); }
summary { cursor: pointer; font-weight: 800; }
.event-list { display: grid; gap: 8px; margin-top: 10px; }
.event-row { display: grid; gap: 6px; padding: 10px; border: 1px solid rgba(143, 181, 205, 0.12); border-radius: 14px; background: rgba(5, 10, 16, 0.3); }

@media (max-width: 380px) {
  .dashboard { padding-left: 9px; padding-right: 9px; }
  .metric-grid { gap: 7px; }
  .metric { padding: 10px; }
  .metric strong { font-size: 18px; }
  .nav-item strong { font-size: 10px; }
  .brand-copy p { max-width: 50vw; }
}

@media (min-width: 760px) {
  :root { --bottom-nav-h: 0px; }
  .dashboard { padding: 20px; }
  .app-header { margin: 0 0 18px; padding: 0; position: static; background: transparent; border-bottom: 0; backdrop-filter: none; }
  .bottom-nav { display: none; }
  .metric-grid.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid.two { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .symbol-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .symbol-list.compact, .node-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-card { grid-template-columns: 1.4fr repeat(4, minmax(130px, 1fr)); align-items: center; }
  .sheet-panel { left: 50%; right: auto; top: 50%; bottom: auto; width: min(860px, calc(100vw - 40px)); max-height: min(86dvh, 860px); transform: translate(-50%, -50%); border-radius: 26px; border: 1px solid var(--line); }
}

@media (min-width: 1040px) {
  .metric-grid.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .symbol-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .symbol-list.compact, .node-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


.axis-line { stroke: rgba(143, 181, 205, 0.22); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-area { fill: rgba(34, 211, 238, 0.11); stroke: none; }
