*,
*::before,
*::after {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);

--reg-primary: #123a7a;
    --reg-primary-hover: #0f2f63;
    --reg-primary-soft: #edf4ff;
    --reg-primary-tint-text: #123a7a;
    --reg-gradient: linear-gradient(135deg, #123a7a 0%, #2f80ed 100%);
    --reg-shadow-hero: 0 20px 50px rgba(18, 58, 122, 0.30);
    --reg-danger: var(--color-danger);
}

/* ============================================================
   MEDICAL LIGHT THEME - token layer
   ------------------------------------------------------------
   Medical identity matching variables.css. This screen loads
   variables.css first, so re-declaring the same tokens here
   re-themes the whole page without touching a single selector,
   layout value, font metric, radius, breakpoint or behaviour.
   ============================================================ */
:root {
    /* ---- Medical identity (mirrors variables.css) ---- */
    --color-primary: #123a7a;
    --color-primary-hover: #0f2f63;
    --color-primary-light: #edf4ff;
    --color-primary-soft: #edf4ff;
    --color-primary-tint-text: #123a7a;

    /* ---- Accent: medical blue (links, focus, selected icons, ring) ---- */
    --color-accent: #2f80ed;
    --color-accent-light: rgba(47, 128, 237, 0.16);

    /* ---- Surfaces: light medical tones ---- */
    --color-bg: #f6f8fc;
    --color-card: #ffffff;
    --color-surface: #ffffff;
    --color-surface-alt: #eef3fb;
    --color-bg-subtle: #eef3fb;
    --color-muted: #e9eef6;
    --color-input-bg: #ffffff;
    --color-nav: #ffffff;
    --color-border: #e5eaf2;
    --color-border-strong: #d4dce8;

    /* ---- Text: medical navy family ---- */
    --color-text: #17325c;
    --color-text-secondary: #6b7280;
    --color-text-muted: #98a4b8;
    --color-text-inverse: #ffffff;

    /* ---- App bar / drawer shell: medical navy ---- */
    --color-sidebar: #0c1f42;
    --color-sidebar-2: #0a1833;
    --color-sidebar-text: rgba(255, 255, 255, 0.78);
    --color-sidebar-muted: rgba(255, 255, 255, 0.45);
    --color-sidebar-hover: rgba(255, 255, 255, 0.08);
    --color-sidebar-active: rgba(47, 128, 237, 0.22);

    /* ---- Status colours: functional semantics preserved ---- */
    --color-success: #20b15a;
    --color-success-light: #e9f9f0;
    --color-success-text: #15803d;
    --color-success-solid: #20b15a;
    --color-warning: #f59e0b;
    --color-warning-light: #fff7e8;
    --color-warning-soft: #fff7e8;
    --color-warning-text: #b45309;
    --color-danger: #ef4444;
    --color-danger-light: #fdeeee;
    --color-danger-soft: #fdeeee;
    --color-danger-text: #b91c1c;
    --color-danger-solid: #ef4444;

    /* ---- Shadows: soft medical blue glow ---- */
    --shadow-card: 0 15px 40px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 4px 14px rgba(18, 58, 122, 0.06);
    --shadow-md: 0 10px 28px rgba(18, 58, 122, 0.10);
    --shadow-lg: 0 24px 60px rgba(18, 58, 122, 0.16);
    --shadow-primary: 0 12px 26px rgba(18, 58, 122, 0.30);
    --shadow-accent: 0 12px 26px rgba(47, 128, 237, 0.32);
    --shadow-danger: 0 10px 22px rgba(239, 68, 68, 0.30);
    --shadow-success: 0 10px 22px rgba(32, 177, 90, 0.30);

    /* ---- Focus: medical blue ring ---- */
    --focus-ring: 0 0 0 4px rgba(47, 128, 237, 0.28);
    /* ---- Light overlays ---- */
    --color-overlay-faint: rgba(255, 255, 255, 0.10);
    --color-overlay-soft: rgba(255, 255, 255, 0.14);
    --color-overlay: rgba(255, 255, 255, 0.18);
    --color-overlay-mid: rgba(255, 255, 255, 0.22);
    --color-overlay-strong: rgba(255, 255, 255, 0.28);
}

.reg-body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-family);
    -webkit-tap-highlight-color: transparent;
}

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

a {
    color: inherit;
    text-decoration: none;
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.c-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.c-skip-link {
    position: fixed;
    top: var(--safe-top);
    inset-inline-start: var(--space-3);
    z-index: calc(var(--z-drawer) + 20);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--reg-primary);
    color: var(--color-text-inverse);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
}

.c-skip-link:focus-visible {
    transform: none;
}

.reg-main {
    flex: 1;
    display: flex;
    padding: var(--space-5) var(--gutter) calc(var(--space-6) + var(--safe-bottom));
}

.reg-shell {
    width: 100%;
    max-width: 440px;
    margin: auto;
}

.reg-topbar {
    position: relative;
    z-index: 0;
    background: var(--reg-gradient);
    border-radius: 24px;
    box-shadow: var(--reg-shadow-hero);
    padding: var(--space-5) var(--space-5) var(--space-6);
    text-align: center;
    color: var(--color-text-inverse);
}

.reg-back {
    position: absolute;
    top: var(--space-3);
    inset-inline-start: var(--space-4);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
    background: var(--color-overlay);
    border: 1px solid var(--color-border-strong);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    transition: background var(--transition-fast);
}

.reg-back:hover {
    background: var(--color-overlay-strong);
}

.reg-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    font-size: 1.7rem;
    background: var(--color-overlay);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    margin-bottom: var(--space-3);
    overflow: hidden;
}

/* Admin-managed brand logo (register.js paints it over the shop icon).
   Fills the mark without distortion; the icon stays when no logo is set. */
.reg-mark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    display: block;
}

.reg-title {
    margin: 0;
    font-size: var(--fs-2xl);
    font-weight: var(--fw-extrabold);
    line-height: 1.3;
}

.reg-subtitle {
    margin: var(--space-2) auto 0;
    max-width: 300px;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
}

.reg-card {
    position: relative;
    z-index: 1;
    margin-top: calc(-1 * var(--space-4));
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 24px;
    box-shadow: var(--shadow-card);
    padding: var(--space-5);
}

.reg-step-title {
    margin: 0 0 var(--space-4);
    font-size: var(--fs-lg);
    font-weight: var(--fw-extrabold);
    color: var(--color-text);
}

.reg-progress {
    margin: var(--space-4) 0 0;
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
}

.reg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-6) 0;
    color: var(--color-text-secondary);
    font-size: var(--fs-sm);
}

.c-spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid var(--color-border-strong);
    border-top-color: var(--reg-primary);
    animation: reg-spin 0.8s linear infinite;
}

@keyframes reg-spin {
    to { transform: rotate(360deg); }
}

.reg-types {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.reg-type {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    background: var(--color-card);
    text-align: start;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.reg-type:hover {
    border-color: var(--reg-primary);
    background: var(--reg-primary-soft);
}

.reg-type.is-selected {
    border-color: var(--reg-primary);
    background: var(--reg-primary-soft);
    box-shadow: var(--shadow-md);
}

.reg-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 16px;
background: var(--reg-primary-soft);
    color: var(--color-accent);
    font-size: 1.5rem;
}

.reg-type-body {
    flex: 1;
    min-width: 0;
}

.reg-type-name {
    display: block;
    font-size: var(--fs-base);
    font-weight: var(--fw-bold);
    color: var(--color-text);
}

.reg-type-desc {
    display: block;
    margin-top: 2px;
    font-size: var(--fs-xs);
    line-height: 1.6;
    color: var(--color-text-secondary);
}

.reg-type-radio {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--color-border-strong);
    transition: border-color var(--transition-fast);
}

.reg-type.is-selected .reg-type-radio {
    border-color: var(--reg-primary);
    background: var(--reg-primary);
    box-shadow: inset 0 0 0 4px var(--color-card);
}

.reg-form {
    display: flex;
    flex-direction: column;
}

.reg-form-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.reg-form-head .reg-step-title {
    margin: 0;
}

.reg-change-type {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border: none;
    background: transparent;
    color: var(--reg-primary-tint-text);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    opacity: 0.85;
}

.reg-change-type:hover {
    opacity: 1;
    text-decoration: underline;
}

.reg-chosen {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-4);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
background: var(--reg-primary-soft);
    color: var(--reg-primary-tint-text);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
}

.reg-field {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--space-4);
    position: relative;
}

.reg-row {
    display: flex;
    gap: var(--space-3);
}

.reg-row .reg-field {
    flex: 1;
    min-width: 0;
}

.reg-label {
    margin-bottom: var(--space-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
}

.reg-control {
    position: relative;
}

.reg-control-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: var(--space-3);
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.reg-input {
    width: 100%;
    height: var(--btn-height);
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--fs-base);
    line-height: 1.2;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.reg-control .reg-input {
    padding-inline-start: calc(var(--space-3) + 1.5rem);
}

.reg-control-toggle {
    padding-inline-end: 0;
}

.reg-control-toggle .reg-input {
    padding-inline-start: var(--space-3);
    padding-inline-end: var(--btn-height);
}

.reg-input::placeholder {
    color: var(--color-text-muted);
}

.reg-input:focus {
    outline: none;
    border-color: var(--reg-primary);
    box-shadow: var(--focus-ring);
}

.reg-input.has-error {
    border-color: var(--reg-danger);
}

.reg-toggle {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--btn-height);
    height: var(--btn-height);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
}

.reg-toggle:hover {
    color: var(--reg-primary-tint-text);
}

.reg-field-error {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-xs);
    line-height: 1.6;
    color: var(--reg-danger);
}

.reg-hint {
    margin: calc(-1 * var(--space-2)) 0 var(--space-4);
    font-size: var(--fs-xs);
    color: var(--color-text-muted);
    line-height: 1.6;
}

.reg-terms {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    cursor: pointer;
    font-size: var(--fs-sm);
    line-height: 1.6;
    color: var(--color-text);
}

.reg-terms input {
    flex: none;
    margin-top: 3px;
    width: 18px;
    height: 18px;
    accent-color: var(--reg-primary);
}

.reg-error {
    margin: 0 0 var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--reg-danger) 10%, var(--color-card));
    border: 1px solid color-mix(in srgb, var(--reg-danger) 40%, var(--color-card));
    color: var(--reg-danger);
    font-size: var(--fs-sm);
    line-height: 1.7;
}

.reg-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-7) var(--space-4);
}

.reg-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
background: var(--color-success-light);
    color: var(--color-success);
    font-size: 2.4rem;
    margin-bottom: var(--space-4);
}

.reg-success-title {
    margin: 0 0 var(--space-2);
    font-size: var(--fs-xl);
    font-weight: var(--fw-extrabold);
    color: var(--color-text);
}

.reg-success-text {
    margin: 0;
    font-size: var(--fs-base);
    color: var(--color-text-secondary);
}

.reg-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    font-size: var(--fs-xs);
    line-height: 1.7;
    color: var(--color-text-muted);
    text-align: center;
}

.reg-footer i {
    font-size: 1.1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: var(--btn-height);
    padding: 0 var(--space-5);
    border-radius: var(--radius-md);
    border: none;
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    line-height: 1;
    cursor: pointer;
    text-align: center;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.btn i {
    font-size: 1.15em;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    height: 64px;
    border-radius: var(--radius-lg);
    font-size: var(--fs-md);
}

.btn-primary {
    background: var(--reg-primary);
    color: var(--color-text-inverse);
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--reg-primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .c-skip-link,
    .c-spinner {
        transition: none;
        animation: none;
        transform: none;
    }
}

@media (min-width: 768px) {
    .reg-shell {
        max-width: 440px;
    }

    .reg-topbar {
        padding: var(--space-6) var(--space-6) var(--space-7);
    }

    .reg-card {
        padding: var(--space-7);
    }
}
/* ============================================================
   BASE TEXT COLOUR
   ------------------------------------------------------------
   variables.css set no body colour, so every element that did
   not declare its own inherited BLACK onto a near-black surface.
   This is the safety net for that whole class of bug.
   ============================================================ */
html,
body {
    color: var(--color-text);
}

::selection {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

/* ============================================================
   BUTTON SYSTEM - one source of truth for every variant/state.

   Two bugs this fixes, both found by measuring computed colours
   in a real browser rather than by reading the source:

   1. Only .btn-primary had a hover background. The other six
      variants fell back to .btn:active's scale() alone, so they
      gave the user no pressable feedback at all.
   2. Hover must never move the FOREGROUND away from the surface.
      Hover only shifts the background; text stays light.

   Disabled is a neutral surface rather than a faded primary:
   a primary button at 0.6 opacity still reads as the primary
   action, which is exactly the "looks active" defect.
   ============================================================ */
.btn-secondary:hover:not(:disabled) {
    background: var(--color-surface-alt);
    border-color: var(--color-border-strong);
}
.btn-secondary:active:not(:disabled) {
    background: var(--color-bg-subtle);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-primary-light);
    border-color: var(--color-accent);
}
.btn-outline:active:not(:disabled) {
    background: var(--color-primary-soft);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-overlay-soft);
    color: var(--color-text);
}
.btn-ghost:active:not(:disabled) {
    background: var(--color-overlay);
}

.btn-danger:hover:not(:disabled) {
    background: #B32B31;
}
.btn-danger:active:not(:disabled) {
    background: #8E1B21;
}
.btn-danger-outline:hover:not(:disabled) {
    background: var(--color-danger-light);
}
.btn-success:hover:not(:disabled) {
    background: #1D8553;
}
.btn-success:active:not(:disabled) {
    background: #12593A;
}
.btn-warning:hover:not(:disabled) {
    background: #F0B75C;
}
.btn-warning:active:not(:disabled) {
    background: #D18F2C;
}

/* --- disabled: inert surface, readable text, no elevation --- */
.btn:disabled,
.btn[disabled] {
    opacity: 1;
    background: var(--color-muted);
    color: var(--color-text-muted);
    border-color: var(--color-border);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}
.btn:disabled .bi,
.btn[disabled] .bi {
    color: inherit;
}