:root {
  --bg: #0b0f14;
  --bg-soft: #111823;
  --panel: #131c28;
  --panel-2: #182333;
  --line: #223044;
  --text: #e8eef7;
  --muted: #8fa0b8;
  --accent: #4f8cff;
  --accent-2: #6ee7b7;
  --warn: #f6c453;
  --err: #ff6b6b;
  --ok: #4ade80;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16213a 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { margin: 0; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 232px;
  background: #0d141d; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700;
  font-size: 17px; padding: 4px 8px 18px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); font-size: 12px; font-weight: 800; color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: var(--muted); font-size: 14px; }
.nav-item:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-ico { width: 18px; text-align: center; opacity: .85; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }
.org-name { color: var(--text); font-weight: 600; margin-bottom: 2px; }
.user-line { margin-bottom: 8px; }

.main { padding: 26px 34px 60px; max-width: 1180px; }
.main.with-side { margin-left: 232px; }
.centered { display: grid; place-items: center; }
.centered .main { width: 100%; max-width: 420px; padding: 0; margin: 0; }

/* ---------- header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.subtitle { color: var(--muted); margin-top: 5px; font-size: 14px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: linear-gradient(180deg, var(--panel), var(--bg-soft)); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px;
  border-bottom: 1px solid var(--line); }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main.with-side { margin-left: 0; padding: 18px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- stats ---------- */
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid rgba(34, 48, 68, .55); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(79, 140, 255, .04); }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line);
  border-radius: var(--radius); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: rgba(74, 222, 128, .13); color: var(--ok); }
.badge-err { background: rgba(255, 107, 107, .13); color: var(--err); }
.badge-warn { background: rgba(246, 196, 83, .13); color: var(--warn); }
.badge-info { background: rgba(79, 140, 255, .15); color: #8fb6ff; }
.badge-muted { background: rgba(143, 160, 184, .12); color: var(--muted); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: #0d1520; color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; font: inherit; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 140, 255, .15); }
textarea { resize: vertical; min-height: 90px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.inline-form { display: inline; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff;
  border: 0; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: var(--err); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- flash / errors ---------- */
.flashes { margin-bottom: 16px; }
.flash { background: rgba(79, 140, 255, .12); border: 1px solid rgba(79, 140, 255, .35);
  padding: 10px 14px; border-radius: 9px; margin-bottom: 8px; font-size: 14px; }
.error-box { text-align: center; padding: 40px 20px; }
.error-code { font-size: 64px; font-weight: 800; color: var(--line); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.code { background: #0d1520; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-x: auto; }
.row-actions { display: flex; gap: 10px; }
.login-wrap { width: 100%; max-width: 380px; margin: 8vh auto; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card .subtitle { margin-bottom: 20px; }
.kpi-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 0; }
.kpi { font-size: 13px; color: var(--muted); }
.kpi b { color: var(--text); }
.progress { height: 8px; background: #0d1520; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.issues { margin: 10px 0 4px; padding-left: 20px; }
.issues li { margin: 4px 0; line-height: 1.5; }
