:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --online: #16a34a;
  --offline: #94a3b8;
  --warn: #d97706;
  --error: #dc2626;
  --crit: #9333ea;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --panel: #131c2e;
    --panel-2: #0f1830;
    --border: #26324a;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #3b82f6;
    --accent-soft: #1e3a5f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; }
.shield { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.autorefresh { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; }

.btn {
  background: var(--accent); color: #fff; border: none;
  padding: 7px 14px; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }

.layout { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100% - 57px); }
@media (max-width: 720px) { .layout { grid-template-columns: 1fr; } }

.sidebar { border-right: 1px solid var(--border); background: var(--panel); padding: 16px; }
.sidebar-title { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.device-item {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; background: var(--panel-2); transition: border-color .15s;
}
.device-item:hover { border-color: var(--accent); }
.device-item.active { border-color: var(--accent); background: var(--accent-soft); }
.device-item .name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.device-item .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.online { background: var(--online); box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.dot.offline { background: var(--offline); }

.content { padding: 20px; overflow: auto; }
.placeholder { color: var(--muted); display: grid; place-items: center; height: 60vh; }

.detail-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-header h1 { margin: 0; font-size: 22px; }
.status-badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status-badge.online { background: rgba(22,163,74,.15); color: var(--online); }
.status-badge.offline { background: rgba(148,163,184,.2); color: var(--offline); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 15px; }

.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.info-grid dt { color: var(--muted); }
.info-grid dd { margin: 0; word-break: break-word; }

.drives { display: flex; flex-direction: column; gap: 12px; }
.drive .drive-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.bar { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--border); }
.bar > span { display: block; height: 100%; background: var(--accent); }

.logs-card { margin-top: 0; }
.logs-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.logs-controls select { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.table-scroll { overflow-x: auto; max-height: 460px; overflow-y: auto; }
.logs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table th, .logs-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.logs-table th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 600; }
.logs-table td.msg { white-space: pre-wrap; word-break: break-word; }
.lvl { font-weight: 600; font-size: 12px; }
.lvl.Information { color: var(--muted); }
.lvl.Debug, .lvl.Trace { color: var(--muted); opacity: .8; }
.lvl.Warning { color: var(--warn); }
.lvl.Error { color: var(--error); }
.lvl.Critical { color: var(--crit); }

.muted { color: var(--muted); }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); filter: none; }
#whoami { font-size: 13px; }

.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: var(--bg);
}
.login-card {
  width: min(360px, 90vw);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 14px;
}
.login-card .btn { margin-top: 6px; padding: 10px; }
.login-error { color: var(--error); font-size: 13px; margin: 0; }
