:root {
  --bg: #1f1919;
  --panel: #261f1f;
  --panel-2: #312727;
  --line: rgba(183, 154, 129, 0.22);
  --text: #f5f0eb;
  --muted: #c8b8aa;
  --accent: #b79a81;
  --accent-strong: #d7b89b;
  --danger: #ff7b7b;
  --success: #8cd17d;
  --warning: #f3c969;
  --shadow: 0 14px 40px rgba(0,0,0,.24);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Inter, Arial, sans-serif; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
body { min-height: 100vh; }
.container { width: min(1400px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 30; backdrop-filter: blur(12px);
  background: rgba(31,25,25,.9); border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; }
.brand { display: flex; flex-direction: column; gap: 4px; }
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
.nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nav a, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text); cursor: pointer; text-decoration: none; box-shadow: var(--shadow);
}
.nav a.active, .btn.primary { background: var(--accent); color: #1b1414; border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { background: rgba(255,123,123,.12); color: #ffd2d2; border-color: rgba(255,123,123,.3); }
.page { padding: 24px 0 40px; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.muted { color: var(--muted); }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; }
.stat-foot { margin-top: 10px; font-size: 12px; color: var(--muted); }
.two-col { display: grid; gap: 18px; grid-template-columns: 1.3fr .9fr; }
.three-col { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
tr:hover td { background: rgba(255,255,255,.02); }
.badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px;
  font-size: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03);
}
.badge.ok { color: var(--success); }
.badge.error { color: var(--danger); }
.badge.warn { color: var(--warning); }
form.stack { display: grid; gap: 14px; }
label { display: grid; gap: 8px; font-size: 14px; }
input, textarea, select {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,.03); color: var(--text); padding: 10px 12px; font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.flash-list { display: grid; gap: 10px; margin-bottom: 16px; }
.flash { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); }
.flash.success { background: rgba(140,209,125,.12); color: #d5ffd0; }
.flash.error { background: rgba(255,123,123,.12); color: #ffd7d7; }
.flash.info { background: rgba(183,154,129,.15); color: #f0dfd2; }
.kpi-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.02); }
.kpi .label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.kpi .value { font-size: 22px; font-weight: 700; }
.small { font-size: 12px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(460px, 100%); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
@media (max-width: 1024px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .container { width: min(100% - 20px, 1400px); }
  .topbar-inner { flex-direction: column; align-items: stretch; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
}
