:root {
  --bg: #07090f;
  --panel: #0e141f;
  --panel-2: #121a28;
  --line: #1e2a3d;
  --line-soft: #172131;
  --text: #e7edf5;
  --muted: #8ea0b8;
  --cyan: #02b3d7;
  --cyan-dim: #0a2a35;
  --amber: #e6a636;
  --amber-dim: #2e2410;
  --red: #e2564f;
  --red-dim: #2c1513;
  --green: #45c08a;
  --radius: 12px;
  --ctrl: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-family: "Space Grotesk", sans-serif; font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0a1018, var(--bg));
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: var(--cyan);
  clip-path: polygon(50% 0, 100% 22%, 100% 60%, 50% 100%, 0 60%, 0 22%);
}
.actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  font: inherit; font-weight: 500; cursor: pointer;
  padding: 8px 14px; border-radius: var(--ctrl);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: #2c3d57; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cyan); border-color: var(--cyan); color: #04222b; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--red); border-color: var(--red-dim); }
.btn.danger:hover { background: var(--red-dim); }
.btn:focus-visible, .input:focus-visible, .tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 12px 24px 0; border-bottom: 1px solid var(--line); }
.tab {
  font: inherit; cursor: pointer; color: var(--muted);
  background: none; border: none; padding: 10px 14px; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--cyan); }

main { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

/* Toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.input {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--ctrl); padding: 8px 12px;
}
#search { flex: 1; min-width: 200px; }
.window { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

/* Banner */
.banner {
  padding: 12px 14px; border-radius: var(--ctrl); margin-bottom: 16px; font-size: 14px;
  background: var(--red-dim); border: 1px solid #52201d; color: #f2b3ae;
}

/* Table */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line-soft); }
th {
  font-family: "Space Grotesk", sans-serif; font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--panel-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #0f1826; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
.name { font-weight: 500; }
.gen { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Badges */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; letter-spacing: .02em; white-space: nowrap;
}
.badge.controlled { background: var(--cyan-dim); color: #6fd8ec; border: 1px solid #0c3a47; }
.badge.low { background: var(--amber-dim); color: var(--amber); border: 1px solid #43340f; }
.badge.expired { background: var(--red-dim); color: #f2938c; border: 1px solid #52201d; }
.badge.soon { background: var(--amber-dim); color: var(--amber); border: 1px solid #43340f; }
.stack { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.exp-expired { color: #f2938c; }
.exp-soon { color: var(--amber); }
.exp-ok { color: var(--muted); }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(3,6,11,.66);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 20;
}
.modal {
  width: 440px; max-width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
}
.modal h2 { font-family: "Space Grotesk", sans-serif; font-size: 17px; font-weight: 600; margin: 0 0 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .input { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; accent-color: var(--cyan); }
.check label { margin: 0; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .actions { justify-content: stretch; }
  .actions .btn { flex: 1; }
  .hide-sm { display: none; }
}
