:root {
    color-scheme: light;
    --accent: #1f6feb;
    --accent-dark: #1858c4;
    --rail: #16181d;
    --panel: #23262d;
    --panel-text: #e7e9ee;
    --panel-muted: #9aa1ad;
    --surface: #ffffff;
    --text: #1d2129;
    --muted: #68707d;
    --line: #e4e7ec;
    --online: #2fb344;
    --danger: #c9372c;
    --link: #1f6feb;
    --hover: #f3f5f8;
    --row-hover: #f7f9fc;
    --menu-hover: #eef2f8;
    --field: #ffffff;
    --field-line: #cfd4dc;
    --banner: #eaf2ff;
    --banner-line: #c6dafc;
    --banner-error: #fdecea;
    --banner-error-line: #f5c6c1;
    --tag: #e8eefb;
    --tag-text: #1f4fa8;
    --tag-warn: #fdf0d5;
    --tag-warn-text: #8a5a00;
    --neutral: #c3c8d1;
    --bar-online: #a5dfb0;
    --bar-idle: #e1e4ea;
    --danger-line: #f0c4c0;
    --success: #1e7b34;
    --code: #16181d;
}

/* Dark theme: chosen with the switch in the rail, or taken from the system while nothing was chosen. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --rail: #0f1114;
    --panel: #15171c;
    --surface: #1b1e24;
    --text: #e4e7ec;
    --muted: #9aa1ad;
    --line: #2f343d;
    --danger: #f0776c;
    --link: #6ea8ff;
    --hover: #272b33;
    --row-hover: #21252c;
    --menu-hover: #2a2f38;
    --field: #14161a;
    --field-line: #3a404b;
    --banner: #16263f;
    --banner-line: #27457a;
    --banner-error: #3a1c1a;
    --banner-error-line: #6b2a25;
    --tag: #1f2f4d;
    --tag-text: #9dbcf5;
    --tag-warn: #3d3012;
    --tag-warn-text: #e6c36a;
    --neutral: #4a505b;
    --bar-online: #2c6b39;
    --bar-idle: #353a43;
    --danger-line: #6b2a25;
    --success: #5fd07a;
    --code: #0f1114;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
    color-scheme: dark;
    --rail: #0f1114;
    --panel: #15171c;
    --surface: #1b1e24;
    --text: #e4e7ec;
    --muted: #9aa1ad;
    --line: #2f343d;
    --danger: #f0776c;
    --link: #6ea8ff;
    --hover: #272b33;
    --row-hover: #21252c;
    --menu-hover: #2a2f38;
    --field: #14161a;
    --field-line: #3a404b;
    --banner: #16263f;
    --banner-line: #27457a;
    --banner-error: #3a1c1a;
    --banner-error-line: #6b2a25;
    --tag: #1f2f4d;
    --tag-text: #9dbcf5;
    --tag-warn: #3d3012;
    --tag-warn-text: #e6c36a;
    --neutral: #4a505b;
    --bar-online: #2c6b39;
    --bar-idle: #353a43;
    --danger-line: #6b2a25;
    --success: #5fd07a;
    --code: #0f1114;
    }
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
}

button, input { font: inherit; }

button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
}
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); }
a.button { display: inline-block; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; text-decoration: none; line-height: normal; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
a.button.primary:hover { background: var(--accent-dark); }
button.danger { color: var(--danger); border-color: var(--danger-line); }
button.link { border: 0; background: none; color: var(--link); padding: 0 4px; }
button.wide { width: 100%; border-radius: 999px; padding: 8px; }

input {
    border: 1px solid var(--field-line);
    border-radius: 6px;
    padding: 7px 10px;
    width: 100%;
    background: var(--field);
    color: var(--text);
}
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- shell -------------------------------------------------------------- */

.shell { display: flex; height: 100vh; }
.shell-body { flex: 1; min-width: 0; }

.rail {
    width: 84px;
    background: var(--rail);
    color: var(--panel-text);
    display: flex;
    flex-direction: column;
    align-items: stretch;
}
.rail form { margin: 0; }
.rail-spacer { flex: 1; }
.rail-user {
    font-size: 11px;
    text-align: center;
    color: var(--panel-muted);
    padding: 8px 6px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 12px 4px;
    border: 0;
    border-radius: 0;
    border-left: 3px solid transparent;
    background: none;
    color: var(--panel-text);
    font-size: 12px;
    text-decoration: none;
}
.rail-item:hover:not(:disabled) { background: #20232a; }
.rail-item.active { border-left-color: var(--accent); background: var(--panel); }
.rail-item svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.brand { display: block; height: 56px; width: auto; margin: 14px 0 10px; align-self: center; flex-shrink: 0; }
.brand-logo { display: block; height: 96px; width: auto; margin: 0 auto; }

/* ---- access page -------------------------------------------------------- */

.access { display: flex; height: 100vh; }

.groups {
    width: 320px;
    flex-shrink: 0;
    background: var(--panel);
    color: var(--panel-text);
    padding: 18px 16px;
    overflow-y: auto;
}
.groups h1 { font-size: 22px; font-weight: 500; margin: 0 0 8px; }
.groups .hint { color: var(--panel-muted); margin: 0 0 16px; }
.groups nav { margin-top: 20px; display: flex; flex-direction: column; }
.group {
    display: flex;
    justify-content: space-between;
    border: 0;
    border-left: 3px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--panel-muted);
    padding: 8px 10px;
    text-align: left;
}
.group:hover:not(:disabled) { background: #2c3038; color: var(--panel-text); }
.group.selected { border-left-color: var(--accent); color: #fff; font-weight: 600; }
.group .count { font-variant-numeric: tabular-nums; }

.list { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.list-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.list-header h2 { flex: 1; font-size: 18px; font-weight: 600; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter { max-width: 280px; }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 6px; background: var(--banner); border: 1px solid var(--banner-line); }
.banner.error { background: var(--banner-error); border-color: var(--banner-error-line); }
.banner a { color: var(--link); }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--line);
}
.row:hover { background: var(--row-hover); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--neutral); flex-shrink: 0; }
.row.online .dot { background: var(--online); }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 16px; }
.row.offline .row-name { color: var(--muted); }
.row-sub { font-size: 12px; color: var(--muted); min-height: 1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-status { width: 220px; flex-shrink: 0; text-align: center; font-size: 12px; color: var(--muted); }
.bar { height: 3px; border-radius: 2px; background: var(--neutral); margin-bottom: 4px; }
.row.online .bar { background: var(--bar-online); }
.bar.active, .row.online .bar.active { background: var(--online); }
/* ---- access page: action bar, selectable rows, detail panel ---------------- */
.list-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.list-actions .hint { color: var(--muted); font-size: 12px; margin-right: 8px; }
.action { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--text); padding: 6px 10px; border-radius: 6px; text-decoration: none; font-size: 14px; cursor: pointer; }
.action:hover { background: var(--hover); }
.action svg, .row-screen svg, .detail-tabs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.row.selectable { cursor: pointer; border-left: 3px solid transparent; padding-left: 17px; }
.row.selected { background: var(--row-hover); border-left-color: var(--accent); }
.row-screen { display: inline-flex; flex-shrink: 0; padding: 4px; border-radius: 6px; color: var(--neutral); }
.row-screen svg { width: 30px; height: 30px; }
.row.online .row-screen { color: var(--online); }
a.row-screen:hover { background: var(--hover); }

.detail { width: 440px; flex-shrink: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.detail-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.detail-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-tabs { display: flex; justify-content: center; gap: 6px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); }
.detail-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 14px; }
.detail-tabs button:hover:not(:disabled) { background: none; color: var(--text); }
.detail-tabs button.selected { color: var(--text); border-bottom-color: var(--accent); }
.detail-body { padding: 16px 18px 24px; }
.detail-body h4 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field { display: block; margin: 0 0 14px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 15px; font-weight: 400; color: var(--text); background: none; border: 0; border-bottom: 1px solid var(--field-line); border-radius: 0; padding: 4px 2px; }
.field textarea { border: 1px solid var(--field-line); border-radius: 6px; padding: 7px 10px; background: var(--field); resize: vertical; }
.field input:disabled { border-bottom-style: dashed; opacity: 1; }
.detail-state { display: flex; align-items: center; gap: 8px; margin: 18px 0; font-size: 13px; color: var(--muted); }
.detail-state .dot.on { background: var(--online); }
.preview { position: relative; margin: 0 auto; max-width: 400px; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.preview img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.preview img.hidden { display: none; }
.preview-none { padding: 16px; text-align: center; font-size: 12px; color: #9aa1ad; }
.preview-caption { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
.preview-large { max-width: 96vw; max-height: 94vh; border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); cursor: zoom-out; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline .when { flex-shrink: 0; width: 118px; color: var(--muted); font-size: 12px; }
.notes-text { white-space: pre-wrap; }
@media (max-width: 1500px) { .detail { width: 380px; } .row-status { width: 170px; } .row-status.host { width: 150px; } }

/* A fixed width, buttons to the right: the status bars then line up in every row, whatever buttons a row has. */
.row-actions { display: flex; gap: 6px; flex-shrink: 0; width: 280px; justify-content: flex-end; }

/* ---- dialogs ------------------------------------------------------------ */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 18, 24, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 10;
}
.dialog {
    background: var(--surface);
    border-radius: 10px;
    padding: 20px 22px;
    width: min(640px, 100%);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .25);
}
.dialog h3 { margin: 0 0 12px; font-size: 18px; }
.dialog label { display: block; margin: 12px 0; font-size: 12px; color: var(--muted); }
.dialog label input { margin-top: 4px; font-size: 14px; color: var(--text); }
.dialog pre {
    background: var(--code);
    color: #e7e9ee;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: Consolas, monospace;
    font-size: 13px;
    user-select: all;
}
.dialog .hint { color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.grow { flex: 1; }

/* ---- sign in ------------------------------------------------------------ */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--panel); padding: 16px; }
.login-card { background: var(--surface); border-radius: 12px; padding: 32px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { text-align: center; font-size: 20px; margin: 0; }
.login-card label { font-size: 12px; color: var(--muted); }
.login-card label input { margin-top: 4px; font-size: 14px; color: var(--text); }
.login-card .error { color: var(--danger); margin: 0; text-align: center; }
.login-card .success { color: var(--success); margin: 0; text-align: center; }
.login-card a { color: var(--link); text-align: center; }
.groups .download { display: block; margin-top: 18px; color: var(--panel-muted); font-size: 12px; }
.groups .download:hover { color: var(--panel-text); }
.dialog a { color: var(--link); }
.dialog .hint.warn { color: var(--danger); }
.dialog textarea { width: 100%; margin-top: 4px; font: inherit; font-size: 14px; color: var(--text); background: var(--field); border: 1px solid var(--field-line); border-radius: 6px; padding: 7px 10px; resize: vertical; }
.dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--tag); color: var(--tag-text); font-size: 11px; vertical-align: middle; }
.tag.warn { background: var(--tag-warn); color: var(--tag-warn-text); }

/* ---- right-click menu, tools, support ------------------------------------ */
.menu-backdrop { position: fixed; inset: 0; z-index: 20; }
.context-menu { position: fixed; z-index: 21; margin: 0; padding: 6px; list-style: none; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.context-menu button, .context-menu a { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; background: none; padding: 7px 12px; color: var(--text); text-decoration: none; font-size: 14px; }
.context-menu button:hover, .context-menu a:hover { background: var(--menu-hover); }
.context-menu button.danger { color: var(--danger); }
.dialog.wide { width: min(860px, 100%); }
.command-row { display: flex; gap: 8px; margin: 10px 0; }
pre.output { background: var(--code); color: #e7e9ee; padding: 12px; border-radius: 6px; max-height: 50vh; overflow: auto; font-family: Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; }
.invite { border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; text-align: center; }
.invite p { margin: 6px 0; color: var(--muted); }
.invite p.big { font-size: 20px; font-weight: 600; color: var(--text); user-select: all; overflow-wrap: anywhere; }
.rail-item.active { border-left-color: var(--accent); background: var(--panel); }
.login-card.guest h1 { font-size: 18px; }
.login-card.guest .hint { color: var(--muted); font-size: 12px; margin: 0; text-align: center; }
.code-row { display: flex; gap: 8px; }
.code-row input { font-size: 22px; text-align: center; letter-spacing: 2px; }
.code-row button { font-size: 20px; padding: 6px 16px; }

/* ---- access rows: connected technician (left) and computer status (right) -- */
.row-status.host { width: 190px; }
.row.online .bar.idle, .bar.idle { background: var(--bar-idle); }
a.button.wide { display: block; text-align: center; border-radius: 999px; padding: 8px; }
.dialog h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* ---- admin panel ---------------------------------------------------------- */
.group.with-icon span { display: inline-flex; align-items: center; gap: 10px; }
.group.with-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.list.admin { padding: 22px 32px 40px; display: block; }
.list.admin > h2, .panel > h2 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.list.admin h3, .panel h3 { font-size: 14px; margin: 26px 0 8px; }
.list.admin .lead { color: var(--muted); margin: 0 0 18px; max-width: 760px; }
.list.admin .hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.list.admin .hint.warn { color: var(--danger); }
.list.admin a { color: var(--link); }
.list.admin a.button { color: var(--text); }
.panel { max-width: 1000px; }
.panel .banner, .list.admin .banner { margin: 0 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 16px 0 22px; max-width: 900px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 12px; }
.card .number { font-size: 24px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.facts.wide { max-width: 900px; gap: 8px 24px; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; max-width: 760px; }
.form-grid label { font-size: 12px; color: var(--muted); }
.form-grid input { margin-top: 4px; font-size: 14px; color: var(--text); }
pre.command { background: var(--code); color: #e7e9ee; padding: 12px 14px; border-radius: 6px; font-family: Consolas, monospace; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; max-width: 900px; margin: 0; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 760px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting > input { width: 240px; flex-shrink: 0; }
.setting > input.short { width: 90px; }
.setting button { flex-shrink: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.switch input { width: 18px; height: 18px; }
.audit-tools { display: flex; gap: 8px; max-width: 520px; margin: 12px 0; }
table.audit td { font-size: 12.5px; vertical-align: top; }
table.audit td:first-child { white-space: nowrap; color: var(--muted); }
table.audit td:last-child { overflow-wrap: anywhere; }

/* ---- users and account pages -------------------------------------------- */
.page { padding: 24px 32px; max-width: 1000px; height: 100vh; overflow-y: auto; }
.page h1 { font-size: 22px; font-weight: 500; margin: 0 0 16px; }
.page h2 { font-size: 16px; margin: 28px 0 10px; }
.page .banner { margin: 0 0 16px; }
.page .hint { color: var(--muted); font-size: 12px; }
table.users { width: 100%; border-collapse: collapse; }
table.users th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.users td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users td.actions { white-space: nowrap; text-align: right; }
table.users td.actions button { margin-left: 6px; }
select { font: inherit; border: 1px solid var(--field-line); border-radius: 6px; padding: 6px 8px; background: var(--field); color: var(--text); }
.add-user { display: flex; gap: 8px; max-width: 560px; margin-top: 14px; }
.panel h3 { margin: 26px 0 10px; }

/* ---- role editor ---------------------------------------------------------- */
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 18px; }
.dialog .checks label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text); cursor: pointer; }
.dialog .checks label input { width: 16px; height: 16px; margin: 0; padding: 0; flex-shrink: 0; }
.grant { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 10px 0; }
.grant-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.grant-head select { flex-shrink: 0; }
.grant-head input { max-width: 280px; }
.grant-head button { margin-left: auto; }
.grant .hint { margin: 10px 0 0; }
pre.secret { background: var(--code); color: #e7e9ee; padding: 10px 12px; border-radius: 6px; font-family: Consolas, monospace; font-size: 15px; letter-spacing: 1px; user-select: all; margin: 8px 0; white-space: pre-wrap; }
.login.column { flex-direction: column; gap: 16px; padding: 24px 16px; height: 100vh; min-height: 0; overflow-y: auto; justify-content: flex-start; }
.login.column > a { color: #c9d4ee; }

/* Narrow windows: the name gets its own line, bars and buttons follow below it. */
@media (max-width: 1300px) {
    .row { flex-wrap: wrap; }
    .row-main { flex-basis: calc(100% - 40px); }
    .row-status.host { margin-left: 24px; }
    .row-actions { margin-left: auto; }
}

@media (max-width: 900px) {
    .groups { width: 220px; }
    .row { flex-wrap: wrap; }
    .row-status { width: auto; }
    .row-actions { width: auto; }
}
