:root {
  --bg: #0b0d12;
  --surface: #141821;
  --surface-2: #1b2029;
  --line: #262c38;
  --text: #e6e8ee;
  --text-dim: #8b8f9c;
  --accent: #d9a44c;
  --accent-soft: rgba(217, 164, 76, 0.14);
  --accent-text: #1a1305;
  --pos: #3ecf8e;
  --pos-soft: rgba(62, 207, 142, 0.14);
  --neg: #f2555f;
  --neg-soft: rgba(242, 85, 95, 0.14);
  --warn: #e0a63c;
  --warn-soft: rgba(224, 166, 60, 0.14);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.small { font-size: 12px; }

/* ─── вход ─── */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0 0 8px; }

input, select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font: inherit;
  min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-accent:hover { filter: brightness(1.08); color: var(--accent-text); }
.btn-danger:hover { border-color: var(--neg); color: var(--neg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

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

/* ─── каркас ─── */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 600; margin-right: auto; }
.topbar input { flex: 0 1 340px; }

.tabs { display: flex; gap: 4px; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  padding: 6px 12px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .btn-accent { margin-left: auto; }
.check { display: flex; align-items: center; gap: 7px; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.check input { width: auto; }

.code-value {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: .04em;
  cursor: pointer;
  border-bottom: 1px dashed var(--line);
}
.code-value:hover { color: var(--accent); border-bottom-color: var(--accent); }

.stats { display: flex; gap: 12px; padding: 18px 24px 0; flex-wrap: wrap; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 120px;
}
.stat b { display: block; font-size: 22px; font-family: var(--mono); }

main { padding: 18px 24px 40px; }

table.users { width: 100%; border-collapse: collapse; }
table.users th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
table.users td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users tr:hover td { background: var(--surface); }
.actions-col { text-align: right; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn { margin-left: 6px; }
.mono { font-family: var(--mono); font-size: 13px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active  { background: var(--pos-soft);   color: var(--pos); }
.badge-expired { background: var(--warn-soft);  color: var(--warn); }
.badge-blocked { background: var(--neg-soft);   color: var(--neg); }
.badge-none    { background: var(--surface-2);  color: var(--text-dim); }

.empty { padding: 40px; text-align: center; color: var(--text-dim); }

/* ─── диалог ─── */
.dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  width: min(380px, 90vw);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h2 { margin: 0 0 16px; font-size: 17px; }
.dialog label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12px; color: var(--text-dim); }
.dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 18px 0 0; padding: 0; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 10px;
  z-index: 20;
}
.toast.err { border-color: var(--neg); color: var(--neg); }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .topbar input { flex: 1 1 100%; order: 3; }
  table.users th:nth-child(2), table.users td:nth-child(2),
  table.users th:nth-child(5), table.users td:nth-child(5) { display: none; }
}
