:root {
    color-scheme: dark;
}

body[data-theme] {
    --admin-bg: var(--color-page-bg, #0F172A);
    --admin-surface: var(--surface-gradient-soft, #111827);
    --admin-surface-strong: var(--color-input-bg, #1F2937);
    --admin-border: var(--color-border, #334155);
    --admin-text: var(--color-text-primary, #F8FAFC);
    --admin-muted: var(--color-text-secondary, #CBD5E1);
    --admin-accent: var(--color-primary, #13BEDB);
    --admin-accent-soft: var(--overlay-primary-12, rgba(19, 190, 219, 0.24));
    --admin-accent-border: var(--overlay-primary-25, rgba(19, 190, 219, 0.35));
    --admin-shadow: var(--shadow-3d-soft, 0 12px 24px rgba(2, 6, 23, 0.3));
}

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

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

html,
body,
#app {
    min-height: 100%;
    margin: 0;
}

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

a {
    color: inherit;
}

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

code {
    overflow-wrap: anywhere;
}

:where(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--admin-accent);
    outline-offset: 2px;
}

:where(button, input, select, textarea):disabled {
    cursor: not-allowed;
}

.admin-skip-link {
    position: fixed;
    top: var(--space-2, 0.5rem);
    left: var(--space-2, 0.5rem);
    z-index: 100;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--admin-accent-border);
    border-radius: var(--radius-pill, 999rem);
    background: var(--color-card-bg, #111827);
    box-shadow: var(--shadow-elevated, var(--admin-shadow));
    color: var(--admin-text);
    font-weight: 800;
    text-decoration: none;
    transform: translateY(calc(-100% - 1rem));
    transition: transform 0.15s ease;
}

.admin-skip-link:focus-visible {
    outline: none;
    box-shadow: var(--shadow-elevated, var(--admin-shadow)), var(--focus-ring-primary, 0 0 0 3px rgba(19, 190, 219, 0.3));
    transform: translateY(0);
}

.admin-shell {
    min-height: 100vh;
    background: var(--admin-bg);
}

.admin-shell__header {
    min-height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4, 1rem);
    min-width: 0;
    padding: 0 var(--space-8, 2rem);
    border-bottom: 1px solid var(--admin-border);
    background: var(--color-card-bg, #111827);
    box-shadow: var(--shadow-subtle, 0 4px 16px rgba(2, 6, 23, 0.48));
    position: sticky;
    top: 0;
    z-index: 20;
}

.admin-shell__brand {
    align-items: center;
    color: var(--admin-text);
    display: inline-flex;
    flex: 0 0 auto;
    gap: var(--space-2, 0.5rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
}

.admin-shell__brand-mark {
    border-radius: var(--radius-sm, 0.5rem);
    display: block;
    height: 2rem;
    width: 2rem;
}

.admin-shell__nav {
    align-items: center;
    display: flex;
    gap: var(--space-1, 0.25rem);
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.admin-shell__nav a {
    border: 1px solid transparent;
    border-radius: var(--radius-pill, 999rem);
    color: var(--admin-muted);
    flex: 0 0 auto;
    font-size: 0.9rem;
    font-weight: 700;
    min-height: var(--tap-target-sm, 2.5rem);
    padding: 0.55rem 0.8rem;
    text-decoration: none;
}

.admin-shell__nav a:hover,
.admin-shell__nav a:focus-visible,
.admin-shell__nav a.admin-shell__nav-link--active {
    background: var(--admin-accent-soft);
    border-color: var(--admin-accent-border);
    color: var(--admin-text);
    outline: none;
}

.admin-shell__nav a.admin-shell__nav-link--active {
    box-shadow: inset 0 -2px 0 var(--admin-accent);
}

.admin-shell__nav a:focus-visible,
.admin-shell__brand:focus-visible {
    box-shadow: var(--focus-ring-primary, 0 0 0 3px rgba(19, 190, 219, 0.3));
}

.admin-placeholder__eyebrow {
    color: var(--admin-accent);
    font-size: 0.875rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-shell__content,
.admin-auth-shell__content {
    min-width: 0;
}

.admin-shell__content {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: var(--space-12, 3rem) 0 4rem;
}

.admin-shell__content:focus,
.admin-auth-shell__content:focus {
    outline: none;
}

.admin-table-scroll,
.admin-subscriptions-table-scroll,
.admin-coupons-table-scroll,
.admin-customer-billing-table-scroll {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.admin-placeholder,
.admin-auth-card {
    padding: var(--space-8, 2rem);
    border: 1px solid var(--border-3d-soft, var(--admin-border));
    border-radius: var(--radius-xl, 1.25rem);
    background: var(--surface-gradient-soft, var(--color-card-bg, #111827));
    box-shadow: var(--admin-shadow);
}

.admin-placeholder h1,
.admin-auth-card h1 {
    color: var(--admin-text);
    margin: var(--space-2, 0.5rem) 0 var(--space-4, 1rem);
}

.admin-placeholder p,
.admin-auth-card p {
    line-height: 1.7;
    color: var(--admin-muted);
}

.admin-auth-card {
    width: min(480px, 100%);
    margin: 0 auto;
}

.admin-auth-card form {
    display: grid;
    gap: var(--space-3, 0.75rem);
    margin-top: var(--space-6, 1.5rem);
}

.admin-auth-card label {
    margin-top: var(--space-1, 0.25rem);
    color: var(--admin-text);
    font-weight: 700;
}

.admin-auth-card input,
.admin-auth-card select,
.admin-auth-card textarea {
    width: 100%;
    min-height: var(--tap-target-md, 2.75rem);
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--admin-border);
    border-radius: var(--radius-md, 0.75rem);
    background: var(--admin-surface-strong);
    color: var(--admin-text);
}

.admin-auth-card input:focus-visible,
.admin-auth-card select:focus-visible,
.admin-auth-card textarea:focus-visible {
    border-color: var(--admin-accent);
    outline: none;
    box-shadow: var(--focus-ring-primary, 0 0 0 3px rgba(19, 190, 219, 0.3));
}

.admin-primary-button,
.admin-secondary-button,
.admin-primary-link {
    align-items: center;
    border-radius: var(--radius-pill, 999rem);
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    gap: 0.45rem;
    justify-content: center;
    min-height: var(--tap-target-lg, 3rem);
    padding: 0.55rem 1rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.admin-primary-button,
.admin-primary-link {
    background: linear-gradient(180deg, var(--color-primary, #13BEDB), var(--color-primary-dark, #22D3EE));
    border: 1px solid var(--color-primary-dark, #22D3EE);
    box-shadow: var(--shadow-3d-soft, var(--admin-shadow));
    color: var(--color-page-bg, #0F172A);
}

.admin-secondary-button {
    background: var(--surface-gradient-soft, var(--color-card-bg, #111827));
    border: 1px solid var(--border-3d-soft, var(--admin-border));
    box-shadow: var(--shadow-3d-soft, var(--admin-shadow));
    color: var(--color-button-secondary-text, var(--admin-text));
}

.admin-primary-button:hover:not(:disabled),
.admin-primary-link:hover,
.admin-secondary-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-3d-medium, var(--admin-shadow));
}

.admin-primary-button:focus-visible,
.admin-primary-link:focus-visible,
.admin-secondary-button:focus-visible {
    outline: none;
    box-shadow: var(--shadow-3d-soft, var(--admin-shadow)), var(--focus-ring-primary, 0 0 0 3px rgba(19, 190, 219, 0.3));
}

.admin-primary-button:active:not(:disabled),
.admin-secondary-button:active:not(:disabled) {
    transform: translateY(1px);
    box-shadow: var(--shadow-3d-pressed, none);
}

.admin-primary-button:disabled,
.admin-secondary-button:disabled {
    background: var(--color-button-disabled-bg, #1E293B);
    border-color: var(--admin-border);
    box-shadow: none;
    color: var(--color-button-disabled-text, #94A3B8);
    cursor: not-allowed;
    transform: none;
}

.admin-auth-error {
    margin: var(--space-2, 0.5rem) 0;
    padding: var(--space-3, 0.75rem);
    border: 1px solid var(--overlay-danger-30, rgba(251, 113, 133, 0.44));
    border-radius: var(--radius-md, 0.75rem);
    background: var(--color-danger-soft-bg, #3F1D2A);
    color: var(--color-danger-dark, #FDA4AF) !important;
}

.admin-boot {
    align-items: center;
    color: var(--admin-muted);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-8, 2rem);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 1rem 1rem 1rem;
    padding: 1rem;
    border: 1px solid var(--overlay-danger-30, rgba(251, 113, 133, 0.44));
    border-radius: var(--radius-md, 0.75rem);
    background: var(--color-danger-soft-bg, #3F1D2A);
    color: var(--admin-text);
    box-shadow: var(--shadow-elevated, var(--admin-shadow));
}

@media (max-width: 820px) {
    .admin-shell__header {
        align-items: flex-start;
        flex-direction: column;
        gap: var(--space-2, 0.5rem);
        padding: var(--space-3, 0.75rem) var(--space-4, 1rem);
    }

    .admin-shell__nav {
        width: 100%;
        padding-bottom: 0.2rem;
    }
}

@media (max-width: 640px) {
    .admin-shell__content {
        width: min(1180px, calc(100% - 1rem));
        padding-top: var(--space-8, 2rem);
    }

    .admin-placeholder,
    .admin-auth-card {
        padding: var(--space-5, 1.25rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .admin-skip-link,
    .admin-primary-button,
    .admin-secondary-button,
    .admin-primary-link {
        transition: none;
    }

    .admin-primary-button:hover:not(:disabled),
    .admin-primary-button:active:not(:disabled),
    .admin-secondary-button:hover:not(:disabled),
    .admin-secondary-button:active:not(:disabled),
    .admin-primary-link:hover {
        transform: none;
    }
}
