:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #111722;
  --panel-2: #151d2b;
  --text: #f4f7fb;
  --muted: #8792a5;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #55e6a5;
  --danger: #ff6370;
  --warn: #f5bd4f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at top left, rgba(85, 230, 165, 0.15), transparent 36%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

button, a { font: inherit; touch-action: manipulation; }

.app-shell {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(86px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex: 0 0 auto;
  min-width: 0;
}

.view {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}

.topbar > div:first-child { min-width: 0; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(85, 230, 165, 0.12);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 26px; letter-spacing: -0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { margin: 0; }

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

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

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025)), var(--panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
  min-width: 0;
}

.metric-label { color: var(--muted); font-size: 11px; }
.metric-value { margin-top: 5px; font-size: 18px; font-weight: 800; letter-spacing: -0.04em; }
.positive { color: var(--accent); }
.negative { color: var(--danger); }
.warn { color: var(--warn); }

.list { display: grid; gap: 10px; }
.item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: var(--panel-2);
  color: var(--text);
  min-width: 0;
}

.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.symbol { font-weight: 800; letter-spacing: -0.02em; min-width: 0; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 12px; line-height: 1.45; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.kv div { border-radius: 14px; padding: 10px; background: rgba(0,0,0,0.18); }
.kv span { display: block; color: var(--muted); font-size: 11px; }
.kv strong { display: block; margin-top: 4px; font-size: 14px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.action {
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--accent);
  color: #06110c;
  font-weight: 800;
}
.action.secondary { background: rgba(255,255,255,0.08); color: var(--text); }
.action.danger { background: rgba(255, 99, 112, 0.15); color: var(--danger); }

.form { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 12px; }
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(0,0,0,0.22);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.notice { color: var(--muted); font-size: 12px; line-height: 1.45; }
.full-text { color: var(--text); font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

.tabbar {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 8px;
  background: rgba(13, 17, 25, 0.88);
  backdrop-filter: blur(18px);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  border: 0;
  border-radius: 17px;
  padding: 11px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.tab.active { background: rgba(85, 230, 165, 0.14); color: var(--accent); font-weight: 800; }

.html-box { color: var(--text); line-height: 1.5; white-space: pre-wrap; }
.empty { padding: 30px 14px; text-align: center; color: var(--muted); }
.chart { width: 100%; border-radius: 18px; border: 1px solid var(--line); background: rgba(0,0,0,0.25); }
.route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.explain { color: var(--muted); font-size: 13px; line-height: 1.55; }

@media (min-width: 720px) {
  .app-shell { max-width: 900px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
