:root {
  --yellow: #ffd400;
  --black: #070707;
  --ink: #14171f;
  --muted: #6b7280;
  --bg: #eef1f5;
  --panel: #ffffff;
  --soft: #f7f8fa;
  --line: #e4e7ec;
  --dark: #111827;
  --green: #16a34a;
  --danger: #ef4444;
  --shadow: 0 22px 60px rgba(17, 24, 39, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 212, 0, .18), transparent 28%),
    linear-gradient(135deg, #f8fafc, var(--bg));
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.logo-box {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  background: var(--yellow);
  color: var(--black);
  border-radius: 12px;
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(255, 212, 0, .32);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--black);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 34px;
  align-items: center;
  width: min(1120px, calc(100% - 44px));
  margin: auto;
}
.auth-hero {
  display: grid;
  gap: 16px;
}
.auth-hero h1 {
  margin: 0;
  font-size: clamp(44px, 7vw, 78px);
  line-height: .95;
  letter-spacing: 0;
}
.auth-hero p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 20px;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.hero-stats div, .auth-card, .today-card, .metric, .panel {
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-stats div {
  padding: 16px;
  border-radius: 18px;
}
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats span {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}
.auth-card {
  border-radius: 24px;
  padding: 18px;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: var(--soft);
}
.auth-tab {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-weight: 900;
  color: var(--muted);
}
.auth-tab.active {
  background: var(--black);
  color: white;
}
.auth-panel { display: none; padding: 12px; }
.auth-panel.active { display: block; }
.auth-panel h2, .api-panel h2 { margin: 18px 0; }
.api-panel { padding: 12px; }
label {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  font-weight: 800;
}
input, select {
  height: 48px;
  width: 100%;
  border: 1px solid #cbd2dc;
  border-radius: 14px;
  padding: 0 14px;
  background: white;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 4px rgba(255, 212, 0, .18);
}
.primary-btn {
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  background: var(--yellow);
  color: var(--black);
  font-weight: 900;
}
.primary-btn.full { width: 100%; }
.link-btn {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 900;
  text-decoration: underline;
}
.message {
  min-height: 22px;
  color: var(--green);
  font-weight: 800;
}
.error { color: #b91c1c; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 18px;
  padding: 20px;
}
.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand strong { display: block; font-size: 22px; }
.brand small { color: var(--muted); font-weight: 700; }
.menu { display: grid; gap: 8px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}
.nav-link span {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}
.nav-link.active, .nav-link:hover {
  background: var(--black);
  color: white;
}
.nav-link.active span, .nav-link:hover span {
  background: var(--yellow);
  color: var(--black);
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}
.live-card {
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(145deg, #111827, #050505);
  color: white;
}
.live-card small { color: var(--yellow); font-weight: 800; }
.logout {
  height: 44px;
  border: 1px solid var(--black);
  border-radius: 14px;
  background: white;
  color: var(--black);
  font-weight: 900;
}

.workspace {
  min-width: 0;
  display: grid;
  gap: 16px;
}
.topbar {
  position: sticky;
  top: 20px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr 260px auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 14px 36px rgba(17, 24, 39, .06);
  backdrop-filter: blur(12px);
}
.icon-btn, .ghost-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 900;
}
.icon-btn { display: none; }
.search {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.search span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.search input {
  height: 42px;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.page { display: none; }
.page.active {
  display: grid;
  gap: 16px;
}
.page-head {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255,255,255,.72), rgba(247,248,250,.96));
  border: 1px solid rgba(255,255,255,.75);
}
.page-head h1, .section-title h1 {
  margin: 14px 0 8px;
  font-size: clamp(38px, 5vw, 58px);
  line-height: 1;
  letter-spacing: 0;
}
.page-head p, .section-title p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}
.today-stack {
  display: grid;
  gap: 12px;
}
.today-card {
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
}
.today-card.dark {
  background: linear-gradient(145deg, #111827, #050505);
  color: white;
}
.today-card small, .metric span, .metric small, .panel-head span {
  color: var(--muted);
  font-weight: 800;
}
.today-card.dark small, .today-card.dark span { color: #d1d5db; }
.today-card strong { font-size: 32px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}
.metric {
  min-height: 136px;
  padding: 18px;
  border-radius: 18px;
}
.metric.featured {
  background: linear-gradient(145deg, #0b0b0b, #242424);
  color: white;
}
.metric.featured span, .metric.featured small { color: #f3f4f6; }
.metric strong {
  display: block;
  margin: 14px 0 8px;
  font-size: clamp(26px, 2.6vw, 34px);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 14px;
}
.dashboard-grid.lower { grid-template-columns: 1fr 1fr; }
.panel {
  border-radius: 18px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 20px; }
.chart-panel canvas {
  width: 100%;
  height: 260px;
  display: block;
  padding: 14px;
}
.section-title {
  padding: 22px;
  border-radius: 26px;
  background: var(--soft);
  border: 1px solid rgba(255,255,255,.75);
}
.filters {
  display: grid;
  grid-template-columns: 1fr 240px 190px;
  gap: 12px;
}
.table-scroll { overflow: auto; }
.table-scroll.compact { max-height: 330px; }
.table-scroll.tall { max-height: calc(100vh - 270px); }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: white;
  color: #657080;
  font-size: 12px;
  text-transform: uppercase;
  z-index: 1;
}
td { font-size: 14px; }
td strong { display: block; }
td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
tbody tr:hover { background: #fff9d7; }
.empty { color: var(--muted); font-weight: 800; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff4b8;
  color: #4b3b00;
  font-weight: 900;
}

@media (max-width: 1320px) {
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .dashboard-grid, .dashboard-grid.lower { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .auth-screen {
    grid-template-columns: 1fr;
    width: min(100% - 24px, 560px);
    padding: 24px 0;
  }
  .hero-stats { grid-template-columns: 1fr; }
  .app {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .sidebar {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    z-index: 40;
    width: 270px;
    height: auto;
    transform: translateX(-110%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar {
    top: 12px;
    grid-template-columns: auto 1fr;
  }
  .icon-btn { display: inline-flex; align-items: center; }
  .topbar select, .topbar .primary-btn { grid-column: span 1; }
  .page-head { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .auth-card { padding: 12px; border-radius: 20px; }
  .metrics { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr; }
  .search {
    grid-template-columns: 1fr;
    height: auto;
    padding: 10px 14px;
  }
  .today-card strong { font-size: 26px; }
  th, td { padding: 12px; }
}
