:root {
  --bg: #f5f6fb; --panel: #ffffff; --panel-2: #f9fafc; --text: #0f172a; --muted: #64748b; --line: #e6e8f0;
  --side: #0f1222; --side-2: #171b30; --side-text: #a5adc6; --side-strong: #fff;
  --accent: #4f46e5; --accent-2: #6366f1; --accent-soft: #eef0ff; --accent-text: #fff;
  --good: #059669; --warn: #d97706; --bad: #dc2626;
  --good-bg: #e7f8f1; --warn-bg: #fdf3e2; --bad-bg: #fdeaea; --chip: #f0f2f7; --code: #f1f3f9;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d18; --panel: #121729; --panel-2: #161c31; --text: #e6e9f2; --muted: #8a93ad; --line: #222a42;
    --side: #070912; --side-2: #10142a; --accent: #6d68ff; --accent-2: #8b87ff; --accent-soft: #1d1f45;
    --good: #34d399; --warn: #fbbf24; --bad: #f87171;
    --good-bg: #0b2a20; --warn-bg: #2d2109; --bad-bg: #2f1214; --chip: #1a2038; --code: #0d1122;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--code); padding: 1px 6px; border-radius: 5px; font: 12.5px ui-monospace, "Cascadia Code", Consolas, monospace; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
h3 { font-size: 13px; font-weight: 600; margin: 20px 0 8px; }
.ico { width: 18px; height: 18px; flex-shrink: 0; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; padding: 18px 14px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--side-strong); padding: 4px 8px 18px; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #8b5cf6); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .45); }
.logo svg { width: 22px; height: 22px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6582; padding: 6px 10px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--side-text); padding: 9px 12px; border-radius: 9px; display: flex; align-items: center; gap: 12px; font-weight: 500; transition: background .15s, color .15s; }
.side nav a:hover { background: var(--side-2); color: var(--side-strong); text-decoration: none; }
.side nav a.on { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .35); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.host { display: flex; align-items: center; gap: 10px; background: var(--side-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.host b { display: block; color: var(--side-strong); font-size: 13px; font-weight: 600; }
.host small { color: #5d6582; font-size: 11.5px; }
.host .dot, .status-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .18); flex-shrink: 0; }
.side-link { display: flex; align-items: center; gap: 12px; width: 100%; color: var(--side-text); background: none; border: 0; padding: 9px 12px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.side-link:hover { background: var(--side-2); color: var(--side-strong); text-decoration: none; }

main { flex: 1; padding: 26px 32px 56px; min-width: 0; max-width: 1400px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.top h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.025em; }
.menu-btn { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 7px; color: var(--text); cursor: pointer; }
.scrim { display: none; }

/* Cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid > .card { margin-bottom: 0; }
.grid > * { min-width: 0; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.empty { text-align: center; padding: 48px 24px; }
.empty h2 { justify-content: center; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: linear-gradient(120deg, var(--panel) 40%, var(--accent-soft)); }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.hero-title { font-size: 22px; margin: 4px 0 2px; letter-spacing: -.02em; }
.hero p { margin: 0; }
.status-badge { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; font-weight: 600; background: var(--good-bg); color: var(--good); }
.status-badge.bad { background: var(--bad-bg); color: var(--bad); }
.status-badge.bad .dot { background: var(--bad); box-shadow: 0 0 0 4px rgba(220, 38, 38, .18); }

.stat { display: flex; align-items: center; gap: 16px; }
.stat .label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .label .ico { width: 15px; height: 15px; }
.stat-main { font-size: 17px; font-weight: 600; margin-top: 2px; letter-spacing: -.01em; }
.stat .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.ring { width: 74px; height: 74px; flex-shrink: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--chip); }
.ring .val { stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring.good .val { stroke: var(--accent); } .ring.warn .val { stroke: var(--warn); } .ring.bad .val { stroke: var(--bad); }
.ring text { transform: rotate(90deg); transform-origin: 50px 50px; text-anchor: middle; dominant-baseline: central; font-size: 21px; font-weight: 700; fill: var(--text); }

.bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; border-radius: 3px; }
.bar .good { background: var(--accent); } .bar .warn { background: var(--warn); } .bar .bad { background: var(--bad); }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; font-weight: 500; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.tbl th:first-child { border-top-left-radius: 8px; } .tbl th:last-child { border-top-right-radius: 8px; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover td, .tbl tr:hover td { background: var(--panel-2); }
.tbl tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.r { text-align: right; } .nowrap { white-space: nowrap; } .break { word-break: break-all; }
.muted { color: var(--muted); } .small { font-size: 12px; } .b { font-weight: 700; }
.more { margin-left: auto; font-size: 12.5px; font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--chip); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.good::before, .pill.bad::before, .pill.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.counts div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.counts b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.counts span { color: var(--muted); font-size: 12px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; white-space: pre-wrap; border: 1px solid transparent; font-weight: 500; }
.flash.ok { background: var(--good-bg); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.flash.err { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 15px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 2px 8px rgba(79, 70, 229, .3); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.warnbtn { color: var(--warn); }
.btn.sm { padding: 4px 11px; font-size: 12.5px; border-radius: 7px; }
.btn.lg { padding: 11px 18px; font-size: 15px; justify-content: center; }
.btn.busy { opacity: .6; cursor: progress; }
.btn.busy::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
form.inline { display: inline; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form + .form { margin-top: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; flex: 1; min-width: 180px; font-size: 13px; }
.form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.form .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; min-width: 0; }
.form .btn { align-self: flex-start; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { flex: 1; min-width: 160px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 6px 20px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 14px; width: 100%; padding-top: 8px; }
.checks[hidden] { display: none; }
.addon { display: flex; align-items: stretch; }
.addon input { border-radius: 9px 0 0 9px; }
.addon span { background: var(--panel-2); border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; padding: 9px 12px; color: var(--muted); font-weight: 400; white-space: nowrap; }

/* Domain page */
.crumbs { display: flex; align-items: center; gap: 8px; margin: -10px 0 14px; color: var(--muted); flex-wrap: wrap; }
.crumbs .right { margin-left: auto; }
.crumbs .right + .right { margin-left: 0; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 5px; box-shadow: var(--shadow); }
.tabs a { padding: 8px 14px; color: var(--muted); border-radius: 8px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.tabs a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.log { background: #0b0f1d; color: #cdd3e3; padding: 16px; border-radius: 10px; max-height: 560px; overflow: auto; font: 12px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all; margin: 0; }
.cmdlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2px 16px; }
.cmdlist a { display: flex; gap: 10px; padding: 6px 8px; color: var(--text); font-size: 12.5px; border-radius: 7px; }
.cmdlist a:hover { background: var(--panel-2); text-decoration: none; }
.cmdlist span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent), var(--bg); }
.login-wrap { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 24px 64px rgba(15, 23, 42, .12); }
.login-hero { background: linear-gradient(150deg, #1e1b4b, #312e81 55%, #4f46e5); color: #e0e7ff; padding: 36px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.login-hero .brand { color: #fff; padding: 0; }
.login-hero .logo { background: rgba(255, 255, 255, .15); box-shadow: none; }
.login-hero h1 { color: #fff; font-size: 32px; line-height: 1.15; letter-spacing: -.03em; margin: 0 0 12px; }
.login-hero p { margin: 0 0 22px; color: #c7d2fe; }
.login-hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.login-hero li { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.login-hero li .ico { color: #a5b4fc; }
.login-hero small { color: #a5b4fc; }
.login-form { padding: 44px 40px; display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.login-form h2 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.login-form p { margin: -8px 0 6px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; }

/* Mobile */
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s ease; }
  .nav-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .menu-btn { display: inline-flex; }
  main { padding: 16px 16px 40px; }
  .top h1 { font-size: 20px; }
  .grid.two { grid-template-columns: 1fr; }
  .counts { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 110px 1fr; }
  .card { padding: 16px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 28px; }
  .login-hero ul, .login-hero small { display: none; }
  .login-hero h1 { font-size: 24px; }
  .login-form { padding: 28px; }
}

/* File manager */
.fm { padding-top: 14px; }
.fm-path { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font: 13px ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin-bottom: 12px; }
.fm-path span { color: var(--muted); }
.fm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.fm-tools label.btn { cursor: pointer; }
.fm-tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.fm-tools .right { margin-left: auto; }
.fm-name { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 500; }
.fi { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--chip); color: var(--muted); font-size: 13px; flex-shrink: 0; }
.fi.dir { background: var(--accent-soft); color: var(--accent); }
.fm-table td { padding-top: 7px; padding-bottom: 7px; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.dropzone { position: fixed; inset: 16px; border: 3px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--accent) 12%, var(--bg)); display: none; place-items: center; font-size: 20px; z-index: 50; pointer-events: none; }
.dropzone.on { display: grid; }
.editor-card { padding: 0; overflow: hidden; }
.editor-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.editor-bar .right { margin-left: auto; }
.editor-card textarea { border: 0; border-radius: 0; min-height: 60vh; }
.editor-card .CodeMirror { font: 13px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; }
.kbd { font-size: 11px; opacity: .8; }
.btn.primary .kbd { color: #c7d2fe; }

/* Database viewer */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.db-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.db-layout > * { min-width: 0; }
.db-tables { padding: 14px; position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; gap: 10px; }
.db-tables-head { display: flex; justify-content: space-between; align-items: center; }
.db-tables input { padding: 6px 10px; font-size: 13px; }
.db-tables nav { display: flex; flex-direction: column; overflow-y: auto; gap: 1px; }
.db-tables nav a { padding: 6px 10px; border-radius: 7px; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-tables nav a:hover { background: var(--panel-2); text-decoration: none; }
.db-tables nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.db-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.db-bar form { flex: 1; max-width: 460px; gap: 8px; display: flex; }
.tbl.data td { font: 12.5px ui-monospace, "Cascadia Code", Consolas, monospace; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.tbl.data th a { color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.row-editor { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.row-editor label > span:first-child { font-weight: 400; }
.row-editor .check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; }
@media (max-width: 860px) {
  .db-layout { grid-template-columns: 1fr; }
  .db-tables { position: static; max-height: 260px; }
  .fm-tools .right { margin-left: 0; width: 100%; }
}
