@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #14161c;
  --surface: #1b1e26;
  --surface-2: #21242e;
  --border: #2a2e3a;
  --text: #e7e9f2;
  --text-muted: #8b90a3;
  --accent: #6c8cff;
  --accent-dim: #6c8cff33;
  --green: #45c988;
  --yellow: #e0b13e;
  --red: #ef6a6a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.mono { font-family: 'IBM Plex Mono', monospace; }

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  margin: 0;
}

a { color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
}
.login-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.login-card h1 { font-size: 22px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.btn {
  width: 100%;
  background: var(--accent);
  color: #0d0f14;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { opacity: 0.9; }
.login-error {
  background: #3a1f22;
  border: 1px solid #5a2a2e;
  color: #f3a3a3;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-success {
  background: #1a3324;
  border: 1px solid #2a5a3a;
  color: var(--green);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.auth-switch {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---------- Report shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.brand { font-size: 18px; }
.brand-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
select, .select-like {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}
.user-chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
}
.badge-admin {
  color: var(--accent);
  border-color: var(--accent-dim);
}
.logout-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.logout-link:hover { color: var(--text); border-color: var(--text-muted); }

.container { padding: 24px 28px 60px; max-width: 1180px; margin: 0 auto; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  border-left: 3px solid var(--border);
}
.metric-card.zone-green { border-left-color: var(--green); }
.metric-card.zone-yellow { border-left-color: var(--yellow); }
.metric-card.zone-red { border-left-color: var(--red); }
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.metric-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 28px;
  font-weight: 600;
}
.metric-value.green { color: var(--green); }
.metric-value.yellow { color: var(--yellow); }
.metric-value.red { color: var(--red); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.panel-header h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.count-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}
.search-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  width: 240px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }
.panel-body { padding: 4px 0; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 18px; text-align: left; font-size: 13px; }
th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sort-active { color: var(--accent); }
th .sort-hint { margin-left: 5px; font-size: 10px; opacity: 0.35; }
th .sort-arrow { margin-left: 5px; font-size: 10px; opacity: 0.9; }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child { border-bottom: none; }
td.num, th.num { font-family: 'IBM Plex Mono', monospace; text-align: right; }

.acc-text { font-weight: 600; }
.acc-text.green { color: var(--green); }
.acc-text.yellow { color: var(--yellow); }
.acc-text.red { color: var(--red); }

.acc-bar-track {
  width: 100px;
  height: 6px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
.acc-bar-fill { height: 100%; }
.acc-bar-fill.green { background: var(--green); }
.acc-bar-fill.yellow { background: var(--yellow); }
.acc-bar-fill.red { background: var(--red); }

.reason-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.reason-row:last-child { border-bottom: none; }
.reason-row:hover { background: var(--surface-2); }
.reason-name { flex: 0 0 220px; font-size: 13px; }
.reason-bar-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.reason-bar-fill { height: 100%; background: var(--accent); }
.reason-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  width: 70px;
  text-align: right;
}

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

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 15, 0.7);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-close {
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
}
.modal-body { padding: 8px 0; overflow-y: auto; }
.record-row { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.record-row:last-child { border-bottom: none; }
.record-id { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--accent); }
.record-comment { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.record-mod { font-size: 12px; color: var(--text-muted); }

.status-strip {
  height: 3px;
  width: 100%;
}
.status-strip.green { background: var(--green); }
.status-strip.yellow { background: var(--yellow); }
.status-strip.red { background: var(--red); }

@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .reason-name { flex-basis: 140px; }
}
