:root {
  --bg: #0b0f14;
  --panel: #141a22;
  --panel-2: #1b232d;
  --text: #e8edf2;
  --muted: #8b98a8;
  --accent: #c9a14a;
  --accent-2: #4aa3df;
  --ok: #4cd964;
  --warn: #f5a623;
  --err: #ff5c5c;
  --border: #243140;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 18px; color: var(--accent); }
.topbar nav a { margin-left: 20px; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }

main { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* Hub */
.hero { text-align: center; padding: 48px 0 32px; }
.hero h1 { font-size: 42px; margin: 0 0 12px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; color: transparent; }
.hero .lead { color: var(--muted); font-size: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; margin-top: 32px; }
.tile {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px 20px; text-align: center; color: var(--text);
  transition: transform .15s, border-color .15s; position: relative;
}
.tile:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.tile.disabled { opacity: .5; cursor: not-allowed; }
.tile.disabled:hover { transform: none; border-color: var(--border); }
.tile .flag { font-size: 56px; line-height: 1; }
.tile .name { font-size: 22px; font-weight: 600; margin-top: 12px; }
.tile .country { color: var(--muted); font-size: 13px; margin-top: 4px; }
.tile .badge { display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 10px; margin-top: 12px; text-transform: uppercase; letter-spacing: .5px; }
.tile .badge.live { background: rgba(76,217,100,.15); color: var(--ok); }
.tile .badge.soon { background: rgba(139,152,168,.15); color: var(--muted); }
.empty { text-align: center; padding: 80px 20px; }
.big-flag { font-size: 96px; }

/* Dashboard layout */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}
main .dashboard { padding: 0; }
main:has(.dashboard) { max-width: none; padding: 0; }

.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 0;
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.sb-head { display: flex; gap: 12px; padding: 0 20px 16px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sb-flag { font-size: 40px; line-height: 1; }
.sb-city { font-size: 18px; font-weight: 600; }
.sb-sub { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.sb-nav { display: flex; flex-direction: column; }
.sb-nav a {
  padding: 10px 20px;
  color: var(--muted);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sb-nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.sb-nav a.active { background: var(--panel-2); color: var(--accent); border-left-color: var(--accent); }
.sb-foot { padding: 16px 20px; border-top: 1px solid var(--border); margin-top: 16px; }
.sb-legend { display: flex; flex-direction: column; gap: 6px; font-size: 11px; }
.lbl.verified { color: var(--ok); }
.lbl.proxy { color: var(--warn); }
.lbl.social { color: var(--accent-2); }

.content { min-width: 0; }

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
}
.fb-title { font-size: 20px; font-weight: 600; color: var(--text); }
.fb-controls { display: flex; gap: 10px; }
.fb-select, .fb-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.fb-select:hover, .fb-btn:hover { border-color: var(--accent); }

/* Modules */
.module {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}
.module.coming { opacity: 0.7; }
.mod-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.mod-head h2 { margin: 0; font-size: 18px; color: var(--accent); flex: 1; }
.mod-hint { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.coming-soon { color: var(--muted); font-style: italic; padding: 20px; background: var(--panel-2); border-radius: 8px; }

.badge { font-size: 10px; padding: 4px 10px; border-radius: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.badge.verified { background: rgba(76,217,100,.15); color: var(--ok); }
.badge.proxy { background: rgba(245,166,35,.15); color: var(--warn); }
.badge.social { background: rgba(74,163,223,.15); color: var(--accent-2); }
.badge.soon { background: rgba(139,152,168,.15); color: var(--muted); }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.kpi .k-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.k-info { background: transparent; border: 1px solid var(--border); color: var(--muted); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; font-size: 11px; padding: 0; line-height: 1; transition: all .15s; }
.k-info:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.kpi .k-value { font-size: 28px; font-weight: 700; color: var(--text); margin: 6px 0 2px; }
.kpi .k-hint { font-size: 11px; color: var(--muted); }

.chart-wrap { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 16px; }
.chart-wrap h3 { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.chart-wrap canvas { max-height: 320px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
table th, table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
table th { color: var(--muted); font-weight: 500; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.stage { display: grid; grid-template-columns: 40px 180px 1fr; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; border-left: 3px solid var(--accent); }
.stage.disabled { opacity: 0.4; border-left-color: var(--muted); }
.stage .s-n { font-size: 20px; font-weight: 700; color: var(--accent); }
.stage.disabled .s-n { color: var(--muted); }
.stage .s-t { font-weight: 600; }
.stage .s-v { color: var(--muted); font-size: 13px; }

.foot { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; border-top: 1px solid var(--border); margin-top: 40px; }

/* Modal for metric detail */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px; backdrop-filter: blur(4px);
}
.modal-body {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  max-width: 600px; width: 100%; padding: 28px; position: relative;
  max-height: 85vh; overflow-y: auto;
}
.modal-close {
  position: absolute; top: 12px; right: 16px;
  background: transparent; border: none; color: var(--muted);
  font-size: 28px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-header { margin-bottom: 20px; }
.modal-header h2 { margin: 10px 0 0; font-size: 22px; color: var(--accent); }
.modal-section { margin-bottom: 16px; }
.mm-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.modal-section code {
  display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 12px; color: var(--accent-2); font-family: "SF Mono", Monaco, monospace;
}
.modal-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Knowledge tables */
.tbl-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.tbl-def { max-width: 500px; color: var(--muted); font-size: 12px; line-height: 1.5; }
#tbl-glossary td, #tbl-sources td { vertical-align: top; padding: 12px; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; max-height: none; }
  .sb-nav { flex-direction: row; overflow-x: auto; }
  .sb-nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .sb-nav a.active { border-left: none; border-bottom-color: var(--accent); }
}
