/* ControlBridge design system — "mission control for remote desktop".
   Display: Space Grotesk (headings, brand, instrument readouts). Body: Inter.
   Signature: a deep command-navy sidebar with a signal-green active indicator. */

@font-face {
  font-family: "Space Grotesk";
  src: url("/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "InterVar";
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-body: "InterVar", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", var(--font-body);
  --font-mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;

  --ink: #0b1220;          /* command navy — sidebar */
  --ink-2: #131f38;        /* raised navy surface */
  --ink-line: rgba(255, 255, 255, 0.09);
  --canvas: #eceff6;       /* cool page canvas */
  --panel: #ffffff;
  --line: #e4e8f1;
  --line-strong: #d2d9e6;
  --text: #131b2e;
  --muted: #5b6b84;
  --subtle: #8593a8;
  --primary: #3f5bf6;      /* electric indigo */
  --primary-ink: #2c45d6;
  --signal: #12b981;       /* live / online / success */
  --signal-soft: #e7f8f1;
  --danger: #e5484d;
  --warning: #e8912a;
  --shadow: 0 14px 40px rgba(17, 27, 46, 0.07);
  --shadow-sm: 0 2px 8px rgba(17, 27, 46, 0.05);

  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; background: var(--canvas); }
body, button, input, textarea, select { font-family: var(--font-body); font-size: 14px; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.hidden { display: none !important; }

/* ---- Shell + command sidebar (the signature) ---- */
.desktop-shell, .admin-layout { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar {
  background: var(--ink);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(63, 91, 246, 0.22), transparent 60%);
  border-right: 1px solid var(--ink-line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 26px; color: #c7d2e4;
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  /* The "Bridge" mark: a white bridge symbol on the brand gradient. The legacy
     "CB" text in the markup is hidden (font-size:0) so this stays the symbol. */
  background:
    url("/brand-mark.svg") center / 28px 28px no-repeat,
    linear-gradient(140deg, var(--primary), #6b7bff);
  box-shadow: 0 8px 20px rgba(63, 91, 246, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-size: 0; color: transparent;
}
.brand strong { display: block; font-family: var(--font-display); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: #fff; }
.brand span { display: block; font-size: 11px; color: #7e8db0; margin-top: 1px; }
.sidebar-foot { margin-top: auto; padding: 10px 12px 2px; }
.version-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-display); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.04em; color: #7e8db0;
}
.version-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.side-nav { display: grid; gap: 3px; }
.side-nav a {
  position: relative; padding: 10px 12px; border-radius: 9px; color: #9fb0cd;
  font-weight: 500; font-size: 13.5px; transition: background 0.15s, color 0.15s;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #eaf0fb; }
.side-nav a.active { background: rgba(63, 91, 246, 0.16); color: #fff; }
.side-nav a.active::before {
  content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--signal); box-shadow: 0 0 12px var(--signal);
}

/* ---- Main pane ---- */
.main-pane, .admin-main { min-width: 0; padding: 26px 28px; overflow: auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.searchbox { width: min(460px, 44vw); height: 42px; background: #fff; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; box-shadow: var(--shadow-sm); }
.searchbox input { border: 0; min-width: 0; flex: 1; background: transparent; box-shadow: none; padding: 0; }
.searchbox input:focus-visible { outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.content-column, .device-column { min-width: 0; display: grid; gap: 20px; }
.welcome h1 { margin: 6px 0 0; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.025em; }
.eyebrow, .section-label { margin: 0 0 6px; color: var(--subtle); text-transform: uppercase; letter-spacing: 0.1em; font-size: 10.5px; font-weight: 700; }

/* ---- Panels + type ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-heading.compact { margin-bottom: 14px; }
h1, h2 { font-family: var(--font-display); letter-spacing: -0.015em; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.muted { color: var(--muted); }
label { display: block; margin: 14px 0 6px; color: #3c4a60; font-size: 12px; font-weight: 600; }
input, textarea, select { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--text); background: #fff; padding: 10px 12px; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(63, 91, 246, 0.14); outline: none; }
textarea { resize: vertical; min-height: 78px; }

/* ---- Buttons ---- */
button, .text-link { border-radius: 10px; padding: 10px 14px; background: var(--primary); color: #fff; font-weight: 600; transition: filter 0.15s, transform 0.05s; }
button:hover:not(:disabled), .text-link:hover { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button.secondary, .text-link { background: #eef1f8; color: #3c4a60; border: 1px solid var(--line-strong); }
button.secondary:hover { background: #e6ebf5; filter: none; }
button.danger { background: var(--danger); color: #fff; }
.trust-btn { width: 100%; margin-top: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-ink)); box-shadow: 0 8px 20px rgba(63, 91, 246, 0.28); }
.control-grant { background: var(--signal); }
.round-add { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 26px; line-height: 1; box-shadow: 0 10px 22px rgba(63, 91, 246, 0.28); }
.icon-button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; background: #eef1f8; color: var(--primary-ink); }
button.small { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }

/* ---- Badges ---- */
.status-badge, .security-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: #56677d; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-badge.active { color: #0c8a5f; border-color: #bfe9d6; background: var(--signal-soft); }
.status-badge.active::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px rgba(18, 185, 129, 0.18); }
.status-badge.idle { color: var(--muted); }
.status-badge.warn { color: #92580e; border-color: #f5dca6; background: #fdf4e3; }
.status-badge.danger { color: #a5282c; border-color: #f4c6c8; background: #fdecec; }
.tiny { font-size: 11px; word-break: break-all; }
.mono { font-family: var(--font-mono); }

/* ---- Devices ---- */
.devices-panel { min-height: 260px; }
.devices-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.device-card { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: #fbfcff; display: grid; gap: 9px; transition: border-color 0.15s, box-shadow 0.15s; }
.device-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.device-card strong { font-size: 14px; }
.device-card .device-meta { color: var(--muted); font-size: 12px; }
.device-card button { width: fit-content; }
/* Known-devices launcher tiles */
.device-tile { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 18px 14px 15px; background: #fbfcff; display: grid; justify-items: center; gap: 8px; text-align: center; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s; }
.device-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.device-tile:active { transform: translateY(1px); }
.device-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.device-tile-icon { display: grid; place-items: center; width: 66px; height: 52px; border-radius: 12px; background: #eef2fb; color: #6b7a90; }
.device-tile-trusted .device-tile-icon { background: #e7ebfe; color: var(--primary); }
.device-tile-warn .device-tile-icon { background: #fdf1e0; color: #b4791f; }
.device-tile-name { font-size: 14px; color: var(--text); }
.device-tile-status { font-size: 12px; color: var(--muted); }
.device-tile-status-trusted { color: var(--primary); font-weight: 600; }
.device-tile-status-warn { color: #b4791f; font-weight: 600; }
.device-tile-info { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); font: italic 600 12px/1 serif; cursor: pointer; }
.device-tile-info:hover { color: var(--text); border-color: var(--line-strong); }
.device-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.trusted-list { display: grid; gap: 8px; margin: 10px 0; }
.trusted-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fbfcff; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.trusted-item strong { font-size: 13px; display: block; }
.trusted-item .device-meta { color: var(--muted); font-size: 12px; }
.trusted-item .trusted-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#pairDialogSas { text-align: center; margin: 14px 0; letter-spacing: 0.18em; }
.unattended-section { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 15px; display: grid; gap: 10px; }
.activation-card { display: grid; gap: 10px; }
#activationControls { display: grid; gap: 10px; }
.empty-state { min-height: 175px; display: grid; place-items: center; align-content: center; gap: 12px; color: #9aa8bd; text-align: center; }
.empty-illustration { width: 76px; height: 62px; border-radius: 14px; display: grid; place-items: center; background: #f0f3fa; color: #c0cbdb; font-size: 32px; }

/* ---- This Device ---- */
.this-device-card { display: grid; gap: 12px; }
.live-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 5px rgba(18, 185, 129, 0.14); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); padding-top: 15px; }
.toggle-row strong { display: block; font-size: 13px; }
.toggle-row span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.switch { width: 42px; height: 24px; margin: 0; position: relative; flex: 0 0 auto; }
.switch input { display: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cfd8e6; transition: 0.16s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); transition: 0.16s; }
.switch input:checked + span { background: var(--signal); }
.switch input:checked + span::after { transform: translateX(18px); }
.auth-type { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: #eef2fb; border-radius: 10px; color: #4b6688; font-size: 12px; }
.auth-type strong { color: var(--primary-ink); }
.code-box { background: linear-gradient(180deg, #f2f5ff, #eaf0ff); border: 1px solid #d9e2fb; border-radius: 12px; padding: 16px; }
.session-code-big { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: 0.06em; color: var(--ink); }
.code-actions, .link-row, .control-pad { display: flex; align-items: center; gap: 9px; margin-top: 10px; }
.link-row input { flex: 1; min-width: 0; }

/* ---- Session workspace + viewer ---- */
.workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.session-panel, .helper-panel { box-shadow: none; }
.control-stack { display: grid; gap: 9px; margin-top: 14px; }
.session-code { display: flex; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 14px; }
.session-code span { color: var(--muted); }
.active-banner { margin-top: 13px; border-radius: 10px; background: #fdf4e3; border: 1px solid #f5dca6; color: #7a530c; padding: 12px; font-size: 12px; }
.banner-hint { display: block; margin-top: 6px; font-size: 11px; opacity: 0.85; }
.banner-hint.hidden { display: none; }

/* Inline status feedback (join / activation / verification / license request) */
.status-info { color: var(--muted); }
.status-success { color: #0d8a63; }
.status-warn { color: #a36a10; }
.status-error { color: var(--danger); }
.status-success::before, .status-warn::before, .status-error::before { content: "●"; font-size: 8px; vertical-align: 2px; margin-right: 6px; }
.request-list { display: grid; gap: 10px; }
.request-item { border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; padding: 13px; display: grid; gap: 8px; }
.request-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.request-actions button { padding: 8px 11px; font-size: 12px; }

.stage { padding: 0; overflow: hidden; }
.stage-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 18px 10px; }
.viewer-toolbar { display: flex; align-items: center; gap: 8px; padding: 0 18px 14px; flex-wrap: wrap; }
.viewer-toolbar select { width: auto; min-width: 130px; padding: 8px 10px; }
.viewer-toolbar button { padding: 8px 11px; }
.toolbar-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.toolbar-check input { width: auto; margin: 0; cursor: pointer; }
#fileStatus { flex: 1 1 auto; text-align: right; min-width: 120px; }
.video-card { position: relative; height: 430px; background: #0b1120; overflow: auto; display: grid; place-items: center; border-radius: 0 0 16px 16px; }
.video-card video { background: #0b1120; display: block; }
.video-card.fit video { width: 100%; height: 100%; object-fit: contain; }
.video-card.actual { place-items: start; }
.video-card.actual video { width: auto; height: auto; max-width: none; max-height: none; }
.video-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #7e90ab; pointer-events: none; padding: 0 24px; text-align: center; }

/* Live-session disruption overlay: reconnecting / interrupted. Sits above the
   (frozen) video so the user never mistakes a stalled frame for a live one. */
.conn-state { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 0 24px; background: rgba(7, 13, 24, 0.88); color: #e6eefc; pointer-events: none; }
.conn-state.hidden { display: none; } /* this rule is later than the global .hidden — restate it */
.conn-state strong { font-family: var(--font-display); font-size: 17px; letter-spacing: 0.01em; }
.conn-state .conn-sub { font-size: 12.5px; color: #b7c6dd; }
.conn-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #e6eefc; animation: conn-spin 0.9s linear infinite; margin-bottom: 4px; }
@keyframes conn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .conn-spinner { animation: none; border-top-color: rgba(255, 255, 255, 0.25); } }
.stats-overlay { position: absolute; top: 12px; right: 12px; width: 250px; margin: 0; padding: 11px; border-radius: 10px; color: #d8efff; background: rgba(7, 13, 24, 0.82); font-family: var(--font-mono); font-size: 11px; line-height: 1.5; white-space: pre-wrap; }

/* Fullscreen remote-control workspace */
.video-card:fullscreen { background: #000; border-radius: 0; }
.video-card:fullscreen video { background: #000; }
/* Fit mode can't overflow — hide the stray scrollbar; actual-size keeps scroll. */
.video-card.fit:fullscreen { overflow: hidden; }
.control-chip { position: absolute; top: 12px; left: 12px; z-index: 5; padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em; color: #cfe0f5; background: rgba(7, 13, 24, 0.72); border: 1px solid rgba(255, 255, 255, 0.14); pointer-events: none; }
.control-chip.chip-live { color: #d9fbe9; border-color: rgba(18, 185, 129, 0.55); }
.control-chip.chip-live::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--signal); vertical-align: 1px; }
.control-chip.chip-paused { color: #ffe9c4; border-color: rgba(217, 156, 15, 0.6); }
.fs-toolbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 12px; background: rgba(246, 249, 255, 0.94); border: 1px solid rgba(11, 17, 32, 0.12); box-shadow: 0 8px 28px rgba(2, 6, 16, 0.45); transition: opacity 0.18s ease, transform 0.18s ease; }
.fs-toolbar.fs-faded { opacity: 0; transform: translateX(-50%) translateY(-10px); pointer-events: none; }
.fs-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; margin: 0; width: auto; border: 0; border-radius: 8px; background: transparent; color: #24344d; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: none; }
.fs-ico { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fs-btn:hover:not(:disabled) { background: rgba(11, 17, 32, 0.08); transform: none; }
.fs-btn:disabled { opacity: 0.42; }
.fs-btn[aria-pressed="true"] { background: rgba(63, 91, 246, 0.14); color: var(--primary); }
.fs-btn.fs-accent { background: var(--primary); color: #fff; }
.fs-btn.fs-accent:hover:not(:disabled) { background: var(--primary); filter: brightness(1.08); }
.fs-btn.fs-accent.fs-live { background: var(--danger); }
.fs-select { width: auto; min-width: 0; padding: 5px 6px; margin: 0; border-radius: 8px; border: 1px solid rgba(11, 17, 32, 0.14); background: #fff; font-size: 12.5px; }
.fs-sep { width: 1px; height: 18px; background: rgba(11, 17, 32, 0.14); margin: 0 3px; flex: none; }
.fs-toast { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 6; max-width: 70%; padding: 7px 14px; border-radius: 999px; background: rgba(7, 13, 24, 0.82); color: #e6eefc; font-size: 12.5px; text-align: center; pointer-events: none; transition: opacity 0.25s ease; }
.fs-toast.fs-faded { opacity: 0; }
/* Exclusive Control: active state on a plain (non-accent) toolbar button. */
.fs-btn.fs-live { background: var(--signal); color: #04231a; }
.fs-btn.fs-live:hover:not(:disabled) { background: var(--signal); filter: brightness(1.06); }
/* Special-keys popover, anchored under the Keys button. */
.fs-keys-wrap { position: relative; display: inline-flex; }
.fs-keys-menu { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 7; display: flex; flex-direction: column; gap: 2px; min-width: 210px; max-height: 70vh; overflow-y: auto; padding: 6px; border-radius: 10px; background: rgba(246, 249, 255, 0.98); border: 1px solid rgba(11, 17, 32, 0.14); box-shadow: 0 12px 30px rgba(2, 6, 16, 0.5); }
.fs-keys-menu.hidden { display: none; }
.fs-keys-sep { height: 1px; margin: 4px 6px; background: rgba(11, 17, 32, 0.12); flex: 0 0 auto; }
.fs-key-item { width: 100%; text-align: left; padding: 7px 10px; margin: 0; border: 0; border-radius: 7px; background: transparent; color: #24344d; font-size: 12.5px; font-weight: 600; white-space: nowrap; box-shadow: none; }
.fs-key-item:hover:not(:disabled) { background: rgba(63, 91, 246, 0.12); color: var(--primary); transform: none; }
.fs-key-item em { font-style: normal; opacity: 0.6; font-weight: 500; }
/* Emergency release hint — always visible while exclusive is active. */
.exclusive-hint { position: absolute; top: 12px; left: 12px; z-index: 6; padding: 6px 13px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #ffe9c4; background: rgba(7, 13, 24, 0.82); border: 1px solid rgba(217, 156, 15, 0.6); pointer-events: none; }
.exclusive-hint b { color: #fff; }
/* Immersive: while exclusive, hide the state chip (the Esc hint carries the state). */
body.exclusive-active .control-chip { display: none; }
@media (prefers-reduced-motion: reduce) { .fs-toolbar, .fs-toast { transition: none; } }
.security-pill { background: #eef1f8; color: #4b6688; }

.quick-connect-card, .log-panel { box-shadow: none; }
#log { min-height: 160px; max-height: 260px; overflow: auto; margin: 0; color: #56677d; white-space: pre-wrap; font-family: var(--font-mono); font-size: 11px; line-height: 1.5; }
.add-dialog { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: 0 30px 80px rgba(11, 18, 32, 0.28); }

/* Guided license-request flow: Review -> Approve -> Send code -> Done */
.req-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 12px 0 14px; counter-reset: reqstep; }
.req-steps li { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--subtle); counter-increment: reqstep; padding: 5px 0; border-top: 2px solid var(--line); }
.req-steps li::before { content: counter(reqstep); display: grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--line); color: #fff; font-size: 10px; flex: none; }
.req-steps li.req-step-active { color: var(--primary); border-top-color: var(--primary); }
.req-steps li.req-step-active::before { background: var(--primary); }
.req-steps li.req-step-done { color: #0d8a63; border-top-color: var(--signal); }
.req-steps li.req-step-done::before { content: "✓"; background: var(--signal); }

/* System Stability: what Stable / Warning / Critical mean */
.stab-legend { display: grid; gap: 10px; }
.stab-legend-item { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; color: var(--muted); }
.stab-legend-item .status-badge { flex: none; margin-top: 1px; }
.add-dialog::backdrop { background: rgba(11, 18, 32, 0.4); backdrop-filter: blur(2px); }
.add-dialog menu { display: flex; justify-content: flex-end; padding: 0; margin: 14px 0 0; }

/* ---- Admin console ---- */
.admin-gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(120% 80% at 50% 0%, #1a2743, var(--ink)); z-index: 100; }
.admin-gate-card { max-width: 440px; width: 100%; display: grid; gap: 14px; border-radius: 18px; }

/* Connection status pill on the admin gate */
.admin-conn { display: inline-flex; align-items: center; gap: 9px; padding: 8px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; align-self: start; border: 1px solid var(--line); }
.admin-conn i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.admin-conn-checking { color: var(--muted); background: var(--canvas); }
.admin-conn-checking i { background: var(--subtle); }
.admin-conn-online { color: #0c8a5f; background: var(--signal-soft); border-color: #bfe9d6; }
.admin-conn-online i { background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.admin-conn-offline { color: #b4292d; background: #fdecec; border-color: #f4c9ca; }
.admin-conn-offline i { background: var(--danger); }

.admin-auth-form { display: grid; gap: 6px; }
.admin-auth-form.hidden { display: none; }
.admin-auth-form h2 { margin: 6px 0 0; font-family: var(--font-display); font-size: 22px; }
.admin-auth-form label { font-size: 12.5px; font-weight: 600; margin-top: 8px; }
.admin-auth-form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 10px; }
.admin-auth-form .auth-password input { padding-right: 62px; }
.admin-auth-form .trust-btn, .admin-auth-form .danger { margin-top: 12px; width: 100%; }
.admin-auth-alt { margin: 10px 0 0; text-align: center; }

.settings-form { display: grid; gap: 6px; max-width: 360px; margin-top: 8px; }
.settings-form label { font-size: 12.5px; font-weight: 600; margin-top: 6px; }
.settings-form input { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; }
.settings-form button { margin-top: 10px; justify-self: start; }
.admin-main .topbar h1 { font-size: 22px; margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; background: #fff; display: grid; gap: 6px; box-shadow: var(--shadow-sm); }
.stat-card span { color: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
.stat-card strong { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }

/* ---- Redesigned admin dashboard ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; background: #fff; display: grid; gap: 6px; box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; }
.kpi-card > span { color: var(--subtle); font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 600; }
.kpi-card > strong { font-family: var(--font-display); font-size: 34px; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.kpi-card > small { font-size: 12px; color: var(--muted); }
.kpi-card > small b { color: var(--text); }
.kpi-action { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
.kpi-action:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.kpi-action.has-pending { border-color: var(--warning); background: linear-gradient(180deg, #fff, #fff8ef); }
.kpi-action.has-pending > strong { color: #9a5a12; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-grid .panel { margin: 0; }
.dash-grid .panel-heading.compact { margin-bottom: 12px; }
.dash-list { display: grid; gap: 2px; }
.dash-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 8px; border-radius: 9px; border: 0; background: transparent; width: 100%; text-align: left; }
.dash-item + .dash-item { border-top: 1px solid var(--line); border-radius: 0; }
.dash-item strong { display: block; font-size: 13.5px; }
.dash-item span { display: block; font-size: 12px; color: var(--muted); }
.dash-item-btn { cursor: pointer; }
.dash-item-btn:hover { background: var(--canvas); }
.dash-cta { color: var(--primary-ink); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.dash-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-empty { margin: 6px 2px; font-size: 13px; color: var(--muted); }

.status-bars { display: grid; gap: 12px; }
.status-bar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.status-bar-top b { font-family: var(--font-display); }
.status-bar-track { height: 8px; border-radius: 6px; background: var(--canvas); overflow: hidden; }
.status-bar-track i { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.sb-active { background: var(--signal); }
.sb-trial { background: var(--primary); }
.sb-idle { background: var(--subtle); }
.sb-warn { background: var(--warning); }
.sb-danger { background: var(--danger); }

/* System Stability page */
.stab-hero { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: 16px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.stab-hero > div { flex: 1; display: grid; gap: 2px; }
.stab-hero strong { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.stab-hero > div > span { font-size: 13px; color: var(--muted); }
.stab-hero-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--subtle); }
.stab-checked { font-size: 12px; color: var(--subtle); white-space: nowrap; align-self: flex-start; }
.stab-hero-stable { border-color: #bfe9d6; background: var(--signal-soft); }
.stab-hero-stable .stab-hero-dot { background: var(--signal); box-shadow: 0 0 0 4px rgba(18, 185, 129, 0.18); }
.stab-hero-stable strong { color: #0c8a5f; }
.stab-hero-warning { border-color: #f5dca6; background: #fdf4e3; }
.stab-hero-warning .stab-hero-dot { background: var(--warning); box-shadow: 0 0 0 4px rgba(217, 156, 15, 0.18); }
.stab-hero-warning strong { color: #92580e; }
.stab-hero-critical { border-color: #f4c6c8; background: #fdecec; }
.stab-hero-critical .stab-hero-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(214, 57, 62, 0.16); }
.stab-hero-critical strong { color: #a5282c; }
.stab-warning { display: flex; gap: 10px; align-items: flex-start; padding: 10px 8px; font-size: 13px; line-height: 1.45; }
.stab-warning + .stab-warning { border-top: 1px solid var(--line); }
.stab-warning i { width: 8px; height: 8px; border-radius: 50%; flex: none; margin-top: 5px; background: var(--warning); }
.stab-warning-critical i { background: var(--danger); }
.kpi-card.kpi-alert-warn > strong { color: #92580e; }
.kpi-card.kpi-alert-crit > strong { color: #a5282c; }

@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.admin-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 12px 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.admin-form .field { display: grid; gap: 5px; }
.admin-form .field.grow { flex: 1; min-width: 220px; }
.admin-form .field label { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.admin-form .field label .muted { font-weight: 500; }
.admin-form select, .admin-form input { width: auto; min-width: 96px; background: #fff; }
.admin-form .field.grow input { width: 100%; }
.admin-form button { white-space: nowrap; width: auto; margin: 0; }
.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.4; }
.admin-table thead th { color: var(--subtle); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.admin-table tbody tr:hover { background: #f7f9fd; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr.empty-row:hover { background: transparent; }

/* Startup / background-running section (This Device card, desktop app only) */
.startup-section { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.startup-section.hidden { display: none; }

/* Email verification + license request (customer License card) */
.verify-block { margin: 10px 0 4px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 10px; background: var(--canvas); display: grid; gap: 6px; }
.verify-block p { margin: 0; }
.verify-row { display: flex; gap: 8px; }
.verify-row input { flex: 1; min-width: 0; text-align: center; letter-spacing: 0.35em; font-family: var(--font-display); font-size: 17px; }
.verify-row .trust-btn { width: auto; margin: 0; padding: 10px 18px; }
.license-request { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.license-request p { margin: 0; }
.license-request textarea { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font-family: var(--font-body); }
#licenseRequestForm { display: grid; gap: 8px; }
#licenseRequestForm.hidden { display: none; }

/* Minted-code result in the license-request approve dialog */
.code-result { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 12px 14px; border: 1px solid var(--signal); border-radius: 12px; background: var(--signal-soft); }
.code-result code { font-family: var(--font-display); font-size: 18px; letter-spacing: 0.04em; color: #0c8a5f; flex: 1; }
.send-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.send-row .phone-input { flex: 1; min-width: 150px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px; }
#licenseRequestForm input[type=tel] { width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 10px; }

/* Designed empty states inside tables */
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 42px 16px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--canvas); border: 1px solid var(--line); color: var(--subtle); margin-bottom: 4px; }
.empty-state strong { font-size: 14px; color: var(--text); }
.empty-state span:not(.empty-icon) { font-size: 12.5px; color: var(--muted); max-width: 46ch; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 6px 0 12px; }
.settings-grid > div { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.settings-grid span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--subtle); font-weight: 600; }
.settings-grid strong { display: block; margin-top: 4px; font-family: var(--font-display); font-weight: 600; }
.account-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.account-actions .days-input { width: 90px; }
.section-label.mt { margin-top: 14px; }
#accountDialog { max-width: 520px; }

/* ---- Responsive ---- */
@media (max-width: 1400px) {
  .workspace { grid-template-columns: 1fr; }
  .session-panel, .helper-panel { position: static; }
}
@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .device-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .desktop-shell, .admin-layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--ink-line); }
  .side-nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .side-nav a.active::before { display: none; }
  .topbar { align-items: stretch; flex-direction: column; }
  .searchbox { width: 100%; }
  .device-column { grid-template-columns: 1fr; }
}

/* In-app update banner (desktop apps only; injected by update-banner.js) */
.update-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: min(680px, calc(100vw - 32px));
  padding: 14px 16px 14px 18px;
  background: var(--ink);
  color: #f4f7ff;
  border: 1px solid var(--ink-line);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(11, 18, 32, 0.34);
}
.update-banner.hidden { display: none; }
.update-banner-body { display: flex; align-items: center; gap: 12px; min-width: 0; }
.update-dot {
  flex: none;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 12px var(--signal);
}
.update-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.update-text strong { font-size: 14px; }
.update-text span { font-size: 12.5px; color: rgba(244, 247, 255, 0.72); }
.update-actions { display: flex; gap: 8px; flex: none; }
.update-actions button { padding: 9px 14px; font-size: 13px; }
.update-actions .secondary { background: rgba(255, 255, 255, 0.08); color: #f4f7ff; }
.update-actions .secondary.hidden { display: none; }
@media (max-width: 560px) {
  .update-banner { flex-direction: column; align-items: stretch; gap: 12px; left: 16px; right: 16px; transform: none; }
  .update-actions button { flex: 1; }
}

/* ============================================================
   Auth (login / register) — split mission-control layout
   ============================================================ */
.auth-page { display: grid; grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); min-height: 100vh; }

/* Signature: the command-navy brand panel */
.auth-brand {
  background: radial-gradient(120% 90% at 15% 10%, #1a2748 0%, var(--ink-2) 42%, var(--ink) 100%);
  color: #eaf0ff;
  padding: 40px 44px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  position: relative; overflow: hidden;
}
.auth-brand::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(60% 40% at 85% 100%, rgba(63, 91, 246, 0.22), transparent 70%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand strong { color: #fff; }
.auth-brand .brand span { color: rgba(234, 240, 255, 0.6); }

.auth-brand-body h1 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 40px); line-height: 1.08; letter-spacing: -0.02em;
  margin: 0 0 16px; color: #fff; font-weight: 600;
}
.auth-brand-body p { margin: 0 0 34px; max-width: 34ch; color: rgba(234, 240, 255, 0.72); font-size: 15px; line-height: 1.5; }

/* Connection motif: two device nodes joined by a live signal */
.auth-link { display: flex; align-items: center; gap: 14px; }
.auth-node {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 18px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--ink-line);
  color: #cdd8f5; font-size: 12px; min-width: 96px;
}
.auth-node svg { color: #aab9e6; }
.auth-wire { flex: 1; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.12); position: relative; overflow: hidden; max-width: 90px; }
.auth-wire i {
  position: absolute; top: 0; left: -30%; height: 100%; width: 30%;
  background: linear-gradient(90deg, transparent, var(--signal), transparent);
  animation: authPulse 2.4s linear infinite;
}
@keyframes authPulse { to { left: 100%; } }

.auth-status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(234, 240, 255, 0.66); }
.auth-status i { width: 8px; height: 8px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 10px var(--signal); }

/* Form column */
.auth-form-col { display: flex; align-items: center; justify-content: center; padding: 40px 24px; position: relative; background: var(--panel); }
.auth-back { position: absolute; top: 26px; right: 28px; color: var(--muted); font-size: 13px; font-weight: 500; }
.auth-back:hover { color: var(--text); }

.auth-card { width: 100%; max-width: 400px; }

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 26px; background: var(--canvas); border-radius: 12px; }
.auth-tab { background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 9px 12px; border-radius: 9px; }
.auth-tab.is-active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }

.auth-form h2 { font-family: var(--font-display); font-size: 24px; letter-spacing: -0.01em; margin: 0 0 4px; }
.auth-lede { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.auth-form label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin: 14px 0 6px; }
.auth-form input { width: 100%; padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font-size: 14px; }

.auth-password { position: relative; }
.auth-password input { padding-right: 62px; }
.auth-reveal {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  background: transparent; color: var(--primary-ink); font-weight: 600; font-size: 12.5px;
  padding: 6px 8px; border-radius: 7px;
}
.auth-reveal:hover { background: var(--canvas); }

.auth-invite { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.auth-invite summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); list-style: none; }
.auth-invite summary::-webkit-details-marker { display: none; }
.auth-invite summary::before { content: "+ "; color: var(--subtle); }
.auth-invite[open] summary::before { content: "– "; }
.auth-hint { margin: 6px 0 0; font-size: 12px; color: var(--subtle); }

.auth-options { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 4px; }
.auth-remember { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; margin: 0; }
.auth-remember input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; cursor: pointer; }

/* Text links (forgot password, activation help) */
.auth-textlink { background: transparent; color: var(--primary-ink); font-weight: 600; font-size: 13px; padding: 0; border-radius: 4px; }
.auth-textlink:hover { text-decoration: underline; }
.auth-footlinks { margin: 16px 0 0; text-align: center; }

/* Saved-account suggestion */
.auth-saved { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; padding: 12px 12px 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--canvas); }
.auth-saved-id { display: flex; align-items: center; gap: 11px; min-width: 0; cursor: pointer; }
.auth-saved-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; color: #fff; background: linear-gradient(140deg, var(--primary), #6b7bff); }
.auth-saved-id strong { display: block; font-size: 13.5px; line-height: 1.2; }
.auth-saved-id span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.auth-forget { background: transparent; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 6px 8px; border-radius: 7px; }
.auth-forget:hover { background: #fff; color: var(--danger); }

.auth-submit { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; font-weight: 600; border-radius: 10px; background: var(--primary); color: #fff; }
.auth-submit:hover:not(:disabled) { background: var(--primary-ink); }

.auth-message { margin: 18px 0 0; padding: 11px 13px; border-radius: 10px; font-size: 13px; line-height: 1.45; background: var(--signal-soft); color: #0c8a5f; border: 1px solid #bfe9d6; }
.auth-message.is-error { background: #fdecec; color: #b4292d; border-color: #f4c9ca; }
.auth-message.is-warning { background: #fef4e6; color: #9a5a12; border-color: #f4d9ac; }

.auth-continue { display: block; margin-top: 12px; padding: 11px; text-align: center; font-weight: 600; font-size: 14px; color: #fff; background: var(--primary); border-radius: 10px; }
.auth-continue:hover { background: var(--primary-ink); }

/* Help panels */
.auth-help { margin: 16px 0 0; padding: 13px 14px; border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: 10px; background: var(--canvas); }
.auth-help strong { display: block; font-size: 13px; margin-bottom: 4px; }
.auth-help p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

@media (max-width: 860px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { padding: 24px 22px; gap: 20px; flex-direction: row; align-items: center; justify-content: space-between; }
  .auth-brand-body h1 { font-size: 20px; margin-bottom: 6px; }
  .auth-brand-body p, .auth-link, .auth-brand-foot { display: none; }
  .auth-back { position: static; align-self: flex-end; margin-bottom: 8px; }
  .auth-form-col { flex-direction: column; align-items: stretch; padding: 20px 18px 36px; }
}
