*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a0a0c;
  --surface:   #111114;
  --surface2:  #18181c;
  --surface3:  #1e1e24;
  --border:    rgba(255,255,255,0.05);
  --border2:   rgba(255,255,255,0.10);
  --text:      #ececf1;
  --muted:     #8e8e93;
  --hint:      #5a5a60;
  --gold:      #c9a84c;
  --green:     #4ade80;
  --red:       #f87171;
  --blue:      #60a5fa;
  --amber:     #fbbf24;
  --purple:    #a78bfa;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 220px; min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 24px 0; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 10;
}
.sidebar-logo { padding: 0 20px 24px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.sidebar-logo-title { font-size: 14px; font-weight: 700; color: var(--gold); letter-spacing: .08em; }
.sidebar-logo-sub   { font-size: 11px; color: var(--hint); margin-top: 4px; font-weight: 400; }

.nav-section { padding: 10px 20px 6px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--hint); font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; font-size: 13px; color: var(--muted);
  text-decoration: none; border-radius: 8px; margin: 2px 12px;
  transition: all .15s ease; font-weight: 500;
}
.nav-link:hover  { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(201,168,76,0.10); color: var(--gold); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer { margin-top: auto; padding: 16px 16px 0; border-top: 1px solid var(--border); }
.last-push { font-size: 10px; color: var(--hint); line-height: 1.6; margin-top: 12px; }

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--surface2);
  border-radius: var(--radius); margin-bottom: 10px;
  cursor: pointer; text-decoration: none; border: 1px solid var(--border);
  transition: border-color .15s;
}
.user-pill:hover { border-color: var(--border2); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), #3b82f6);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 500; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main content ──────────────────────────────────────────── */
.main { margin-left: 220px; flex: 1; padding: 32px 40px; min-width: 0; }
.page-header { margin-bottom: 32px; }
.page-title  { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub    { font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 400; }

/* ── Stat cards ──────────────────────────────────────────── */
.stat-row  { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: border-color .15s; }
.stat-card:hover { border-color: var(--border2); }
.stat-label { font-size: 10px; color: var(--hint); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
table  { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--surface2); color: var(--text); padding: 12px 16px; text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.num { font-variant-numeric: tabular-nums; font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.b-spike  { background: rgba(248,113,113,.10); color: #f87171; border: 1px solid rgba(248,113,113,.20); }
.b-dip    { background: rgba(96,165,250,.10); color: #60a5fa; border: 1px solid rgba(96,165,250,.20); }
.b-high   { background: rgba(251,191,36,.10); color: #fbbf24; border: 1px solid rgba(251,191,36,.20); }
.b-low    { background: rgba(167,139,250,.10); color: #a78bfa; border: 1px solid rgba(167,139,250,.20); }
.b-normal { background: rgba(74,222,128,.10);  color: #4ade80; border: 1px solid rgba(74,222,128,.20); }
.b-ok     { background: rgba(74,222,128,.10);  color: #4ade80; border: 1px solid rgba(74,222,128,.20); }
.b-no     { background: rgba(248,113,113,.08);  color: #f87171; border: 1px solid rgba(248,113,113,.15); }

/* ── Misc ──────────────────────────────────────────────────── */
.empty    { padding: 56px; text-align: center; color: var(--muted); font-size: 13px; }
.not-viable { opacity: .35; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hint); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 768px) {
  .sidebar { display: none; }

  /* Main content — padded bottom so content clears the fixed nav */
  .main {
    margin-left: 0;
    padding: 16px 14px 76px;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page-title { font-size: 20px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }

  /* Tables scroll horizontally instead of being cut off */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: max-content;
  }

  /* Bottom nav — fixed, always visible regardless of zoom */
  .mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 9999;
    padding: 0;
    height: 60px;
    /* Use env() safe area for notched phones */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--hint);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 8px 2px;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav a.active { color: var(--gold); }
  .mobile-nav a span.nav-icon { font-size: 18px; line-height: 1; }

  /* Cards and grids — stack on mobile */
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
}

@media (min-width: 769px) {
  .mobile-nav { display: none; }
}

/* Landscape phone — more compact but still scrollable */
@media (max-width: 896px) and (orientation: landscape) {
  .sidebar { display: none; }
  .mobile-nav {
    display: flex !important;
    height: 48px;
  }
  .main {
    margin-left: 0;
    padding: 10px 12px 54px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .page-title { font-size: 17px; }
}