/* CSS Custom Properties (Variables) for Dynamic Theming */
:root {
    /* Primary colors */
    --primary-color: #5469d4;
    --primary-hover-color: #4358c4;
    --primary-active-color: #3d4eae;

    /* Text colors */
    --text-primary-color: #32325d;
    --text-secondary-color: #8898aa;
    --text-light-color: #6c757d;
    --link-color: #4a5a9d;

    /* Background colors */
    --background-color: #f5f7fa;
    --surface-color: #ffffff;
    --surface-alt-color: #f8f9fa;

    /* Border colors */
    --border-color: #e6ebf1;

    /* Status colors */
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    /* Header/Footer */
    --header-background-color: #ffffff;
    --footer-text-color: #8898aa;

    /* Derived colors (computed from status colors) */
    --success-bg-color: #d4edda;
    --success-text-color: #155724;
    --success-border-color: #c3e6cb;
    --error-bg-color: #f8d7da;
    --error-text-color: #721c24;
    --error-border-color: #f5c6cb;
    --warning-bg-color: #fff3cd;
    --warning-text-color: #856404;
    --info-bg-color: #cce5ff;
    --info-text-color: #004085;
    --neutral-bg-color: #e2e3e5;
    --neutral-text-color: #383d41;

    /* Interactive / Polish */
    --scrollbar-thumb-color: rgba(199, 200, 255, 0.7);
    --scrollbar-thumb-hover: rgba(199, 200, 255, 0.9);
    --focus-ring-color: rgba(84, 105, 212, 0.4);
    --focus-shadow-color: rgba(84, 105, 212, 0.1);

    /* Sidebar specific */
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a; /* Deep space blue */
    --sidebar-text: #f8fafc;
    --sidebar-text-muted: #94a3b8;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active-bg: rgba(255, 255, 255, 0.12);
    --sidebar-active-border: #d1b75c; /* Gold filigree color */
}

/* Dark Mode Overrides */
body.dark-mode {
    --text-primary-color: #e4e4e7;
    --text-secondary-color: #a1a1aa;
    --text-light-color: #71717a;
    --link-color: #93a3e8;
    --background-color: #18181b;
    --surface-color: #27272a;
    --surface-alt-color: #3f3f46;
    --border-color: #52525b;
    --header-background-color: #27272a;
    --footer-text-color: #a1a1aa;

    /* Dark mode derived colors */
    --success-bg-color: #14532d;
    --success-text-color: #86efac;
    --success-border-color: #166534;
    --error-bg-color: #7f1d1d;
    --error-text-color: #fca5a5;
    --error-border-color: #991b1b;
    --warning-bg-color: #713f12;
    --warning-text-color: #fde047;
    --info-bg-color: #1e3a5f;
    --info-text-color: #7dd3fc;
    --neutral-bg-color: #3f3f46;
    --neutral-text-color: #d4d4d8;

    /* Interactive / Polish for Dark Mode */
    --scrollbar-thumb-color: rgba(255, 255, 255, 0.2);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.3);
    --focus-ring-color: rgba(147, 163, 232, 0.5);
    --focus-shadow-color: rgba(84, 105, 212, 0.3);
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary-color);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    overscroll-behavior: none;
}

.app-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.app-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    min-width: 0;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

main {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 12px rgba(255, 255, 255, 0.1);
    padding: 30px;
    width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    display: flex;
    flex-direction: column;
    color: var(--text-primary-color);
}

/* Surface contrast — nested sections visually distinct from parent */
/* Elements using surface-alt-color get a subtle inset shadow for depth */
[style*="surface-alt-color"],
.settings-section,
.processor-subcard,
.rollup-metric,
.section-header,
.loa-template-slot {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Reusable white child card — sits on the dark main surface */
.content-card {
    background: var(--surface-alt-color, #f0ead0);
    border: 1px solid var(--border-color, #c9a84c);
    border-radius: 8px;
    padding: 30px 25px;
    color: var(--text-primary-color, #003049);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.content-card h1,
.content-card h2,
.content-card h3,
.content-card label {
    color: var(--text-primary-color, #003049);
}

.content-card a {
    color: var(--text-secondary-color, #1a4a64);
}

.content-card input,
.content-card select,
.content-card textarea {
    background: #fff;
    color: var(--text-primary-color, #003049);
}

/* Footer */
footer {
    text-align: center;
    padding: 8px 0;
    color: var(--footer-text-color);
    font-size: 11px;
    flex-shrink: 0;
    line-height: 1.4;
}

footer nav {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Organization Header Section */
.org-header-section {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.org-logo-large {
    max-width: 100%;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin-bottom: 15px;
    border-radius: 8px;
}

.org-name-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary-color);
    margin: 0;
}

/* Payment Form */
.payment-container {
    max-width: 850px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

#paymentCardContainer {
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid var(--border-color, #e6ebf1);
    border-radius: 8px;
    background-color: var(--input-bg-color, #fff);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

#paymentCardContainer:focus-within {
    border-color: var(--primary-color, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1), inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.payment-container h2 {
    font-size: 1.75rem;
    margin-bottom: 2rem;
    text-align: left;
    color: var(--text-primary-color);
    font-weight: 700;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 20px;
    padding-bottom: 0;
}

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-primary-color);
}

.form-group input,
.form-group select {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--text-primary-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-shadow-color);
}

.form-group input::placeholder {
    color: var(--text-secondary-color);
}

/* Two column layout */
.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    max-width: 100%;
}

.form-group.half {
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

/* Stripe Card Element */
#card-element {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#card-element.StripeElement--focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-shadow-color);
}

#card-element.StripeElement--invalid {
    border-color: var(--error-color);
}

/* Error Message */
.error-message {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 8px;
    min-height: 20px;
}

/* Submit Button — neutralized green */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    color: #FFFFFF;
    background-color: #5FA77A;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    text-decoration: none;
}

.btn-primary:hover {
    background-color: #4E966A;
    transform: translateY(-1px);
    box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
}

.btn-primary:active {
    background-color: #4E966A;
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Secondary Button — neutralized blue */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #FFFFFF;
    background-color: #5F7FBF;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    text-decoration: none;
}

.btn-secondary:hover {
    background-color: #4E6EAD;
    transform: translateY(-1px);
}

.btn-secondary:active {
    background-color: #4E6EAD;
    transform: translateY(0);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =========================================================================
   Semantic Button Colors (standardized across all templates)
   ========================================================================= */

/* Global text shadow and soft white for button text */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-edit,
.btn-action,
.btn-success,
.btn-payment {
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
    color: #f0f0f0;
}

/* Yellow edit button keeps dark text */
.btn-edit {
    color: #2a2a2a;
}

/* Serious / Destructive actions (remove, revoke, cancel, delete) — neutralized red */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    background-color: #C96464;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-danger:hover { background-color: #B55353; transform: translateY(-1px); }
.btn-danger:active { background-color: #B55353; transform: translateY(0); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Edit actions (edit details, resend welcome, reset password) — neutralized yellow */
.btn-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #1F1F1F;
    background-color: #D1B75C;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-edit:hover { background-color: #BFA74E; transform: translateY(-1px); }
.btn-edit:active { background-color: #BFA74E; transform: translateY(0); }
.btn-edit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Non-primary actions (email, Google Meet, external links) — neutralized blue */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    background-color: #5F7FBF;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-action:hover { background-color: #4E6EAD; transform: translateY(-1px); }
.btn-action:active { background-color: #4E6EAD; transform: translateY(0); }
.btn-action:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Positive actions (submit, agree, approve) — neutralized green */
.btn-success {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #FFFFFF;
    background-color: #5FA77A;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-success:hover { background-color: #4E966A; transform: translateY(-1px); }
.btn-success:active { background-color: #4E966A; transform: translateY(0); }
.btn-success:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Payment buttons — neutralized red with white text */
.btn-payment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 700;
    color: #FFFFFF;
    background-color: #C96464;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn-payment:hover { background-color: #B55353; transform: translateY(-1px); }
.btn-payment:active { background-color: #B55353; transform: translateY(0); }
.btn-payment:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--surface-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Message */
.message {
    margin-top: 20px;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}

.message.success {
    background-color: var(--success-bg-color);
    color: var(--success-text-color);
    border: 1px solid var(--success-border-color);
}

.message.error {
    background-color: var(--error-bg-color);
    color: var(--error-text-color);
    border: 1px solid var(--error-border-color);
}

/* Hidden class */
.hidden {
    display: none;
}

/* Result Pages */
.result-container {
    text-align: center;
    max-width: 800px;
    margin: auto;
    padding: 20px;
    box-sizing: border-box;
}

.result-icon {
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-container.success .result-icon {
    color: var(--success-color);
}

.result-container.failure .result-icon {
    color: var(--error-color);
}

.result-container h2 {
    font-size: 28px;
    margin-bottom: 15px;
}

.result-container.success h2 {
    color: var(--success-color);
}

.result-container.failure h2 {
    color: var(--error-color);
}

.result-message {
    font-size: 16px;
    color: var(--text-light-color);
    margin-bottom: 25px;
}

/* Payment Details */
.payment-details {
    background: var(--surface-alt-color, #f8fafc);
    border: 1px solid var(--border-color, #edf2f7);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    text-align: left;
}

.payment-details h3 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-light-color, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.payment-details dl {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 0.75rem 1rem;
    margin: 0;
}

.payment-details dt {
    font-weight: 500;
    color: var(--text-light-color, #718096);
    font-size: 0.9rem;
}

.payment-details dd {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary-color, #1a202c);
    font-size: 0.95rem;
}

.payment-details dt {
    font-weight: 500;
    color: var(--text-secondary-color);
}

.payment-details dd {
    color: var(--text-primary-color);
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-pending {
    background-color: var(--warning-bg-color);
    color: var(--warning-text-color);
}

.status-processing {
    background-color: var(--info-bg-color);
    color: var(--info-text-color);
}

.status-completed {
    background-color: var(--success-bg-color);
    color: var(--success-text-color);
}

.status-failed {
    background-color: var(--error-bg-color);
    color: var(--error-text-color);
}

.status-refunded {
    background-color: var(--neutral-bg-color);
    color: var(--neutral-text-color);
}

.status-cancelled {
    background-color: var(--neutral-bg-color);
    color: var(--neutral-text-color);
}

.status-admin {
    background-color: rgba(84, 105, 212, 0.15);
    color: var(--primary-color);
}

/* Confirmation Page Styles */
.confirmation-header {
    text-align: center;
    margin-bottom: 25px;
}

.confirmation-header h3 {
    font-size: 22px;
    color: var(--text-primary-color);
    margin-bottom: 10px;
}

.confirmation-note {
    font-size: 14px;
    color: var(--text-secondary-color);
    margin-bottom: 25px;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}

.confirm-buttons .btn-edit {
    flex: 1;
}

.confirm-buttons .btn-payment {
    flex: 2;
}

/* Payment Flow Button Styles — fixed semantic colors */
#review-button {
    background-color: #00DE5E;
    color: #003300;
    border: 2px solid #00DE5E;
}

#review-button:hover {
    background-color: #00c754;
    border-color: #00c754;
}

#review-button:active {
    background-color: #00b04a;
    border-color: #00b04a;
}

#submit-button {
    background-color: #F22E2E;
    color: #C7CF00;
    border: 2px solid #F22E2E;
}

#submit-button:hover {
    background-color: #d92626;
    border-color: #d92626;
    color: #C7CF00;
}

#submit-button:active {
    background-color: #c02020;
    border-color: #c02020;
}

#edit-button {
    background-color: #CCC200;
    color: #1a1a00;
    border: 2px solid #CCC200;
}

#edit-button:hover {
    background-color: #b5ac00;
    color: #1a1a00;
}

#edit-button:active {
    background-color: #9e9600;
    border-color: #9e9600;
}

.error-details {
    background: var(--error-bg-color);
    border: 1px solid var(--error-border-color);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    text-align: left;
}

.help-text {
    font-size: 14px;
    color: var(--text-light-color);
    margin-bottom: 25px;
}

/* Color Scheme Editor (Owner Only) */
.color-scheme-editor {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.color-scheme-editor h2 {
    margin-bottom: 30px;
    color: var(--text-primary-color);
}

.color-group {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--surface-alt-color);
    border-radius: 8px;
}

.color-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
}

.color-input-group {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 100%;
}

.color-input-group label {
    flex: 1;
    min-width: 150px;
    font-size: 14px;
    color: var(--text-primary-color);
    overflow-wrap: break-word;
}

.color-input-group input[type="color"] {
    width: 50px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.color-input-group input[type="text"] {
    width: 100px;
    max-width: 100%;
    padding: 8px;
    font-size: 14px;
    font-family: monospace;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--surface-color);
    color: var(--text-primary-color);
    text-transform: uppercase;
    box-sizing: border-box;
}

.color-preview {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Preview Section */
.preview-section {
    margin-top: 40px;
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
}

.preview-section h3 {
    margin-bottom: 20px;
    color: var(--text-primary-color);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    main {
        padding: 20px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group.half {
        flex: none;
        width: 100%;
        max-width: 100%;
    }

    .payment-details dl {
        grid-template-columns: 1fr;
    }

    .payment-details dt {
        margin-top: 10px;
    }

    .confirm-buttons {
        flex-direction: column;
    }

    .confirm-buttons .btn-edit,
    .confirm-buttons .btn-payment {
        flex: none;
        width: 100%;
    }

    .org-logo-large {
        max-width: 80px;
    }

    .org-name-title {
        font-size: 20px;
    }

    .color-input-group {
        flex-wrap: wrap;
    }

    .color-input-group label {
        flex-basis: 100%;
        margin-bottom: 8px;
        min-width: 100%;
    }

    /* Ensure tables scroll on small screens */
    .table-container {
        margin-left: -15px;
        margin-right: -15px;
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Stack navigation items vertically on very small screens if needed */
    header nav {
        word-break: break-word;
    }

    footer nav {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    footer nav span {
        display: none;
    }

    /* Reduce font sizes slightly on small screens to prevent overflow */
    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }
}

/* Additional responsive breakpoint for tablets */
@media (max-width: 768px) {
    .form-row {
        flex-wrap: wrap;
    }

    .form-group.half {
        min-width: calc(50% - 8px);
    }

    .color-input-group {
        flex-wrap: wrap;
    }
}

/* Ensure very small screens don't have overflow */
@media (max-width: 320px) {
    .container {
        padding: 10px;
    }

    main {
        padding: 15px;
    }

    .form-group.half {
        min-width: 100%;
    }

    .color-input-group label {
        min-width: 100%;
    }

    .color-input-group input[type="text"] {
        width: 80px;
    }
}

/* Toggle Switch */
.toggle-input-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-input-group > label:first-child {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary-color);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--surface-color);
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px var(--focus-shadow-color);
}

.toggle-label {
    font-size: 14px;
    color: var(--text-secondary-color);
    min-width: 70px;
}

/* Table Responsiveness - Prevent horizontal overflow */
table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
}

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table th,
table td {
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

/* Utility classes for overflow prevention */
.overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.max-w-full {
    max-width: 100%;
}

.word-break {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Ensure pre and code elements don't cause overflow */
pre, code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Ensure iframes and embedded content are responsive */
iframe, embed, object, video {
    max-width: 100%;
    height: auto;
}

/* Additional overflow prevention for specific elements */
.payment-container,
.result-container,
.color-scheme-editor {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Ensure article content in policy pages doesn't overflow */
article {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

article > div {
    max-width: 100%;
}

article h1, article h2, article h3 {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

article ul, article ol {
    max-width: 100%;
    padding-left: 20px;
}

/* Org grid responsiveness improvements */
.org-grid {
    max-width: 100%;
}

/* Ensure buttons don't cause overflow */
button, [class*="btn-"] {
    max-width: 100%;
    overflow-wrap: break-word;
}

/* Additional form element safeguards */
input, select, textarea {
    max-width: 100%;
    box-sizing: border-box;
    color: var(--text-primary-color);
    background-color: var(--surface-color);
}

textarea {
    width: 100%;
    resize: vertical;
}

/* ===== Form Validation Styles ===== */
.field-error {
    border-color: var(--error-color) !important;
    background-color: var(--error-bg-color);
}

.field-error:focus {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1) !important;
}

.form-group .error-message {
    color: var(--error-color);
    font-size: 13px;
    margin-top: 6px;
    display: none;
    font-weight: 500;
}

.form-group .error-message:not(:empty) {
    display: block;
}

/* Success state for validated fields */
.field-success {
    border-color: var(--success-color) !important;
}

.field-success:focus {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1) !important;
}

/* Password strength indicator */
.password-strength-indicator {
    margin-top: 8px;
}

.strength-bar {
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.strength-fill {
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    width: 0;
}

.strength-bar.strength-weak .strength-fill {
    width: 33%;
    background-color: var(--error-color);
}

.strength-bar.strength-medium .strength-fill {
    width: 66%;
    background-color: var(--warning-color);
}

.strength-bar.strength-strong .strength-fill {
    width: 100%;
    background-color: var(--success-color);
}

.strength-text {
    font-size: 13px;
    color: var(--text-secondary-color);
}

.strength-text strong {
    color: var(--text-primary-color);
    text-transform: capitalize;
}

/* ===== Skip to Content Link (Accessibility) ===== */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 500;
}

.skip-to-content:focus {
    top: 0;
    outline: 3px solid var(--primary-hover-color);
    outline-offset: 2px;
}

/* ===== Screen Reader Only Content ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ===== Focus Visible Enhancement ===== */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ===== Hamburger Menu for Mobile ===== */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 2px solid var(--border-color);
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--surface-alt-color);
    border-color: var(--text-secondary-color);
}

.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
}

.hamburger-icon span {
    display: block;
    height: 2px;
    background-color: var(--text-primary-color);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:first-child {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-icon span:last-child {
    transform: rotate(-45deg) translate(6px, -6px);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .sticky-header .nav-links,
    .sticky-header .nav-bottom-actions {
        display: none;
    }

    .sticky-header.menu-open .nav-links,
    .sticky-header.menu-open .nav-bottom-actions {
        display: flex;
    }

    .sticky-header.menu-open {
        max-width: 90%;
    }

    .header-main {
        position: relative;
    }

    .mobile-menu-toggle {
        position: absolute;
        top: 0;
        right: 0;
    }
}

/* ========================================
   Icon Utility Classes
   ======================================== */

/* Icon sizes - use with img tags */
.icon-xs {
    width: 14px;
    height: 14px;
    object-fit: contain;
}

.icon-sm {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.icon-md {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.icon-lg {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.icon-xl {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.icon-2xl {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

/* Icon containers with background */
.icon-container {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 8px;
}

.icon-container-sm {
    padding: 4px;
}

.icon-container-lg {
    padding: 12px;
}

/* Icon container backgrounds by type */
.icon-container-success {
    background: rgba(10, 191, 23, 0.15);
}

.icon-container-error {
    background: rgba(239, 68, 68, 0.15);
}

.icon-container-warning {
    background: rgba(245, 158, 11, 0.15);
}

.icon-container-info {
    background: rgba(59, 130, 246, 0.15);
}

.icon-container-neutral {
    background: var(--surface-alt-color);
}

/* Inline icon alignment */
.icon-inline {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.icon-inline-end {
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}

/* =========================================================================
   Sidebar Layout (#268)
   ========================================================================= */

.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1400;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    z-index: 1500;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
}

.app-main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--background-color);
}

/* Sidebar Branding */
.sidebar-header {
    padding: 30px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    max-height: 40px;
    width: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: none !important;
}

.sidebar-brand-name {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--sidebar-text);
    font-family: 'Sen', sans-serif;
}

/* Sidebar User Info */
.sidebar-user {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-user-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--sidebar-text);
    margin-bottom: 4px;
}

.sidebar-user-role {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-active-border);
    padding: 2px 8px;
    background: rgba(209, 183, 92, 0.1);
    border: 1px solid rgba(209, 183, 92, 0.2);
    border-radius: 4px;
}

.shadow-mode-banner {
    margin-top: 8px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: #0f172a;
    background: #d1b75c;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
    letter-spacing: 0.05em;
}

.sidebar-request-id {
    font-size: 10px;
    color: var(--sidebar-text-muted);
    font-family: monospace;
    margin-bottom: 12px;
    text-align: center;
    opacity: 0.6;
    cursor: help;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 24px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--sidebar-text-muted);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    text-decoration: none !important;
}

.nav-item:hover {
    color: var(--sidebar-text);
    background-color: var(--sidebar-hover);
}

.nav-item.active {
    color: var(--sidebar-text);
    background-color: var(--sidebar-active-bg);
    border-left: 3px solid var(--sidebar-active-border);
    padding-left: 13px; /* Adjust for border */
}

.nav-item-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item:hover .nav-item-icon,
.nav-item.active .nav-item-icon {
    opacity: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-logout-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout-sidebar:hover {
    background: #ef4444;
    color: white;
}

/* Mobile Toggle - Persistent Hamburger */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1600;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }
    
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .app-sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
    
    .app-layout {
        flex-direction: column;
    }
}

/* Sidebar Context Switcher (#269) */
.sidebar-context-switcher {
    padding: 20px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.context-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--sidebar-text-muted);
    letter-spacing: 0.1em;
    margin-bottom: 12px;
}

.active-org-display {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.context-org-logo {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    object-fit: contain;
    background: white;
}

.active-org-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--sidebar-text);
}

.btn-switch-org {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--sidebar-text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-switch-org:hover {
    background: rgba(255, 255, 255, 0.1);
}

.org-list {
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.org-link {
    display: block;
    padding: 10px 14px;
    color: var(--sidebar-text-muted);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
}

.org-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--sidebar-text);
}

.org-link.active {
    background: rgba(209, 183, 92, 0.1);
    color: #d1b75c;
    font-weight: 700;
    border-left: 3px solid #d1b75c;
}

/* Global Centered Header Styles — Neat and Professional (#268) */
.page-centered-header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
    padding-top: 10px;
}

.header-back-nav {
    position: absolute;
    top: 0;
    left: 0;
}

.btn-back-arrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
}

.btn-back-arrow:hover {
    color: var(--primary-color);
}

.header-logo-container {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.header-logo-main {
    max-height: 80px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
}

.header-main-content h2, 
.header-main-content h1 {
    margin: 0 0 12px;
    color: var(--text-primary-color);
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-badges {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.org-badge-large {
    display: inline-block;
    padding: 4px 12px;
    background: var(--surface-alt-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary-color);
}

.org-list-empty {
    padding: 12px 14px;
    font-size: 11px;
    color: var(--sidebar-text-muted);
    font-style: italic;
    text-align: center;
}

/* Compliance and Consent (SOC 2 / PCI) */
.compliance-box {
    margin: 24px 0;
    padding: 20px;
    background: var(--surface-alt-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.consent-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.consent-row input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.consent-row label {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary-color);
    cursor: pointer;
}

.compliance-note-small {
    margin: 12px 0 0 30px;
    font-size: 12px;
    color: var(--text-secondary-color);
    font-style: italic;
}
