:root {
  --bg: #070b16;
  --bg2: #0b1120;
  --panel: #101a30;
  --panel2: #0c1526;
  --line: #1f2d49;
  --line2: #2b3d5f;
  --text: #e7edf9;
  --muted: #8b9bb8;
  --accent: #6366f1;
  --accent2: #0ea5e9;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(79, 70, 229, 0.22), transparent 60%),
    radial-gradient(800px 480px at 92% 0%, rgba(14, 165, 233, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

a { color: #93c5fd; text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { margin: 0; }

.muted { color: var(--muted); }
.block { display: block; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(7, 11, 22, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.35);
}
.brand-mark.lg { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; margin-bottom: 6px; }

.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a.on, .nav a:hover { color: var(--text); text-decoration: none; }

/* ---------- layout ---------- */

.wrap {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px 24px 48px;
  display: grid;
  gap: 18px;
  flex: 1;
}

.foot {
  padding: 18px 24px 26px;
  text-align: center;
  color: #5b6b88;
  font-size: 12px;
}

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.card-head p { margin-top: 4px; font-size: 13px; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.head-actions.left { padding: 0 22px 20px; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.stat {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #111c33, #0c1526);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.stat.ok::before { background: var(--ok); }
.stat.warn::before { background: var(--warn); }
.stat.info::before { background: var(--accent2); }
.stat span { display: block; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.stat b { display: block; margin-top: 8px; font-size: 30px; line-height: 1.1; }

/* ---------- forms ---------- */

label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; color: #c7d3e8; }
label small { font-weight: 400; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: #0a1222;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
}
input::placeholder { color: #5d6d8b; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 20px 22px 22px;
}
.grid-form .span2 { grid-column: 1 / -1; }

.search { display: flex; gap: 8px; width: min(340px, 100%); }
.search input { padding: 8px 11px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--line2);
  background: #17223a;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #1e2c4a; border-color: #3a5079; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.32);
}
.btn.primary:hover { background: linear-gradient(135deg, #7577f5, #5b52f0); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.btn.danger:hover { background: rgba(248, 113, 113, 0.2); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- table ---------- */

.table-wrap { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 11px 18px;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  background: #0b1324;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
tbody td { padding: 13px 18px; border-bottom: 1px solid #17223a; vertical-align: middle; }
tbody tr:hover { background: rgba(99, 102, 241, 0.05); }
tbody tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: 8px; justify-content: flex-end; }
td.actions form { margin: 0; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

a.code { font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }

.dev { font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge.ok { background: rgba(52, 211, 153, 0.12); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.badge.off { background: rgba(148, 163, 184, 0.12); color: #b6c2d9; border-color: rgba(148, 163, 184, 0.3); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #17223a;
  border: 1px solid var(--line2);
  font-family: var(--mono);
  font-size: 11px;
  color: #b9c7e0;
}

/* ---------- flash / callout ---------- */

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.32); color: #a7f3d0; }
.flash.err { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.32); color: #fecaca; }
.flash.warn { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.32); color: #fde68a; }

.callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 22px 20px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: rgba(14, 165, 233, 0.08);
}
.callout p { font-size: 13px; margin-top: 3px; }

.code-pill {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px dashed rgba(125, 211, 252, 0.55);
  background: #08101f;
  color: #7dd3fc;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  cursor: pointer;
}
.code-pill:hover { background: #0b1729; }

/* ---------- detail ---------- */

.back { color: var(--muted); font-size: 14px; font-weight: 600; }

.details {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding: 20px 22px 22px;
}
.details div { min-width: 0; }
.details span { display: block; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 5px; }
.details b { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------- login ---------- */

.login-wrap { flex: 1; display: grid; place-items: center; padding: 40px 18px; }

.login-card {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 16px;
  justify-items: start;
  padding: 30px 28px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #111c33, #0b1322);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.45);
}
.login-card h1 { font-size: 22px; }
.login-card .muted { font-size: 13px; margin-top: -8px; }
.login-card label, .login-card .btn, .login-card .flash { width: 100%; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .details { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .topbar { padding: 12px 16px; }
  .wrap { padding: 18px 14px 36px; }
  .card-head { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2 { grid-column: auto; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 24px; }
  .details { grid-template-columns: 1fr 1fr; padding: 16px; }
  .callout { flex-direction: column; align-items: stretch; margin: 0 16px 16px; }
  .code-pill { text-align: center; }
  thead { display: none; }
  tbody td { display: block; padding: 8px 16px; border: none; }
  tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid #17223a; }
  td.actions { justify-content: flex-start; padding-top: 12px; }
  .head-actions { flex-wrap: wrap; }
}
