/*
  DeskPilot console.
  Self-hosted tool: system fonts only, no CDN. The one expressive element is the
  RustDesk ID, set large in grouped tabular digits the way the client shows it.
*/
:root {
    --ground: #edf0f2;
    --surface: #ffffff;
    --surface-2: #f6f8f9;
    --ink: #18212b;
    --muted: #5d6b79;
    --line: #d5dbe1;
    --live: #0f7b6c;
    --live-soft: #dff2ee;
    --action: #1f4f8a;
    --action-ink: #ffffff;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --warn: #9a4a07;
    --warn-soft: #fdf1e3;
    --focus: #2f6fd1;
    --side: #1c2733;
    --side-ink: #c9d3dc;
    --side-active: #2a394a;
    --radius-s: 4px;
    --radius-m: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ground: #11171d;
        --surface: #182029;
        --surface-2: #1d2731;
        --ink: #e4e9ee;
        --muted: #93a1ae;
        --line: #2c3946;
        --live: #3cc2a8;
        --live-soft: #173a35;
        --action: #5c94d6;
        --action-ink: #0d1620;
        --danger: #f07167;
        --danger-soft: #3b1f1f;
        --warn: #f0a35c;
        --warn-soft: #3a2a19;
        --side: #0c1116;
        --side-ink: #a9b6c2;
        --side-active: #1f2a35;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    background: var(--ground);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--action); }

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.side {
    background: var(--side);
    color: var(--side-ink);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.5rem; color: #fff; font-weight: 650; font-size: 1.05rem; text-decoration: none; }
.brand svg { flex: none; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    color: var(--side-ink);
    text-decoration: none;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-s);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--live); }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 0.5rem 0.4rem; }

.side-foot { margin-top: auto; padding: 0 0.5rem; font-size: 0.85rem; }
.side-foot .who { color: #fff; display: block; }
.side-foot form { margin: 0.35rem 0 0; }
.side-foot button { background: none; border: 0; padding: 0; color: var(--side-ink); text-decoration: underline; cursor: pointer; font: inherit; }

.main { padding: 1.75rem 2rem 3rem; min-width: 0; max-width: 1400px; }

.topbar { display: none; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
    #menu-toggle:checked + .shell .side { transform: none; }
    .topbar { display: flex; align-items: center; gap: .75rem; background: var(--side); color: #fff; padding: .6rem 1rem; position: sticky; top: 0; z-index: 30; }
    .topbar button { background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: var(--radius-s); padding: .25rem .6rem; font: inherit; }
    .main { padding: 1.25rem 1rem 3rem; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0.25rem 0 0; color: var(--muted); max-width: 70ch; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel + .panel { margin-top: 1.25rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 1rem; }
.panel-body > :first-child { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .panel + .panel { margin-top: 0; }

/* Dashboard counters: a single row, numbers left-aligned with their meaning beside them. */
.tally { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin-bottom: 1.25rem; }
.tally > div { flex: 1 1 160px; padding: 0.9rem 1.1rem; border-right: 1px solid var(--line); }
.tally > div:last-child { border-right: 0; }
.tally b { display: block; font-size: 1.75rem; font-variant-numeric: tabular-nums; font-weight: 650; }
.tally span { color: var(--muted); font-size: 0.9rem; }
.tally .is-live b { color: var(--live); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-weight: 600; color: var(--muted); padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.act { text-align: right; white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: 0.84rem; }
.empty { padding: 2rem 1rem; color: var(--muted); text-align: center; }

/* The RustDesk ID: grouped digits, tabular, slightly larger than body text. */
.rid { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
.rid i { font-style: normal; }
.rid i + i { margin-left: 0.3em; }
.rid-xl { font-size: 1.6rem; }

/* Presence */
.presence { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; color: var(--muted); }
.presence::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.presence.on { color: var(--live); }
.presence.on::before { background: var(--live); box-shadow: 0 0 0 3px var(--live-soft); }
.presence.busy::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px var(--live-soft); } }
@media (prefers-reduced-motion: reduce) { .presence.busy::before { animation: none; } }

.chip { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.chip.live { background: var(--live-soft); color: var(--live); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- Forms ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font: inherit; font-size: 0.92rem; font-weight: 550;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    padding: 0.42rem 0.85rem; border-radius: var(--radius-s); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--action); color: var(--action-ink); border-color: var(--action); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.btn.link { border: 0; background: none; color: var(--action); padding: 0.2rem 0.3rem; }
.btn.link.danger { color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

label.field { display: block; margin-bottom: 0.9rem; }
label.field > span { display: block; font-weight: 550; font-size: 0.9rem; margin-bottom: 0.25rem; }
label.field > small, .hint { display: block; color: var(--muted); font-size: 0.83rem; margin-top: 0.25rem; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], input[type=search], select, textarea {
    width: 100%; font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.42rem 0.6rem;
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.check { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.8rem; }
.check input { margin-top: 0.3rem; }
.check small { display: block; color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.panel-head .toolbar { flex: 1 1 auto; }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; }
.validation-message, .error-text { color: var(--danger); font-size: 0.85rem; }

.kv { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.4rem; margin-bottom: 0.4rem; }

.notice { padding: 0.7rem 0.9rem; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 1rem; }
.notice.ok { background: var(--live-soft); border-color: transparent; color: var(--live); }
.notice.err { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.secret { font-family: var(--mono); word-break: break-all; background: var(--surface-2); padding: 0.5rem; border-radius: var(--radius-s); display: block; margin-top: 0.4rem; user-select: all; }
code { font-family: var(--mono); font-size: 0.88em; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { font: inherit; background: none; border: 0; padding: 0.55rem 0.9rem; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--action); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 16, 22, 0.45); display: grid; place-items: start center; padding: 6vh 1rem; z-index: 60; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius-m); width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); border: 1px solid var(--line); }
.modal.wide { max-width: 820px; }
.modal header { padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal header button { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .body { padding: 1.15rem; }
.modal footer { padding: 0.85rem 1.15rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 80; }
.toast { background: var(--ink); color: var(--surface); padding: 0.6rem 0.9rem; border-radius: var(--radius-s); box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Pager ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; flex-wrap: wrap; gap: .5rem; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login-art { background: var(--side); color: var(--side-ink); padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .brand { padding: 0; }
.login-art .rid { color: #fff; font-size: clamp(2rem, 4.5vw, 3.6rem); display: block; letter-spacing: 0.04em; }
.login-art p { max-width: 36ch; margin: 1rem 0 0; }
.login-form { display: grid; place-items: center; padding: 2rem 1.25rem; }
.login-form form { width: 100%; max-width: 340px; }
.login-form h1 { margin-bottom: 1.25rem; }
.login-form .btn.primary { width: 100%; justify-content: center; padding: 0.6rem; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1.25rem 0; font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sso { display: flex; flex-direction: column; gap: .5rem; }
.sso .btn { justify-content: center; }
@media (max-width: 760px) { .login { grid-template-columns: 1fr; } .login-art { padding: 1.5rem; } .login-art p { display: none; } }

#blazor-error-ui { background: var(--warn-soft); color: var(--warn); bottom: 0; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
