:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --text: #1a2230; --muted: #66758a;
  --border: #dde3ec; --accent: #2563eb; --accent-h: #1d4ed8; --accent-t: #ffffff;
  --ok: #16a34a; --ok-bg: #e7f6ec; --off: #64748b; --off-bg: #eef1f5; --warn: #d97706; --warn-bg: #fdf1dc;
  --danger: #dc2626; --danger-bg: #fdeaea; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.05);
  --c0: #2563eb; --c1: #f59e0b; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #171e28; --surface-2: #1c2531; --text: #e6ebf2; --muted: #92a0b3;
    --border: #2a3646; --accent: #4f8cff; --accent-h: #6ea0ff; --accent-t: #0b1220;
    --ok: #3ccf74; --ok-bg: #12301f; --off: #9aa7b8; --off-bg: #222c39; --warn: #f0a23a; --warn-bg: #3a2b12;
    --danger: #ff6b6b; --danger-bg: #3b1d1f; --shadow: 0 1px 2px rgba(0,0,0,.4);
    --c0: #6ea0ff; --c1: #f5b44a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.spacer { flex: 1; } .inline { display: inline; margin: 0; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-t); font-size: 18px; }
.who { color: var(--muted); font-size: 14px; }
.container { max-width: 1120px; margin: 0 auto; padding: 24px 20px 48px; }
.container.wide { max-width: none; padding: 12px 16px 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; transition: background .12s, border-color .12s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-t); }
.btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; height: 42px; margin-top: 8px; }
.btn:focus-visible, input:focus-visible, .seg-btn:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.skeleton { height: 210px; background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 200% 100%; animation: sk 1.3s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 17px; font-weight: 650; margin: 0; word-break: break-word; }
.card-title a { color: var(--text); }
.vmid { color: var(--muted); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--off-bg); color: var(--off); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.off { background: var(--off-bg); color: var(--off); }
.meter { margin-bottom: 11px; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.k { color: var(--muted); } .v { font-variant-numeric: tabular-nums; font-weight: 550; }
.track { height: 7px; background: var(--off-bg); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s; }
.fill.hi { background: var(--warn); } .fill.crit { background: var(--danger); }
.meta { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin: 6px 0 14px; flex-wrap: wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.more { position: relative; }
.more summary { list-style: none; } .more summary::-webkit-details-marker { display: none; }
.menu { position: absolute; right: 0; top: 42px; min-width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; z-index: 6; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none; font: inherit; font-size: 14px; border-radius: 7px; cursor: pointer; color: var(--text); }
.menu-item:hover { background: var(--surface-2); } .menu-item.danger { color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 20px; }
.vm-page .card { margin-bottom: 16px; }
.specs { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 24px; margin: 0; }
.specs div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--border); padding: 4px 0; font-size: 14px; }
.specs dt { color: var(--muted); } .specs dd { margin: 0; font-weight: 550; text-align: right; }

.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); color: var(--muted); padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.seg-btn.active { background: var(--accent); color: var(--accent-t); font-weight: 600; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 18px; }
@media (max-width: 520px) { .charts { grid-template-columns: 1fr; } }
figure { margin: 0; } figcaption { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.chart .svg { width: 100%; height: auto; display: block; }
.chart .grid-l { stroke: var(--border); stroke-width: 1; } .chart .axis { fill: var(--muted); font-size: 11px; }
.chart .s0 { stroke: var(--c0); fill: none; stroke-width: 2; } .chart .s1 { stroke: var(--c1); fill: none; stroke-width: 2; }
.chart .a0 { fill: var(--c0); opacity: .12; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.nodata { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; }

.auth { display: grid; place-items: center; min-height: 100vh; }
.auth .container { width: 100%; max-width: 420px; padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px 28px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 18px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card form { margin-top: 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
input[type=text], input[type=password] { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--text); font: inherit; }
.alert { margin-top: 14px; padding: 10px 12px; border-radius: 9px; font-size: 14px; }
.alert.error { background: var(--danger-bg); color: var(--danger); }

.console-page .console-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.console-page .back { margin: 0; }
.screen { width: 100%; height: calc(100vh - 150px); min-height: 360px; background: #0b0f14; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.screen:fullscreen { height: 100vh; border: 0; border-radius: 0; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); max-width: 360px; animation: in .18s ease-out; }
.toast.error { background: var(--danger); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }
dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); padding: 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(8,12,18,.55); }
dialog p { margin: 0 0 18px; } dialog .row { display: flex; gap: 8px; justify-content: flex-end; }
[hidden] { display: none !important; }

.alert.ok { background: var(--ok-bg); color: var(--ok); }

/* administrator */
.adm-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.adm-nav a { padding: 7px 12px; border-radius: 8px; color: var(--text); font-weight: 550; font-size: 14px; }
.adm-nav a:hover { background: var(--surface-2); text-decoration: none; }
.adm-nav a[aria-current] { background: var(--accent); color: var(--accent-t); }
.adm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat-card { display: grid; gap: 6px; color: var(--text); padding: 16px; }
.stat-card:hover { text-decoration: none; border-color: var(--accent); }
.stat-card .k { color: var(--muted); font-size: 13px; } .stat-card .v { font-size: 30px; font-weight: 700; }
.adm-filter { display: flex; flex-wrap: wrap; gap: 6px; } .adm-filter .btn { height: 30px; font-size: 13px; } .adm-filter .btn.on { background: var(--accent); color: var(--accent-t); border-color: var(--accent); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.adm-table th, .adm-table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.adm-table th { background: var(--surface-2); font-weight: 650; }
.adm-table tr:last-child td { border-bottom: 0; }
.pre { white-space: pre-wrap; word-break: break-word; }
.inline-form { display: inline-block; margin: 0 8px 8px 0; }
.card + .card { margin-top: 14px; }
.order-form { display: grid; gap: 12px; max-width: 560px; } .order-form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.order-form input, .order-form select, .order-form textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; width: 100%; }
.orders-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.orders-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
