:root {
  --bg: #080a0f;
  --bg-2: #0c0f16;
  --panel: #10141d;
  --panel-2: #151a25;
  --line: #1f2634;
  --line-2: #2a3241;
  --text: #e8ebf3;
  --muted: #8b93a7;
  --muted-2: #626b7f;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  --sidebar: 232px;
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }

/* ---------- boot / login ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 14px;
  justify-items: center; background: var(--bg); z-index: 50;
}
.boot-mark {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  animation: pulse 1.4s ease-in-out infinite;
}
.boot-text { color: var(--muted); font-size: 13px; }
@keyframes pulse { 0%,100% { opacity: .45; transform: scale(.94); } 50% { opacity: 1; transform: scale(1); } }

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.login::before {
  content: ""; position: fixed; inset: -20%;
  background:
    radial-gradient(50% 50% at 20% 10%, rgba(139, 92, 246, .16), transparent 70%),
    radial-gradient(40% 40% at 85% 80%, rgba(34, 211, 238, .12), transparent 70%);
  pointer-events: none;
}
.login-card {
  position: relative; width: 100%; max-width: 380px; padding: 28px;
  background: linear-gradient(180deg, rgba(21, 26, 37, .96), rgba(16, 20, 29, .96));
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-sub { margin: 0 0 4px; font-size: 13px; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; }
.login-hint { color: var(--muted-2); font-size: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--bg-2); padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; padding: 4px 8px 16px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,.08) inset;
}
.brand-lg { font-size: 17px; padding: 0 0 4px; }
.brand-lg .brand-mark { width: 26px; height: 26px; }

.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-group { margin: 14px 8px 4px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted-2); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
  color: var(--muted); font-size: 13.5px; transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a.active { background: rgba(139, 92, 246, .14); color: #cfc2ff; }
.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--panel-2); color: var(--muted); padding: 1px 7px; border-radius: 999px; }

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0;
  padding: 6px 8px; border-radius: 10px; cursor: pointer; text-align: left;
}
.user-chip:hover { background: rgba(255,255,255,.04); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, rgba(139,92,246,.5), rgba(34,211,238,.35));
  font-size: 12px; font-weight: 600; color: #fff;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.user-meta strong { font-size: 13px; font-weight: 550; }
.user-meta small { color: var(--muted); font-size: 11px; text-transform: capitalize; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 15, .82); backdrop-filter: blur(12px);
}
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title #page-sub { font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.view { padding: 20px 22px 60px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- primitives ---------- */
.segmented { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 2px; }
.segmented button {
  background: none; border: 0; padding: 5px 10px; border-radius: 7px; color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.segmented button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer;
  transition: filter .12s, background .12s, border-color .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #9a70ff, #7c4dff); border-color: #7c4dff; color: #fff; font-weight: 550; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(255,255,255,.05); color: var(--text); }
.btn-danger { color: #ffb4b4; border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.1); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }

.card {
  background: linear-gradient(180deg, rgba(21,26,37,.85), rgba(16,20,29,.85));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.grid { display: grid; gap: 14px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); }
.grid.two { grid-template-columns: 1.6fr 1fr; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

.kpi-card {
  background: linear-gradient(180deg, rgba(21,26,37,.9), rgba(14,18,26,.9));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 15px;
  display: flex; flex-direction: column; gap: 5px; position: relative; overflow: hidden;
}
.kpi-card::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,.55), transparent);
}
.kpi-label { font-size: 11.5px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 24px; font-weight: 620; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { font-size: 12px; color: var(--muted); display: flex; gap: 3px 7px; align-items: baseline; flex-wrap: wrap; }
.kpi-foot .delta { white-space: nowrap; }
.delta { font-variant-numeric: tabular-nums; font-weight: 550; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; border: 1px solid var(--line-2); color: var(--muted);
  background: rgba(255,255,255,.03); white-space: nowrap;
}
.badge.good { color: #86efac; border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.1); }
.badge.warn { color: #fde68a; border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.1); }
.badge.bad { color: #fca5a5; border-color: rgba(248,113,113,.3); background: rgba(248,113,113,.1); }
.badge.info { color: #a5c8ff; border-color: rgba(96,165,250,.3); background: rgba(96,165,250,.1); }
.badge.accent { color: #d3c4ff; border-color: rgba(139,92,246,.35); background: rgba(139,92,246,.14); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; background: #12161f; text-align: left; font-weight: 550;
  font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
tbody td { padding: 9px 12px; border-bottom: 1px solid rgba(31,38,52,.7); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.02); }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tfoot td { border-top: 1px solid var(--line); font-weight: 600; background: rgba(255,255,255,.02); }

.swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.bar-track { height: 5px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

.empty {
  padding: 34px 18px; text-align: center; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line-2); border-radius: 12px;
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-size: 14px; }

.loading { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- charts ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: rgba(255,255,255,.06); stroke-width: 1; }
.chart .axis-label { fill: var(--muted-2); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--accent-2); }
.chart .area { fill: url(#areaGrad); }
.chart .point { fill: var(--accent); }
.chart .bar { fill: url(#barGrad); }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.donut { display: flex; gap: 16px; align-items: center; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; flex: 1; }
.donut-legend .item { display: flex; align-items: center; gap: 8px; }
.donut-legend .item .dot { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.donut-legend .item .val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.field > span { font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
  background: #0d1119; border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px;
  color: var(--text); outline: none; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: #6d4fd6; box-shadow: 0 0 0 3px rgba(139,92,246,.16); }
textarea { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-note { font-size: 12px; color: var(--muted-2); }

/* ---------- modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 10, .72); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 22px;
  animation: fade .14s ease-out;
}
.modal {
  width: 100%; max-width: 620px; max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px;
  box-shadow: var(--shadow); animation: rise .16s ease-out;
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 13px 18px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.toast-root { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow);
  animation: slide .18s ease-out; max-width: 380px;
}
.toast.error { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--good); }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } }

/* ---------- misc blocks ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 2px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; padding: 7px 12px; color: var(--muted); cursor: pointer;
  font-size: 13px; border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { color: var(--text); }

.alert-row {
  display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.02); align-items: flex-start;
}
.alert-row .lvl { width: 6px; align-self: stretch; border-radius: 999px; background: var(--muted-2); flex: none; }
.alert-row.critical .lvl { background: var(--bad); }
.alert-row.warning .lvl { background: var(--warn); }
.alert-row.info .lvl { background: var(--info); }
.alert-row strong { font-size: 12.8px; font-weight: 550; }
.alert-row p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(31,38,52,.7);
}
.list-item:last-child { border-bottom: 0; }
.list-item .meta { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }

.pill-flat {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 8px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); font-size: 12px;
}

.stat-strip { display: flex; gap: 18px; flex-wrap: wrap; }
.stat-strip .item { display: flex; flex-direction: column; gap: 2px; }
.stat-strip .item span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-strip .item strong { font-size: 16px; font-variant-numeric: tabular-nums; }

.dropzone {
  border: 1px dashed var(--line-2); border-radius: 12px; padding: 22px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(139,92,246,.06); }
pre.code {
  background: #0a0d13; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 12px; overflow: auto; color: #c9d1e3; margin: 0; max-height: 320px;
}
code.inline { background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.hr { height: 1px; background: var(--line); margin: 4px 0; }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kanban .col-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.kanban .card-sm {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin-bottom: 8px; font-size: 12.5px;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
