:root {
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-soft: #f8fafc;
  --line: #e6eaf0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); font-size: 0.92em; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand strong {
  display: block;
  color: var(--text);
  font-size: 0.98rem;
  letter-spacing: -0.03em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-sub,
.sidebar-kicker,
.login-product,
.login-copy {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.sidebar-kicker {
  margin: 28px 10px 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  font-size: 0.68rem;
}

.side-nav { display: grid; gap: 2px; }

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #475569;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.side-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.side-link:hover { background: var(--bg-soft); color: var(--text); }

.side-link.is-active {
  background: #eff4ff;
  color: var(--accent-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.user-card,
.session {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
}

.user-card strong,
.session-hi {
  display: block;
  font-size: 0.8rem;
}

.session-email {
  color: var(--muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 148px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.badge {
  display: inline-flex;
  align-items: center;
  margin: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.page { padding: 24px 28px 40px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1 {
  margin: 0 0 6px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.muted { margin: 0; color: var(--muted); }

.btn,
.page-actions button,
.login-card button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn:hover,
.page-actions button:hover { background: var(--bg-soft); }

.btn-primary,
.login-card button {
  border-color: transparent;
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover,
.login-card button:hover { background: var(--accent-2); color: #fff; }

.sidebar-logout {
  text-align: center;
  color: var(--muted);
  box-shadow: none;
}

.sidebar-logout:hover { color: var(--text); }

.alert,
.notice,
.cron-summary {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.alert { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.notice { background: #ecfdf5; border-color: #a7f3d0; color: var(--ok); }

.cron-summary {
  background: var(--bg-card);
  border-color: var(--line);
  color: var(--muted);
}

.cron-summary.is-alert {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
  font-weight: 600;
}

.cron-summary.is-dry {
  background: #fffbeb;
  border-color: #fde68a;
  color: var(--warn);
}

.counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.counter,
.dash-card,
.trend-card,
.score-panel,
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.counter { padding: 16px 18px; }

.counter.is-featured {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: none;
}

.counter.is-featured .counter-label { color: rgba(255, 255, 255, 0.78); }

.counter-label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-bottom: 6px;
}

.counter strong {
  font-size: 1.5rem;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filters-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.filter-group {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.chip {
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 650;
}

.chip.is-active {
  background: var(--accent);
  color: #fff;
}

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-soft);
  position: sticky;
  top: 0;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover { color: var(--text); background: #eef2f7; }

th.sortable::after {
  content: ' \2195';
  opacity: 0.35;
  font-size: 0.85em;
}

th[aria-sort='ascending']::after {
  content: ' \2191';
  opacity: 1;
  color: var(--accent);
}

th[aria-sort='descending']::after {
  content: ' \2193';
  opacity: 1;
  color: var(--accent);
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafc; }

.num {
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  white-space: nowrap;
}

.query,
.wait {
  font-family: var(--mono);
  font-size: 0.8rem;
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.query-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 520px;
}

.query-cell .query {
  flex: 1;
  min-width: 0;
}

.copy-btn {
  appearance: none;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
}

.copy-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: #bfdbfe;
  background: #eff6ff;
}

.copy-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.blocked { color: var(--danger); font-weight: 700; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 12px;
}

.row-warn td { background: #fffbeb; }
.row-danger td { background: #fef2f2; }
.row-ok td { background: #ecfdf5; }
.row-muted td { background: #f8fafc; }
.row-blocked td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.status-label {
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 0.78rem;
}

.row-ok .status-label { color: var(--ok); }
.row-danger .status-label { color: var(--danger); }
.row-warn .status-label { color: var(--warn); }
.row-muted .status-label { color: var(--muted); }

.mono { font-family: var(--mono); font-size: 0.84rem; }
.when { white-space: nowrap; }
.when .muted { display: block; font-size: 0.78rem; margin-top: 2px; }

.msg {
  font-family: var(--mono);
  font-size: 0.8rem;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-actions { display: flex; gap: 8px; align-items: flex-start; }
.page-actions form { margin: 0; }

.section-title {
  margin: 28px 0 12px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.var-up { color: var(--warn); }
.var-down { color: var(--ok); }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.08), transparent 32%),
    #eef1f6;
}

.login-wrap { width: min(960px, calc(100% - 32px)); }

.login-card {
  display: flex;
  min-height: 560px;
  background: var(--bg-card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.login-form {
  flex: 1;
  padding: 40px 44px 24px;
  display: flex;
  flex-direction: column;
}

.login-brand { margin-bottom: 4px; }

.login-form h1 {
  margin: 36px 0 8px;
  font-size: 1.85rem;
}

.login-card form { display: grid; gap: 8px; margin-top: 24px; }

.login-card label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  margin-top: 6px;
}

.field { position: relative; }

.field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: #94a3b8;
}

.field-icon svg { width: 18px; height: 18px; display: block; }

.login-card input {
  width: 100%;
  height: 44px;
  border: 1px solid #d8dee8;
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0 12px 0 40px;
  font: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.login-card button {
  margin-top: 14px;
  width: 100%;
  height: 44px;
}

.login-copy { margin-top: auto; padding-top: 24px; }

.login-hero {
  flex: 1;
  min-width: 0;
  background:
    radial-gradient(circle at 80% 0, rgba(255, 255, 255, 0.12), transparent 36%),
    linear-gradient(165deg, #1e3a8a 0%, #1d4ed8 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 28px 28px;
  position: relative;
  overflow: hidden;
}

.hero-console {
  background: rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 20px 18px;
  color: #fff;
}

.hero-kicker {
  margin: 0 0 8px;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 700;
}

.hero-score {
  margin: 0 0 18px;
  font-size: 3.2rem;
  font-weight: 750;
  letter-spacing: -0.06em;
  line-height: 0.9;
}

.hero-score span {
  display: block;
  margin-top: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: #6ee7b7;
}

.hero-metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.hero-metrics li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 10px;
}

.hero-metrics strong { color: #fff; font-variant-numeric: tabular-nums; }

.hero-caption {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.92rem;
  line-height: 1.35;
}

.hero-caption strong { color: #fff; font-size: 1.08rem; }

.score-panel {
  display: flex;
  gap: 28px;
  align-items: stretch;
  padding: 22px 24px;
  margin-bottom: 16px;
}

.score-main { min-width: 132px; }

.score-value {
  margin: 0;
  font-size: 3.4rem;
  line-height: 0.9;
  font-weight: 750;
  letter-spacing: -0.06em;
}

.score-band {
  margin: 10px 0 0;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.score-ok .score-value,
.score-ok .score-band { color: var(--ok); }
.score-warn .score-value,
.score-warn .score-band { color: var(--warn); }
.score-degraded .score-value,
.score-degraded .score-band { color: #ea580c; }
.score-crit .score-value,
.score-crit .score-band { color: var(--danger); }

.score-why { flex: 1; min-width: 0; }

.table-embed {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.table-embed th { background: var(--bg-soft); }

.dash-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dash-card {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  color: inherit;
}

.dash-card strong {
  font-size: 1.3rem;
  letter-spacing: -0.04em;
}

.dash-card.is-ok { box-shadow: inset 3px 0 0 var(--ok), var(--shadow); }
.dash-card.is-warn {
  box-shadow: inset 3px 0 0 var(--warn), var(--shadow);
  background: #fffbeb;
}
.dash-card.is-danger {
  box-shadow: inset 3px 0 0 var(--danger), var(--shadow);
  background: #fef2f2;
}

.trend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.trend-card { padding: 16px 18px 18px; }
.trend-card .section-title { margin: 0 0 8px; }
.trend-kicker { margin: 0 0 4px; font-weight: 700; }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 88px;
  margin-top: 14px;
}

.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.bar {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 3px 3px 0 0;
  background: #93c5fd;
}

@media (max-width: 900px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-foot { margin-top: 16px; }

  .login-card {
    flex-direction: column;
    min-height: 0;
  }

  .login-hero { min-height: 240px; }

  .score-panel,
  .trend-grid,
  .dash-cards {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
