:root {
  --sidebar: #2b2e31; --sidebar-fg: #d9dde2; --sidebar-active: #3a3e42;
  --top: #1a56b3; --top-fg: #fff;
  --bg: #f5f6fb; --card: #fff; --fg: #23272b; --muted: #6b7280; --line: #e6e8ee;
  --primary: #1a56b3; --primary-fg: #fff; --green: #43a047; --red: #e53935; --amber: #f5a623;
  --shadow: 0 1px 3px rgba(20,30,50,.08), 0 1px 2px rgba(20,30,50,.06);
  --radius: 6px;
}
html.dark {
  --bg: #171b21; --card: #1f2630; --fg: #e6e9ee; --muted: #9aa4b2; --line: #2c3540;
  --sidebar: #12161b; --sidebar-active: #1f2630; --top: #143f85;
  --shadow: 0 1px 3px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--fg); background: var(--bg); display: flex; }
a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- layout ---------- */
.sidebar { width: 280px; flex: 0 0 280px; background: var(--sidebar); color: var(--sidebar-fg); display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; font-size: 22px; font-weight: 500; color: #fff; height: 64px; }
.sidebar-brand img { width: 28px; height: 28px; }
.sidebar-nav { display: flex; flex-direction: column; padding: 8px 0; }
.sidebar-nav a { display: flex; align-items: center; gap: 18px; padding: 14px 24px; color: var(--sidebar-fg); font-size: 15px; }
.sidebar-nav a .ico { width: 22px; text-align: center; color: var(--amber); font-size: 18px; }
.sidebar-nav a:hover { background: rgba(255,255,255,.05); }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 0; }
.sidebar-foot { margin-top: auto; padding: 16px 20px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: var(--top); color: var(--top-fg); display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 10; }
.topbar-back, .topbar-menu { background: none; border: 0; color: #fff; font-size: 24px; padding: 4px 8px; line-height: 1; }
.topbar-menu { display: none; }
.topbar-search { margin-left: auto; display: flex; align-items: center; background: rgba(255,255,255,.18); border-radius: 4px; padding: 0 10px; }
.topbar-search input { background: none; border: 0; color: #fff; padding: 8px 6px; width: 240px; outline: 0; }
.topbar-search input::placeholder { color: rgba(255,255,255,.75); }
.topbar-search kbd { font-size: 11px; color: rgba(255,255,255,.75); }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user .link { background: none; border: 0; color: #fff; opacity: .85; }
.content { padding: 24px; flex: 1; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: -280px; transition: left .2s; z-index: 20; }
  .sidebar.open { left: 0; }
  .topbar-menu { display: block; }
  .topbar-search input { width: 120px; }
  .content { padding: 12px; }
}

/* ---------- cards / tables ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 20px; }
.card h3 { margin: 0 0 14px; font-size: 18px; font-weight: 600; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 20px; margin: 4px 0 16px; font-weight: 500; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-weight: 600; font-size: 13px; padding: 12px 10px; border-bottom: 1px solid var(--line); color: var(--fg); }
table.grid td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.clickable:hover td { background: rgba(26,86,179,.05); }
.table-wrap { overflow-x: auto; }
.table-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.table-tools input { border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 4px; width: 300px; outline: 0; }
.table-tools input:focus { border-bottom-color: var(--primary); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* ---------- badges / buttons ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; color: #fff; background: var(--muted); white-space: nowrap; }
.badge.on { background: var(--green); } .badge.off { background: var(--red); } .badge.busy { background: var(--amber); color: #222; }
.badge.soft { background: rgba(120,130,140,.18); color: var(--fg); font-weight: 500; }
.badge.pill { border-radius: 999px; }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--muted); vertical-align: middle; }
.dot.on { background: var(--green); } .dot.off { background: var(--red); }
.btn { border: 1px solid transparent; border-radius: 4px; padding: 9px 16px; font-weight: 600; letter-spacing: .04em; font-size: 13px; text-transform: uppercase; background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-fg); }
.btn-grey { background: #607d8b; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-text { background: none; box-shadow: none; color: var(--primary); padding: 8px 10px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-group { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.btn-group button { border: 0; border-right: 1px solid var(--line); background: var(--card); padding: 7px 12px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--fg); }
.btn-group button:last-child { border-right: 0; }
.btn-group button.active { background: rgba(26,86,179,.12); color: var(--primary); }
.actions-right { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 24px; }
label.f { display: block; font-size: 13px; }
label.f > span { display: block; margin-bottom: 6px; color: var(--fg); }
label.f input, label.f select, label.f textarea, .input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); outline: 0; }
label.f input:focus, label.f select:focus, label.f textarea:focus { border-color: var(--primary); }
label.f input:disabled { background: rgba(120,130,140,.08); color: var(--muted); }
textarea { resize: vertical; min-height: 120px; }
.check { display: inline-flex; align-items: center; gap: 8px; }
.form-error { color: var(--red); margin: 10px 0 0; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #888; border-radius: 22px; transition: .2s; }
.switch span:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span:before { transform: translateX(18px); }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
.tag-input input { border: 0; outline: 0; background: none; flex: 1; min-width: 120px; padding: 4px; }
.tag-input .badge button { background: none; border: 0; color: inherit; margin-left: 4px; padding: 0; }

/* ---------- server header ---------- */
.server-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px; }
.server-head h2 { margin: 0; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.server-head .meta { display: flex; flex-wrap: wrap; gap: 20px; margin: 10px 0 14px; color: var(--fg); font-size: 13px; }
.server-head .meta span:before { content: "▪"; color: var(--muted); margin-right: 6px; }
.server-head .spacer { flex: 1; }
.server-head .head-actions { display: flex; gap: 8px; }
.spec-row { display: flex; flex-wrap: wrap; gap: 16px; }
.spec { border: 1px solid var(--line); border-radius: 4px; padding: 8px 14px; min-width: 170px; }
.spec b { display: block; font-weight: 500; }
.spec small { color: var(--muted); }
.tabs { display: flex; gap: 4px; border-top: 1px solid var(--line); margin: 16px -16px -16px; padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 14px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.two-col-wide { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .two-col, .two-col-wide { grid-template-columns: 1fr; } }

/* ---------- charts ---------- */
.chart-card .chart-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-card h4 { text-align: center; margin: 4px 0 8px; font-size: 15px; }
.chart-box { position: relative; height: 340px; }
.chart-legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.chart-summary { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; margin-top: 8px; color: var(--muted); }

/* ---------- OS cards ---------- */
.os-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.os-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: center; border: 2px solid transparent; }
.os-card.selected { border-color: var(--primary); }
.os-card .os-icon { width: 56px; height: 56px; margin: 4px auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; color: #fff; }
.os-card .os-name { font-weight: 500; margin-bottom: 14px; }
.os-card select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }

/* ---------- misc ---------- */
.progress-log { background: #0f1419; color: #cfe3ff; padding: 12px; border-radius: 4px; max-height: 300px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
.alert { padding: 12px 14px; border-radius: 4px; margin-bottom: 14px; }
.alert-warn { background: rgba(245,166,35,.15); border-left: 4px solid var(--amber); }
.alert-ok { background: rgba(67,160,71,.15); border-left: 4px solid var(--green); }
.alert-err { background: rgba(229,57,53,.12); border-left: 4px solid var(--red); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.note { border-bottom: 1px solid var(--line); padding: 12px 0; }
.note:last-child { border-bottom: 0; }
.note .note-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.note.important { border-left: 4px solid var(--amber); padding-left: 10px; }
.note-body { white-space: pre-wrap; }
.qr { display: inline-block; padding: 8px; background: #fff; }
.menu { position: absolute; right: 0; top: 100%; background: var(--card); box-shadow: 0 4px 16px rgba(0,0,0,.18); border-radius: 4px; min-width: 220px; z-index: 30; padding: 6px 0; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px 16px; border: 0; background: none; color: var(--fg); }
.menu button:hover { background: rgba(26,86,179,.08); }
.menu button.danger { color: var(--red); }
.rel { position: relative; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); color: var(--fg); border-radius: 8px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.modal-head { padding: 18px 20px 6px; font-size: 18px; font-weight: 600; }
.modal-body { padding: 10px 20px; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
#toastRoot { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #323232; color: #fff; padding: 12px 18px; border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.3); min-width: 260px; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }

/* ---------- login ---------- */
body.login-page { align-items: center; justify-content: center; background: var(--sidebar); }
.login-card { background: var(--card); border-radius: 8px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; margin-bottom: 22px; }
.login-brand img { width: 32px; height: 32px; }
.login-card label { display: block; margin-bottom: 14px; font-size: 13px; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); outline: 0; }
.login-card input:focus { border-color: var(--primary); }

/* ---------- v2: closer to the reference UI ---------- */
.sidebar-brand { font-size: 26px; }
.sidebar-nav a .ico { width: 22px; height: 22px; fill: var(--amber); }
.sidebar-nav a .ico.grey { fill: #b8bec5; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; }
.sidebar-foot .bulb { width: 20px; height: 20px; fill: #9aa4b2; }
.topbar-back svg { width: 26px; height: 26px; fill: #fff; }
.topbar-search svg { width: 20px; height: 20px; fill: #fff; opacity: .9; }
.topbar-bell { background: none; border: 0; padding: 4px; }
.topbar-bell svg { width: 22px; height: 22px; fill: #fff; }
.topbar-userbtn { background: none; border: 0; color: #fff; font-size: 14px; }
.topbar-userbtn .caret { font-size: 12px; opacity: .8; }
.topbar-user .menu { min-width: 180px; }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.icon-group { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.icon-group button { border: 0; border-right: 1px solid var(--line); background: var(--card); width: 46px; height: 32px; color: var(--fg); }
.icon-group button:last-child { border-right: 0; }
.icon-group button svg { width: 18px; height: 18px; fill: currentColor; vertical-align: middle; }
.icon-group button:hover { background: rgba(26,86,179,.08); }
table.grid th .th-ico { float: right; color: var(--muted); font-size: 12px; }
.table-foot { display: flex; align-items: center; gap: 24px; padding-top: 12px; font-size: 13px; flex-wrap: wrap; }
.table-foot select { border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; background: var(--card); }
.table-foot .pager { display: inline-flex; gap: 4px; align-items: center; }
.table-foot .pager button { background: none; border: 0; color: var(--fg); font-size: 16px; padding: 2px 6px; }
.table-foot .pager button:disabled { opacity: .35; }
.table-foot.right { justify-content: flex-end; }
.server-head .meta span:before { content: none; }
.server-head .meta span { display: inline-flex; align-items: center; gap: 6px; }
.server-head .meta svg { width: 16px; height: 16px; fill: var(--muted); }
.spec { display: flex; align-items: center; gap: 12px; }
.spec svg { width: 22px; height: 22px; fill: var(--fg); flex: 0 0 auto; }
.spec > div b { display: block; font-weight: 400; font-size: 15px; }
.spec > div small { color: var(--fg); font-size: 14px; }
.spec b { font-weight: 400; }
.btn svg { width: 16px; height: 16px; fill: currentColor; vertical-align: -3px; margin-right: 6px; }
.chart-card .chart-tools { justify-content: space-between; }
.chart-card .chart-tools .right { display: flex; gap: 4px; }
.btn-group button.cal svg { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; margin-right: 4px; }
.summary-box { background: rgba(120,130,140,.08); border-radius: 4px; padding: 10px 12px; margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 14px; font-size: 12px; }
.summary-box b { display: block; font-size: 14px; font-weight: 500; }
.ipmi-head { display: flex; align-items: center; justify-content: space-between; }
.detail-table { width: 100%; font-size: 12px; margin-top: 8px; border-collapse: collapse; }
.detail-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.os-card .os-logo { width: 56px; height: 56px; object-fit: contain; margin: 4px auto 10px; display: block; }
.none-link { color: var(--red); font-style: italic; text-decoration: underline; }
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; background: rgba(120,130,140,.12); border-radius: 4px 4px 0 0; padding: 6px 8px; }
.editor-toolbar button { background: none; border: 0; width: 32px; height: 28px; border-radius: 3px; color: var(--fg); font-weight: 600; font-size: 13px; }
.editor-toolbar button:hover { background: rgba(26,86,179,.12); }
.editor-toolbar button svg { width: 16px; height: 16px; fill: currentColor; vertical-align: middle; }
.editor-area { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; min-height: 90px; background: var(--card); font-style: italic; outline: 0; }
.editor-area:not(:placeholder-shown) { font-style: normal; }
.note-card { padding: 0; overflow: hidden; }
.note-card .note-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; }
.note-body h1, .note-body h2, .note-body h3 { margin: 6px 0; }
.note-body ul, .note-body ol { margin: 4px 0 4px 20px; }
.note-body code { background: rgba(120,130,140,.15); padding: 1px 4px; border-radius: 3px; }
.note-body blockquote { border-left: 3px solid var(--line); margin: 4px 0; padding-left: 10px; color: var(--muted); }
.note-body hr { border: 0; border-top: 1px solid var(--line); }
.search-inline { border: 0; border-bottom: 1px solid var(--line); background: none; padding: 8px 4px; outline: 0; width: 220px; }
.search-inline:focus { border-bottom-color: var(--primary); }
.table-wrap.fit table { table-layout: fixed; }
