/* F83 MDM dashboard. Self-hosted, no external fonts or frameworks (strict CSP). */
:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --border: #e3e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --brand: #0b63ce;
    --brand-weak: #e8f1fd;
    --side-bg: #111622;
    --side-text: #9aa6bb;
    --side-active: #1d2738;
    --ok: #0f9d58;
    --ok-weak: #e6f6ee;
    --warn: #b7791f;
    --warn-weak: #fdf5e6;
    --danger: #c62828;
    --danger-weak: #fdecec;
    --info-weak: #eef2ff;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.icon { width: 16px; height: 16px; vertical-align: -3px; flex-shrink: 0; }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 16px; border-bottom: 1px solid #222c3f; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #06b6d4, #2563eb); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.brand-name { color: #fff; font-weight: 700; }
.brand-sub { font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; padding: 14px 10px 6px; color: #6b778c; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); font-size: 13px; }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #38bdf8; }
.nav .badge { margin-left: auto; }
.side-foot { border-top: 1px solid #222c3f; padding: 12px 16px; font-size: 12px; }
.side-foot .who { color: #fff; font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.topbar .crumb { font-weight: 600; }
.topbar .actions { display: flex; align-items: center; gap: 12px; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* panels */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat.alert .value { color: var(--danger); }
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfd; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
td .sub { color: var(--muted); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef1f6; color: #475569; white-space: nowrap; }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.info { background: var(--brand-weak); color: var(--brand); }

/* forms and buttons */
.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; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c5cfdd; background: #f8fafc; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0a56b3; }
.btn.danger { color: var(--danger); border-color: #f2c4c4; }
.btn.danger:hover { background: var(--danger-weak); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
label { display: block; font-weight: 600; font-size: 12.5px; margin: 12px 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #cdd5e1; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3f5; border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: auto; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.callout { border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 13px; background: var(--info-weak); }
.callout.warn { background: var(--warn-weak); }
.callout.danger { background: var(--danger-weak); color: #7f1d1d; }
.secret { font-family: ui-monospace, Consolas, monospace; background: #0f172a; color: #e2e8f0; padding: 10px 12px; border-radius: 8px; word-break: break-all; user-select: all; }

/* dialog */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(520px, 92vw); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
dialog form { padding: 20px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog .error { color: var(--danger); margin-top: 10px; font-size: 13px; }

/* toast */
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 380px; font-size: 13px; border-left: 4px solid #38bdf8; }
.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; }
.toast b { display: block; margin-bottom: 2px; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--side-bg); padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border-radius: 14px; padding: 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.login-card .brand { border: 0; padding: 0 0 12px; }
.login-card .brand-name { color: var(--text); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 10px; }
.error-text { color: var(--danger); margin-top: 10px; min-height: 1em; font-size: 13px; }
.qr { width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 8px; }

@media (max-width: 860px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .nav { display: flex; flex-wrap: wrap; }
    .nav-group { display: none; }
    dl.kv { grid-template-columns: 1fr; }
}

/* spacing utilities (no inline styles) */
.mt { margin-top: 12px; }
.mb { margin-bottom: 16px; }
