/* WebAMT — modern design system */
:root {
    --bg: #0b0e14;
    --bg-elev: #121722;
    --bg-elev2: #1a2130;
    --bg-hover: #1f2736;
    --border: #232c3d;
    --border-strong: #313d54;
    --text: #e6ebf4;
    --text-dim: #97a3b8;
    --text-faint: #5f6b80;
    --accent: #4f8cff;
    --accent-soft: rgba(79, 140, 255, 0.14);
    --accent-2: #7c5cff;
    --good: #2ecc8f;
    --good-soft: rgba(46, 204, 143, 0.14);
    --warn: #f4b740;
    --warn-soft: rgba(244, 183, 64, 0.14);
    --bad: #ff5f6d;
    --bad-soft: rgba(255, 95, 109, 0.14);
    --radius: 12px;
    --radius-sm: 8px;
    --head-h: 62px; /* shared height for the sidebar logo (.brand) and the main navbar (.topbar) so they align */
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "SF Mono", "Cascadia Code", Consolas, "Roboto Mono", monospace;
}
:root[data-theme="light"] {
    --bg: #eef1f6;
    --bg-elev: #ffffff;
    --bg-elev2: #f5f7fb;
    --bg-hover: #eaeef5;
    --border: #dde3ec;
    --border-strong: #c6cfdd;
    --text: #1a2130;
    --text-dim: #566076;
    --text-faint: #8b95a8;
    --accent-soft: rgba(79, 140, 255, 0.12);
    --shadow: 0 10px 40px rgba(20, 30, 60, 0.12);
}

* { box-sizing: border-box; }

/* SF-style inline icons */
.ic-svg { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.btn .ic-svg { vertical-align: -0.18em; }
.tab .ic { display: inline-flex; align-items: center; }
.stat .label .ic-svg { vertical-align: -0.2em; }
html, body { height: 100%; margin: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ---- App shell ---- */
.app { display: grid; grid-template-columns: 280px 1fr; height: 100vh; }
.sidebar {
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--head-h); padding: 0 20px; box-sizing: border-box; border-bottom: 1px solid var(--border); }
.brand .logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px;
    box-shadow: 0 4px 14px var(--accent-soft);
}
.brand .title { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand .sub { font-size: 11px; color: var(--text-faint); margin-top: -2px; }

.dev-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 8px; }
.dev-head span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); font-weight: 600; }
.dev-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.dev {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
    cursor: pointer; margin-bottom: 3px; border: 1px solid transparent; position: relative;
}
.dev:hover { background: var(--bg-hover); }
.dev.active { background: var(--accent-soft); border-color: var(--border-strong); }
.dev .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.dev.on .dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.dev.err .dot { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.dev.busy .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
/* AMT reachable on standby power but the machine itself is powered off / asleep */
.dev.off .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); opacity: .55; }
.dev .meta { min-width: 0; flex: 1; }
.dev .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .host { font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .edit { opacity: 0; color: var(--text-faint); font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.dev:hover .edit { opacity: 1; }
.dev .edit:hover { background: var(--bg-elev2); color: var(--text); }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ---- Main area ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
    display: flex; align-items: center; gap: 16px; padding: 0 22px; height: var(--head-h);
    border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-shrink: 0; box-sizing: border-box;
}
.topbar .tb-title { font-weight: 700; font-size: 16px; }
.topbar .tb-sub { color: var(--text-dim); font-size: 12.5px; }
.topbar .spacer { flex: 1; }

.tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--bg-elev); overflow-x: auto; flex-shrink: 0; }
.tab {
    padding: 12px 15px; font-size: 13.5px; color: var(--text-dim); cursor: pointer;
    border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .ic { font-size: 15px; }

.content { flex: 1; overflow-y: auto; padding: 24px; min-height: 0; }
.content.nopad { padding: 0; }

/* ---- Empty / disconnected states ---- */
.center-state { height: 100%; display: grid; place-items: center; text-align: center; padding: 40px; }
.center-state .big { font-size: 46px; margin-bottom: 14px; opacity: 0.9; }
.center-state h2 { margin: 0 0 8px; font-weight: 700; }
.center-state p { color: var(--text-dim); max-width: 440px; margin: 0 auto 20px; }

/* ---- Cards & grid ---- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); font-weight: 600; }
.card.pad0 { padding: 0; overflow: hidden; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title-row h3 { margin: 0; }

.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { font-size: 12px; color: var(--text-dim); font-weight: 500; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-dim); }

/* ---- Power hero ---- */
.power-hero { display: flex; align-items: center; gap: 22px; }
.power-orb {
    width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
    font-size: 34px; border: 2px solid var(--border-strong); position: relative;
}
.power-orb.on { border-color: var(--good); color: var(--good); background: var(--good-soft); box-shadow: 0 0 0 6px var(--good-soft); }
.power-orb.off { border-color: var(--text-faint); color: var(--text-faint); }
.power-orb.sleep { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--bg-elev2); color: var(--text);
    cursor: pointer; font-size: 13.5px; font-weight: 550; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.good { color: var(--good); border-color: var(--good-soft); }
.btn.good:hover { background: var(--good-soft); border-color: var(--good); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.icon { padding: 8px 10px; }
.btn.block { width: 100%; justify-content: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg-elev2); border: 1px solid var(--border); }
.badge.good { color: var(--good); background: var(--good-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.badge.dot::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---- Definition tables ---- */
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 8px 4px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 13.5px; }
.kv tr:last-child td { border-bottom: none; }
.kv td.k { color: var(--text-dim); width: 42%; font-weight: 500; }
.kv td.v { color: var(--text); word-break: break-word; }
.kv td.v.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---- Data tables ---- */
.tbl-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; padding: 11px 14px; color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-elev); }
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
table.data tr:hover td { background: var(--bg-elev2); }
table.data td.mono { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
table.data th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
table.data th.th-sort:hover { color: var(--text); }
table.data th .th-arrow { color: var(--accent); margin-left: 4px; font-weight: 700; }

/* ---- Forms ---- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--bg); color: var(--text); font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.check { display: flex; align-items: center; gap: 9px; padding: 7px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---- Modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(6, 9, 16, 0.66); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; }
.modal.wide { max-width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.x-close { cursor: pointer; color: var(--text-faint); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.x-close:hover { color: var(--text); background: var(--bg-hover); }

/* ---- Toasts ---- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--bg-elev2); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); min-width: 260px; max-width: 380px; animation: slidein 0.2s ease; }
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 650; margin-bottom: 2px; font-size: 13.5px; }
.toast .t-msg { color: var(--text-dim); font-size: 12.5px; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Progress bar ---- */
.progline { height: 2px; background: transparent; overflow: hidden; }
.progline.active::after { content: ''; display: block; height: 100%; width: 40%; background: var(--accent); animation: prog 1s infinite ease-in-out; }
@keyframes prog { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* ---- Terminal ---- */
.term-shell { height: 100%; display: flex; flex-direction: column; background: #05070c; }
.term-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-elev); }
.term-scroll { flex: 1; overflow: auto; padding: 12px 16px; }
#termContainer { font-family: var(--mono); font-size: 13px; line-height: 1.15; white-space: pre; color: #d6dde8; }
#termContainer table { border-collapse: collapse; }
#termContainer td { padding: 0; }

/* ---- KVM ---- */
.kvm-shell { height: 100%; display: flex; flex-direction: column; background: #05070c; }
.kvm-bar { display: flex; align-items: center; gap: 7px; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--bg-elev); flex-wrap: wrap; }
.kvm-bar .kvm-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }
.kvm-bar select.btn { padding: 5px 8px; max-width: 190px; }
.kvm-bar .kvm-vo { padding: 4px 8px; font-size: 12.5px; color: var(--text-dim); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-elev2); gap: 6px; }
.kvm-bar .kvm-vo input { width: 14px; height: 14px; }
.kvm-stage { flex: 1; overflow: auto; display: grid; place-items: center; padding: 10px; position: relative; }
#kvmCanvas { background: #000; box-shadow: var(--shadow); border-radius: 4px; display: block; }
#kvmCanvas:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.kvm-hint { position: absolute; color: var(--text-faint); font-size: 13.5px; pointer-events: none; text-align: center; }
.kvm-shell:fullscreen { background: #000; }
.kvm-shell:fullscreen .kvm-stage { padding: 0; }

/* ---- Explorer ---- */
.explorer { display: grid; grid-template-columns: 300px 1fr; gap: 16px; height: 100%; }
.explorer .classlist { overflow-y: auto; }
.explorer .classlist .ci { padding: 7px 11px; border-radius: 6px; cursor: pointer; font-size: 12.5px; font-family: var(--mono); }
.explorer .classlist .ci:hover { background: var(--bg-hover); }
.explorer .classlist .ci.active { background: var(--accent-soft); color: var(--accent); }
pre.json { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; overflow: auto; font-family: var(--mono); font-size: 12.5px; margin: 0; color: var(--text); max-height: 100%; }
.json-key { color: var(--accent); }
.json-str { color: var(--good); }
.json-num { color: var(--warn); }
.json-bool { color: var(--accent-2); }

.filter-input { padding: 7px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); font-family: inherit; font-size: 13.5px; }
.filter-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.section-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.section-sub { color: var(--text-dim); margin: 0 0 20px; font-size: 13.5px; }
.muted { color: var(--text-dim); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
