/*
 * Shared form, table, notification and theme primitives.
 * The desktop-client section below defines the SukiUI Blue workspace layout.
 * Colours are written once with light-dark(); `data-theme` on <html> forces a scheme.
 */

:root {
  color-scheme: light dark;

  --bg: light-dark(#ffffff, #09090b);
  --surface: light-dark(#ffffff, #09090b);
  --surface-2: light-dark(#f4f4f5, #18181b);
  --surface-3: light-dark(#fafafa, #111113);
  --border: light-dark(#e4e4e7, #27272a);
  --border-strong: light-dark(#d4d4d8, #3f3f46);
  --text: light-dark(#09090b, #fafafa);
  --muted: light-dark(#71717a, #a1a1aa);
  --faint: light-dark(#a1a1aa, #71717a);

  --primary: light-dark(#18181b, #fafafa);
  --primary-hover: light-dark(#27272a, #e4e4e7);
  --on-primary: light-dark(#fafafa, #18181b);
  --ring: light-dark(rgba(24, 24, 27, 0.18), rgba(250, 250, 250, 0.22));

  --brand: #6366f1;
  --brand-2: #8b5cf6;

  --ok: light-dark(#15803d, #4ade80);
  --ok-soft: light-dark(#f0fdf4, rgba(74, 222, 128, 0.1));
  --ok-line: light-dark(#bbf7d0, rgba(74, 222, 128, 0.3));
  --danger: light-dark(#dc2626, #f87171);
  --danger-soft: light-dark(#fef2f2, rgba(248, 113, 113, 0.1));
  --danger-line: light-dark(#fecaca, rgba(248, 113, 113, 0.3));
  --warn: light-dark(#b45309, #fbbf24);
  --warn-soft: light-dark(#fffbeb, rgba(251, 191, 36, 0.1));
  --warn-line: light-dark(#fde68a, rgba(251, 191, 36, 0.3));
  --accent: light-dark(#6d28d9, #c4b5fd);
  --accent-soft: light-dark(#f5f3ff, rgba(196, 181, 253, 0.1));
  --accent-line: light-dark(#ddd6fe, rgba(196, 181, 253, 0.3));
  --info: light-dark(#0369a1, #7dd3fc);
  --info-soft: light-dark(#f0f9ff, rgba(125, 211, 252, 0.1));
  --info-line: light-dark(#bae6fd, rgba(125, 211, 252, 0.3));

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-lg: light-dark(0 20px 50px rgba(9, 9, 11, 0.18), 0 20px 50px rgba(0, 0, 0, 0.6));
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 600; }
h2 { font-size: 22px; font-weight: 600; overflow-wrap: anywhere; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.icon { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-small { width: 30px; }
.btn-block { width: 100%; height: 40px; }
.btn.is-busy { pointer-events: none; opacity: 0.7; }

/* ---------- forms ---------- */

.field { display: grid; gap: 6px; margin-top: 14px; }
.field > span { font-size: 13px; font-weight: 500; }
input:not([type=checkbox]) {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--faint); }
input:focus { outline: none; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
input:disabled { opacity: 0.5; cursor: not-allowed; }
.form-error {
  display: flex;
  align-items: flex-start;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}

/* ---------- login ---------- */

.login { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.login-side {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 44px;
  background: #09090b;
  color: #fafafa;
  overflow: hidden;
}
.login-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 400px at 0% 0%, rgba(99, 102, 241, 0.35), transparent 60%),
    radial-gradient(600px 400px at 100% 100%, rgba(139, 92, 246, 0.25), transparent 60%);
  pointer-events: none;
}
.login-brand { position: relative; display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 600; }
.login-brand.compact { display: none; margin-bottom: 28px; color: var(--text); }
.login-quote { position: relative; max-width: 460px; }
.login-quote-text { font-size: 17px; line-height: 1.6; color: rgba(250, 250, 250, 0.92); }
.login-quote-foot { margin-top: 12px; font-size: 13px; color: rgba(250, 250, 250, 0.55); }
.login-main { display: grid; place-items: center; padding: 32px 24px; }
.login-card { width: 100%; max-width: 360px; }
.login-head { margin-bottom: 8px; }
.login-head p { margin-top: 6px; }
.login-card .btn-block { margin-top: 22px; }
.login-foot { display: flex; align-items: flex-start; gap: 6px; margin-top: 18px; font-size: 12.5px; line-height: 1.5; }
.login-foot .icon { width: 13px; height: 13px; margin-top: 3px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  flex: 0 0 auto;
}
.brand-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell: top bar + page ---------- */

.shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.sidebar-brand-text { display: grid; line-height: 1.2; }
.sidebar-brand-text strong { font-size: 14px; font-weight: 600; }
.sidebar-brand-text small { font-size: 12px; color: var(--muted); }
.topbar-foot { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: 0 0 auto; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 6px; }
.user-chip-text { display: grid; min-width: 0; line-height: 1.2; }
.user-chip-text strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.user-chip-text small { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  flex: 0 0 auto;
}
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* Steps: brand > device > version, each one a button that jumps back. */
.steps { display: flex; align-items: center; gap: 4px; min-width: 0; margin-left: 12px; }
.step-sep { color: var(--faint); width: 14px; height: 14px; }
.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  min-width: 0;
  padding: 0 10px 0 6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.step:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.step:disabled { cursor: default; opacity: 0.6; }
.step.active { color: var(--text); }
.step.done { color: var(--text); }
.step-num {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 11.5px;
  font-weight: 600;
  flex: 0 0 auto;
}
.step.active .step-num { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.step.done .step-num { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.step-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.step:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.page { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px 24px 56px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { margin-top: 4px; }
.head-with-back { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.head-with-back > .btn { margin: 2px 0 0 -8px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.head-actions .search-box { width: 260px; }

/* ---------- cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 15px; }
.card-head p { margin-top: 2px; font-size: 13px; }
.card-head.pad-x { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.group-card { margin-bottom: 16px; }
.group-title { display: flex; align-items: center; gap: 8px; }
.group-title .icon { color: var(--muted); }
.group-title .count { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 2px; }
.empty-card { padding: 56px 16px; text-align: center; color: var(--muted); }
.empty-card .retry, .empty .retry { margin-top: 12px; }

/* ---------- brand grid ---------- */

.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.brand-card {
  display: grid;
  gap: 4px;
  min-height: 84px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.brand-card:hover { border-color: var(--border-strong); background: var(--surface-3); }
.brand-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.brand-card strong { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.brand-card small { color: var(--muted); font-size: 12.5px; }
.brand-grid .empty { grid-column: 1 / -1; }
.brand-grid.is-loading { opacity: 0.5; pointer-events: none; }

/* ---------- toolbar / search ---------- */

.search-box { position: relative; flex: 0 1 320px; max-width: 340px; }
.search-box .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.major-chips { margin-bottom: 16px; }
.major-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-sm); }
.chip small { color: var(--muted); font-size: 12px; }
.chip:hover { background: var(--surface-2); }
.chip.active { border-color: var(--primary); background: var(--primary); color: var(--on-primary); font-weight: 500; }
.chip.active small { color: inherit; opacity: 0.75; }
.chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; transition: opacity 0.15s; }
.table-wrap.is-loading { opacity: 0.5; pointer-events: none; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th, td.nowrap, td.col-actions { white-space: nowrap; }
th { height: 40px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
td { height: 48px; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-3); }
tbody tr:last-child td { border-bottom: none; }
table.compact { min-width: 480px; }
table.devices tbody tr { cursor: pointer; }
table.devices td.name { font-weight: 500; }
table.devices .col-actions .icon { color: var(--faint); }
td.version { font-weight: 500; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
td.size, td.date { color: var(--muted); white-space: nowrap; }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 0; }
.row-actions .btn { padding: 0 10px; box-shadow: none; }
.empty { padding: 56px 16px; text-align: center; color: var(--muted); }
tbody tr.row-flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge-ok { color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.badge-danger { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.badge-warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.badge-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge-info { color: var(--info); border-color: var(--info-line); background: var(--info-soft); }
.badge-plain::before { content: none; }

/* ---------- dialog ---------- */

.modal {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal-wide { width: min(640px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(0, 0, 0, 0.6); }
.modal[open] { animation: pop 0.16s ease-out; }
.modal-head h3 { font-size: 17px; overflow-wrap: anywhere; }
.modal-head p { margin-top: 6px; font-size: 13.5px; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

.credential {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 18px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.credential:empty { display: none; }
.credential dt { color: var(--muted); font-size: 13px; }
.credential dd { margin: 0; font-size: 13.5px; word-break: break-all; }
.credential dd.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; user-select: all; }

.links { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 16px; }
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.link-row .link-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  color: var(--text);
  user-select: all;
}
.link-row .link-host { display: block; font-size: 11.5px; color: var(--muted); font-family: inherit; }
.link-row .btn { box-shadow: none; }
.links .empty { padding: 28px 12px; }
.links .loading { padding: 28px 12px; text-align: center; color: var(--muted); }

/* ---------- toasts ---------- */

.toasts { position: fixed; right: 24px; bottom: 24px; z-index: 50; display: grid; gap: 8px; pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  animation: rise 0.18s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; }
.toast-success::before { background: var(--ok); }
.toast-error::before { background: var(--danger); }
.toast.leaving { opacity: 0; transform: translateY(6px); }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-brand.compact { display: flex; }
  .login-main { align-items: start; padding-top: 64px; }

  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .topbar-brand .sidebar-brand-text small { display: none; }
  .steps { order: 3; flex-basis: 100%; margin: 0; overflow-x: auto; }
  .step-text { max-width: 120px; }
  .user-chip-text { display: none; }
}

@media (max-width: 640px) {
  .page { padding: 16px 12px 40px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions { flex-wrap: wrap; }
  .head-actions .search-box, .search-box { width: auto; max-width: none; flex: 1 1 100%; }
  .brand-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .brand-card { min-height: 72px; padding: 12px 14px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .modal { padding: 18px; }
  .link-row { flex-wrap: wrap; }
  .link-row .link-url { flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; }

  /* Tables become stacked cards: each cell shows its column header as a label. */
  .table-wrap table, .table-wrap table.compact { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; height: auto; }
  .table-wrap tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: none; }
  .table-wrap td { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px 8px; padding: 4px 0; border: none; text-align: right; white-space: normal; }
  .table-wrap td[data-label]::before { content: attr(data-label); flex: 0 0 auto; margin-right: auto; color: var(--muted); font-size: 12px; text-align: left; }
  .table-wrap td.name, .table-wrap td.version { display: block; text-align: left; font-size: 15px; padding-bottom: 8px; }
  .table-wrap td.name::before, .table-wrap td.version::before { content: none; }
  .table-wrap td.col-actions { display: block; width: auto; padding-top: 10px; text-align: left; white-space: normal; }
  .table-wrap td.col-actions::before { content: none; }
  .table-wrap td.col-actions:empty { display: none; }
  table.devices .col-actions { display: none; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  .row-actions .btn { padding: 0 10px; border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
  .table-wrap td.empty { display: block; text-align: center; padding: 40px 12px; }
  .table-wrap td.empty::before { content: none; }
  .table-wrap tr:has(> td.empty) { padding: 0; }
}

/* Desktop client: SukiUI Blue, device browser and two firmware panes. */
:root {
  --bg: light-dark(#f3f6fc, #111824);
  --surface: light-dark(#ffffff, #1a2332);
  --surface-2: light-dark(#edf3fd, #243249);
  --surface-3: light-dark(#f6f9ff, #202d40);
  --border: light-dark(#e3eaf5, #2c3b51);
  --border-strong: light-dark(#bbd0f1, #46668e);
  --text: light-dark(#253650, #e1eafa);
  --muted: light-dark(#77869d, #9aacc5);
  --faint: light-dark(#95a2b6, #8294af);
  --primary: light-dark(#3978e8, #619bff);
  --primary-hover: light-dark(#2865d2, #7aabff);
  --on-primary: light-dark(#ffffff, #101c30);
  --ring: #3978e825;
  --brand: #3978e8;
  --brand-2: #3978e8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 3px 14px #193e7410;
}
body { font-size: 13px; }
a { color: var(--primary); }
.shell { max-width: 1680px; margin: auto; padding: 0 30px; }
.topbar { position: static; height: 110px; padding: 0 4px; border: 0; background: transparent; backdrop-filter: none; justify-content: space-between; }
.topbar-brand { gap: 15px; }
.topbar-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; font-size: 25px; font-weight: 650; box-shadow: 0 5px 14px #3978e824; }
.topbar h1 { font-size: 23px; font-weight: 650; letter-spacing: .02em; }
.topbar-brand p { margin-top: 5px; font-size: 12px; }
.topbar-foot { margin-left: auto; gap: 12px; }
.avatar { background: var(--surface-2); color: var(--primary); border: 1px solid var(--border); }
.page { max-width: none; width: 100%; padding: 0; }
.card { box-shadow: 0 4px 24px #294b7a05; }
.filter-bar { display: grid; grid-template-columns: 220px 180px minmax(0,1fr); gap: 20px; padding: 16px 20px 18px; margin-bottom: 18px; }
.filter-bar .field { margin: 0; gap: 7px; }
.field > span { color: var(--muted); font-size: 12px; }
input:not([type=checkbox]), select { height: 39px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-3); box-shadow: none; }
select { width: 100%; color: var(--text); font: inherit; padding: 0 12px; }
select:focus-visible { outline: 3px solid var(--ring); border-color: var(--primary); }
.search-field .search-box { width: 100%; max-width: none; }
.workspace { display: grid; grid-template-columns: 278px minmax(0,1fr); gap: 18px; align-items: stretch; }
.device-panel { min-width: 0; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; padding: 20px 18px 15px; }
.panel-heading h2, .download-heading h2 { font-size: 15px; font-weight: 650; }
.panel-heading p { margin-top: 5px; font-size: 11px; }
.panel-tag { font-size: 11px; color: var(--primary); background: var(--surface-2); border-radius: 5px; padding: 3px 8px; }
#devices-wrap { height: min(55vh, 570px); min-height: 340px; overflow: auto; padding: 0 9px 12px; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.devices, table.compact.devices { min-width: 0; display: block; }
.devices thead { display: none; }
.devices tbody { display: block; }
.devices tbody tr { display: grid; grid-template-columns: minmax(0,1fr) 18px; padding: 11px 12px; border: 1px solid transparent; border-radius: 9px; margin: 3px 0; cursor: pointer; position: relative; }
.devices tbody tr.selected { background: var(--surface-2); border-color: var(--border-strong); }
.devices tbody tr.selected::before { content: ''; position: absolute; left: -1px; top: 15px; bottom: 15px; width: 3px; border-radius: 3px; background: var(--primary); }
.devices tbody td { display: block; height: auto; border: 0; padding: 0; text-align: left; }
.devices td.name { font-size: 13px; line-height: 1.7; color: var(--text); }
.devices td:nth-child(2) { grid-row: 2; }
.devices td .badge { border: 0; padding: 0; background: transparent; color: var(--muted); font-size: 11px; height: auto; }
.devices td.col-actions { display: block; grid-column: 2; grid-row: 1 / 3; align-self: center; }
.devices td.empty { grid-column: 1 / -1; padding: 30px 4px; font-size: 12px; }
.firmware-panel { padding: 21px; min-width: 0; }
.firmware-panel .page-head { align-items: center; gap: 14px; margin-bottom: 19px; }
.eyebrow { display: block; color: var(--muted); font-size: 11px; margin-bottom: 5px; }
.firmware-panel h2 { font-size: 20px; }
.firmware-panel .page-head p { font-size: 11px; margin-top: 6px; }
.head-actions .search-box { width: 210px; }
.btn { box-shadow: none; height: 36px; }
.btn:focus-visible, tr[tabindex]:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.major-chips { border-bottom: 1px solid var(--border); padding-bottom: 16px; margin-bottom: 18px; gap: 8px; }
.chip { border-radius: 7px; box-shadow: none; background: var(--surface-3); height: 29px; font-size: 11px; }
.chip.active { background: var(--surface-2); color: var(--primary); border-color: var(--border-strong); }
.firmware-columns { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.firmware-columns:has(.group-card[hidden]) { grid-template-columns: minmax(0,1fr); }
.group-card { margin: 0; min-width: 0; }
.group-card .card-head { padding: 0 0 12px; gap: 6px; }
.group-title { color: var(--primary); }
.group-title .icon { color: inherit; }
.group-title h3 { font-size: 13px; }
.group-card .card-head > .muted { font-size: 10px; }
.group-card .table-wrap { max-height: min(43vh,450px); overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.versions { min-width: 0; display: block; }
.versions thead { display: none; }
.versions tbody { display: grid; gap: 9px; }
.versions tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-3); }
.versions tbody tr:hover { border-color: var(--border-strong); }
.versions tbody td { padding: 0; border: 0; height: auto; min-width: 0; text-align: left; font-size: 11px; }
.versions td.version { grid-column: 1 / -1; grid-row: 1; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.65; font-family: 'Segoe UI','Microsoft YaHei',sans-serif; }
.versions td:first-child { color: var(--muted); grid-row: 2; }
.versions td:nth-child(3) { grid-row: 2; justify-self: end; }
.versions .badge { font-size: 10px; height: 19px; padding: 0 6px; }
.versions .badge::before { display: none; }
.versions td.size { grid-column: 1; grid-row: 3; align-self: center; }
.versions td.date { grid-column: 1; grid-row: 4; }
.versions td.col-actions { grid-column: 2; grid-row: 3 / 5; width: auto; align-self: center; }
.versions .btn { font-size: 11px; height: 29px; color: var(--primary); background: var(--surface); padding: 0 9px; gap: 5px; }
.versions .btn:hover { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.versions .btn .icon { width: 12px; height: 12px; }
.empty-card { border: 1px dashed var(--border); border-radius: 12px; padding: 100px 20px; background: var(--surface-3); }
.empty-card > .icon { width: 38px; height: 38px; color: var(--border-strong); margin-bottom: 14px; }
.empty-card h3 { font-size: 15px; margin-bottom: 8px; color: var(--muted); }
.empty-card p { font-size: 12px; }
.download-panel { margin-top: 18px; padding: 18px 21px; }
.download-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.download-heading .group-title { color: var(--text); }
#download-hint { background: var(--surface-3); border-radius: 8px; padding: 18px 14px; font-size: 12px; }
#link-dialog .modal-head h3 { font-size: 13px; }
#link-dialog .modal-head p { font-size: 11px; }
.credential { display: flex; flex-wrap: wrap; align-items: center; margin-top: 12px; padding: 8px 12px; font-size: 11px; }
.credential dd, .credential dt { font-size: 11px; }
.links { margin-top: 10px; }
.link-row { background: var(--surface-3); }
.modal-actions { margin-top: 10px; }
.statusbar { padding: 13px 4px 20px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin-right: 6px; }
.brand-picker { padding: 25px; min-height: 380px; }
.brand-picker h2 { font-size: 19px; }
.brand-picker .page-head p { font-size: 12px; }
.brand-grid { grid-template-columns: repeat(auto-fill,minmax(180px,1fr)); gap: 14px; }
.brand-card { min-height: 100px; border-radius: 11px; padding: 20px; background: var(--surface-3); box-shadow: none; }
.brand-card:hover { border-color: var(--primary); background: var(--surface-2); }
.brand-card strong { color: var(--primary); font-size: 17px; }
.login-side { background: #1c3864; }
.login-side::before { background: radial-gradient(ellipse at top left,#3978e85a,transparent 70%); }
.login-card { max-width: 390px; }
.login-card > p.muted { font-size: 12px; margin-top: 16px; line-height: 1.8; }
@media(min-width:1500px) { .workspace { grid-template-columns: 310px minmax(0,1fr); } }
@media(max-width:1100px) { .shell { padding: 0 18px; } .workspace { grid-template-columns: 235px minmax(0,1fr); gap: 14px; } .firmware-panel .page-head { flex-wrap: wrap; } .head-actions { width: 100%; } .head-actions .search-box { max-width: none; flex: 1; } .filter-bar { grid-template-columns: 180px 150px minmax(0,1fr); } }
@media(max-width:760px) { .shell { padding: 0 12px; } .topbar { height: 94px; padding: 12px 0; gap: 8px; flex-wrap: nowrap; } .topbar h1 { font-size: 19px; } .topbar-brand p { font-size: 10px; } .topbar-brand { gap: 10px; } .topbar-brand .brand-mark { width: 40px; height: 40px; font-size: 21px; } .topbar-foot { gap: 3px; } .topbar-foot .avatar { display: none; } .filter-bar { grid-template-columns: 1fr 1fr; gap: 12px; padding: 15px; } .search-field { grid-column: 1/-1; } .workspace { grid-template-columns: minmax(0,1fr); } #devices-wrap { height: 185px; min-height: 0; } .firmware-panel { padding: 16px; } .firmware-columns { gap: 12px; } .firmware-panel h2 { font-size: 18px; } .group-card .card-head > .muted { display: none; } .versions td::before, .devices td::before { display: none !important; } .statusbar { flex-direction: column; gap: 6px; } .brand-picker { padding: 18px; } .download-panel { padding: 16px; } }
@media(max-width:480px) { .firmware-columns { grid-template-columns: minmax(0,1fr); } .group-card .table-wrap { max-height: 380px; } .brand-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } .brand-card { padding: 14px; } .versions .row-actions { display: block; } .user-chip { display: none; } .topbar-brand p { max-width: 180px; } }
