:root {
  --bg: #05060a;
  --text: #e9eef5;
  --muted: #a2b0c2;
  --border: rgba(255,255,255,0.08);
  --blood: #c61a1a;
  --bone: #e7e2da;
  --glow: rgba(198,26,26,0.22);
  --topbar-height: 64px;
  --ok: #3fae5a;
  --warn: #d99a2b;
  --err: #c61a1a;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 800px at 18% 12%, rgba(198,26,26,0.10), transparent 56%),
    radial-gradient(900px 700px at 90% 20%, rgba(231,226,218,0.04), transparent 60%),
    radial-gradient(1400px 900px at 50% 110%, rgba(0,0,0,0.8), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

a { color: inherit; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 340px;
  background: rgba(8,10,16,0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 20px 80px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}

.login-card .brand {
  font-family: "UnifrakturCook", serif;
  font-size: 32px;
  text-align: center;
  text-shadow: 0 0 24px var(--glow);
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 20px;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 14px;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.72);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.login-card input:focus {
  border-color: rgba(198,26,26,0.55);
  box-shadow: 0 0 0 3px rgba(198,26,26,0.10);
}

.login-error {
  color: var(--err);
  font-size: 12px;
  margin-top: 12px;
  min-height: 14px;
  text-align: center;
}

/* ===== APP SHELL ===== */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

#topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: var(--topbar-height);
  background: linear-gradient(90deg, rgba(6,8,14,0.96), rgba(12,14,22,0.92));
  border-bottom: 1px solid var(--border);
  box-shadow: 0 12px 50px rgba(0,0,0,0.35);
  z-index: 10;
}

#topbar .brand {
  font-family: "UnifrakturCook", serif;
  font-size: 24px;
  text-shadow: 0 0 24px var(--glow);
  white-space: nowrap;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.nav a {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease;
}

.nav a:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav a.active { color: var(--bone); background: rgba(198,26,26,0.16); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.whoami { font-size: 12px; color: var(--muted); }

.content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== COMPONENTS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.62);
  color: rgba(231,226,218,0.92);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(198,26,26,0.40); background: rgba(198,26,26,0.10); }
.btn-mini { padding: 6px 10px; font-size: 12px; border-radius: 10px; }
.btn-primary { width: 100%; justify-content: center; background: rgba(198,26,26,0.18); border-color: rgba(198,26,26,0.45); }
.btn-primary:hover { background: rgba(198,26,26,0.30); }

.card {
  background: rgba(8,10,16,0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.20);
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat-card .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 700; }
.stat-card .value { font-size: 30px; font-weight: 800; margin-top: 6px; color: var(--bone); }
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.warn { color: var(--warn); }
.stat-card .value.err { color: var(--err); }

h2 { font-size: 16px; margin: 0 0 14px; color: var(--bone); }

.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 5px 0; }
.bar-row .bar-label { width: 110px; flex-shrink: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 8px; background: rgba(255,255,255,0.06); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--blood), rgba(198,26,26,0.6)); }
.bar-row .bar-count { width: 50px; text-align: right; color: var(--text); font-weight: 700; }

/* ===== TOOLBAR / FILTERS ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input, .toolbar select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(4,6,10,0.62);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: rgba(198,26,26,0.45); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--bone); }
tbody td { padding: 9px 12px; border-top: 1px solid rgba(255,255,255,0.05); white-space: nowrap; }
tbody tr:hover { background: rgba(198,26,26,0.05); }
tbody tr.clickable { cursor: pointer; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.ok { background: rgba(63,174,90,0.15); color: var(--ok); }
.badge.warn { background: rgba(217,154,43,0.15); color: var(--warn); }
.badge.err { background: rgba(198,26,26,0.15); color: var(--err); }
.badge.muted { background: rgba(162,176,194,0.15); color: var(--muted); }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: 560px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: rgba(10,12,18,0.97); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; box-shadow: 0 20px 80px rgba(0,0,0,0.5);
}
.modal h3 { margin: 0 0 16px; color: var(--bone); }
.modal label { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 12px; text-transform: uppercase; }
.modal input, .modal textarea {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10); background: rgba(4,6,10,0.72); color: var(--text);
  font-size: 13px; outline: none; font-family: inherit;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-error { color: var(--err); font-size: 12px; margin-top: 10px; }
.modal-close { float: right; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; }

.log-line { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 4px 0; border-top: 1px solid rgba(255,255,255,0.04); display: flex; gap: 10px; }
.log-line .ts { color: var(--muted); flex-shrink: 0; }
.log-line .lvl { flex-shrink: 0; width: 56px; font-weight: 700; }
.log-line .lvl.info { color: var(--muted); }
.log-line .lvl.warning { color: var(--warn); }
.log-line .lvl.error { color: var(--err); }

.empty { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }
.loading { color: var(--muted); font-size: 13px; padding: 20px; text-align: center; }

/* ===== MONITOR ===== */
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.mon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 300ms;
}
.pulse-dot.live { animation: pulse-anim 2s ease-in-out infinite; }

@keyframes pulse-anim {
  0%, 100% { box-shadow: 0 0 0 0 rgba(63,174,90,0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(63,174,90,0); }
}

.log-stream {
  height: 420px;
  overflow-y: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  scroll-behavior: smooth;
}

.log-stream .log-line {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  border-top: 1px solid rgba(255,255,255,0.04);
  word-break: break-all;
  white-space: pre-wrap;
}

@keyframes log-flash {
  from { background: rgba(63,174,90,0.10); }
  to   { background: transparent; }
}
.log-new { animation: log-flash 1.8s ease-out; }

.mon-run-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.mon-run-row:first-child { border-top: none; padding-top: 0; }
