/* AxisVNC — dark console theme (light variant below), brand red + ink */
:root {
  --bg: #1a1c20; --panel: #22252a; --side: #15171a; --head: #2b2f35; --group: #262a30; --hover: #2c3138;
  --line: #33383f; --text: #e4e6ea; --muted: #959ba4; --brand: #ff2d3a; --accent: #e50914; --accent-hi: #ff3340;
  --ok: #3ecf7a; --off: #5f656e; --danger: #ff6b6b; --warn-bg: rgba(229, 9, 20, .12);
  --top: #0e0f11; --top-text: #f2f2f2;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef0f3; --panel: #ffffff; --side: #ffffff; --head: #e6e9ee; --group: #f3f4f7; --hover: #f7f8fa;
    --line: #d9dde3; --text: #1b1d21; --muted: #5d636c; --brand: #e50914; --accent: #d40812; --accent-hi: #e50914;
    --ok: #1d9d55; --off: #9aa0a8; --danger: #c4161c; --warn-bg: rgba(229, 9, 20, .07);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
code { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
svg { flex: none; }

/* buttons + inputs */
button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 4px; background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { background: var(--accent-hi); }
button:disabled { opacity: .5; cursor: default; }
button svg { width: 16px; height: 16px; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--text); font: inherit; }
label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 13px; }
.err { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 13px; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; letter-spacing: -.4px; color: inherit; text-decoration: none; margin: 0; }
.brand b { color: var(--brand); font-weight: inherit; }

/* ---------- console layout ---------- */
.topbar { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px; background: var(--top); color: var(--top-text); border-bottom: 3px solid var(--accent); }
.topbar .brand { color: var(--top-text); margin-right: auto; }
.account { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-left: 1px solid #2a2d33; border-right: 1px solid #2a2d33; height: 100%; min-width: 0; }
.account div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.account strong, .account small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account small { color: #a3a8b0; }
.topbtn { background: transparent; color: var(--top-text); padding: 6px 10px; }
.topbtn:hover { background: #22252a; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 56px); }
.sidebar { background: var(--side); border-right: 1px solid var(--line); padding: 16px 0; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: var(--text); text-decoration: none; font-weight: 600; border-left: 3px solid transparent; }
.sidebar a svg { width: 18px; height: 18px; color: var(--muted); }
.sidebar a:hover { background: var(--hover); }
.sidebar a.active { background: var(--hover); border-left-color: var(--accent); }
.sidebar a.active svg { color: var(--brand); }

.content { padding: 20px 24px 32px; min-width: 0; }
.content h1 { font-size: 20px; margin: 0 0 14px; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.toolbar input[type=search] { width: 260px; }
button.tool { background: var(--panel); color: var(--text); border: 1px solid var(--line); padding: 7px 9px; }
button.tool:hover { background: var(--hover); }

/* data grid */
.grid-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { position: sticky; top: 0; background: var(--head); color: var(--muted); font-weight: 600; font-size: 12px; text-align: left; padding: 9px 10px; white-space: nowrap; }
.grid td { padding: 7px 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr:not(.group):hover td { background: var(--hover); }
.grid tr.group td { background: var(--group); color: var(--muted); padding: 8px 10px; }
.grid tr.group strong { color: var(--text); margin-right: 12px; }
.grid tr.off td { color: var(--muted); }
.grid tr.alert td { background: var(--warn-bg); }
.grid td.none { text-align: center; color: var(--muted); padding: 20px; }
.c-status { width: 56px; text-align: center !important; }
.c-actions { width: 44px; text-align: right !important; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--off); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(62, 207, 122, .18); }
button.name, span.name { font-weight: 700; text-transform: uppercase; letter-spacing: .2px; }
button.name { background: none; padding: 0; color: var(--text); }
button.name:hover { background: none; color: var(--brand); text-decoration: underline; }
button.link { background: none; padding: 2px 4px; color: var(--brand); font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }
button.icon-btn { background: none; color: var(--muted); padding: 4px; }
button.icon-btn:hover { background: none; color: var(--danger); }
.empty { color: var(--muted); padding: 16px 2px; }

/* add-computer dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 6px; padding: 22px 24px; max-width: min(460px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dialog ol { padding-left: 20px; line-height: 1.8; }
#add-dialog form { display: flex; justify-content: flex-end; margin-top: 16px; }

/* remote viewer */
#viewer { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; z-index: 10; }
#viewer .bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--top); color: var(--top-text); border-bottom: 3px solid var(--accent); }
#viewer .bar span { flex: 1; font-weight: 700; text-transform: uppercase; }
#viewer .bar .ghost { color: var(--top-text); border-color: #3a3e45; }
#screen { flex: 1; min-height: 0; width: 100%; object-fit: contain; cursor: default; }

/* ---------- sign-in page ---------- */
main.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 6px; padding: 26px 24px; }
.card .brand { margin-bottom: 18px; }
.tabs { display: flex; gap: 8px; margin-bottom: 4px; }
.tabs button { flex: 1; justify-content: center; }
.tabs button.ghost { color: var(--muted); }
.card form button[type=submit] { width: 100%; justify-content: center; margin-top: 20px; padding: 10px; }
.qr { display: block; margin: 12px auto; width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 6px; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { display: flex; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .sidebar a { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 14px; }
  .sidebar a.active { border-bottom-color: var(--accent); }
  .content { padding: 16px; }
  .account { display: none; }
  .toolbar input[type=search] { width: 100%; order: 5; }
  .c-os, .c-ip, .c-connect { display: none; }
}

/* ---------- organizations + members ---------- */
.org-name.sub { padding-left: 22px; position: relative; }
.org-name.sub::before { content: "└"; position: absolute; left: 6px; color: var(--muted); }
.org-actions { display: flex; gap: 6px; justify-content: flex-end; width: auto !important; }
button.tool { font-weight: 600; font-size: 13px; }
button.icon-btn.danger-hover:hover { color: var(--danger); }
button.icon-btn:hover { color: var(--brand); }
dialog.wide { width: min(760px, calc(100vw - 32px)); max-width: none; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; }
.dialog-head form { margin: 0; }
dialog h3 { font-size: 15px; margin: 18px 0 4px; }
#member-form { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: 4px; margin: 14px 0 0; padding: 10px 14px 12px; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
.checks.indent { margin: 4px 0 0 24px; max-height: 180px; overflow-y: auto; }
label.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-weight: 400; font-size: 14px; cursor: pointer; }
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
label.check:has(input:disabled) { color: var(--muted); cursor: default; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); color: var(--text); font: inherit; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--head); color: var(--muted); }
.badge.ok { background: rgba(62, 207, 122, .15); color: var(--ok); }
.invite { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--ok); border-radius: 4px; background: rgba(62, 207, 122, .08); }
.invite p { margin: 4px 0 10px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
#move-dialog { width: min(420px, calc(100vw - 32px)); }
.c-num { width: 90px; text-align: right !important; }
button.tool.danger-text { color: var(--danger); }
button.tool:disabled:hover { background: var(--panel); }
#popup { width: min(440px, calc(100vw - 32px)); }
#popup h2 { margin: 0 0 8px; }
#popup p#popup-msg { margin: 0 0 12px; color: var(--muted); line-height: 1.5; }
#popup p#popup-msg:empty { display: none; }
#popup .err:empty { min-height: 0; margin: 0; }
button.danger-solid { background: var(--danger); }
button.danger-solid:hover { background: var(--accent-hi); }

/* ---------- account settings + banner ---------- */
.settings { display: grid; gap: 16px; max-width: 640px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 18px 20px; }
.panel h2 { font-size: 16px; margin: 0 0 8px; display: flex; align-items: center; gap: 10px; }
.panel .qr { margin: 12px 0; }
.panel .form-actions { justify-content: flex-start; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 10px 14px; border: 1px solid var(--accent); border-left-width: 4px; border-radius: 4px; background: var(--warn-bg); }
.banner span { flex: 1; min-width: 200px; }
.banner-link { color: var(--brand); font-weight: 700; text-decoration: none; }
.banner-link:hover { text-decoration: underline; }
input[readonly] { color: var(--muted); }
.skip { display: block; text-align: center; margin-top: 14px; color: var(--muted); font-size: 13px; }
.skip:hover { color: var(--text); }
