/* ─────────────────────────────────────────────────────────────────────────
   narko panel — main stylesheet
   Design tokens: neutral surface, single accent (indigo), generous spacing.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e3e6ec;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-soft-2: #e0e7ff;
  --up: #059669;
  --up-soft: #d1fae5;
  --down: #dc2626;
  --down-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #dbeafe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10), 0 4px 8px rgba(15, 23, 42, 0.06);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 8px;
  display: inline-block;
}
.brand:hover { color: var(--accent); }

.navlinks {
  display: flex;
  gap: 4px;
  flex: 1;
}
.navlinks a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
.navlinks a:hover {
  color: var(--text);
  background: var(--bg);
  text-decoration: none;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
}
.username {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

/* ── Main content ───────────────────────────────────────────────────────── */

.content {
  max-width: 1280px;
  margin: 28px auto;
  padding: 0 28px 80px;
}

h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 24px;
  letter-spacing: -0.02em;
  color: var(--text);
}
h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 14px;
  letter-spacing: -0.01em;
  color: var(--text);
}
h3 {
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.crumbs {
  color: var(--muted);
  margin-bottom: 14px;
  font-size: 13px;
}
.crumbs a {
  color: var(--muted);
  font-weight: 500;
}
.crumbs a:hover { color: var(--accent); }
.crumbs span { color: var(--text-2); font-weight: 500; }

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

code {
  background: rgba(79, 70, 229, 0.08);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.cards {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-head {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}
.card-head h2 a { color: var(--text); }
.card-head h2 a:hover { color: var(--accent); text-decoration: none; }
.card-head .muted {
  font-size: 12.5px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ── Stats inside cards (key-value tables) ─────────────────────────────── */

.kv {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 14px;
}
.kv td {
  padding: 6px 0;
  font-size: 13.5px;
  border-bottom: 1px dashed var(--border);
}
.kv tr:last-child td { border-bottom: none; }
.kv td:first-child {
  color: var(--muted);
  font-weight: 500;
}
.kv td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.12s;
  cursor: pointer;
}
.btn:hover {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

button.primary {
  padding: 8px 18px;
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.12s;
}
button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.primary.small {
  padding: 5px 12px;
  font-size: 12.5px;
}
button.primary:active {
  transform: translateY(1px);
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
}
.link-button:hover { color: var(--accent-hover); text-decoration: underline; }
.link-button.danger { color: var(--down); }
.link-button.danger:hover { color: #b91c1c; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data th,
table.data td {
  padding: 11px 14px;
  text-align: left;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}
table.data thead th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding-top: 12px;
  padding-bottom: 12px;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 0.08s; }
table.data tbody tr:hover { background: var(--accent-soft); }

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.delta-up { color: var(--up); font-weight: 600; }
.delta-down { color: var(--down); font-weight: 600; }

.parse-fail td { background: var(--down-soft); }
.parse-partial td { background: var(--warn-soft); }

.sparkline-cell { padding: 4px 14px !important; width: 140px; }
.sparkline-cell canvas { display: block; }

/* ── Sections ───────────────────────────────────────────────────────────── */

section {
  margin-bottom: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}
section > h2:first-child {
  margin-top: 0;
}
section.bare {
  background: transparent;
  border: none;
  padding: 0;
  box-shadow: none;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.filter-bar label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0;
}

select,
input[type="text"],
input[type="password"],
input[type="file"],
input[type="number"],
textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
input[type="file"] {
  padding: 6px 10px;
  cursor: pointer;
}

/* ── Status badges (pills) ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-on  { background: var(--up-soft);    color: var(--up);   border-color: rgba(5, 150, 105, 0.25); }
.badge-off { background: #f3f4f6;           color: var(--muted); border-color: var(--border); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(217, 119, 6, 0.25); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: rgba(2, 132, 199, 0.25); }
.badge-err  { background: var(--down-soft); color: var(--down); border-color: rgba(220, 38, 38, 0.25); }

/* Big stat number block (used in dashboard) */
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .stat-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat .stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Login page ─────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 30%, rgba(79, 70, 229, 0.08), transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(99, 102, 241, 0.06), transparent 60%),
    var(--bg);
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.login-box h1::before {
  content: "";
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.login-box .subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 26px;
}
.login-box form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-box label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}
.login-box input {
  font-size: 14px;
  padding: 10px 12px;
}
.login-box button.primary {
  margin-top: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
}
.login-box .error {
  background: var(--down-soft);
  border: 1px solid rgba(220, 38, 38, 0.25);
  color: var(--down);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: -4px;
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.empty strong { color: var(--text-2); display: block; margin-bottom: 6px; font-size: 15px; }
.empty code { font-size: 12.5px; }

/* ── Misc ───────────────────────────────────────────────────────────────── */

.tag-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Make the toggle button look like a clean pill instead of an emoji */
.toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.12s;
}
.toggle-btn.on {
  background: var(--up-soft);
  color: var(--up);
  border-color: rgba(5, 150, 105, 0.25);
}
.toggle-btn.off {
  background: #f3f4f6;
}
.toggle-btn:hover { box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .topbar-inner { padding: 12px 16px; gap: 16px; flex-wrap: wrap; }
  .content { padding: 0 16px 60px; margin: 18px auto; }
  .cards { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 9px 10px; }
}
