/* SecureView dashboard — matches the approved mockup */
:root {
  --ink: #0F172A; --ink-2: #334155; --muted: #475569; --line: #E2E8F0; --line-2: #F1F5F9;
  --ground: #F3F5F8; --card: #FFFFFF; --blue: #1D4ED8; --blue-dark: #1E3A8A; --blue-soft: #DBEAFE;
  --green: #166534; --green-soft: #DCFCE7; --green-dot: #16A34A;
  --orange: #9A3412; --orange-line: #C2410C; --orange-soft: #FFF7ED; --orange-soft-2: #FFEDD5;
  --red: #B91C1C; --red-soft: #FEE2E2;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--ground); min-height: 100vh; font-size: 15px; }
h1, h2, .brand { font-family: "Space Grotesk", Inter, "Segoe UI", system-ui, sans-serif; letter-spacing: -0.01em; }
a { color: var(--blue); } a:hover { color: var(--blue-dark); }
button { font-family: inherit; font-size: inherit; }
[hidden] { display: none !important; }
svg.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* top bar */
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--ink); color: #F8FAFC; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.brand svg { width: 28px; height: 28px; stroke: #60A5FA; }
.topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; font-size: 13px; }
.relay-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: #14532D; color: #DCFCE7; }
.relay-pill.down { background: #7F1D1D; color: #FEE2E2; }
.relay-pill svg { width: 14px; height: 14px; }
.topbar .muted { color: #CBD5E1; }
.btn-dark { min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid #334155; background: #1E293B; color: #F8FAFC; cursor: pointer; }

/* layout */
.shell { display: flex; flex-wrap: wrap; gap: 24px; max-width: 1360px; margin: 0 auto; padding: 24px; }
nav.side { flex: 1 1 200px; display: flex; flex-direction: column; gap: 4px; }
nav.side a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; color: var(--ink-2); text-decoration: none; }
nav.side a.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.btn-add { margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px dashed #94A3B8; background: transparent; color: #1E293B; font-weight: 600; cursor: pointer; }
main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
#computers { display: flex; flex-direction: column; gap: 16px; }
.head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 28px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.filters { display: flex; gap: 6px; padding: 4px; background: var(--line); border-radius: 10px; }
.filters button { min-height: 36px; padding: 6px 14px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; background: transparent; color: var(--muted); }
.filters button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.12); }

/* computer cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.os-icon { width: 44px; height: 44px; border-radius: 10px; background: #EFF6FF; color: var(--blue); display: flex; align-items: center; justify-content: center; flex: none; }
.os-icon svg { width: 22px; height: 22px; }
.card h2 { margin: 0; font-family: inherit; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card .os { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; flex: none; background: var(--line-2); color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: #94A3B8; }
.status.on { background: var(--green-soft); color: var(--green); }
.status.on::before { background: var(--green-dot); }
.status.busy { background: var(--blue-soft); color: var(--blue-dark); }
.status.busy::before { background: var(--blue); }
.legacy { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--orange-soft); color: var(--orange); font-size: 12px; line-height: 1.4; }
.seen { margin: 0; font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.btn-primary { flex: 1; min-height: 44px; border-radius: 10px; border: none; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px; }
.btn-primary:disabled { background: var(--line); color: #64748B; cursor: not-allowed; }
.btn-wake { flex: 1; min-height: 44px; border-radius: 10px; border: 2px solid var(--orange-line); background: var(--orange-soft); color: var(--orange); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-icon { width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid #CBD5E1; background: #fff; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #CBD5E1; background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; }
.btn-danger { min-height: 44px; padding: 0 16px; border-radius: 10px; border: none; background: var(--red); color: #fff; font-weight: 600; cursor: pointer; }
.empty { background: var(--card); border: 1px dashed #94A3B8; border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 12px; }

/* panels */
.panels { display: flex; flex-wrap: wrap; gap: 24px; }
.panel { flex: 1 1 300px; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; }
.panel h2 { margin: 0 0 8px; font-size: 18px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.row:last-child { border-bottom: none; }
.row p { margin: 0; }
.row .t { font-size: 14px; font-weight: 600; }
.row .d { margin-top: 2px; font-size: 13px; color: var(--muted); }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; flex: none; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--green-soft); color: var(--green); font-size: 13px; }
.pill.warn { background: var(--orange-soft-2); color: var(--orange); }
.switch { position: relative; width: 52px; height: 30px; flex: none; border-radius: 999px; border: none; cursor: pointer; padding: 0; background: #94A3B8; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 999px; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"]::after { left: 25px; }
.switch:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #60A5FA; outline-offset: 2px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #F8FAFC; font-size: 14px; box-shadow: 0 8px 24px rgba(15,23,42,.25); z-index: 30; }
.toast.err { background: var(--red); }

/* sign-in + setup */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 8px 30px rgba(15,23,42,.08); display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand { color: var(--ink); }
.auth-card .brand svg { stroke: var(--blue); }
.auth-card h1 { font-size: 22px; }
.auth-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=password] { min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid #94A3B8; font-size: 16px; font-family: inherit; color: var(--ink); background: #fff; }
input.code { letter-spacing: .3em; font-variant-numeric: tabular-nums; text-align: center; font-size: 20px; }
.err-msg { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--red-soft); color: var(--red); font-size: 14px; }
.qr { align-self: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 14px; word-break: break-all; background: var(--line-2); padding: 10px; border-radius: 8px; color: var(--ink); }
.steps { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }

/* dialogs */
dialog { border: none; border-radius: 16px; padding: 24px; max-width: min(440px, calc(100% - 32px)); width: 100%; box-shadow: 0 20px 50px rgba(15,23,42,.3); color: var(--ink); }
dialog::backdrop { background: rgba(15,23,42,.5); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 12px; }
.big-code { font-family: ui-monospace, Consolas, monospace; font-size: 30px; font-weight: 700; letter-spacing: .12em; text-align: center; padding: 16px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-dark); margin: 0 0 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dialog-form { display: flex; flex-direction: column; gap: 12px; }

/* viewer page */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.viewer { background: #0B1220; overflow: hidden; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.v-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--ink); color: #F8FAFC; flex: none; }
.v-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.v-back { color: #F8FAFC; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; }
.v-back:hover { color: #fff; background: #1E293B; }
.v-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.v-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.v-btn { min-height: 36px; padding: 6px 12px; border-radius: 8px; border: 1px solid #334155; background: #1E293B; color: #F8FAFC; font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.v-btn:hover { background: #273449; }
.v-btn[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.v-btn.light { background: #fff; color: var(--ink); border-color: #CBD5E1; }
.v-btn.light:hover { background: var(--line-2); }
.v-select select { min-height: 36px; padding: 6px 8px; border-radius: 8px; border: 1px solid #334155; background: #1E293B; color: #F8FAFC; font: inherit; font-size: 14px; }
.v-end { min-height: 36px; }
.v-stage { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; background: #0B1220; }
.v-stage:not(.fit) { align-items: flex-start; justify-content: flex-start; touch-action: pan-x pan-y pinch-zoom; }
.v-stage:not(.fit) canvas { touch-action: pan-x pan-y pinch-zoom; }
.v-stage.fit { overflow: hidden; }
.v-stage.fit canvas { touch-action: none; }
canvas#screen { display: block; outline: none; cursor: default; flex: none; image-rendering: auto; }
canvas#screen[hidden] { display: none; }
.v-msg { max-width: 520px; padding: 24px; display: flex; flex-direction: column; gap: 12px; text-align: center; color: #CBD5E1; }
.v-msg h1 { color: #F8FAFC; font-size: 22px; }
.v-msg p { margin: 0; line-height: 1.5; }
.v-msg-btn { align-self: center; text-decoration: none; flex: none; padding: 0 20px; }
.v-clipbar { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 12px; background: #fff; color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 14px; max-width: calc(100% - 32px); z-index: 20; }
.kbd-input { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; border: 0; padding: 0; resize: none; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; }
dialog textarea { min-height: 100px; padding: 10px 12px; border-radius: 10px; border: 1px solid #94A3B8; font: inherit; font-size: 16px; resize: vertical; }
@media (max-width: 600px) {
  .v-bar { padding: 6px 8px; }
  .v-btn { padding: 6px 10px; }
  #state-pill { display: none; }
}

@media (max-width: 600px) {
  .shell { padding: 16px; }
  .topbar { padding: 12px 16px; }
  nav.side { flex-direction: row; flex-wrap: wrap; }
  nav.side a { padding: 10px 12px; }
  .btn-add { margin-top: 0; }
}
