:root {
    --brand-navy: #1e2a3a;
    --brand-navy-dark: #16202c;
    --gold: #c9a227;
    --gold-hover: #d4b139;
    --radius: 8px;
}

html[data-bs-theme="light"] {
    color-scheme: light;
    --bg: #f6f7f9;
    --background: #f4f6f9;
    --surface: #fff;
    --surface-elevated: #fff;
    --surface-muted: #f8fafc;
    --surface-hover: rgba(30, 42, 58, 0.06);
    --border: #e2e6ea;
    --border-strong: #c9d2dc;
    --text: #111827;
    --muted: #4b5563;
    --navy: var(--brand-navy);
    --navy-soft: #243b5a;
    --input-bg: #fff;
    --danger: #b3261e;
    --danger-surface: #fdecea;
    --danger-border: #f3c2bd;
    --focus-ring: rgba(201, 162, 39, 0.32);
    --shadow: 0 18px 40px -32px rgba(30, 42, 58, 0.65);
    --page-bg: var(--bg);
    --surface-soft: var(--surface-muted);
    --inverse: #fff;
    --color-page-bg: var(--bg);
    --color-surface: var(--surface);
    --color-surface-subtle: var(--surface-muted);
    --color-border: var(--border);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text);
    --color-text-secondary: var(--muted);
    --color-text-muted: #6b7280;
    --color-text-inverse: #fff;
    --color-brand-navy: var(--brand-navy);
    --color-brand-gold: var(--gold);
    --color-success: #15803d;
}

html[data-bs-theme="dark"] {
    color-scheme: dark;
    --bg: #121923;
    --background: #121923;
    --surface: #1b2634;
    --surface-elevated: #202b3a;
    --surface-muted: #172231;
    --surface-hover: rgba(255, 255, 255, 0.055);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f5f7fb;
    --muted: #a8b2c0;
    --navy: #f5f7fb;
    --navy-soft: #d4dae3;
    --input-bg: #172231;
    --danger: #ffb4ab;
    --danger-surface: rgba(244, 67, 54, 0.14);
    --danger-border: rgba(244, 67, 54, 0.32);
    --focus-ring: rgba(201, 162, 39, 0.36);
    --shadow: 0 20px 46px -30px rgba(0, 0, 0, 0.72);
    --page-bg: var(--bg);
    --surface-soft: var(--surface-muted);
    --inverse: #fff;
    --color-page-bg: var(--bg);
    --color-surface: var(--surface);
    --color-surface-subtle: var(--surface-muted);
    --color-border: var(--border);
    --color-border-strong: var(--border-strong);
    --color-text-primary: var(--text);
    --color-text-secondary: var(--muted);
    --color-text-muted: #8e99a8;
    --color-text-inverse: #fff;
    --color-brand-navy: var(--brand-navy);
    --color-brand-gold: var(--gold);
    --color-success: #7bd88f;
}

html[data-bs-theme] body {
    background: var(--bg);
    color: var(--text);
}

html[data-bs-theme] :where(.page, .site-page) {
    background-color: var(--bg);
    color: var(--text);
}

html[data-bs-theme] :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control)::placeholder {
    color: var(--muted);
    opacity: 1;
}

html[data-bs-theme] :where(input, select, textarea, button, a):focus-visible {
    outline-color: var(--focus-ring);
}

html[data-bs-theme] :where(input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--gold);
}

html[data-bs-theme] body :where(.public-header__actions, .site-header__actions) {
    display: flex;
    align-items: center;
    gap: 10px;
}

html[data-bs-theme] body .public-header__actions {
    flex: 0 0 auto;
    justify-content: flex-end;
}

html[data-bs-theme] body .myfirm-public-theme-toggle {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--navy);
    box-shadow: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease;
}

html[data-bs-theme] body .myfirm-public-theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--gold);
    color: var(--navy);
}

html[data-bs-theme] body .myfirm-public-theme-toggle:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

html[data-bs-theme] body .myfirm-public-theme-toggle i {
    display: block;
    font-size: 1.25rem;
    line-height: 1;
}

html[data-bs-theme] body .myfirm-public-theme-toggle--inline {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 999px;
    background: var(--surface-muted);
    border-color: var(--border);
}

html[data-bs-theme] body .myfirm-public-theme-toggle--inline i {
    font-size: 1.12rem;
}

html[data-bs-theme] body .myfirm-public-theme-toggle--floating {
    position: fixed;
    inset-block-start: max(16px, env(safe-area-inset-top));
    inset-inline-end: max(16px, env(safe-area-inset-right));
    z-index: 100;
    box-shadow: var(--shadow);
}

html[dir="rtl"][data-bs-theme] body .myfirm-public-theme-toggle--floating {
    inset-inline-end: max(16px, env(safe-area-inset-left));
}

@media (max-width: 760px) {
    html[data-bs-theme] body .public-header__actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

html[data-bs-theme] :where(.errorlist, .errors, .signature-error, .required-marker) {
    color: var(--danger);
}

html[data-bs-theme] :where(.detail-label) {
    color: var(--muted);
}

html[data-bs-theme] :where(.detail-value, .detail-link, .filled) {
    color: var(--text);
}

html[data-bs-theme] :where(.invitation-email, .status-icon) {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
}

html[data-bs-theme] :where(.registration-loading-overlay) {
    background: rgba(5, 10, 18, 0.82);
}

html[data-bs-theme] :where(.signature-canvas-wrap) {
    border-color: var(--border-strong);
}

html[data-bs-theme] body :where(.public-header, .public-footer, .panel, .card, .document, .registration-loading-card) {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    box-shadow: var(--shadow);
}

html[data-bs-theme] body :where(.public-header, .public-footer) {
    background: var(--surface-elevated);
    box-shadow: none;
}

html[data-bs-theme] body :where(h1, h2, h3, .brand, .header-link, label, .success-status, .registration-loading-card h2, .registration-loading-status, .registration-loading-percentage) {
    color: var(--navy);
}

html[data-bs-theme] body :where(.subtitle, .panel__note, .secondary-action, .copy-feedback, .muted, .help, .lawyer-line, .security-note, .optional, .registration-loading-description, .registration-loading-percentage__label) {
    color: var(--muted);
}

html[data-bs-theme] body :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea, .form-control) {
    background: var(--input-bg);
    border-color: var(--border-strong);
    color: var(--text);
}

html[data-bs-theme] body :where(input:not([type="checkbox"]):not([type="radio"]):disabled, select:disabled, textarea:disabled, .form-control:disabled, input[readonly], textarea[readonly]) {
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--muted);
    cursor: not-allowed;
    opacity: 1;
}

html[data-bs-theme] body :where(input[type="file"])::file-selector-button {
    border: 0;
    border-inline-end: 1px solid var(--border-strong);
    background: var(--surface-muted);
    color: var(--navy);
    cursor: pointer;
}

html[data-bs-theme] body :where(input[type="file"]:disabled)::file-selector-button {
    color: var(--muted);
    cursor: not-allowed;
}

html[data-bs-theme] body :where(.btn, .button, .submit-button) {
    background: var(--brand-navy);
    color: #fff;
}

html[data-bs-theme] body :where(.btn:hover, .button:hover, .submit-button:hover) {
    background: var(--brand-navy-dark);
    color: #fff;
}

html[data-bs-theme] body [data-handoff-form] button[type="submit"] {
    background: var(--brand-navy);
    color: #fff;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

html[data-bs-theme] body [data-handoff-form] button[type="submit"]:hover:not(:disabled):not([aria-disabled="true"]) {
    background: var(--brand-navy-dark);
    color: #fff;
}

html[data-bs-theme] body [data-handoff-form] button[type="submit"]:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 3px;
}

html[data-bs-theme] body [data-handoff-form] button[type="submit"]:active:not(:disabled):not([aria-disabled="true"]) {
    background: var(--brand-navy-dark);
    color: #fff;
    transform: translateY(1px);
}

html[data-bs-theme] body [data-handoff-form] button[type="submit"]:disabled,
html[data-bs-theme] body [data-handoff-form] button[type="submit"][aria-disabled="true"] {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 1;
    transform: none;
}

html[data-bs-theme="dark"] body [data-handoff-form] button[type="submit"] {
    border: 1px solid var(--gold);
    box-shadow:
        0 12px 28px -20px rgba(0, 0, 0, 0.76),
        0 0 0 1px rgba(201, 162, 39, 0.08);
}

html[data-bs-theme="dark"] body [data-handoff-form] button[type="submit"]:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--gold-hover);
    box-shadow:
        0 14px 30px -20px rgba(0, 0, 0, 0.82),
        0 0 0 1px rgba(201, 162, 39, 0.14);
}

html[data-bs-theme="dark"] body [data-handoff-form] button[type="submit"]:active:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--gold-hover);
    box-shadow: 0 6px 18px -16px rgba(0, 0, 0, 0.88);
}

html[data-bs-theme] body :where(.btn--secondary, .clear-button, .header-link) {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--navy);
}

html[data-bs-theme] body :where(.btn--secondary:hover, .clear-button:hover, .header-link:hover) {
    background: var(--surface-hover);
    border-color: var(--gold);
    color: var(--navy);
}

html[data-bs-theme] body :where(.non-field-errors) {
    background: var(--danger-surface);
    border-color: var(--danger-border);
    color: var(--danger);
}

html[data-bs-theme] body :where(.registration-loading-progress) {
    background: var(--surface-muted);
}

html[data-bs-theme] body :where(.signature-canvas-wrap, #signature-canvas) {
    background: #fff;
}

html[data-bs-theme="dark"] body :where(.page) {
    background:
        linear-gradient(180deg, rgba(18, 25, 35, 0.96), rgba(18, 25, 35, 1) 42%),
        var(--bg);
}

html[data-bs-theme="dark"] body :where(.site-header) {
    background: rgba(27, 38, 52, 0.96);
    border-color: var(--border);
}

html[data-bs-theme="dark"] body :where(.hero__media-placeholder) {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
        var(--surface-muted);
}

html[data-bs-theme="dark"] body :where(.contact-placeholder input, .contact-placeholder textarea, .contact-placeholder button) {
    background: var(--input-bg);
    border-color: var(--border-strong);
    color: var(--muted);
}

html[data-bs-theme="dark"] body :where(.workspace, .faq__item, .item-card, .contact-list li, .contact-placeholder, .service-card, .step, .pricing__card) {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

html[data-bs-theme="dark"] body :where(.pill--open) {
    background: rgba(80, 140, 255, 0.18);
    color: #a8c7ff;
}

html[data-bs-theme="dark"] body :where(.pill--active) {
    background: rgba(36, 158, 82, 0.18);
    color: #7bd88f;
}

html[data-bs-theme="dark"] body :where(.error, .errors, .non-field-errors, .signature-error) {
    background: var(--danger-surface);
    border-color: var(--danger-border);
    color: var(--danger);
}
