:root {
  --bg: var(--tg-theme-bg-color, #0b0b0f);
  --bg2: var(--tg-theme-secondary-bg-color, #16161d);
  --bg3: #1f1f28;
  --text: var(--tg-theme-text-color, #f2f0eb);
  --text2: var(--tg-theme-hint-color, #8a8a96);
  --gold: #e8b84b;
  --gold-dim: #b8923a;
  --green: #34c77b;
  --red: #ef5959;
  --border: #26262f;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* TOPBAR */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  display: flex; align-items: center; justify-content: center; color: #0b0b0f; font-weight: 700; font-size: 16px;
}
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: 0.5px; }
.brand-sub { font-size: 11px; color: var(--text2); margin-top: 1px; }
.status-dot-wrap { padding: 6px; }
.status-dot { display: block; width: 9px; height: 9px; border-radius: 50%; background: var(--text2); }
.status-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* MAIN / SCREENS */
main { flex: 1; padding: 16px 16px 90px; overflow-y: auto; }
.screen.hidden { display: none; }

/* HERO CARD */
.hero-card {
  background: linear-gradient(155deg, #1c1a12, var(--bg2));
  border: 1px solid #3a3120; border-radius: 16px; padding: 18px; margin-bottom: 14px;
}
.hero-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); font-weight: 700; }
.hero-hint { color: var(--text2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.hero-value { font-size: 32px; font-weight: 700; margin-top: 8px; font-family: 'Consolas', monospace; }
.hero-sub { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* STAT TILES */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 20px; }
.stat-tile {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.stat-tile-value { font-size: 18px; font-weight: 700; color: var(--gold); }
.stat-tile-label { font-size: 10px; color: var(--text2); margin-top: 4px; line-height: 1.3; }

/* SECTION LABELS */
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text2); font-weight: 700; margin-bottom: 10px; }
.section-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; margin-top: 4px; }
.link-btn { background: none; border: none; color: var(--gold); font-size: 12px; font-weight: 600; cursor: pointer; }

/* QUICK ACCESS GRID */
.quick-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 22px; }
.quick-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 4px; color: var(--text); font-size: 10px; cursor: pointer;
}
.quick-item:active { background: var(--bg3); }
.quick-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--gold); }
.quick-icon svg { width: 100%; height: 100%; }

/* CARDS */
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}
.card-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); margin-bottom: 10px; font-weight: 700;
}
.row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.notes { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.5; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.badge.supportive { background: var(--green); color: #06210f; }
.badge.opposing { background: var(--red); color: #2a0808; }
.badge.neutral { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }

/* SIGNAL FILTER CHIPS */
.signal-filter { display: flex; gap: 6px; margin-bottom: 12px; }
.chip {
  padding: 6px 12px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text2); font-size: 12px; cursor: pointer;
}
.chip.active { background: var(--gold); color: #1a1812; border-color: var(--gold); }

/* SIGNAL CARDS */
.signal-list { display: flex; flex-direction: column; gap: 10px; }
.signal-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
}
.signal-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.signal-side-badge {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px;
  padding: 3px 9px; border-radius: 8px;
}
.signal-side-badge.LONG { background: rgba(52,199,123,0.15); color: var(--green); }
.signal-side-badge.SHORT { background: rgba(239,89,89,0.15); color: var(--red); }
.signal-symbol { font-size: 11px; color: var(--text2); margin-left: 4px; }
.signal-meta { font-size: 11px; color: var(--text2); margin-top: 4px; }
.signal-levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; margin: 10px 0 8px; }
.signal-levels div { background: var(--bg); border-radius: 8px; padding: 6px; text-align: center; }
.signal-levels .label { color: var(--text2); font-size: 9px; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.signal-size { font-size: 11px; color: var(--gold); margin-bottom: 6px; }
.signal-reason { font-size: 12px; color: var(--text2); line-height: 1.5; margin-bottom: 6px; }
.signal-status {
  display: inline-block; font-size: 10px; padding: 2px 8px; border-radius: 8px; font-weight: 700;
}
.signal-status.open { background: var(--bg); color: var(--gold); border: 1px solid var(--gold); }
.signal-status.closed-win { background: var(--green); color: #06210f; }
.signal-status.closed-loss { background: var(--red); color: #2a0808; }
.signal-status.expired { background: var(--bg); color: var(--text2); border: 1px solid var(--border); }
.signal-empty { font-size: 13px; color: var(--text2); text-align: center; padding: 30px 0; }

/* STATS */
.stat-big { font-size: 32px; font-weight: 700; color: var(--gold); }
.stat-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.stat-bar-row { margin-bottom: 10px; }
.stat-bar-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.stat-bar-track { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--gold); }
.stat-bar-note { font-size: 10px; color: var(--text2); margin-top: 2px; }

/* SETTINGS */
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 13px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--bg3); border-radius: 22px; transition: 0.2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: var(--text2); border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--gold); }
.switch input:checked + .slider::before { transform: translateX(18px); background: #1a1812; }

.field-row { margin-bottom: 12px; }
.field-row label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.field-row input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px; font-family: 'Consolas', monospace;
}
.field-row input:focus { outline: none; border-color: var(--gold); }
.save-btn {
  width: 100%; background: var(--gold); color: #1a1812; border: none; border-radius: 10px;
  padding: 12px; font-weight: 700; font-size: 13px; cursor: pointer; margin-top: 4px;
}
.save-btn:active { background: var(--gold-dim); }
.save-status { font-size: 11px; color: var(--green); margin-top: 8px; height: 14px; }

/* BOTTOM NAV */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  background: var(--bg2); border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text2); font-size: 10px; padding: 4px; cursor: pointer;
}
.nav-item.active { color: var(--gold); }
.nav-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 100%; height: 100%; }
