:root {
  color-scheme: dark;
  --bg: #080e16;
  --surface: #101a27;
  --surface-2: #162335;
  --line: #25364d;
  --text: #e8f0fb;
  --muted: #91a6c2;
  --accent: #43d4a8;
  --accent-2: #4d9dff;
  --danger: #ff647c;
  --warning: #ffc65c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 15% -10%, #16304d 0, transparent 42%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  background: rgba(8, 14, 22, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand { font-weight: 800; letter-spacing: 0.08em; white-space: nowrap; }
.brand span { color: var(--accent); }

.paper-banner {
  flex: 1;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #071a14;
  background: var(--accent);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
}

main {
  width: min(1240px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
  display: grid;
  gap: 1.25rem;
}

.card {
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(1rem, 2.5vw, 1.6rem);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

h1, h2, h3 { margin: 0 0 0.6rem; line-height: 1.2; }
h1 { font-size: clamp(1.4rem, 3vw, 2.1rem); }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0.2rem 0 0.8rem; }
.muted { color: var(--muted); font-size: 0.86rem; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; }

.auth-card { max-width: 860px; margin: 4vh auto; }
.auth-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.stack { display: grid; gap: 0.7rem; }
.stack.compact { margin-bottom: 0.9rem; }
label { display: grid; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 0.5rem; }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: #0b1421;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.6rem 0.7rem;
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }

button {
  cursor: pointer;
  background: var(--accent);
  border-color: transparent;
  color: #061b14;
  font-weight: 700;
}

button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); color: #21070d; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.active { outline: 2px solid var(--accent-2); }

.card-heading { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; }
.badge-group { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge { font-size: 0.7rem; padding: 0.3rem 0.55rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.badge-paper { color: var(--accent); border-color: var(--accent); }

.leveler { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
.leveler input { flex: 1; accent-color: var(--accent); }
.leveler output { min-width: 3.5rem; text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.policy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.metric { background: #0c1726; border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem; }
.metric span { display: block; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric strong { display: block; margin-top: 0.25rem; font-size: 1rem; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.grid { display: grid; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.7rem; align-items: end; margin-bottom: 1rem; }
.rows { display: grid; gap: 0.5rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; justify-content: space-between; align-items: center; padding: 0.65rem 0.8rem; background: #0c1726; border: 1px solid var(--line); border-radius: 10px; font-size: 0.84rem; }
.row .meta { color: var(--muted); overflow-wrap: anywhere; }
.row button { padding: 0.35rem 0.6rem; font-size: 0.78rem; }

.kill-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
.tab { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
th, td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: #0c1726; color: var(--muted); white-space: nowrap; }
td { overflow-wrap: anywhere; }
.empty { padding: 1rem; color: var(--muted); text-align: center; }

dialog { width: min(460px, calc(100% - 2rem)); color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem; }
dialog::backdrop { background: rgba(2, 6, 12, 0.75); }
textarea { width: 100%; margin-bottom: 0.8rem; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .paper-banner { order: 3; flex-basis: 100%; font-size: 0.62rem; }
  main { width: min(100% - 1rem, 1240px); }
  .kill-controls { width: 100%; }
  .kill-controls input { flex: 1; min-width: 120px; }
}
