:root {
  --bg: #071019;
  --panel: rgba(14, 24, 37, .82);
  --panel-strong: rgba(17, 30, 46, .96);
  --line: rgba(148, 163, 184, .16);
  --text: #e8eef8;
  --muted: #93a4b8;
  --soft: #172235;
  --accent: #4de1c1;
  --accent-2: #7c6cff;
  --accent-3: #ffb454;
  --danger: #ff647c;
  --shadow: 0 18px 70px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button, input { font: inherit; }
.bg-glow {
  position: fixed;
  inset: -30% -10% auto -10%;
  height: 52vh;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 25%, rgba(77, 225, 193, .22), transparent 28%),
    radial-gradient(circle at 72% 8%, rgba(124, 108, 255, .24), transparent 30%),
    radial-gradient(circle at 88% 60%, rgba(255, 180, 84, .12), transparent 26%);
  filter: blur(8px);
}

.login-shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(17, 30, 46, .92), rgba(10, 18, 29, .9));
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 18px 0 4px; font-size: 28px; letter-spacing: -.04em; }
.login-card p { margin: 0 0 26px; color: var(--muted); }
.login-card form { display: grid; gap: 14px; }
.login-card label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(7, 16, 25, .7);
  color: var(--text);
  outline: none;
}
.login-card input:focus { border-color: rgba(77, 225, 193, .62); }
.login-card button, .ghost-button, .icon-button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}
.login-card button {
  margin-top: 8px;
  padding: 13px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #051018;
  font-weight: 800;
}
.form-error { min-height: 18px; color: var(--danger); font-size: 13px; }

.app-shell {
  position: relative;
  height: 100%;
  display: grid;
  grid-template-columns: 276px 1fr;
}
.sidebar {
  position: relative;
  z-index: 5;
  height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(7, 16, 25, .78);
  backdrop-filter: blur(18px);
}
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
}
.sidebar-head strong { display: block; letter-spacing: -.03em; }
.sidebar-head small { color: var(--muted); }
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: conic-gradient(from 180deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  box-shadow: 0 8px 32px rgba(77, 225, 193, .18);
}
.brand-mark span {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #071019;
  color: var(--accent);
  font-size: 15px;
}
.brand-mark.big { width: 54px; height: 54px; border-radius: 19px; }
.brand-mark.big span { width: 39px; height: 39px; border-radius: 14px; }

.nav {
  height: calc(100vh - 86px);
  overflow-y: auto;
  padding-right: 4px;
}
.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  margin: 3px 0;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.nav button:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav button.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(77, 225, 193, .14), rgba(124, 108, 255, .14));
  border-color: rgba(77, 225, 193, .18);
}
.nav .nav-icon { width: 24px; text-align: center; font-size: 18px; }

.main-shell {
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 25, .62);
  backdrop-filter: blur(18px);
}
.page-title-wrap { min-width: 0; display: flex; align-items: center; gap: 13px; }
.page-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 20px;
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(77, 225, 193, .12);
  color: var(--accent);
  border: 1px solid rgba(77, 225, 193, .22);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}
.ghost-button, .icon-button {
  padding: 9px 12px;
  border-radius: 13px;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
}
.mobile-only { display: none; }

.content {
  min-width: 0;
  overflow: auto;
  padding: 22px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}
.card {
  grid-column: span 4;
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 12px 38px rgba(0,0,0,.18);
}
.card.wide { grid-column: span 8; }
.card.full { grid-column: 1 / -1; }
.card h2 { margin: 0 0 8px; font-size: 16px; letter-spacing: -.02em; }
.card p { margin: 0; color: var(--muted); line-height: 1.55; }
.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(148, 163, 184, .28);
  border-radius: 26px;
  background: rgba(255,255,255,.025);
}
.empty-state .symbol { font-size: 42px; margin-bottom: 12px; }
.empty-state h2 { margin: 0 0 8px; letter-spacing: -.04em; }
.empty-state p { max-width: 520px; margin: 0 auto; color: var(--muted); }
.placeholder-line {
  height: 10px;
  border-radius: 999px;
  margin: 12px 0;
  background: linear-gradient(90deg, rgba(255,255,255,.08), rgba(255,255,255,.025));
}
.placeholder-line.short { width: 58%; }
.placeholder-line.mid { width: 78%; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 4;
  background: rgba(0,0,0,.44);
  backdrop-filter: blur(2px);
}

@media (max-width: 980px) {
  body { overflow: hidden; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 330px);
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { height: 68px; padding: 10px 12px; }
  .topbar-actions { gap: 6px; }
  .ghost-button { padding: 8px 10px; }
  .status-pill { display: none; }
  .page-icon { width: 38px; height: 38px; border-radius: 13px; }
  .topbar h1 { font-size: 18px; }
  .topbar p { display: none; }
  .content { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .grid { grid-template-columns: 1fr; }
  .card, .card.wide, .card.full { grid-column: 1; }
  .empty-state { min-height: 300px; padding: 18px; }
}

@media (max-width: 520px) {
  .login-shell { padding: 14px; }
  .login-card { padding: 22px; border-radius: 24px; }
  .topbar { gap: 8px; }
  .page-title-wrap { gap: 9px; }
  .logout-text { display: none; }
}

.dashboard-stack {
  display: grid;
  gap: 14px;
}
.stat-grid {
  display: grid;
  gap: 12px;
}
.stat-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(17,30,46,.92), rgba(10,18,29,.78));
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
  margin-bottom: 8px;
}
.stat-card strong {
  display: block;
  font-size: clamp(22px, 2.7vw, 34px);
  line-height: 1;
  letter-spacing: -.05em;
}
.stat-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 12px 38px rgba(0,0,0,.18);
}
.full-panel { padding: 18px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.03em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.loading, .error-box, .warn-box, .empty-compact {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--muted);
}
.error-box { color: var(--danger); border-color: rgba(255,100,124,.28); }
.warn-box { margin-top: 12px; color: var(--accent-3); border-color: rgba(255,180,84,.25); }
.line-chart {
  width: 100%;
  height: 250px;
  display: block;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
  overflow: hidden;
}
.chart-zero { stroke: rgba(148,163,184,.18); stroke-width: 1; }
.chart-line { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 10px rgba(77,225,193,.25)); }
.chart-caption {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}
.flow-strip {
  display: grid;
  grid-template-columns: repeat(13, auto);
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.flow-item {
  min-width: 132px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
}
.flow-item strong {
  display: block;
  font-size: 26px;
  letter-spacing: -.05em;
}
.flow-item span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.flow-arrow {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 28px;
  padding: 0 2px;
}
.bar-list { display: grid; gap: 9px; }
.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 54px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-row span { color: var(--text); font-weight: 700; }
.bar-row b { text-align: right; color: var(--muted); font-weight: 700; }
.bar-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,.06);
}
.bar-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(148,163,184,.10);
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: rgba(17,30,46,.98);
  color: var(--muted);
  font-size: 12px;
  z-index: 1;
}
td { color: #dbe6f3; }
tr:last-child td { border-bottom: 0; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.selected { color: var(--accent); border-color: rgba(77,225,193,.28); background: rgba(77,225,193,.10); }
.tag.watchlist { color: var(--accent-3); border-color: rgba(255,180,84,.26); background: rgba(255,180,84,.10); }
.tag.rejected { color: var(--danger); border-color: rgba(255,100,124,.22); background: rgba(255,100,124,.08); }
.mini-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 11px;
  cursor: pointer;
}

@media (max-width: 980px) {
  .stat-grid.three, .stat-grid.four { grid-template-columns: 1fr; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .line-chart { height: 210px; }
  .flow-strip { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); min-height: 18px; }
  .flow-item { min-width: 0; }
  .bar-row { grid-template-columns: 82px 1fr 46px; }
  table { min-width: 720px; }
}

.health-list { display: grid; gap: 12px; }
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.035);
}
.health-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.health-main strong, .health-state b { display: block; font-size: 14px; }
.health-main small, .health-state small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.health-state { text-align: right; flex: 0 0 auto; }
.health-dot { width: 11px; height: 11px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 18px rgba(77,225,193,.8); flex: 0 0 auto; }
.health-row.warn .health-dot { background: var(--accent-3); box-shadow: 0 0 18px rgba(255,180,84,.75); }
.health-row.danger .health-dot { background: var(--danger); box-shadow: 0 0 18px rgba(255,100,124,.75); }
@media (max-width: 620px) {
  .health-row { align-items: flex-start; flex-direction: column; }
  .health-state { text-align: left; }
}
.tag.passed { color: var(--accent); border-color: rgba(77,225,193,.28); background: rgba(77,225,193,.10); }
.tag.observe { color: var(--accent-3); border-color: rgba(255,180,84,.26); background: rgba(255,180,84,.10); }
