:root {
  --bg: #0b0f17;
  --bg-2: #111827;
  --panel: #151c2b;
  --panel-2: #1b2334;
  --border: #253048;
  --border-2: #31405c;
  --text: #e5e9f2;
  --muted: #8b96ad;
  --muted-2: #667089;
  --accent: #4f8cff;
  --accent-2: #2f6ff0;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.14);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, 0.14);
  --run: #60a5fa;
  --run-soft: rgba(96, 165, 250, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: 0 0 232px; background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: grid; place-items: center; color: #fff; }
.brand-text { font-weight: 700; line-height: 1.05; font-size: 15px; }
.brand-text small { font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav-item:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: #cfe0ff; }
.nav-item svg { flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--accent); border: 1px solid var(--border-2); }
.user-name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 28px 12px; }
.page-title { font-size: 22px; }
.subtitle { color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 8px 28px 40px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-h h2 { font-size: 15px; }
.card-b { padding: 16px 18px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } .sidebar { display: none; } .topbar, .content { padding-left: 16px; padding-right: 16px; } }

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.ok .value { color: var(--ok); }
.stat.err .value { color: var(--err); }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: rgba(255,255,255,0.015); }
.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.expandable { cursor: pointer; }
.table tr.sub td { background: rgba(0,0,0,0.18); padding: 0; }
.table .sub-inner { padding: 10px 14px 14px 44px; }
.table .sub-inner table.table th, .table .sub-inner table.table td { padding: 6px 10px; font-size: 12.5px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border-2); line-height: 1.6; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(52,211,153,0.3); }
.badge.err { background: var(--err-soft); color: var(--err); border-color: rgba(248,113,113,0.3); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251,191,36,0.3); }
.badge.run { background: var(--run-soft); color: var(--run); border-color: rgba(96,165,250,0.3); }
.badge.run::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--run); animation: pulse 1.2s infinite ease-in-out; }
.badge.muted { opacity: 0.8; }
.badge.accent { background: var(--accent-soft); color: #bcd3ff; border-color: rgba(79,140,255,0.35); }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.05s; white-space: nowrap; }
.btn:hover { background: #222c40; border-color: #3d4d6d; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: transparent; border-color: rgba(248,113,113,0.45); color: var(--err); }
.btn.danger:hover { background: var(--err-soft); }
.btn.danger.solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn .spinner { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
.form { max-width: 760px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; }
.input, select, textarea { width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 9px 11px; font: inherit; outline: none; transition: border-color 0.12s, box-shadow 0.12s; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono { font-family: var(--mono); }
textarea { min-height: 80px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); width: 15px; height: 15px; }
.check .t { font-weight: 500; }
.check .d { color: var(--muted); font-size: 12px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .row, .row.three { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-error { background: var(--err-soft); border: 1px solid rgba(248,113,113,0.4); color: #fecaca; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.result-box { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-2); font-size: 13px; }
.result-box.ok { border-color: rgba(52,211,153,0.4); }
.result-box.err { border-color: rgba(248,113,113,0.4); color: #fecaca; }
.result-box ul { margin: 6px 0 0 16px; padding: 0; }
.checkbox-list { border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--bg-2); max-height: 380px; overflow: auto; }
.checkbox-list .item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.checkbox-list .item:last-child { border-bottom: 0; }
.checkbox-list .item:hover { background: rgba(255,255,255,0.03); }
.checkbox-list .item input { accent-color: var(--accent); }
.checkbox-list .item .n { flex: 1; font-weight: 500; }
.checkbox-list .item .s { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 80px; text-align: right; }
.checkbox-list .item .m { color: var(--muted-2); font-size: 12px; min-width: 70px; text-align: right; }
.list-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.list-toolbar .input { max-width: 260px; }

/* flash + toasts */
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid var(--border-2); background: var(--panel-2); }
.flash.success { border-color: rgba(52,211,153,0.4); background: var(--ok-soft); color: #bbf7d0; }
.flash.error { border-color: rgba(248,113,113,0.4); background: var(--err-soft); color: #fecaca; }
.flash.warning { border-color: rgba(251,191,36,0.4); background: var(--warn-soft); color: #fde68a; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast { background: var(--panel-2); border: 1px solid var(--border-2); color: var(--text); padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow); animation: toast-in 0.18s ease-out; font-size: 13px; }
.toast.ok { border-color: rgba(52,211,153,0.5); }
.toast.err { border-color: rgba(248,113,113,0.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(3,6,12,0.7); display: grid; place-items: center; z-index: 90; animation: toast-in 0.12s ease-out; }
.modal { width: min(480px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { margin: 0 0 12px; color: var(--muted); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* progress + logs */
.progress { height: 8px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--accent), #8b5cf6); width: 0; transition: width 0.4s ease; }
.progress .bar.indeterminate { width: 40%; animation: indet 1.4s infinite ease-in-out; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.progress.thin { height: 5px; }
.bar-inline { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); vertical-align: middle; opacity: 0.85; }
.log { background: #070a10; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #c9d3e6; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; margin: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; }
.kv .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.kv .v { font-weight: 500; word-break: break-word; }
.kv .v.mono { font-size: 12.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.warn { background: var(--warn); }
.meter { display: flex; align-items: center; gap: 8px; }
.meter .track { flex: 1; height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); min-width: 60px; }
.meter .fill { height: 100%; background: var(--accent); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 18px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters .field { margin-bottom: 0; min-width: 160px; }
.warn-box { background: var(--warn-soft); border: 1px solid rgba(251,191,36,0.4); color: #fde68a; padding: 12px 14px; border-radius: var(--radius-sm); }
.danger-box { background: var(--err-soft); border: 1px solid rgba(248,113,113,0.45); color: #fecaca; padding: 12px 14px; border-radius: var(--radius-sm); }
.info-box { background: var(--accent-soft); border: 1px solid rgba(79,140,255,0.35); color: #cfe0ff; padding: 12px 14px; border-radius: var(--radius-sm); }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, rgba(79,140,255,0.16), transparent), radial-gradient(900px 500px at 100% 100%, rgba(139,92,246,0.14), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card .brand { padding: 0 0 18px; }
.auth-card h2 { font-size: 18px; margin-bottom: 4px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
