:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --sidebar: #182433;
  --sidebar-muted: #91a1b4;
  --text: #17202c;
  --muted: #667085;
  --border: #d9e1e8;
  --accent: #1769e0;
  --accent-strong: #0f54b7;
  --green: #0b8f6a;
  --amber: #b46a00;
  --red: #c43d3d;
  --shadow: 0 14px 40px rgba(22, 36, 50, 0.08);
  --radius: 8px;
  --sidebar-width: 248px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.svg-sprite {
  display: none;
}

.toast {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 40;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-left-color: var(--red);
}

.toast.success {
  border-left-color: var(--green);
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 22, 34, 0.52);
}

.modal-dialog {
  width: min(640px, 100%);
  max-height: min(840px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(12, 22, 34, 0.24);
}

.modal-dialog.wide {
  width: min(900px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2,
.modal-head p,
.modal-error {
  margin: 0;
}

.modal-head h2 {
  font-size: 21px;
}

.modal-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.modal-close {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #475467;
  font-size: 25px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--surface-soft);
}

.modal-form {
  padding: 18px 20px 20px;
}

.modal-fields {
  display: grid;
  gap: 15px;
}

.modal-field {
  display: grid;
  gap: 7px;
}

.modal-field > span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.modal-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.modal-field input[type="file"] {
  height: auto;
  min-height: 52px;
  padding: 8px;
  border-style: dashed;
  background: #f8fbff;
}

.modal-field input[type="file"]::file-selector-button {
  height: 34px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid #c9daf2;
  border-radius: var(--radius);
  background: #e8f0fb;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.modal-picker {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}

.modal-picker-options {
  max-height: 280px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 6px;
  overflow-y: auto;
}

.modal-picker-option {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid #d9e2ec;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.modal-picker-option:hover {
  border-color: #9fbce8;
  background: #f4f8ff;
}

.modal-picker-option.selected {
  border-color: var(--accent);
  background: #eaf2ff;
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.2);
}

.modal-picker-option span,
.modal-picker-option strong,
.modal-picker-option small {
  min-width: 0;
  display: block;
}

.modal-picker-option-main {
  flex: 1 1 auto;
}

.modal-picker-option strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.modal-picker-option.selected strong {
  color: #0b55bd;
}

.modal-picker-option small {
  margin-top: 3px;
}

.modal-picker-option-state {
  flex: 0 0 auto;
  display: grid !important;
  justify-items: end;
  gap: 5px;
}

.modal-picker-option em,
.modal-picker-option-state b {
  flex: 0 0 auto;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.modal-picker-option em {
  color: var(--accent);
}

.modal-picker-option-state b {
  display: none;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.modal-picker-option.selected .modal-picker-option-state b {
  display: inline-flex;
}

.modal-picker.compact .modal-picker-option {
  min-height: 54px;
}

.modal-picker.compact .modal-picker-option-main small {
  display: none;
}

.modal-picker-selection,
.modal-picker-empty {
  color: var(--muted);
  font-size: 12px;
}

.modal-picker-selection {
  min-height: 32px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 2px;
}

.modal-picker-selection-label {
  flex: 0 0 auto;
  color: #344054;
  font-weight: 700;
}

.modal-picker-selection-chips {
  min-width: 0;
  display: flex !important;
  flex-wrap: wrap;
  gap: 5px;
}

.modal-picker-selection-chip {
  max-width: 190px;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid #b8d2f7;
  border-radius: var(--radius);
  background: #edf5ff;
  color: #184f97;
  font-weight: 700;
}

.modal-picker-selection-chip b {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
}

.modal-picker-selection-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-picker-empty {
  padding: 18px 8px;
  text-align: center;
}

.modal-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.modal-choice-option {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  border: 2px solid #d9e2ec;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.modal-choice-option:hover {
  border-color: #9fbce8;
  background: #f4f8ff;
}

.modal-choice-option.selected {
  border: 2px solid var(--accent);
  background: #eef5ff;
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.2);
}

.modal-choice-option strong,
.modal-choice-option small {
  display: block;
}

.modal-choice-option strong {
  font-size: 13px;
}

.modal-choice-option small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.modal-error {
  margin-top: 12px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: #fff0f0;
  color: var(--red);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.program-devices-dialog {
  width: min(1040px, 100%);
}

.program-devices-content {
  padding: 18px 20px 20px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 210px;
}

.mini-btn.danger {
  border-color: #f3b7b7;
  background: #fff2f2;
  color: var(--red);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px;
  background:
    linear-gradient(120deg, rgba(23, 105, 224, 0.08), transparent 38%),
    linear-gradient(160deg, transparent 55%, rgba(11, 143, 106, 0.08)),
    var(--bg);
}

.login-panel {
  width: 460px;
  display: grid;
  gap: 22px;
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #13202e;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  font-size: 13px;
}

.login-panel h1,
.topbar h1,
.panel h2,
.sidebar-brand h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 26px;
  line-height: 1.25;
}

.login-panel p,
.panel-head p,
.sidebar-brand p,
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: end;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid label {
  display: grid;
  gap: 7px;
}

.form-grid label > span {
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd8e2;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 116px;
  padding: 10px 11px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.wide-field {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-btn,
.ghost-btn,
.link-btn,
.icon-btn,
.mini-btn {
  border: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.primary-btn.danger {
  background: var(--red);
}

.primary-btn.danger:hover {
  background: #b42318;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: #344054;
}

.ghost-btn:hover {
  border-color: #b8c5d2;
  background: #f8fafc;
}

.ghost-btn.danger {
  color: var(--red);
}

.link-btn {
  min-height: 32px;
  padding: 0 8px;
  background: transparent;
  color: var(--accent);
}

.icon-btn {
  width: 40px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: #344054;
}

.mini-btn {
  min-width: 34px;
  padding: 0 9px;
  border: 1px solid #c9daf2;
  background: #e8f0fb;
  color: var(--accent);
}

.mini-btn:hover {
  background: #dbe9fa;
}

.mini-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

a.ghost-btn {
  text-decoration: none;
}

.icon-btn svg,
.btn-icon,
.side-nav svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex: 0 0 auto;
}

.inline-control {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

.batch-control {
  grid-template-columns: minmax(82px, 1fr) repeat(8, auto);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f9fbfd;
}

.switch-row.compact {
  min-height: 40px;
  padding: 0 10px;
  background: var(--surface);
}

.switch-row strong {
  display: block;
  font-size: 13px;
}

.switch-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #c8d2dd;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.sidebar-brand h2 {
  font-size: 16px;
}

.sidebar-brand p {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 22px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-title {
  margin: 0 12px 4px;
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
}

.nav-item,
.external-nav {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 12px;
  background: transparent;
  color: #cbd5e1;
  font-size: 14px;
  text-align: left;
}

.external-nav {
  text-decoration: none;
}

.external-nav svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.nav-item:hover,
.nav-item.active,
.external-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.workspace {
  min-width: 0;
  padding: 22px 26px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.25;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(22, 36, 50, 0.04);
}

.metric-card {
  padding: 18px;
  min-height: 128px;
}

.metric-card span,
.metric-card em {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.metric-card strong {
  display: block;
  margin: 14px 0 10px;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.metric-card.accent strong {
  color: var(--green);
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2 {
  font-size: 17px;
}

.panel-head.split {
  align-items: center;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 18px;
}

.cabinets-layout {
  grid-template-columns: 390px minmax(0, 1fr);
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

#overviewView table {
  min-width: 0;
  table-layout: fixed;
}

#overviewView th,
#overviewView td {
  overflow-wrap: anywhere;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  background: #f7f9fb;
  color: #475467;
  font-weight: 700;
}

td {
  color: #273444;
}

tr:last-child td {
  border-bottom: 0;
}

.compact-table table {
  min-width: 520px;
}

.empty-cell {
  height: 76px;
  color: var(--muted);
  text-align: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #edf4ff;
  color: var(--accent);
}

.tag.green {
  background: #e8f6f1;
  color: var(--green);
}

.tag.amber {
  background: #fff3df;
  color: var(--amber);
}

.tag.red {
  background: #fff0f0;
  color: var(--red);
}

.search-input {
  width: 230px;
}

.filter-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-actions,
.asset-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.service-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #c9daf2;
  border-radius: var(--radius);
  background: #edf4ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.version-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ota-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.ota-summary-grid > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.ota-summary-grid span,
.ota-summary-grid strong {
  display: block;
}

.ota-summary-grid span {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.ota-summary-grid strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.signage-status-panel {
  min-height: 160px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
}

.signage-status-panel h2,
.signage-status-panel p {
  margin: 0;
}

.signage-status-panel p {
  color: var(--muted);
  font-size: 13px;
}

.table-link {
  color: var(--accent);
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.form-switch {
  min-height: 64px;
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 34px;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  transform: translateY(-50%);
}

.unavailable-panel {
  min-height: 220px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.unavailable-panel h2,
.unavailable-panel p {
  margin: 0;
}

.unavailable-panel p {
  max-width: 560px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.service-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  margin-top: 16px;
  border: 1px dashed #c4cfda;
  border-radius: var(--radius);
  background: #fafbfd;
  color: var(--muted);
  font-size: 13px;
}

.service-empty.compact-empty {
  min-height: 180px;
  margin-top: 0;
}

.editor-panel {
  padding-bottom: 0;
  overflow: hidden;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(190px, 0.68fr) minmax(480px, 2.2fr) minmax(230px, 0.85fr);
  min-height: 640px;
  margin: 0 -18px;
  border-top: 1px solid var(--border);
}

.editor-pane,
.editor-workspace {
  min-width: 0;
  padding: 18px;
}

.editor-pane + .editor-workspace,
.editor-workspace + .editor-pane {
  border-left: 1px solid var(--border);
}

.editor-pane h3 {
  margin: 0 0 14px;
  font-size: 14px;
}

.editor-pane-hint,
.editor-canvas-hint {
  margin: -7px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.editor-workspace {
  display: grid;
  grid-template-rows: auto minmax(420px, 1fr) auto;
  gap: 14px;
  background: #eef2f6;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) repeat(2, minmax(110px, 0.8fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.editor-toolbar label {
  display: grid;
  gap: 6px;
}

.editor-toolbar label > span {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.editor-canvas-shell {
  min-height: 420px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 22px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background-color: #dbe3ec;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.45) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.editor-stage,
.preview-stage {
  position: relative;
  width: min(100%, 720px);
  max-height: 540px;
  overflow: hidden;
  border: 1px solid #111827;
  background: #0b1220;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.22);
  touch-action: none;
}

.editor-stage:empty::after {
  content: "从左侧添加素材";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 13px;
}

.canvas-layer {
  position: absolute;
  min-width: 24px;
  min-height: 24px;
  overflow: hidden;
  border: 1px solid transparent;
  background: #111827;
  user-select: none;
}

.canvas-layer.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
}

.canvas-layer img,
.canvas-layer video {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.canvas-layer-name {
  position: absolute;
  top: 4px;
  left: 4px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.canvas-resize-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 3px 0 0;
  background: var(--accent);
  cursor: nwse-resize;
}

.editor-asset-list {
  display: grid;
  gap: 8px;
  max-height: 550px;
  overflow-y: auto;
}

.editor-asset-chip {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.editor-asset-chip:hover {
  border-color: var(--accent);
  background: #f4f8ff;
}

.editor-asset-chip.selected {
  border-color: var(--accent);
  background: #edf4ff;
  box-shadow: 0 0 0 2px rgba(23, 105, 224, 0.1);
}

.editor-selection {
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.editor-asset-chip span,
.editor-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.editor-layer-list {
  display: grid;
  gap: 7px;
  max-height: 230px;
  overflow-y: auto;
}

.editor-layer-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.editor-layer-row.active {
  border-color: var(--accent);
  background: #edf4ff;
}

.editor-layer-row em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.editor-layer-properties {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.editor-property-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.editor-property-grid label,
.editor-property-fit {
  display: grid;
  gap: 5px;
}

.editor-property-grid span,
.editor-property-fit span {
  color: #475467;
  font-size: 11px;
  font-weight: 700;
}

.editor-layer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.editor-layer-actions button {
  justify-content: center;
  padding-inline: 6px;
}

.preview-backdrop {
  z-index: 70;
}

.preview-dialog {
  width: min(1180px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 64px rgba(12, 22, 34, 0.3);
}

.preview-content {
  min-height: 620px;
  display: grid;
  place-items: center;
  padding: 26px;
  background: #151b24;
}

.preview-stage {
  width: min(100%, 980px);
  max-height: calc(100vh - 190px);
  border-color: #334155;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}

.editor-note {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.capacity-list {
  display: grid;
  gap: 12px;
}

.capacity-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.capacity-item strong {
  display: block;
  font-size: 14px;
}

.capacity-item span,
.capacity-item small {
  color: var(--muted);
  font-size: 12px;
}

.capacity-count {
  color: var(--green);
  font-size: 20px;
  font-weight: 800;
}

.board-list {
  display: grid;
  gap: 10px;
}

.board-card {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--text);
  text-align: left;
}

.board-card:hover,
.board-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.1);
}

.board-card strong {
  font-size: 14px;
}

.board-card span {
  color: var(--muted);
  font-size: 12px;
}

.board-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

@media (max-width: 1260px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .version-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ota-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-layout {
    grid-template-columns: 180px minmax(420px, 1fr) 220px;
  }

  .editor-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    padding: 18px;
  }

  .sidebar-brand {
    margin-bottom: 18px;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .workspace {
    padding: 20px;
  }

  .topbar,
  .panel-head,
  .panel-head.split {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-actions,
  .filter-line {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-input {
    width: min(100%, 320px);
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-pane + .editor-workspace,
  .editor-workspace + .editor-pane {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .editor-asset-list,
  .editor-layer-list {
    max-height: 280px;
  }
}

@media (max-width: 680px) {
  .login-page {
    padding: 20px;
  }

  .login-panel {
    width: 100%;
    padding: 24px;
  }

  .side-nav,
  .metric-grid,
  .form-grid,
  .version-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .ota-summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .modal-choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .wide-field {
    grid-column: span 1;
  }

  .batch-control {
    display: flex;
    flex-wrap: wrap;
  }

  .batch-control input {
    flex: 1 0 100%;
  }

  .topbar-actions .switch-row {
    flex: 1 1 100%;
  }

  .workspace {
    padding: 16px 12px 28px;
  }

  .panel,
  .metric-card {
    padding: 14px;
  }

  .editor-panel {
    padding-bottom: 0;
  }

  .editor-layout {
    margin: 0 -14px;
  }

  .form-actions,
  .form-actions .primary-btn,
  .panel-actions .primary-btn,
  .panel-actions .ghost-btn {
    width: 100%;
  }
}
