html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
}

.site-pref-toolbar {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  display: grid;
  justify-items: end;
  gap: 0.7rem;
  max-width: min(18rem, calc(100vw - 1.5rem));
}

body.console-page .site-pref-toolbar {
  position: static;
  right: auto;
  bottom: auto;
  display: inline-flex;
  align-items: center;
  justify-items: unset;
  gap: 0.6rem;
  max-width: none;
}

body.console-page .site-pref-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.6rem);
  z-index: 20;
}

body.console-page .site-pref-toggle {
  min-height: 2.6rem;
  padding: 0.45rem 0.8rem;
}

.site-pref-toggle,
.site-pref-panel,
.site-pref-button {
  backdrop-filter: blur(18px);
}

.site-pref-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.85rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(117, 140, 167, 0.22);
  border-radius: 999px;
  background: rgba(8, 13, 24, 0.82);
  box-shadow: 0 18px 40px rgba(7, 11, 20, 0.24);
  color: #eef6ff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.site-pref-toggle-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(77, 124, 255, 1), rgba(24, 208, 255, 1));
  box-shadow: 0 0 0 0.22rem rgba(77, 124, 255, 0.16);
}

.site-pref-panel {
  display: grid;
  gap: 0.7rem;
  width: min(18rem, calc(100vw - 1.5rem));
  min-width: 13.5rem;
  max-height: min(60vh, 22rem);
  overflow: auto;
  overscroll-behavior: contain;
  resize: both;
  padding: 0.8rem;
  border-radius: 20px;
  border: 1px solid rgba(117, 140, 167, 0.22);
  background: rgba(8, 13, 24, 0.82);
  box-shadow: 0 18px 40px rgba(7, 11, 20, 0.24);
}

.site-pref-panel[hidden] {
  display: none;
}

.site-pref-inline {
  display: none;
  align-items: center;
  gap: 0.6rem;
}

body.console-page .site-pref-inline {
  display: inline-flex;
}

body.console-page .site-pref-toggle {
  display: none;
}

body.console-page .site-pref-panel {
  display: none !important;
}

.site-pref-group {
  display: grid;
  gap: 0.45rem;
}

.site-pref-label {
  color: #c0d0df;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-pref-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.site-pref-button {
  min-height: 2.3rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(138, 162, 189, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #eef6ff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.site-pref-button.pref-icon-button {
  min-height: 2.6rem;
  padding: 0.35rem;
}

.site-pref-button.pref-icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.site-pref-button.active {
  border-color: rgba(92, 162, 255, 0.46);
  background: linear-gradient(90deg, rgba(77, 124, 255, 0.24), rgba(24, 208, 255, 0.18));
}

html[data-theme="light"] .site-pref-toolbar {
  background: transparent;
  box-shadow: none;
}

html[data-theme="light"] .site-pref-toggle,
html[data-theme="light"] .site-pref-panel {
  border-color: rgba(99, 117, 148, 0.14);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(74, 89, 116, 0.16);
}

html[data-theme="light"] .site-pref-label {
  color: #4f5e73;
}

html[data-theme="light"] .site-pref-button {
  border-color: rgba(113, 133, 163, 0.18);
  background: rgba(235, 241, 250, 0.9);
  color: #1d2b44;
}

html[data-theme="light"] .site-pref-button.active {
  border-color: rgba(76, 120, 255, 0.32);
  background: linear-gradient(90deg, rgba(76, 120, 255, 0.15), rgba(44, 172, 240, 0.14));
}

html[data-theme="light"] {
  --auth-bg: #edf3fb;
  --auth-panel: rgba(255, 255, 255, 0.82);
  --auth-panel-strong: rgba(248, 251, 255, 0.96);
  --auth-line: rgba(116, 142, 174, 0.14);
  --auth-line-strong: rgba(69, 124, 255, 0.34);
  --auth-text: #162741;
  --auth-soft: #5e7189;
  --auth-muted: #788aa0;
  --auth-primary: #406fff;
  --auth-primary-2: #1ea8ef;
  --auth-success: #1fa36b;
  --auth-danger: #da5c6a;

  --console-bg: #eef4fb;
  --console-bg-soft: #f6f9fd;
  --console-panel: rgba(255, 255, 255, 0.84);
  --console-panel-strong: rgba(246, 249, 253, 0.98);
  --console-line: rgba(105, 131, 162, 0.14);
  --console-line-strong: rgba(69, 140, 255, 0.32);
  --console-text: #12243d;
  --console-soft: #5c728b;
  --console-muted: #74879d;
  --console-primary: #4270ff;
  --console-primary-2: #17a8f2;
  --console-shadow: 0 20px 40px rgba(70, 90, 120, 0.12);

  --bg: #f2f6f3;
  --bg-top: #f6faf8;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-soft: rgba(245, 249, 246, 0.94);
  --panel-deep: #ffffff;
  --line: rgba(115, 138, 124, 0.12);
  --line-strong: rgba(50, 168, 110, 0.24);
  --ink: #152326;
  --ink-soft: #61706e;
  --ink-muted: #82908d;
  --accent: #1ea86a;
  --accent-strong: #11975c;
  --accent-warm: #f3942a;
  --accent-warm-deep: #db641f;
}

html[data-theme="light"] body.auth-body {
  background:
    radial-gradient(circle at top left, rgba(80, 123, 255, 0.12), transparent 24%),
    radial-gradient(circle at 85% 15%, rgba(31, 209, 255, 0.08), transparent 20%),
    radial-gradient(circle at bottom right, rgba(41, 211, 145, 0.08), transparent 24%),
    linear-gradient(180deg, #f7faff 0%, #eef4fb 100%);
}

html[data-theme="light"] body.console-page {
  background:
    radial-gradient(circle at top left, rgba(77, 124, 255, 0.1), transparent 24%),
    radial-gradient(circle at top right, rgba(24, 208, 255, 0.08), transparent 26%),
    radial-gradient(circle at bottom right, rgba(34, 200, 135, 0.08), transparent 22%),
    linear-gradient(180deg, #f7faff 0%, #edf3fb 100%);
}

html[data-theme="light"] body.console-page .console-sidebar,
html[data-theme="light"] body.console-page .console-panel,
html[data-theme="light"] body.console-page .console-stat {
  box-shadow: 0 16px 36px rgba(70, 90, 120, 0.12);
}

html[data-theme="light"] body.console-page .nav-link,
html[data-theme="light"] body.console-page .ghost-button,
html[data-theme="light"] body.console-page .mini-button,
html[data-theme="light"] body.console-page .tab-button,
html[data-theme="light"] body.console-page .filter-input,
html[data-theme="light"] body.console-page .filter-select {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(90, 115, 150, 0.2);
  color: #162741;
}

html[data-theme="light"] body.console-page .nav-link.active,
html[data-theme="light"] body.console-page .tab-button.active {
  border-color: rgba(66, 112, 255, 0.4);
  background: rgba(66, 112, 255, 0.12);
}

html[data-theme="light"] body.console-page .data-table {
  background: rgba(255, 255, 255, 0.96);
}

html[data-theme="light"] body.console-page .data-table th {
  color: #5b6d85;
}

html[data-theme="light"] body.console-page .data-table td {
  border-bottom: 1px solid rgba(110, 130, 160, 0.18);
}

html[data-theme="light"] body.console-page .table-wrap {
  background: rgba(255, 255, 255, 0.9);
}

html[data-theme="light"] body.checkout-page {
  background:
    radial-gradient(circle at top left, rgba(243, 145, 47, 0.12), transparent 26%),
    radial-gradient(circle at right center, rgba(43, 226, 126, 0.08), transparent 24%),
    linear-gradient(180deg, #f8fbf8 0%, #eef5f1 100%);
}

html[data-theme="light"] .glow-left {
  background: rgba(243, 145, 47, 0.28);
}

html[data-theme="light"] .glow-right {
  background: rgba(43, 226, 126, 0.18);
}

html[data-theme="dark"] {
  --page-bg: #09111d;
  --hero-blue-start: #3340b6;
  --hero-blue-end: #167bb1;
  --card-bg: rgba(13, 22, 37, 0.92);
  --card-line: rgba(144, 169, 208, 0.14);
  --text: #edf5ff;
  --text-soft: #9eb4d0;
  --accent: #4a7dff;
  --accent-soft: rgba(74, 125, 255, 0.18);

  --success: #2fd07f;
  --success-soft: rgba(47, 208, 127, 0.14);
  --danger: #ff7a7a;
  --danger-soft: rgba(255, 122, 122, 0.16);
  --line: rgba(145, 167, 203, 0.14);
}

html[data-theme="dark"] body.paynow-page {
  --page-bg: #050b13;
  --card-bg: rgba(12, 20, 34, 0.92);
  --card-line: rgba(136, 160, 194, 0.16);
  --text: #f3f6ff;
  --text-soft: rgba(243, 246, 255, 0.72);
  --accent-soft: rgba(74, 125, 255, 0.18);
  background:
    radial-gradient(circle at top left, rgba(70, 84, 245, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(26, 169, 233, 0.18), transparent 28%),
    linear-gradient(180deg, #0a1220 0%, #07101a 56%, #050b13 100%);
}

/* Cashier is always a light checkout (keep it white even in dark theme). */
html[data-theme="dark"] body.paynow-page.cashier-page {
  background: #ffffff;
  color: #111827;
}

html[data-theme="dark"] body.paynow-page.cashier-page .cashier-card,
html[data-theme="dark"] body.paynow-page.cashier-page .cashier-row,
html[data-theme="dark"] body.paynow-page.cashier-page .cashier-list {
  background: #ffffff;
  color: #111827;
}

html[data-theme="dark"] .paynow-card,
html[data-theme="dark"] .error-card {
  background: rgba(12, 20, 34, 0.9);
  border-color: rgba(136, 160, 194, 0.16);
  box-shadow:
    0 30px 60px rgba(8, 13, 23, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .meta-row,
html[data-theme="dark"] .status-banner,
html[data-theme="dark"] .paynow-app,
html[data-theme="dark"] .secondary-action,
html[data-theme="dark"] .qr-panel,
html[data-theme="dark"] .qr-toggle {
  background: rgba(18, 28, 46, 0.88);
  border-color: rgba(136, 160, 194, 0.16);
}

html[data-theme="dark"] .secondary-action {
  color: var(--text);
  box-shadow: 0 14px 26px rgba(5, 10, 18, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .secondary-action:hover {
  border-color: rgba(74, 125, 255, 0.35);
  background: rgba(20, 32, 54, 0.92);
}

html[data-theme="dark"] body.result-page {
  background:
    radial-gradient(circle at top left, rgba(73, 98, 255, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(30, 163, 91, 0.12), transparent 26%),
    linear-gradient(180deg, #08111e 0%, #050b14 100%);
}

html[data-theme="dark"] body.result-page[data-result-mode="failed"] {
  background:
    radial-gradient(circle at top left, rgba(73, 98, 255, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(208, 80, 80, 0.14), transparent 26%),
    linear-gradient(180deg, #08111e 0%, #050b14 100%);
}

html[data-theme="dark"] .result-card {
  background: rgba(12, 20, 34, 0.92);
  border-color: rgba(140, 163, 199, 0.16);
  box-shadow:
    0 28px 60px rgba(6, 10, 19, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .meta-row {
  background: rgba(18, 28, 46, 0.92);
}

@media (max-width: 720px) {
  .site-pref-toolbar {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    max-width: none;
    justify-items: stretch;
  }

  .site-pref-toggle,
  .site-pref-panel {
    width: 100%;
  }

  .site-pref-panel {
    min-width: 0;
    max-height: min(50vh, 20rem);
    resize: none;
  }
}
