:root,
.amz-appearance-swatches[data-palette="blue"],
html[data-theme="blue"] {
    --amz-theme-primary: #0d6efd;
    --amz-theme-primary-hover: #1d4ed8;
    --amz-theme-border: #60a5fa;
    --amz-theme-bg-selected: #bfdbfe;
    --amz-theme-bg-subtle: #dbeafe;
    --amz-theme-bg-data: #f0f9ff;
    --amz-theme-primary-rgb: 13, 110, 253;
    --amz-theme-focus-ring: rgba(13, 110, 253, 0.2);
    /* Reuse the subtle background; keep sticky cell backgrounds opaque. */
    --amz-theme-table-row-hover-bg: var(--amz-theme-bg-subtle);
    --amz-table-toolbar-padding: 8px 16px 2px;
    --amz-table-head-padding: 8px 4px;
}

.amz-appearance-swatches[data-palette="purple"],
html[data-theme="purple"] {
    --amz-theme-primary: #6D28D9;
    --amz-theme-primary-hover: #5B21B6;
    --amz-theme-border: #a78bfa;
    --amz-theme-bg-selected: #ddd6fe;
    --amz-theme-bg-subtle: #ede9fe;
    --amz-theme-bg-data: #f5f3ff;
    --amz-theme-primary-rgb: 109, 40, 217;
    --amz-theme-focus-ring: rgba(109, 40, 217, 0.2);
}

.amz-appearance-swatches[data-palette="teal"],
html[data-theme="teal"] {
    --amz-theme-primary: #168577;
    --amz-theme-primary-hover: #116d62;
    --amz-theme-border: #78beb3;
    --amz-theme-bg-selected: #c3e5de;
    --amz-theme-bg-subtle: #e0f2ed;
    --amz-theme-bg-data: #f3faf7;
    --amz-theme-primary-rgb: 22, 133, 119;
    --amz-theme-focus-ring: rgba(22, 133, 119, 0.2);
}

.amz-appearance-swatches[data-palette="iris"],
html[data-theme="iris"] {
    --amz-theme-primary: #6960c7;
    --amz-theme-primary-hover: #574db0;
    --amz-theme-border: #aaa5e2;
    --amz-theme-bg-selected: #ddd9f6;
    --amz-theme-bg-subtle: #f0eefb;
    --amz-theme-bg-data: #fbfafe;
    --amz-theme-primary-rgb: 105, 96, 199;
    --amz-theme-focus-ring: rgba(105, 96, 199, 0.2);
}

.amz-appearance-swatches[data-palette="orange"],
html[data-theme="orange"] {
    --amz-theme-primary: #c45113;
    --amz-theme-primary-hover: #a8410b;
    --amz-theme-border: #e2a074;
    --amz-theme-bg-selected: #f8ddc9;
    --amz-theme-bg-subtle: #fff0e5;
    --amz-theme-bg-data: #fffcf9;
    --amz-theme-primary-rgb: 196, 81, 19;
    --amz-theme-focus-ring: rgba(196, 81, 19, 0.2);
}

.amz-appearance-swatches[data-palette="lake"],
html[data-theme="lake"] {
    --amz-theme-primary: #087ea4;
    --amz-theme-primary-hover: #066787;
    --amz-theme-border: #75bbd1;
    --amz-theme-bg-selected: #c9e8f2;
    --amz-theme-bg-subtle: #e7f4f9;
    --amz-theme-bg-data: #f7fcfe;
    --amz-theme-primary-rgb: 8, 126, 164;
    --amz-theme-focus-ring: rgba(8, 126, 164, 0.2);
}

.amz-appearance-swatches[data-palette="emerald"],
html[data-theme="emerald"] {
    --amz-theme-primary: #17804a;
    --amz-theme-primary-hover: #11663a;
    --amz-theme-border: #82c5a0;
    --amz-theme-bg-selected: #cdebd9;
    --amz-theme-bg-subtle: #eaf7ef;
    --amz-theme-bg-data: #f8fcf9;
    --amz-theme-primary-rgb: 23, 128, 74;
    --amz-theme-focus-ring: rgba(23, 128, 74, 0.2);
}

.amz-appearance-swatches[data-palette="berry"],
html[data-theme="berry"] {
    --amz-theme-primary: #b83280;
    --amz-theme-primary-hover: #972668;
    --amz-theme-border: #d995bd;
    --amz-theme-bg-selected: #f2d3e5;
    --amz-theme-bg-subtle: #fbeaf3;
    --amz-theme-bg-data: #fefafc;
    --amz-theme-primary-rgb: 184, 50, 128;
    --amz-theme-focus-ring: rgba(184, 50, 128, 0.2);
}

/* Explicit ordinary-control scopes; never theme sales business dialogs. */
.compact-main-navbar .navbar-brand.text-primary { color: var(--amz-theme-primary) !important; }
.compact-main-navbar .btn-primary,
.amz-theme-controls .btn-primary {
    --bs-btn-bg: var(--amz-theme-primary);
    --bs-btn-border-color: var(--amz-theme-primary);
    --bs-btn-hover-bg: var(--amz-theme-primary-hover);
    --bs-btn-hover-border-color: var(--amz-theme-primary-hover);
    --bs-btn-active-bg: var(--amz-theme-primary-hover);
    --bs-btn-active-border-color: var(--amz-theme-primary-hover);
    --bs-btn-disabled-bg: var(--amz-theme-primary);
    --bs-btn-disabled-border-color: var(--amz-theme-primary);
    --bs-btn-focus-shadow-rgb: var(--amz-theme-primary-rgb);
    --bs-btn-focus-box-shadow: 0 0 0 .25rem var(--amz-theme-focus-ring);
}
.compact-main-navbar .btn-outline-primary,
.amz-theme-controls .btn-outline-primary {
    --bs-btn-color: var(--amz-theme-primary);
    --bs-btn-border-color: var(--amz-theme-border);
    --bs-btn-hover-bg: var(--amz-theme-primary-hover);
    --bs-btn-hover-border-color: var(--amz-theme-primary-hover);
    --bs-btn-active-bg: var(--amz-theme-primary-hover);
    --bs-btn-active-border-color: var(--amz-theme-primary-hover);
    --bs-btn-disabled-color: var(--amz-theme-primary);
    --bs-btn-disabled-border-color: var(--amz-theme-border);
    --bs-btn-focus-shadow-rgb: var(--amz-theme-primary-rgb);
    --bs-btn-focus-box-shadow: 0 0 0 .25rem var(--amz-theme-focus-ring);
}
.amz-user-menu { position: relative; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; color: #0f172a; }
.amz-user-menu > summary { display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; border: 1px solid var(--amz-theme-border); border-radius: 20px; padding: 4px 12px; background: var(--amz-theme-bg-data); font-size: 13px; font-weight: 600; }
.amz-user-menu > summary::-webkit-details-marker { display: none; }
.amz-user-menu > summary:hover { background: var(--amz-theme-bg-subtle); }
.amz-user-menu[open] > summary { background: var(--amz-theme-bg-selected); }
.amz-user-menu-panel { position: absolute; top: calc(100% + 4px); right: 0; z-index: 1080; min-width: 160px; padding: 6px; border: 1px solid var(--amz-theme-border); border-radius: 8px; background: white; }
.amz-user-menu .amz-user-menu-action { display: block; width: 100%; border: 0; border-radius: 4px; padding: 8px 12px; background: transparent; color: var(--amz-theme-primary); text-decoration: none; text-align: left; font: 600 13px "Segoe UI", "Microsoft YaHei", sans-serif; white-space: nowrap; }
.amz-user-menu .amz-user-menu-action:hover { background: var(--amz-theme-bg-subtle); }
.compact-main-navbar .amz-user-menu .amz-user-menu-panel .amz-account-logout { color: var(--amz-theme-primary); font: 600 13px "Segoe UI", "Microsoft YaHei", sans-serif !important; }
.amz-appearance-dialog { box-sizing: border-box; width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--amz-theme-border); border-radius: 12px; color: #0f172a; background: white; font: 500 14px "Segoe UI", "Microsoft YaHei", sans-serif; }
.amz-appearance-dialog::backdrop { background: rgba(15, 23, 42, 0.35); }
.amz-appearance-dialog h2 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.amz-appearance-option { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--amz-theme-border); border-radius: 6px; background: white; }
.amz-appearance-option + .amz-appearance-option { margin-top: 8px; }
.amz-appearance-option:hover { background: var(--amz-theme-bg-subtle); }
.amz-appearance-option:has(input:checked) { background: var(--amz-theme-bg-selected); }
.amz-appearance-option input { accent-color: var(--amz-theme-primary); }
.amz-appearance-option-content { min-width: 0; flex: 1; }
.amz-appearance-swatches { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; margin-top: 6px; }
.amz-appearance-swatch { display: block; height: 18px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }
.amz-appearance-swatch[data-color="primary"] { background: var(--amz-theme-primary); }
.amz-appearance-swatch[data-color="primary-hover"] { background: var(--amz-theme-primary-hover); }
.amz-appearance-swatch[data-color="border"] { background: var(--amz-theme-border); }
.amz-appearance-swatch[data-color="bg-selected"] { background: var(--amz-theme-bg-selected); }
.amz-appearance-swatch[data-color="bg-subtle"] { background: var(--amz-theme-bg-subtle); }
.amz-appearance-swatch[data-color="bg-data"] { background: var(--amz-theme-bg-data); }
.amz-appearance-legend { margin: 8px 0; font-size: 12px; color: #475569; }
.amz-appearance-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.amz-appearance-actions button { height: 30px; padding: 0 12px; border: 1px solid var(--amz-theme-border); border-radius: 5px; background: white; color: var(--amz-theme-primary); font: 700 13px "Segoe UI", "Microsoft YaHei", sans-serif; }
.amz-appearance-actions button[type="submit"] { color: white; background: var(--amz-theme-primary); }
.amz-appearance-actions button:hover:not(:disabled) { background: var(--amz-theme-bg-subtle); }
.amz-appearance-actions button[type="submit"]:hover:not(:disabled) { background: var(--amz-theme-primary-hover); }
.amz-appearance-actions button:disabled { opacity: .6; cursor: wait; }
.amz-appearance-error { color: #dc3545; margin: 12px 0 0; }
.amz-user-menu :focus-visible,
.amz-appearance-dialog :focus-visible { outline: 2px solid var(--amz-theme-primary); outline-offset: 2px; box-shadow: 0 0 0 3px var(--amz-theme-focus-ring); }
