:root {
  --primary: #1e40af;
  --secondary: #3b82f6;
  --accent: #d97706;
  --bg: #f8fafc;
  --ink: #172554;
  --muted: #64748b;
  --card: #fff;
  --border: #dbeafe;
  --danger: #b91c1c;
  --ring: #1e40af;
  --shadow: 0 12px 30px rgba(30, 64, 175, 0.08);
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button,
input,
select {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--ring) 30%, transparent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.muted {
  color: var(--muted);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.22);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, #dbeafe 0, transparent 34%),
    radial-gradient(circle at 90% 90%, #ffedd5 0, transparent 27%), var(--bg);
}
.login-card {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.12;
  margin: 18px 0 8px;
}
.login-card label {
  display: block;
  font-weight: 700;
  margin: 18px 0 7px;
}
.login-card input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid #94a3b8;
  border-radius: 10px;
  background: #fff;
}
.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}
.login-card button:disabled {
  cursor: wait;
  opacity: 0.7;
}
.form-error {
  min-height: 24px;
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}
.app-shell {
  min-height: 100vh;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--border);
  background: #fff;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 24px;
  font-weight: 850;
}
.sidebar nav {
  display: grid;
  gap: 6px;
}
.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.nav-item:hover,
.nav-item.active {
  background: #eff6ff;
  color: var(--primary);
}
.ghost-button {
  min-height: 44px;
  margin-top: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}
main {
  margin-left: 236px;
  padding: 28px;
  max-width: 1600px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.topbar h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2rem);
}
.header-actions {
  display: flex;
  gap: 9px;
}
.header-actions select {
  min-width: 210px;
}
.header-actions select,
.secondary-button {
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}
.secondary-button:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.metric-card {
  min-height: 142px;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 14px rgba(30, 64, 175, 0.035);
}
.metric-card strong {
  display: block;
  margin: 13px 0 2px;
  font-size: 2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric-card > span {
  color: var(--muted);
  font-size: 0.82rem;
}
.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}
.realtime-card {
  border-color: #bfdbfe;
  background: linear-gradient(145deg, #eff6ff, #fff);
}
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 5px rgba(22, 163, 74, 0.12);
  animation: pulse 2s infinite;
}
.panel {
  margin-top: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 14px rgba(30, 64, 175, 0.035);
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0;
  font-size: 1.08rem;
}
.chart-panel svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 220px;
}
.chart-grid {
  stroke: #dbeafe;
  stroke-width: 1;
}
.chart-area {
  fill: url(#areaGradient);
}
.chart-line {
  fill: none;
  stroke: var(--secondary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-dot {
  fill: #fff;
  stroke: var(--secondary);
  stroke-width: 3;
}
.empty-state {
  padding: 44px 16px;
  text-align: center;
  color: var(--muted);
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #eaf1fb;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
th:first-child,
td:first-child {
  text-align: left;
}
th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
td:first-child {
  font-weight: 750;
}
.setup-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 2fr);
  gap: 20px;
  align-items: center;
}
.setup-panel p {
  margin-bottom: 0;
}
.code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.code-row code {
  display: block;
  min-width: 0;
  flex: 1;
  overflow: auto;
  padding: 13px;
  border-radius: 9px;
  background: #0f172a;
  color: #dbeafe;
  font-size: 0.76rem;
  white-space: nowrap;
}
.code-row button {
  flex: none;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 0 9px rgba(22, 163, 74, 0);
  }
}
@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .setup-panel {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand {
    padding: 0;
    margin-right: auto;
  }
  .sidebar nav {
    display: none;
  }
  .ghost-button {
    margin: 0 0 0 8px;
    padding: 0 12px;
  }
  main {
    margin: 0;
    padding: 18px 14px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .header-actions {
    width: 100%;
  }
  .header-actions select {
    min-width: 0;
    flex: 1;
  }
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .metric-card {
    min-height: 126px;
    padding: 15px;
  }
  .metric-card strong {
    font-size: 1.75rem;
  }
  .panel {
    padding: 16px;
  }
  .setup-panel {
    gap: 14px;
  }
  .code-row {
    align-items: stretch;
    flex-direction: column;
  }
  .code-row button {
    width: 100%;
  }
}
@media (max-width: 430px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .brand > span:last-child {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .live-dot {
    animation: none;
  }
}
