:root {
  --theme-toggle-bg: #142433;
  --theme-toggle-text: #edf8ff;
  --theme-toggle-border: #3b5368;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef0f3;
  --bg-deep: #e6e9ed;
  --surface: rgba(255, 255, 255, .96);
  --surface-solid: #fff;
  --surface-raised: #f3f5f7;
  --border: #d5dbe2;
  --border-strong: #9baec1;
  --text: #263342;
  --muted: #5d6b7b;
  --cyan: #21658d;
  --cyan-soft: rgba(33, 101, 141, .09);
  --green: #14734d;
  --green-soft: rgba(20, 115, 77, .09);
  --amber: #8c5800;
  --red: #b4233e;
  --red-soft: rgba(180, 35, 62, .08);
  --shadow: 0 20px 64px rgba(32, 45, 61, .12);
  --theme-toggle-bg: #fff;
  --theme-toggle-text: #3c536b;
  --theme-toggle-border: #c6d0dc;
  background: var(--bg-deep);
  color: var(--text);
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 60;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--theme-toggle-border);
  border-radius: 50%;
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-text);
  box-shadow: 0 4px 14px rgba(25, 39, 56, .08);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--cyan, #8fc8ff); }
.theme-toggle:focus-visible { outline: 3px solid var(--cyan, #8fc8ff); outline-offset: 3px; }
.theme-toggle svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
body > .console .topbar { padding-right: 82px; }
body > main > header { padding-right: 48px; }

:root[data-theme="light"] body { background: linear-gradient(145deg, #e9ecf0, #f2f3f5); color: var(--text); }
:root[data-theme="light"] .ambient { opacity: .035; }
:root[data-theme="light"] .login-card,
:root[data-theme="light"] .sidebar,
:root[data-theme="light"] .topbar,
:root[data-theme="light"] .stat-card,
:root[data-theme="light"] .policy-item,
:root[data-theme="light"] dialog,
:root[data-theme="light"] .management-tabs,
:root[data-theme="light"] .management-form > .dialog-actions,
:root[data-theme="light"] .create-agent-form > .dialog-actions,
:root[data-theme="light"] .user-table td:last-child,
:root[data-theme="light"] .toast,
:root[data-theme="light"] body > main > section { background: var(--surface-solid); }
:root[data-theme="light"] .panel { box-shadow: 0 8px 28px rgba(32, 45, 61, .045); }
:root[data-theme="light"] label,
:root[data-theme="light"] .dialog-card h3 { color: var(--text); }
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea { background: #f7f9fb; color: var(--text); border-color: var(--border); }
:root[data-theme="light"] input:focus,
:root[data-theme="light"] select:focus,
:root[data-theme="light"] textarea:focus { background: #fff; }
:root[data-theme="light"] input::placeholder,
:root[data-theme="light"] textarea::placeholder { color: #788595; }
:root[data-theme="light"] .user-filter,
:root[data-theme="light"] .custom-package-section,
:root[data-theme="light"] .switch-label,
:root[data-theme="light"] .balance-confirm-details > div,
:root[data-theme="light"] .user-detail-grid > div,
:root[data-theme="light"] .history-summary > div,
:root[data-theme="light"] .guest-admin-item,
:root[data-theme="light"] .guest-zip-details,
:root[data-theme="light"] .guest-zip-preview,
:root[data-theme="light"] .management-tabs button,
:root[data-theme="light"] .keys-result pre { background: var(--surface-raised); }
:root[data-theme="light"] th { background: #edf1f5; color: #53657a; }
:root[data-theme="light"] .user-table tbody tr:hover td:last-child { background: #edf2f6; }
:root[data-theme="light"] .nav-item:hover { background: #edf1f5; }
:root[data-theme="light"] .nav-item span { color: #6a7f92; }
:root[data-theme="light"] .nav-item.active span { color: var(--cyan); }
:root[data-theme="light"] .button-primary { color: #fff; }
:root[data-theme="light"] .button-primary:hover { background: #1a5274; }
:root[data-theme="light"] .button-danger,
:root[data-theme="light"] .danger-button,
:root[data-theme="light"] .badge-disabled,
:root[data-theme="light"] .badge-revoked,
:root[data-theme="light"] .form-error,
:root[data-theme="light"] .package-delete-note,
:root[data-theme="light"] .row-button.danger:hover { color: var(--red); }
:root[data-theme="light"] .button-danger:hover { background: #fbe7ec; }
:root[data-theme="light"] .keys-result pre,
:root[data-theme="light"] .guest-zip-preview pre { color: #35516a; }
:root[data-theme="light"] dialog::backdrop { background: rgba(44, 56, 72, .36); }
:root[data-theme="light"] body > main > header p,
:root[data-theme="light"] body > main > section > p { color: var(--muted); }
:root[data-theme="light"] body > main a { color: var(--cyan); }
:root[data-theme="light"] body > main > section { border-color: var(--border); }
:root[data-theme="light"] body > main th,
:root[data-theme="light"] body > main td { border-color: var(--border); }
:root[data-theme="light"] body > main .muted { color: var(--muted); }
:root[data-theme="light"] .switch { background: #c5ced8; }
:root[data-theme="light"] .switch::after { background: #fff; }
:root[data-theme="light"] .switch-label input:checked + .switch { background: #c0d7e6; }
:root[data-theme="light"] .danger-switch input:checked + .switch { background: #edc8d1; }

@media (max-width: 620px) {
  .theme-toggle { top: 12px; right: 12px; }
  body > .console .topbar { padding-right: 66px; }
}
