.ui-preference-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.auth-card > .ui-preference-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
}
.ui-preference-button {
  display: inline-grid;
  place-items: center;
  min-width: 39px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1;
}
.ui-preference-button:hover { border-color: var(--red); }

:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #e7edf3;
  --navy-deep: #11171e;
  --navy-soft: #27323f;
  --blue: #81b9ed;
  --red: #e64a5b;
  --red-soft: #3a2029;
  --bg: #121922;
  --surface: #1d2732;
  --line: #394757;
  --text: #e8eef5;
  --muted: #aab7c7;
  --good: #70d6ad;
  --warning: #f1c974;
  --shadow: 0 12px 35px rgba(0, 0, 0, .2);
}

[data-theme="dark"] .auth-panel,
[data-theme="dark"] .topbar,
[data-theme="dark"] .surface { background: var(--surface); }
[data-theme="dark"] .auth-panel { background: var(--bg); }
[data-theme="dark"] .stack-form label,
[data-theme="dark"] .field { color: var(--text); }
[data-theme="dark"] .stack-form input,
[data-theme="dark"] .stack-form select,
[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea,
[data-theme="dark"] .search-input,
[data-theme="dark"] .select-input,
[data-theme="dark"] .table-input,
[data-theme="dark"] .segmented,
[data-theme="dark"] .segmented button,
[data-theme="dark"] .icon-button,
[data-theme="dark"] .button-outline {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #8e9cac; }
[data-theme="dark"] .button-ghost,
[data-theme="dark"] .segmented button.active,
[data-theme="dark"] .role-pill { color: var(--blue); background: #26384b; border-color: #36506a; }
[data-theme="dark"] .button-danger { color: #ff9ca7; background: #44262e; }
[data-theme="dark"] .dev-demo-access,
[data-theme="dark"] .catalog-demo-note { color: #ffccbf; background: #38272b; border-color: #875359; }
[data-theme="dark"] .dev-demo-access h3,
[data-theme="dark"] .dev-demo-access p { color: #ffccbf; }
[data-theme="dark"] .alert { color: #ffb0b8; background: #44232d; border-color: #76515b; }
[data-theme="dark"] .alert.info { color: #bbdcf9; background: #26394a; border-color: #3d5b74; }
[data-theme="dark"] .alert.good { color: #a3eacb; background: #1f3c35; border-color: #3c6f5c; }
[data-theme="dark"] .catalog-group-heading h3,
[data-theme="dark"] .catalog-group .product-code,
[data-theme="dark"] .catalog-table .code a { color: #ff8794; }
[data-theme="dark"] .catalog-group .product-card { background: var(--surface); box-shadow: 0 12px 30px rgba(0,0,0,.25); }
[data-theme="dark"] .catalog-group .product-card h3 { color: var(--text); }
[data-theme="dark"] .catalog-group .product-image,
[data-theme="dark"] .product-image { background: #dcecf2; border-color: #526575; }
[data-theme="dark"] .catalog-group .product-image figcaption,
[data-theme="dark"] .product-image figcaption { color: #374554; background: rgba(220,236,242,.92); }
[data-theme="dark"] .product-detail-grid .drawing-unavailable { background: #202d39; }
[data-theme="dark"] .spec-grid div { background: #26323f; }
[data-theme="dark"] .product-thumb { background: #dcecf2; border-color: #526575; }
[data-theme="dark"] .topbar-logo { filter: grayscale(1) brightness(0) invert(1); }
[data-theme="dark"] .data-table th { color: var(--muted); background: #26323f; }
[data-theme="dark"] .data-table td,
[data-theme="dark"] .list-row { border-color: var(--line); }
[data-theme="dark"] .data-table tbody tr:hover { background: #263440; }
[data-theme="dark"] .excel-step { background: #26323f; }
[data-theme="dark"] .cart-qty button,
[data-theme="dark"] .empty-symbol { color: var(--blue); background: #2a3a4a; }
[data-theme="dark"] .badge { color: var(--text); background: #344250; }
[data-theme="dark"] .badge-good { color: #a3eacb; background: #234437; }
[data-theme="dark"] .badge-warning { color: #f1d497; background: #4c3c26; }
[data-theme="dark"] .badge-danger,
[data-theme="dark"] .badge-demo { color: #ffc0c4; background: #4a2b31; border-color: #885057; }
[data-theme="dark"] .badge-blue { color: #bbdcf9; background: #263c53; }
[data-theme="dark"] .demo-alert { color: #ffc5b4; background: #432a2c; border-color: #76515b; }
[data-theme="dark"] .toast { color: #fff; background: #314151; }
[data-theme="dark"] .toast-error { background: #a62c3d; }
[data-theme="dark"] .toast-good { background: #117353; }

@media (max-width: 640px) {
  .topbar-actions .ui-preference-controls { gap: 3px; }
  .topbar-actions .ui-preference-button { min-width: 34px; height: 34px; }
}
@media print {
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --text: #111;
    --muted: #555;
    --line: #ccc;
  }
}
