/* ==========================================================================
   ConnectSolutions Device Console — design system
   Theme palettes live in themes.css (30 palettes, injected at runtime start).
   ========================================================================== */

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

:root {
  --bg: #171c1e; --bg-2: #202729; --bg-3: #2a3334;
  --border: #3a4747; --border-2: #4a5858;
  --text: #dce5e1; --muted: #a0b0aa; --muted-2: #76847f;
  --accent: #83aaa0; --accent-2: #a4c2b8;
  --success: #22c55e; --warn: #f59e0b; --danger: #ef4444; --info: #3b82f6;
  --term-bg: #14191a; --term-text: #b4cdc3;
  --radius: 8px; --radius-lg: 12px;
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
  --topbar-h: 58px;
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* --------------------------------------------------------------------------
   Buttons / inputs
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); border-color: var(--border-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08110f; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.danger:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.active { background: color-mix(in srgb, var(--accent) 22%, var(--bg-3)); border-color: var(--accent); color: var(--text); }

.input, input[type="text"], input[type="password"], input[type="url"], input[type="number"],
input[type="search"], select, textarea {
  width: 100%; padding: 9px 11px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; }
.field-label { display: block; margin: 12px 0 6px; }

.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--border); color: var(--text); font-size: 11px; font-weight: 700;
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border); color: var(--muted); background: var(--bg-3);
  text-transform: uppercase; letter-spacing: .04em;
}
.pill.online { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: color-mix(in srgb, var(--success) 14%, var(--bg-3)); }
.pill.offline { color: var(--muted); }
.pill.live { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 14%, var(--bg-3)); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 12%, var(--bg-3)); }

.login-eyebrow {
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}

.empty-list {
  padding: 26px 16px; text-align: center;
  color: var(--muted-2); font-size: 12.5px; font-style: italic;
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 46px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--bg-2);
}
.empty-state .icon { font-size: 30px; }

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */
#login {
  min-height: 100vh; display: grid;
  grid-template-columns: 1.05fr .95fr;
}
body.authed #login { display: none; }
body:not(.authed) #app { display: none; }
body:not(.authed) #toasts { z-index: 60; }

.login-story {
  position: relative; overflow: hidden;
  padding: 48px 54px; display: flex; flex-direction: column;
  background:
    radial-gradient(1100px 520px at 12% 6%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 62%),
    radial-gradient(760px 460px at 88% 92%, color-mix(in srgb, var(--info) 20%, transparent), transparent 60%),
    linear-gradient(160deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border);
}
.console-wordmark {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
}
.console-wordmark small { font-size: 9.5px; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.console-mark {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: #08110f; font-weight: 900; font-size: 15px;
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}
.login-story .login-eyebrow { margin-top: 64px; color: var(--accent-2); }
.login-story h1 {
  margin: 16px 0 18px; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.1; font-weight: 750;
}
.login-story h1 span { color: var(--accent); }
.login-story p { max-width: 46ch; color: var(--muted); line-height: 1.65; font-size: 14.5px; }
.login-capabilities { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.login-capabilities span {
  font-size: 11.5px; font-weight: 600; color: var(--text);
  padding: 6px 11px; border-radius: 999px;
  background: color-mix(in srgb, var(--bg-3) 80%, transparent);
  border: 1px solid var(--border);
}

.login-orbit { position: relative; width: 280px; height: 280px; margin: 44px auto 0; flex: 0 0 auto; }
.login-orbit::before {
  content: ""; position: absolute; inset: 18px; border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
  animation: spin 26s linear infinite;
}
.login-orbit::after {
  content: ""; position: absolute; inset: 52px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
@keyframes spin { to { transform: rotate(360deg); } }
.orbit-center {
  position: absolute; inset: 82px; border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 32% 26%, color-mix(in srgb, var(--accent) 30%, var(--bg-2)), var(--bg-3));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  font-size: 40px; font-weight: 800; color: var(--accent);
  box-shadow: 0 0 44px color-mix(in srgb, var(--accent) 26%, transparent);
}
.orbit-center span {
  display: block; margin-top: 2px; font-size: 7.5px; letter-spacing: .12em;
  color: var(--muted); font-weight: 700;
}
.orbit-node {
  position: absolute; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 17px;
  background: var(--bg-3); border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
}
.orbit-node:nth-child(1) { top: 4px; left: 50%; transform: translateX(-50%); }
.orbit-node:nth-child(3) { bottom: 4px; left: 50%; transform: translateX(-50%); }
.portable-caption { margin-top: auto; padding-top: 28px; color: var(--muted-2); font-size: 11.5px; }

.login-box {
  display: flex; flex-direction: column; justify-content: center;
  padding: 46px clamp(28px, 5vw, 76px);
  background: var(--bg-2);
}
.login-box h2 { font-size: 27px; margin: 12px 0 6px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-box label { display: block; margin: 0 0 6px; }
.login-box input { margin-bottom: 16px; background: var(--bg); }
.password-field { position: relative; }
.password-field input { padding-right: 68px; }
.password-field button {
  position: absolute; right: 6px; top: 5px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px; padding: 5px 9px; font-size: 11px; font-weight: 700; cursor: pointer;
}
.password-field button:hover { color: var(--text); border-color: var(--border-2); }
#loginBtn {
  margin-top: 6px; width: 100%; justify-content: center;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: var(--radius);
  background: var(--accent); color: #08110f; border: 1px solid var(--accent);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
#loginBtn:hover { background: var(--accent-2); }
#loginBtn:disabled { opacity: .6; }
.login-err {
  min-height: 18px; margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--danger);
}
.login-err.ok { color: var(--success); }
.login-footnote { margin-top: 18px; font-size: 11.5px; line-height: 1.6; color: var(--muted-2); }
.login-help { margin-top: 14px; font-size: 12px; color: var(--muted); }
.login-help summary { cursor: pointer; font-weight: 600; }
.login-help p { margin-top: 8px; line-height: 1.6; color: var(--muted-2); }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
#app {
  height: 100vh; display: grid;
  grid-template-columns: 306px minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: "top top" "side main";
}

.topbar {
  grid-area: top; position: relative; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 14px; letter-spacing: .01em; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
.brand-ver { font-size: 10.5px; color: var(--muted-2); font-weight: 600; }
#connectionState {
  font-size: 11px; font-weight: 700; color: var(--muted);
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-3);
}
#connectionState.live { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
#connectionState.dead { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
#connectionState.warn {
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border));
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-3));
}
#connectionState:hover { filter: brightness(1.08); }
#engineerIdentity { font-size: 12px; color: var(--muted); }

.stats { display: flex; gap: 6px; margin-left: auto; }
.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--bg-3); border: 1px solid var(--border); font-size: 11px; color: var(--muted);
}
.stat-pill b { font-size: 13px; color: var(--text); }
.stat-pill span:last-child { font-weight: 600; }
.stat-pill.online b { color: var(--success); }
.stat-pill.offline b { color: var(--danger); }
.stat-pill.sessions b { color: var(--warn); }

.actions { display: flex; align-items: center; gap: 3px; }
.actions button {
  position: relative; width: 32px; height: 32px; border-radius: 7px;
  background: transparent; border: 1px solid transparent; color: var(--text);
  font-size: 15px; cursor: pointer; line-height: 1;
  transition: background .15s, border-color .15s;
}
.actions button:hover { background: var(--bg-3); border-color: var(--border); }
.actions button.primary { border-color: var(--border); background: var(--bg-3); }
.actions .badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 9.5px; font-weight: 800;
  display: grid; place-items: center;
}

/* Notifications dropdown */
.notif-drop {
  position: absolute; top: calc(var(--topbar-h) - 6px); right: 12px; width: 372px;
  max-height: 70vh; display: none; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden; z-index: 50;
}
.notif-drop.open { display: flex; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 13px; border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 700;
}
.notif-head div { display: flex; gap: 6px; }
.notif-head button {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; font-size: 11px; font-weight: 600; padding: 4px 8px; cursor: pointer;
}
.notif-head button:hover { color: var(--text); border-color: var(--border-2); }
.notif-list { overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; padding: 10px 13px; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  cursor: pointer; transition: background .15s;
}
.notif-item:hover { background: var(--bg-3); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.notif-item .n-icon { font-size: 15px; }
.notif-item .n-title { font-size: 12.5px; font-weight: 600; }
.notif-item .n-msg { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.notif-item .n-time { font-size: 10.5px; color: var(--muted-2); margin-top: 3px; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  grid-area: side; display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2); border-right: 1px solid var(--border);
}
.filter-tabs { display: flex; gap: 4px; padding: 12px 12px 8px; }
.filter-tabs button {
  flex: 1; padding: 7px 6px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.filter-tabs button:hover { color: var(--text); }
.filter-tabs button.active { background: var(--bg-3); color: var(--text); border-color: var(--accent); }
.filter-count {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  background: var(--bg); border-radius: 999px; padding: 1px 6px; min-width: 20px; text-align: center;
}
.filter-tabs button.active .filter-count { color: var(--accent-2); }

.search-box { padding: 4px 12px 10px; }
.search-box input { padding: 8px 10px; font-size: 12.5px; }

.group-nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; max-height: 132px; overflow-y: auto; }
.group-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.group-chip:hover { color: var(--text); border-color: var(--border-2); }
.group-chip.active { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--bg-3)); }
.group-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

.list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 14px; }
.device-row {
  display: grid; grid-template-columns: 15px 34px minmax(0, 1fr) auto; gap: 9px;
  align-items: center; padding: 9px 10px; margin-bottom: 4px;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
}
.device-row:hover { background: var(--bg-3); }
.device-row.picked { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.device-row .sel-box {
  width: 14px; height: 14px; margin: 0; cursor: pointer; accent-color: var(--accent);
  opacity: .55; transition: opacity .15s ease;
}
.device-row:hover .sel-box, .device-row .sel-box:checked { opacity: 1; }
.sel-count { font-size: 11px; font-weight: 650; color: var(--muted); white-space: nowrap; }
.device-row.active { background: color-mix(in srgb, var(--accent) 13%, var(--bg-3)); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.device-avatar {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--border); font-size: 15px; position: relative;
}
.device-avatar .dot {
  position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--bg-2); background: var(--muted-2);
}
.device-avatar .dot.on { background: var(--success); }
.device-meta { min-width: 0; }
.device-name {
  font-size: 12.8px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.device-sub {
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.device-tags { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.device-tags .grp { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Main area
   -------------------------------------------------------------------------- */
.main { grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

.tabs-bar {
  display: flex; align-items: center; gap: 4px; min-height: 40px;
  padding: 0 10px; background: var(--bg-2); border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tabs-bar .hint { padding: 0 10px; color: var(--muted); font-size: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 7px 10px; border-radius: 7px 7px 0 0; margin-top: 6px;
  background: transparent; border: 1px solid transparent; border-bottom: none;
  color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; max-width: 260px;
}
.tab:hover { color: var(--text); background: var(--bg-3); }
.tab.active { color: var(--text); background: var(--bg); border-color: var(--border); }
.tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: 0 0 auto; }
.tab .tab-dot.on { background: var(--success); }
.tab .tab-close { opacity: .5; font-size: 14px; line-height: 1; padding: 0 2px; }
.tab .tab-close:hover { opacity: 1; color: var(--danger); }
.tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.portable-actions { border-bottom: 1px solid var(--border); background: var(--bg); }
.portable-actions > summary {
  list-style: none; cursor: pointer; padding: 6px 16px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted-2); font-weight: 700;
}
.portable-actions > summary::-webkit-details-marker { display: none; }
.portable-actions > summary::before { content: "▸ "; }
.portable-actions[open] > summary::before { content: "▾ "; }

.actions-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 6px 12px 10px;
}
.actions-bar button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 7px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.actions-bar button:hover { background: var(--bg-3); border-color: var(--border-2); }
.actions-bar button.primary { background: color-mix(in srgb, var(--accent) 20%, var(--bg-2)); border-color: var(--accent); }
.actions-bar button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }

.terminal-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.scroll-area { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 40px; }

.workspace-section-heading {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-2);
  font-weight: 700; margin: 22px 0 10px;
}

/* --------------------------------------------------------------------------
   Overview
   -------------------------------------------------------------------------- */
.empty-main { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px 40px; }
.overview-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.overview-title { display: flex; align-items: center; gap: 12px; }
.overview-title .icon {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: var(--bg-3); border: 1px solid var(--border); font-size: 19px;
}
.overview-title h2 { font-size: 19px; }
.overview-title p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.overview-counts { display: flex; gap: 8px; flex-wrap: wrap; }
.count-card {
  min-width: 96px; padding: 9px 13px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border);
}
.count-card b { display: block; font-size: 19px; line-height: 1.15; }
.count-card span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.count-card.online b { color: var(--success); }
.count-card.offline b { color: var(--danger); }
.count-card.sessions b { color: var(--warn); }

.fleet-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.fleet-toolbar .input { max-width: 340px; }
.fleet-toolbar select { max-width: 170px; }

.overview-views { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.overview-views button {
  padding: 9px 13px; background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 12.5px; font-weight: 650; cursor: pointer;
}
.overview-views button:hover { color: var(--text); }
.overview-views button.active { color: var(--text); border-bottom-color: var(--accent); }

.overview-grid { display: none; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }
.overview-grid.active { display: grid; }

.device-card {
  display: flex; flex-direction: column; gap: 10px; padding: 13px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: border-color .15s, transform .1s, box-shadow .15s;
}
.device-card:hover { border-color: var(--border-2); transform: translateY(-1px); box-shadow: var(--shadow); }
.device-card-head { display: flex; align-items: center; gap: 10px; }
.device-card-head .name { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-card-head .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.device-card .thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--term-bg); border: 1px solid var(--border);
}
.device-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.device-card .thumb .no-shot {
  position: absolute; inset: 0; display: grid; place-items: center; gap: 4px;
  color: var(--muted-2); font-size: 11.5px; text-align: center; padding: 10px;
}
.device-card-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.metric b { display: block; font-size: 12.5px; color: var(--text); text-transform: none; letter-spacing: 0; margin-top: 2px; }
.bar { height: 4px; border-radius: 3px; background: var(--bg-3); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.warn > i { background: var(--warn); }
.bar.danger > i { background: var(--danger); }
.device-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.device-card-foot .grp { display: inline-flex; align-items: center; gap: 5px; }
.device-card-foot .grp i { width: 8px; height: 8px; border-radius: 50%; display: block; }

.shot-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; }
.shot-card:hover { border-color: var(--accent); }
.shot-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--term-bg); }
.shot-card .body { padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shot-card .body .name { font-size: 12.5px; font-weight: 650; }

/* --------------------------------------------------------------------------
   Device workspace
   -------------------------------------------------------------------------- */
.console-device { display: flex; flex-direction: column; gap: 14px; }
.device-heading {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.device-heading h2 { font-size: 21px; margin-top: 4px; }
.device-heading p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.device-heading-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.device-feature-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.device-feature-tabs .btn { font-size: 12px; padding: 6px 10px; }
.device-feature-tabs .btn.active { background: var(--accent); border-color: var(--accent); color: #08110f; }

.device-panel { display: none; }
.device-panel.active { display: block; }

.session-dock {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-2); padding: 11px 13px;
}
.session-dock-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.session-dock-heading strong { font-size: 12.5px; }
#sessionDockStatus { margin-left: 8px; font-size: 11.5px; color: var(--muted); }
.session-dock-actions { display: flex; gap: 6px; }
.session-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.session-tabs button {
  padding: 5px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--muted);
}
.session-tabs button.active { color: var(--text); border-color: var(--accent); }
.session-dock-hint { margin-top: 8px; font-size: 11px; color: var(--muted-2); line-height: 1.55; }

.ws-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(268px, 1fr)); gap: 12px; }
.card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 13px 14px;
}
.card h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
  margin-bottom: 10px; font-weight: 750;
}
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.card .row + .row { border-top: 1px solid color-mix(in srgb, var(--border) 45%, transparent); }
.card .row .k { color: var(--muted); }
.card .row .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.tool-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 11px 12px; border-radius: var(--radius);
  background: var(--bg-3); border: 1px solid var(--border); cursor: pointer; text-align: left;
  color: var(--text);
}
.tool-card:hover { border-color: var(--accent); }
.tool-card .t-icon { font-size: 17px; }
.tool-card .t-title { font-size: 12.5px; font-weight: 700; }
.tool-card .t-desc { font-size: 11px; color: var(--muted); line-height: 1.45; }

.screen-frame {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border); background: var(--term-bg);
}
.screen-frame img { width: 100%; display: block; }
.screen-frame .screen-overlay {
  position: absolute; inset: auto 0 0 0; display: flex; align-items: center; gap: 8px;
  padding: 8px 11px; background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  color: #e8f2ee; font-size: 11.5px;
}
.screen-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; font-size: 11.5px; color: var(--muted); }

.live-badge::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); margin-right: 5px; animation: pulse 1.4s infinite;
}

/* Files / backstage */
.fs-bar { display: flex; gap: 6px; align-items: center; margin-bottom: 9px; flex-wrap: wrap; }
.fs-path {
  flex: 1; min-width: 180px; font-family: var(--mono); font-size: 12px;
  padding: 7px 10px; border-radius: var(--radius); background: var(--bg-3);
  border: 1px solid var(--border); overflow-x: auto; white-space: nowrap;
}
.fs-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.fs-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fs-table th {
  text-align: left; padding: 7px 9px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--border);
}
.fs-table td { padding: 6px 9px; border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent); }
.fs-table tbody tr { cursor: pointer; }
.fs-table tbody tr:hover { background: var(--bg-3); }
.fs-table .fs-name { display: flex; align-items: center; gap: 8px; }
.fs-table .fs-size, .fs-table .fs-date { color: var(--muted); white-space: nowrap; font-size: 11.5px; }

.clipboard-box { display: grid; gap: 8px; }
.clipboard-box textarea { min-height: 110px; font-family: var(--mono); font-size: 12px; }

/* Browser workspace */
.browser-frame { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-2); }
.browser-tabs { display: flex; gap: 4px; padding: 6px 6px 0; overflow-x: auto; background: var(--bg-3); }
.browser-tabs .b-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: 11.5px;
  border-radius: 7px 7px 0 0; background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer; white-space: nowrap; max-width: 190px;
}
.browser-tabs .b-tab.active { background: var(--bg-2); border-color: var(--border); border-bottom-color: var(--bg-2); color: var(--text); }
.browser-bar { display: flex; gap: 6px; align-items: center; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.browser-bar .url { flex: 1; font-family: var(--mono); font-size: 11.5px; padding: 6px 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; }
.browser-view { min-height: 280px; padding: 18px; background: linear-gradient(160deg, var(--bg), var(--term-bg)); }
.browser-view .bv-title { font-size: 19px; font-weight: 700; }
.browser-view .bv-url { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }
.browser-view .bv-body { margin-top: 16px; display: grid; gap: 8px; }
.browser-view .bv-line { height: 9px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 22%, transparent); }
.browser-view .bv-card { padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: color-mix(in srgb, var(--bg-3) 70%, transparent); font-size: 12px; }
.browser-view .typed { margin-top: 14px; padding: 9px 11px; border-radius: var(--radius); border: 1px dashed var(--border); font-size: 12px; }

/* Virtual computer */
.virtual-shell { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 12px; }
.virtual-screen {
  position: relative; aspect-ratio: 16 / 10; border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border); background: var(--term-bg); display: grid; place-items: center;
}
.virtual-screen img { width: 100%; height: 100%; object-fit: cover; }
.virtual-idle { text-align: center; color: var(--muted-2); font-size: 12px; padding: 20px; }

/* Terminal */
.terminal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
.terminal-main { min-width: 0; }
.terminal {
  height: 320px; overflow-y: auto; padding: 12px 13px;
  background: var(--term-bg); color: var(--term-text);
  border: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-family: var(--mono); font-size: 12.2px; line-height: 1.55; white-space: pre-wrap;
}
.terminal .t-cmd { color: var(--accent-2); }
.terminal .t-out { color: var(--term-text); }
.terminal .t-meta { color: var(--muted-2); font-size: 11px; }
.terminal .t-err { color: var(--danger); }
.cmd-row {
  display: flex; gap: 0; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow: hidden; background: var(--bg-2);
}
.cmd-row input { border: none; border-radius: 0; font-family: var(--mono); font-size: 12.5px; background: var(--bg-2); }
.cmd-row input:focus { box-shadow: none; }
.cmd-row button {
  padding: 0 16px; border: none; background: var(--accent); color: #08110f;
  font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.cmd-row button:hover { background: var(--accent-2); }

.device-notes { display: flex; flex-direction: column; gap: 9px; min-height: 0; }
.device-notes-head { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; font-weight: 750; color: var(--muted); }
.device-notes-compose textarea { min-height: 76px; font-size: 12px; }
.device-notes-list { flex: 1; max-height: 260px; overflow-y: auto; display: grid; gap: 7px; }
.note-item { padding: 8px 10px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--border); }
.note-item .body { font-size: 12px; line-height: 1.5; }
.note-item .meta { margin-top: 5px; font-size: 10.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.note-item .meta button { background: none; border: none; color: var(--muted-2); cursor: pointer; font-size: 11px; }
.note-item .meta button:hover { color: var(--danger); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 750;
  position: sticky; top: 0; background: var(--bg-2); z-index: 1;
}
.data-table td { padding: 8px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent); vertical-align: top; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--bg-3) 70%, transparent); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; max-height: 60vh; background: var(--bg-2); }

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  padding: 26px 16px; overflow-y: auto;
  background: rgba(0, 0, 0, .62); backdrop-filter: blur(2px);
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-box {
  width: 100%; max-width: 620px; margin: auto;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  animation: modalIn .16s ease-out;
}
.modal-box.wide { max-width: 940px; }
.modal-box.narrow { max-width: 440px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15.5px; }
.modal-header .close {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: 7px; font-size: 14px; cursor: pointer;
}
.modal-header .close:hover { background: var(--bg-3); color: var(--text); border-color: var(--border); }
.modal-body { padding: 16px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.modal-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; line-height: 1.55; }
.inline-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 9px; }
.theme-card {
  padding: 9px; border-radius: var(--radius); cursor: pointer; text-align: left;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text);
}
.theme-card:hover { border-color: var(--border-2); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.theme-swatch { display: flex; height: 26px; border-radius: 5px; overflow: hidden; border: 1px solid var(--border); }
.theme-swatch i { flex: 1; }
.theme-card .t-name { font-size: 11.5px; font-weight: 700; margin-top: 7px; text-transform: capitalize; }
.theme-card .t-mode { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }

/* List rows used inside modals */
.item-list { display: grid; gap: 8px; max-height: 56vh; overflow-y: auto; }
.item-row {
  display: flex; align-items: flex-start; gap: 11px; padding: 10px 12px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius);
}
.item-row .i-icon {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--border); font-size: 14px; flex: 0 0 auto;
}
.item-row .i-main { flex: 1; min-width: 0; }
.item-row .i-title { font-size: 12.8px; font-weight: 700; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.item-row .i-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.item-row .i-code {
  margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--border); font-family: var(--mono); font-size: 11px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 90px; overflow: auto;
}
.item-row .i-actions { display: flex; gap: 5px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12.3px; padding: 5px 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; margin-bottom: 14px; }
.stat-box { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--border); }
.stat-box b { display: block; font-size: 20px; }
.stat-box span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }

.code-block {
  background: var(--term-bg); color: var(--term-text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; font-family: var(--mono); font-size: 11.8px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto;
}

.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.switch-row .label { font-size: 12.5px; font-weight: 600; }
.switch-row .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border);
  transition: background .18s; pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg-2); transition: transform .18s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* Toasts */
#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg-2); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: 12.5px; animation: toastIn .18s ease-out;
}
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast .t-body { flex: 1; line-height: 1.45; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } }

/* Misc utilities */
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--muted) 45%, transparent);
  border-top-color: var(--accent); animation: spin .8s linear infinite; display: inline-block;
}
.hr { height: 1px; background: var(--border); margin: 14px 0; border: 0; }
.tag { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.tag.ok { color: var(--success); }
.tag.bad { color: var(--danger); }

/* Responsive */
@media (max-width: 1180px) {
  #app { grid-template-columns: 268px minmax(0, 1fr); }
  .terminal-layout { grid-template-columns: minmax(0, 1fr); }
  .virtual-shell { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  #login { grid-template-columns: 1fr; }
  .login-story { display: none; }
  .login-box { min-height: 100vh; }
  #app { grid-template-columns: 1fr; grid-template-areas: "top" "main"; }
  .sidebar {
    position: fixed; left: 0; top: var(--topbar-h); bottom: 0; width: 288px; z-index: 35;
    transform: translateX(-100%); transition: transform .2s;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .stats { display: none; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand-ver, #engineerIdentity { display: none; }
  .actions button { width: 29px; height: 29px; font-size: 13.5px; }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .notif-drop { width: calc(100vw - 16px); right: 8px; }
}
