:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e7ef;
  --text: #1b2433;
  --muted: #6b7788;
  --accent: #0f6fde;
  --accent-2: #0b5bb8;
  --accent-soft: #e6f0fd;
  --ok: #18a058;
  --warn: #e39a0b;
  --crit: #d63a3a;
  --off: #9aa4b2;
  --side: #0f1b2d;
  --side-text: #c6d0de;
  --side-active: #1d2f4a;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d131c; --panel: #151d29; --panel-2: #111823; --border: #243044; --text: #e3e9f2; --muted: #8b97a8;
    --accent: #3b8ff0; --accent-2: #5ea3f5; --accent-soft: #16263d; --side: #0a0f16; --side-active: #16263d;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #0d131c; --panel: #151d29; --panel-2: #111823; --border: #243044; --text: #e3e9f2; --muted: #8b97a8;
  --accent: #3b8ff0; --accent-2: #5ea3f5; --accent-soft: #16263d; --side: #0a0f16; --side-active: #16263d;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand .logo { width: 32px; height: 32px; border-radius: 8px; background: linear-gradient(135deg, #1f7ae0, #19b3a3); display: grid; place-items: center; font-size: 14px; color: #fff; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #8fa0b8; }
.nav { padding: 6px 10px; overflow: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); padding: 9px 12px; border-radius: 8px; margin: 1px 0; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.05); }
.nav a.active { background: var(--side-active); color: #fff; }
.nav .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6d7d94; padding: 14px 12px 4px; }
.nav .badge { margin-left: auto; }
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 12px; color: #8fa0b8; }
.side-foot a { color: #c6d0de; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 420px; }
.topbar .spacer { flex: 1; }
.content { padding: 22px 24px 60px; }
.menu-btn { display: none; }

/* components */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .v { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--crit); }
.btn.danger:hover { border-color: var(--crit); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { border-color: transparent; background: transparent; }

input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; min-height: 260px; tab-size: 4; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 550; }
label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); position: sticky; top: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.table-wrap table tr:last-child td { border-bottom: 0; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(24,160,88,.15); }
.dot.ok { background: var(--ok); } .dot.warning { background: var(--warn); } .dot.critical { background: var(--crit); } .dot.pending, .dot.unknown, .dot.disabled { background: var(--off); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.badge.ok { background: rgba(24,160,88,.12); color: var(--ok); border-color: transparent; }
.badge.warning { background: rgba(227,154,11,.14); color: #b77a00; border-color: transparent; }
.badge.critical { background: rgba(214,58,58,.12); color: var(--crit); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.warn > i { background: var(--warn); } .bar.crit > i { background: var(--crit); }
.meter { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.meter .bar { flex: 1; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 11px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; font-weight: 550; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { color: var(--text); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 12px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(8,14,24,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal.wide { width: min(1100px, 100%); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--panel); }

/* toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--side); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.err { background: var(--crit); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% 0%, rgba(31,122,224,.18), transparent), var(--bg); }
.login .card { width: min(380px, 100%); padding: 28px; }
.login .brand { color: var(--text); padding: 0 0 18px; }
.login .brand small { color: var(--muted); }

/* terminal & desktop */
.term-wrap { background: #0b0f15; border-radius: var(--radius); padding: 8px; height: calc(100vh - 260px); min-height: 360px; }
.term-wrap.full { position: fixed; inset: 0; height: 100vh; border-radius: 0; z-index: 60; }
.desk-wrap { background: #0b0f15; border-radius: var(--radius); overflow: auto; position: relative; height: calc(100vh - 250px); min-height: 360px; display: flex; align-items: flex-start; justify-content: center; }
.desk-wrap.full { position: fixed; inset: 0; height: 100vh; border-radius: 0; z-index: 60; }
.desk-wrap canvas { display: block; outline: none; cursor: default; max-width: 100%; }
.desk-wrap.native canvas { max-width: none; }
.desk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.desk-bar select, .desk-bar input { width: auto; }
.desk-full-bar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 61; background: rgba(15,27,45,.9); padding: 6px 10px; border-radius: 10px; display: flex; gap: 6px; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.files-path { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.crumbs a { margin-right: 4px; }
.drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 10px; text-align: center; color: var(--muted); margin-bottom: 10px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

.os-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border); font-size: 11px; font-weight: 700; color: var(--muted); }
.cmd { display: flex; gap: 8px; align-items: stretch; }
.cmd pre { flex: 1; }

@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: -240px; width: 232px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .g2, .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { margin-top: 6px; }
}
