:root {
  --bg: #0a0a0b;
  --bg-2: #111113;
  --bg-3: #18181b;
  --border: #26262b;
  --border-2: #34343b;
  --text: #ededef;
  --muted: #9a9aa3;
  --dim: #6b6b75;
  --accent: #fafafa;
  --blue: #3b82f6;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--blue); }
a.link:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 10px 18px; letter-spacing: -0.01em; }
.brand svg { width: 20px; height: 20px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg-3); color: var(--text); }
.nav a.active { background: var(--bg-3); color: var(--text); }
.nav svg { width: 16px; height: 16px; opacity: .9; }
.sidebar .spacer { flex: 1; }
.main { padding: 32px 40px 80px; max-width: 1180px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.apps { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 96px minmax(0, 1fr); }
  .list-item { padding: 12px 14px; gap: 10px; }
  .list-item > div[style*="width:118px"] { width: auto !important; }
  .page-head > .row { width: 100%; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px; }
  .brand { padding: 0 10px 0 4px; }
  .nav { display: flex; }
  .sidebar .spacer { display: none; }
  .main { padding: 20px 16px 60px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
}

/* Cards */
.card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); }
.card-body { padding: 20px; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.app-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; transition: border-color .15s; cursor: pointer; }
.app-card:hover { border-color: var(--border-2); }
.app-card .title { font-weight: 600; font-size: 15px; }
.app-icon { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2b2b31, #1b1b1f); border: 1px solid var(--border-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; text-transform: uppercase; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--text); }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--bg-3); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s; }
.btn:hover { background: #222227; border-color: #45454d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #0a0a0b; border-color: var(--accent); }
.btn.primary:hover { background: #d4d4d8; }
.btn.danger { background: transparent; color: var(--red); border-color: #5b2323; }
.btn.danger:hover { background: #2a1212; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 15px; height: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--dim); }
input, select, textarea { width: 100%; height: 36px; padding: 0 11px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 6px; color: var(--text); font: inherit; outline: none; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; padding: 10px 11px; font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus { border-color: #6b6b75; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
input.mono { font-family: var(--mono); font-size: 12.5px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border-2); border-radius: 7px; padding: 3px; gap: 2px; }
.seg button { height: 28px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); border-radius: 5px; font: inherit; font-weight: 500; cursor: pointer; }
.seg button.on { background: var(--bg-3); color: var(--text); box-shadow: 0 0 0 1px var(--border-2); }
.input-group { display: flex; }
.input-group input { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; border-left: 0; height: 36px; }

/* Badges & status */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--bg-3); border: 1px solid var(--border-2); color: var(--muted); white-space: nowrap; }
.badge.green { color: #4ade80; border-color: #1f4d30; background: #0e2116; }
.badge.red { color: #f87171; border-color: #5b2323; background: #220e0e; }
.badge.yellow { color: #facc15; border-color: #4d3f12; background: #1f1a08; }
.badge.blue { color: #60a5fa; border-color: #1e3a66; background: #0c1a30; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex-shrink: 0; display: inline-block; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 0 3px rgba(234,179,8,.15); animation: pulse 1.2s infinite; }
.dot.gray { background: var(--dim); }
@keyframes pulse { 50% { opacity: .4; } }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.2); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.tabs .count { font-size: 11px; background: var(--bg-3); border-radius: 99px; padding: 1px 6px; margin-left: 4px; color: var(--muted); }

/* Tables / lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, .list-item.clickable:hover { background: var(--bg-3); cursor: pointer; }
.list-item .grow { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Env editor */
.env-row { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr) 34px; gap: 8px; align-items: start; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.env-row:last-child { border-bottom: 0; }
.env-row .meta { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; margin-top: -2px; font-size: 12px; color: var(--dim); flex-wrap: wrap; }
.env-row.missing input.val { border-color: #4d3f12; }
.env-head { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr) 34px; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--border); color: var(--dim); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 700px) { .env-row, .env-head { grid-template-columns: 1fr 34px; } .env-row .val-wrap { grid-column: 1 / 2; } .env-head span:nth-child(2) { display: none; } }
.val-wrap { position: relative; }
.val-wrap .eye { position: absolute; right: 4px; top: 4px; }
.val-wrap input { padding-right: 36px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--dim); cursor: pointer; }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn svg { width: 15px; height: 15px; }

/* Terminal */
.terminal { background: #050506; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--mono); font-size: 12.5px; line-height: 1.6; padding: 14px 16px; overflow: auto; white-space: pre-wrap; word-break: break-all; color: #d4d4d8; height: 560px; }
.terminal.short { height: 360px; }
.t-b { font-weight: 700; } .t-cyan { color: #67e8f9; } .t-green { color: #4ade80; } .t-yellow { color: #fde047; } .t-red { color: #f87171; } .t-dim { color: #71717a; }

/* Alerts */
.alert { border: 1px solid var(--border-2); background: var(--bg-2); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 12px; align-items: flex-start; }
.alert.warn { border-color: #4d3f12; background: #15120a; }
.alert.error { border-color: #5b2323; background: #170b0b; }
.alert.info { border-color: #1e3a66; background: #0a1322; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert.warn svg { color: var(--yellow); } .alert.error svg { color: var(--red); } .alert.info svg { color: var(--blue); }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 8px; padding: 10px 14px; min-width: 240px; max-width: 420px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slide .2s ease-out; }
.toast.error { border-color: #5b2323; }
.toast.ok { border-color: #1f4d30; }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at top, #18181b 0%, var(--bg) 60%); }
.auth .card { width: 100%; max-width: 380px; }
.auth .brand { justify-content: center; font-size: 20px; padding: 0 0 6px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 480px; }
@keyframes fade { from { opacity: 0; } }

.copy { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 6px; padding: 6px 6px 6px 12px; }
.copy code { flex: 1; overflow-x: auto; white-space: nowrap; color: var(--muted); }
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 10px; }
.steps li::before { content: counter(s); width: 22px; height: 22px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--border-2); display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.sep { width: 1px; height: 18px; background: var(--border-2); }
