<style>
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

    :root {
        color-scheme: light dark;

        /* Core palette */
        --md-sys-color-primary: #4F46E5;
        --md-sys-color-on-primary: #ffffff;
        --md-sys-color-primary-container: #E0E7FF;
        --md-sys-color-on-primary-container: #1E1B6E;
        --md-sys-color-surface: #ffffff;
        --md-sys-color-surface-container: #F8FAFC;
        --md-sys-color-surface-variant: #F1F5F9;
        --md-sys-color-outline: #E2E8F0;
        --md-sys-color-outline-variant: #CBD5E1;
        --md-sys-color-on-surface: #1E293B;
        --md-sys-color-on-surface-variant: #475569;
        --md-sys-color-success: #047857;
        --md-sys-color-success-bg: #D1FAE5;
        --md-sys-color-warning: #B45309;
        --md-sys-color-warning-bg: #FEF3C7;
        --md-sys-color-error: #B91C1C;
        --md-sys-color-error-bg: #FEE2E2;

        /* State layer opacities */
        --md-sys-state-hover-opacity: 0.08;
        --md-sys-state-focus-opacity: 0.12;
        --md-sys-state-pressed-opacity: 0.14;
        --md-sys-state-dragged-opacity: 0.16;

        /* Motion tokens */
        --md-sys-motion-duration-short: 120ms;
        --md-sys-motion-duration-medium: 220ms;
        --md-sys-motion-duration-long: 320ms;
        --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
        --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1.2);

        /* Type scale */
        --md-sys-typescale-title-large-size: 1.75rem;
        --md-sys-typescale-body-large-size: 0.9375rem;
        --md-sys-typescale-body-medium-size: 0.875rem;
        --md-sys-typescale-label-large-size: 0.75rem;

        /* Spacing / elevation / shape */
        --md-sys-space-1: 4px;
        --md-sys-space-2: 8px;
        --md-sys-space-3: 12px;
        --md-sys-space-4: 16px;
        --md-sys-space-5: 20px;
        --md-sys-space-6: 24px;
        --md-sys-space-8: 32px;
        --md-sys-shape-corner-small: 8px;
        --md-sys-shape-corner-medium: 12px;
        --md-sys-shape-corner-large: 16px;
        --md-sys-elevation-level1: 0 2px 8px rgba(0, 0, 0, 0.1);
        --md-sys-elevation-level2: 0 10px 40px rgba(0, 0, 0, 0.15);

        /* App tokens */
        --app-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        --app-gradient-bg: linear-gradient(150deg, #4F46E5 0%, #3730A3 50%, #1E1B6E 100%);
        --app-page-bg: linear-gradient(150deg, #4F46E5 0%, #3730A3 50%, #1E1B6E 100%);
        --app-content-max-width: 760px;
        --app-card-bg: var(--md-sys-color-surface);
        --app-card-fg: var(--md-sys-color-on-surface);
    }

    html[data-theme="light"] {
        color-scheme: light;
    }

    html[data-theme="dark"] {
        color-scheme: dark;
        --md-sys-color-primary: #A5B4FC;
        --md-sys-color-on-primary: #1E1B6E;
        --md-sys-color-primary-container: #312E81;
        --md-sys-color-on-primary-container: #E0E7FF;
        --md-sys-color-surface: #0F172A;
        --md-sys-color-surface-container: #111827;
        --md-sys-color-surface-variant: #1F2937;
        --md-sys-color-outline: #334155;
        --md-sys-color-outline-variant: #475569;
        --md-sys-color-on-surface: #E2E8F0;
        --md-sys-color-on-surface-variant: #CBD5E1;
        --md-sys-color-success-bg: rgba(16, 185, 129, 0.15);
        --md-sys-color-warning-bg: rgba(245, 158, 11, 0.18);
        --md-sys-color-error-bg: rgba(239, 68, 68, 0.2);
        --app-gradient-bg: linear-gradient(150deg, #1E1B6E 0%, #312E81 50%, #111827 100%);
        --app-page-bg: linear-gradient(150deg, #1E1B6E 0%, #312E81 50%, #111827 100%);
    }

    @media (prefers-color-scheme: dark) {
        html:not([data-theme]) {
            color-scheme: dark;
            --md-sys-color-primary: #A5B4FC;
            --md-sys-color-on-primary: #1E1B6E;
            --md-sys-color-primary-container: #312E81;
            --md-sys-color-on-primary-container: #E0E7FF;
            --md-sys-color-surface: #0F172A;
            --md-sys-color-surface-container: #111827;
            --md-sys-color-surface-variant: #1F2937;
            --md-sys-color-outline: #334155;
            --md-sys-color-outline-variant: #475569;
            --md-sys-color-on-surface: #E2E8F0;
            --md-sys-color-on-surface-variant: #CBD5E1;
            --md-sys-color-success-bg: rgba(16, 185, 129, 0.15);
            --md-sys-color-warning-bg: rgba(245, 158, 11, 0.18);
            --md-sys-color-error-bg: rgba(239, 68, 68, 0.2);
            --app-gradient-bg: linear-gradient(150deg, #1E1B6E 0%, #312E81 50%, #111827 100%);
            --app-page-bg: linear-gradient(150deg, #1E1B6E 0%, #312E81 50%, #111827 100%);
        }
    }
    /* ==================== REASON/NOTES BOX STYLES ==================== */
    .reason-box {
        margin-top: 24px;
        padding: 18px 20px;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        animation: slideIn 0.3s ease-out;
    }

    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Incomplete - Orange/Warning (P2 Fix: uses token vars) */
    .reason-box.reason-incomplete {
        background: var(--md-sys-color-warning-bg, #FEF3C7);
        border-left: 5px solid var(--md-sys-color-warning, #B45309);
    }

    .reason-box.reason-incomplete .reason-label {
        color: var(--md-sys-color-warning-text, #92400E);
    }

    /* Closed - Blue/Info */
    .reason-box.reason-closed {
        background: #DBEAFE;
        border-left: 5px solid #1D4ED8;
    }

    .reason-box.reason-closed .reason-label {
        color: #1E40AF;
    }

    /* Can't Do - Red/Error (P2 Fix: uses token vars) */
    .reason-box.reason-cant-do {
        background: var(--md-sys-color-error-bg, #FEE2E2);
        border-left: 5px solid var(--md-sys-color-error, #B91C1C);
    }

    .reason-box.reason-cant-do .reason-label {
        color: var(--md-sys-color-error-text, #991B1B);
    }

    /* Empty reason - Gray */
    .reason-box.empty {
        background: var(--md-sys-color-surface-variant, #F1F5F9);
        border-left: 5px solid #94A3B8;
    }

    .reason-label {
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
        margin-bottom: 10px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .reason-text {
        font-size: 14px;
        color: #1E293B;
        line-height: 1.7;
        font-weight: 500;
        white-space: pre-wrap;
        word-break: break-word;
    }



    /* ============================================
       RESET & GLOBAL STYLES
       ============================================ */
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    html {
        font-size: 16px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    body {
        font-family: var(--app-font-family);
        background: var(--app-page-bg);
        background-attachment: fixed;
        min-height: 100vh;
        padding: 20px;
        line-height: 1.6;
        color: var(--md-sys-color-on-surface);
        -webkit-font-smoothing: antialiased;
    }

    /* ============================================
       CONTAINER
       ============================================ */
    .container {
        max-width: var(--app-content-max-width);
        margin: 0 auto;
        animation: slideUp var(--md-sys-motion-duration-long) var(--md-sys-motion-easing-standard);
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translateY(40px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* ============================================
       HEADER BRANDING
       ============================================ */
    .header-brand {
        text-align: center;
        padding: 20px 0;
        margin-bottom: 20px;
    }

    .header-brand h1 {
        color: white;
        font-size: 28px;
        font-weight: 800;
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        margin-bottom: 8px;
        letter-spacing: -0.5px;
    }

    .header-brand p {
        color: rgba(255, 255, 255, 0.9);
        font-size: 14px;
        font-weight: 500;
    }

    .header-actions {
        margin-top: 14px;
        display: inline-flex;
        align-items: center;
        gap: 10px;
    }

    .theme-toggle-btn {
        border: 1px solid rgba(255, 255, 255, 0.35);
        background: rgba(255, 255, 255, 0.12);
        color: #ffffff;
        border-radius: 999px;
        padding: 8px 14px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.4px;
        cursor: pointer;
        transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
    }

    .theme-toggle-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: translateY(-1px);
    }

    .theme-toggle-btn:focus-visible {
        outline: 3px solid rgba(255, 255, 255, 0.8);
        outline-offset: 2px;
    }

    /* ============================================
       TAB NAVIGATION
       ============================================ */
    .tab-navigation {
        background: var(--md-sys-color-surface);
        border-radius: 16px 16px 0 0;
        display: flex;
        overflow: hidden;
        box-shadow: var(--md-sys-elevation-level1);
        margin-bottom: 0;
    }

    .tab-button {
        flex: 1;
        padding: 18px 20px;
        background: var(--md-sys-color-surface-variant);
        border: none;
        font-size: 15px;
        font-weight: 700;
        color: var(--md-sys-color-on-surface-variant);
        cursor: pointer;
        transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        border-bottom: 3px solid transparent;
    }

    .tab-button:hover {
        background: var(--md-sys-color-outline);
        color: var(--md-sys-color-on-surface);
        transform: translateY(-1px);
    }

    .tab-button.active {
        background: var(--md-sys-color-surface);
        color: var(--md-sys-color-primary);
        border-bottom: 3px solid var(--md-sys-color-primary);
    }

    .tab-button i {
        font-size: 16px;
    }

    /* ============================================
       CHEAT SHEET
       ============================================ */
    .cheat-sheet {
        background: var(--md-sys-color-surface);
        border-radius: 0 0 16px 16px;
        padding: 28px 32px;
        margin-bottom: 24px;
        box-shadow: var(--md-sys-elevation-level2);
        border-left: 6px solid #EF4444;
        animation: fadeIn 0.3s ease-out;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    .cheat-sheet-title {
        font-size: 21px;
        font-weight: 800;
        color: #1E293B;
        margin-bottom: 18px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .cheat-sheet-title i {
        font-size: 26px;
        color: #EF4444;
    }

    .cheat-sheet-subtitle {
        font-size: 16px;
        font-weight: 700;
        color: #DC2626;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 14px 18px;
        background: #FEE2E2;
        border-radius: 10px;
        border-left: 4px solid #DC2626;
    }

    .checklist {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .checklist li {
        padding: 14px 18px;
        margin-bottom: 12px;
        background: var(--md-sys-color-surface-container);
        border-radius: 10px;
        display: flex;
        align-items: flex-start;
        gap: 14px;
        font-size: 14px;
        color: var(--md-sys-color-on-surface);
        line-height: 1.6;
        border: 2px solid var(--md-sys-color-outline);
        transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    }

    .checklist li:hover {
        background: var(--md-sys-color-primary-container);
        border-color: var(--md-sys-color-primary);
        transform: translateX(4px);
        box-shadow: 0 2px 10px rgba(79, 70, 229, 0.1);
    }

    .checklist li i {
        font-size: 18px;
        color: #4F46E5;
        margin-top: 2px;
        flex-shrink: 0;
    }

    .checklist li strong {
        color: #0F172A;
    }

    .magic-fix {
        background: linear-gradient(135deg, #FCD34D 0%, #F59E0B 100%);
        border: 3px solid #D97706 !important;
        color: #78350F;
        font-weight: 700;
        box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
        animation: pulse 2.5s ease-in-out infinite;
    }

    .magic-fix i {
        color: #D97706 !important;
    }

    @keyframes pulse {

        0%,
        100% {
            box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
            transform: scale(1);
        }

        50% {
            box-shadow: 0 4px 20px rgba(245, 158, 11, 0.5), 0 0 0 8px rgba(245, 158, 11, 0.1);
            transform: scale(1.01);
        }
    }

    /* ============================================
       FORM CARDS
       ============================================ */
    .form-card {
        background: var(--md-sys-color-surface);
        border-radius: 16px;
        padding: 36px 32px;
        box-shadow: var(--md-sys-elevation-level2);
        display: none;
    }

    .form-card.active {
        display: block;
        animation: fadeIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    }

    .form-header {
        text-align: center;
        margin-bottom: 32px;
        padding-bottom: 24px;
        border-bottom: 2px solid var(--md-sys-color-outline);
    }

    .form-header h1 {
        font-size: 26px;
        color: var(--md-sys-color-on-surface);
        margin-bottom: 10px;
        font-weight: 800;
        letter-spacing: -0.5px;
    }

    .form-header h1 i {
        margin-right: 8px;
        color: var(--md-sys-color-primary);
    }

    .form-header .subtitle {
        font-size: var(--md-sys-typescale-body-medium-size);
        color: var(--md-sys-color-on-surface-variant);
        font-weight: 500;
        line-height: 1.5;
    }

    .form-header .badge {
        display: inline-block;
        background: var(--app-gradient-bg);
        color: var(--md-sys-color-on-primary);
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 11px;
        font-weight: 700;
        margin-top: 12px;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }

    /* ============================================
       FORM ELEMENTS
       ============================================ */
    .form-group {
        margin-bottom: 24px;
    }

    .form-label {
        font-size: 12px;
        font-weight: 700;
        color: var(--md-sys-color-on-surface-variant);
        margin-bottom: 10px;
        display: block;
        text-transform: uppercase;
        letter-spacing: 0.6px;
    }

    .form-label .required {
        color: #DC2626;
        margin-left: 4px;
        font-size: 14px;
    }

    .form-label .optional {
        color: #94A3B8;
        font-size: 10px;
        font-weight: 600;
        margin-left: 6px;
        text-transform: lowercase;
        letter-spacing: 0.3px;
    }

    .form-input,
    .form-textarea,
    .form-select,
    .c-input,
    .c-textarea,
    .c-select {
        width: 100%;
        padding: 15px 18px;
        border: 2px solid var(--md-sys-color-outline);
        border-radius: 12px;
        font-size: 15px;
        font-weight: 500;
        color: var(--md-sys-color-on-surface);
        transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
        font-family: inherit;
        background: var(--md-sys-color-surface);
    }

    .form-input::placeholder,
    .form-textarea::placeholder,
    .c-input::placeholder,
    .c-textarea::placeholder {
        color: #64748B;
        font-weight: 400;
    }

    .form-select {
        cursor: pointer;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath fill='%23475569' d='M7 10L2 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 18px center;
        background-size: 14px;
        padding-right: 50px;
        appearance: none;
    }

    .form-input:hover,
    .form-textarea:hover,
    .form-select:hover,
    .c-input:hover,
    .c-textarea:hover,
    .c-select:hover {
        border-color: #CBD5E1;
    }

    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus,
    .c-input:focus,
    .c-textarea:focus,
    .c-select:focus {
        outline: none;
        border-color: #4F46E5;
        box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    }

    .form-textarea {
        min-height: 140px;
        resize: vertical;
        line-height: 1.7;
        max-height: 400px;
    }

    .form-hint {
        font-size: 12px;
        color: #64748B;
        margin-top: 8px;
        display: flex;
        align-items: center;
        gap: 8px;
        line-height: 1.5;
    }

    .form-hint i {
        font-size: 13px;
        flex-shrink: 0;
    }

    /* ============================================
       BUTTONS
       ============================================ */
    .btn-container {
        display: flex;
        gap: 14px;
        margin-top: 32px;
    }

    .btn,
    .c-button {
        flex: 1;
        padding: 17px 28px;
        border: none;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 700;
        cursor: pointer;
        transition: all var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        letter-spacing: 0.3px;
    }

    .btn i,
    .c-button i {
        font-size: 16px;
    }

    .btn-primary,
    .c-button--primary {
        background: var(--app-gradient-bg);
        color: var(--md-sys-color-on-primary);
        box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
    }

    .btn-primary:hover:not(:disabled),
    .c-button--primary:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 6px 25px rgba(79, 70, 229, 0.5);
    }

    .btn-primary:active:not(:disabled),
    .c-button--primary:active:not(:disabled) {
        transform: translateY(0);
    }

    .btn-secondary,
    .c-button--secondary {
        background: var(--md-sys-color-surface-variant);
        color: var(--md-sys-color-on-surface-variant);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .btn-secondary:hover,
    .c-button--secondary:hover {
        background: var(--md-sys-color-outline);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }

    .btn:disabled,
    .c-button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none !important;
    }

    /* ============================================
       LOADING STATE
       ============================================ */
    .loading {
        display: none;
        text-align: center;
        padding: 50px 20px;
    }

    .spinner {
        width: 55px;
        height: 55px;
        border: 5px solid var(--md-sys-color-outline);
        border-top-color: #4F46E5;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
        margin: 0 auto 20px;
    }

    @keyframes spin {
        to {
            transform: rotate(360deg);
        }
    }

    .loading p {
        color: var(--md-sys-color-on-surface-variant);
        font-weight: 600;
        font-size: 15px;
    }

    .tab-button:focus-visible {
        outline: 3px solid var(--md-sys-color-primary);
        outline-offset: -2px;
    }

    .loading[aria-hidden="true"] {
        display: none;
    }

    .status-dot-icon {
        font-size: 8px;
    }

    .success-layout {
        text-align: left;
    }

    .success-title {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .success-details {
        margin-top: 16px;
        padding: 16px;
        background: rgba(255, 255, 255, 0.5);
        border-radius: 8px;
    }

    .success-ticket-heading {
        margin-bottom: 10px;
        font-size: 15px;
        font-weight: 700;
    }

    .success-ticket-id {
        color: var(--md-sys-color-primary);
        font-family: monospace;
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 16px;
    }

    .success-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        font-size: 14px;
    }

    .success-notification {
        margin-top: 8px;
    }

    .success-notification.sent {
        color: #059669;
    }

    .success-notification.pending {
        color: #94a3b8;
    }

    .next-steps {
        margin-top: 16px;
        padding: 14px;
        background: #eef2ff;
        border-radius: 8px;
        font-size: 13px;
    }

    .next-steps-title {
        margin-bottom: 8px;
        color: #059669;
    }

    .next-steps-body {
        color: #475569;
        line-height: 1.6;
    }

    .code-chip {
        background: #ffffff;
        padding: 2px 6px;
        border-radius: 4px;
        font-family: monospace;
    }

    .success-meta {
        margin-top: 12px;
        font-size: 12px;
        color: #64748b;
        text-align: center;
    }

    .technical-error {
        margin-top: 8px;
        font-size: 11px;
        color: #7f1d1d;
        background: #fef2f2;
        padding: 8px;
        border-radius: 4px;
        font-family: monospace;
        word-break: break-all;
    }

    .auto-email-icon {
        color: #22c55e;
    }

    .auto-email-hint {
        color: #15803d;
    }

    .form-input.auto-detected {
        border-color: #22c55e;
        background-color: #f0fdf4;
    }

    .multi-account-banner {
        background: #FFF7ED;
        border-left: 5px solid #F59E0B;
        border-radius: 10px;
        padding: 14px 18px;
        margin-bottom: 20px;
        font-size: 13px;
        color: var(--md-sys-color-on-surface);
        display: flex;
        align-items: flex-start;
        gap: 12px;
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15);
        animation: slideIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    }

    .multi-account-banner__icon {
        color: #F59E0B;
        font-size: 20px;
        flex-shrink: 0;
        margin-top: 2px;
    }

    .multi-account-banner__body {
        flex: 1;
        color: var(--md-sys-color-on-surface-variant);
        line-height: 1.6;
    }

    .multi-account-banner__title {
        display: block;
        margin-bottom: 6px;
        color: var(--md-sys-color-on-surface);
    }

    .multi-account-banner__hint {
        font-size: 11px;
        color: #64748B;
        display: block;
        margin-top: 4px;
    }

    .multi-account-link {
        color: var(--md-sys-color-primary);
        font-weight: 700;
        text-decoration: underline;
    }

    .multi-account-banner__dismiss {
        background: none;
        border: none;
        cursor: pointer;
        color: #94A3B8;
        font-size: 18px;
        padding: 0;
        flex-shrink: 0;
        line-height: 1;
    }

    /* ============================================
       SUCCESS & ERROR MESSAGES
       ============================================ */
    .success-message,
    .error-message {
        display: none;
        padding: 20px 24px;
        border-radius: 12px;
        margin-bottom: 24px;
        font-size: 14px;
        font-weight: 600;
        line-height: 1.6;
        animation: slideDown var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .success-message {
        background: var(--md-sys-color-success-bg);
        color: var(--md-sys-color-success);
        border-left: 5px solid var(--md-sys-color-success);
        box-shadow: 0 4px 15px rgba(4, 120, 87, 0.2);
    }

    .error-message {
        background: var(--md-sys-color-error-bg);
        color: var(--md-sys-color-error);
        border-left: 5px solid var(--md-sys-color-error);
        box-shadow: 0 4px 15px rgba(185, 28, 28, 0.2);
    }

    /* ============================================
       TICKET STATUS CARD
       ============================================ */
    .ticket-status-card {
        display: none;
        background: var(--md-sys-color-surface);
        border-radius: 14px;
        padding: 28px;
        margin-top: 24px;
        box-shadow: 0 4px 25px rgba(0, 0, 0, 0.12);
        animation: fadeInScale var(--md-sys-motion-duration-long) var(--md-sys-motion-easing-standard);
    }

    @keyframes fadeInScale {
        from {
            opacity: 0;
            transform: scale(0.96);
        }

        to {
            opacity: 1;
            transform: scale(1);
        }
    }

    .ticket-status-card.show {
        display: block;
    }

    .ticket-status-card[data-loading="true"] {
        display: block;
    }

    .ticket-status-card h2 {
        font-size: 19px;
        color: var(--md-sys-color-on-surface);
        margin-bottom: 18px;
        font-family: 'Courier New', monospace;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .status-badge {
        display: inline-block;
        padding: 10px 18px;
        border-radius: 24px;
        font-size: 13px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        margin-bottom: 24px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .status-badge.not-completed {
        background: var(--md-sys-color-warning-bg);
        color: var(--md-sys-color-warning);
        border: 2px solid var(--md-sys-color-warning);
    }

    .status-badge.completed {
        background: var(--md-sys-color-success-bg);
        color: var(--md-sys-color-success);
        border: 2px solid var(--md-sys-color-success);
    }

    .status-badge.closed {
        background: #E0E7FF;
        color: #3730A3;
        border: 2px solid #4F46E5;
    }

    .status-badge.pending {
        background: #DBEAFE;
        color: #1E40AF;
        border: 2px solid #1D4ED8;
    }

    .ticket-info {
        border-top: 2px solid var(--md-sys-color-outline);
        padding-top: 20px;
    }

    .info-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 14px 0;
        border-bottom: 1px solid var(--md-sys-color-surface-variant);
        gap: 16px;
    }

    .info-row:last-child {
        border-bottom: none;
    }

    .info-label {
        font-size: 13px;
        font-weight: 700;
        color: var(--md-sys-color-on-surface-variant);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        flex-shrink: 0;
    }

    .info-value {
        font-size: 14px;
        font-weight: 600;
        color: var(--md-sys-color-on-surface);
        text-align: right;
        word-break: break-word;
    }

    .status-list-header {
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 2px solid var(--md-sys-color-outline);
    }

    .status-list-title {
        font-size: 17px;
        color: var(--md-sys-color-on-surface);
        margin-bottom: 4px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .status-list-subtitle {
        font-size: 13px;
        color: var(--md-sys-color-on-surface-variant);
    }

    .status-list-item {
        margin-bottom: 20px;
        padding-bottom: 20px;
        border-bottom: 1px solid var(--md-sys-color-surface-variant);
    }

    .status-list-item:last-child {
        margin-bottom: 0;
        padding-bottom: 0;
        border-bottom: none;
    }

    .status-list-item-head {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 10px;
        flex-wrap: wrap;
    }

    .status-list-ticket-id {
        font-family: monospace;
        font-size: 15px;
        font-weight: 700;
        color: var(--md-sys-color-on-surface);
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .status-list-date {
        font-size: 12px;
        color: var(--md-sys-color-on-surface-variant);
        margin-left: auto;
    }

    .status-list-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px 16px;
        font-size: 13px;
        color: var(--md-sys-color-on-surface-variant);
    }

    .status-list-grid .full-row {
        grid-column: 1 / -1;
    }

    .status-skeleton {
        display: grid;
        gap: 12px;
        margin-top: 6px;
    }

    .status-skeleton-line {
        height: 14px;
        border-radius: 8px;
        background: linear-gradient(
            90deg,
            var(--md-sys-color-surface-variant) 0%,
            var(--md-sys-color-outline) 50%,
            var(--md-sys-color-surface-variant) 100%
        );
        background-size: 240% 100%;
        animation: skeletonShimmer 1.2s infinite linear;
    }

    .status-skeleton-line.w-70 { width: 70%; }
    .status-skeleton-line.w-55 { width: 55%; }
    .status-skeleton-line.w-45 { width: 45%; }

    @keyframes skeletonShimmer {
        from { background-position: 200% 0; }
        to { background-position: -200% 0; }
    }

    /* Duplicate reason-box block REMOVED (M4 fix) — see canonical block at top of file */

    /* ============================================
       FOOTER
       ============================================ */
    .footer {
        text-align: center;
        padding: 24px 20px;
        color: rgba(255, 255, 255, 0.8);
        font-size: 13px;
    }

    .footer a {
        color: white;
        text-decoration: none;
        font-weight: 600;
    }

    .footer a:hover {
        text-decoration: underline;
    }

    /* ============================================
       MOBILE RESPONSIVE
       ============================================ */
    @media (max-width: 768px) {
        body {
            padding: 16px;
        }

        .header-brand h1 {
            font-size: 24px;
        }

        .header-actions {
            width: 100%;
            justify-content: center;
        }

        .tab-button {
            font-size: 14px;
            padding: 16px 14px;
            flex-direction: column;
            gap: 4px;
        }

        .cheat-sheet {
            padding: 24px 20px;
        }

        .form-card {
            padding: 28px 24px;
        }

        .btn-container {
            flex-direction: column-reverse;
            gap: 12px;
        }

        .btn {
            width: 100%;
        }

        .info-row {
            flex-direction: column;
            gap: 6px;
        }

        .info-value {
            text-align: left;
        }

        .status-list-grid {
            grid-template-columns: 1fr;
        }

        .status-list-date {
            margin-left: 0;
        }
    }

    @media (max-width: 480px) {

        .form-input,
        .form-textarea,
        .form-select {
            font-size: 16px;
            /* Prevent zoom on iOS */
        }
    }

    /* ============================================
       ACCESSIBILITY
       ============================================ */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }

    @media (prefers-contrast: high) {
        .form-input,
        .form-textarea,
        .form-select,
        .c-input,
        .c-textarea,
        .c-select,
        .btn,
        .c-button,
        .tab-button {
            border-width: 3px;
        }

        .form-hint {
            color: #334155;
        }
    }

    .visually-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        border: 0;
    }

    *:focus-visible {
        outline: 3px solid #667eea;
        outline-offset: 2px;
    }

    /* ============================================
       ✨ NEW IMPROVEMENTS: H1 / H2 / H3 / M7 / H4
       ============================================ */

    /* H1: Real-time inline field validation */
    .form-input.field-valid,
    .form-textarea.field-valid,
    .form-select.field-valid {
        border-color: #22c55e;
        background-color: #f0fdf4;
    }

    .form-input.field-invalid,
    .form-textarea.field-invalid,
    .form-select.field-invalid {
        border-color: #ef4444;
        background-color: #fef2f2;
    }

    .field-validation-msg {
        font-size: 11px;
        font-weight: 600;
        margin-top: 6px;
        display: flex;
        align-items: center;
        gap: 5px;
        min-height: 16px;
    }

    .field-validation-msg.valid {
        color: #15803d;
    }

    .field-validation-msg.invalid {
        color: #dc2626;
    }

    /* H2: Live character counter */
    .char-counter {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        margin-top: 6px;
        font-size: 11px;
        font-weight: 600;
        color: #94a3b8;
        letter-spacing: 0.02em;
        gap: 4px;
    }

    .char-counter.warn {
        color: #d97706;
    }

    .char-counter.limit {
        color: #dc2626;
    }

    /* H3: Copy Ticket ID button */
    .btn-copy {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 10px;
        background: #4F46E5;
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 11px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.2s;
        margin-left: 8px;
        vertical-align: middle;
        letter-spacing: 0.3px;
    }

    .btn-copy:hover {
        background: #4338ca;
    }

    .btn-copy.copied {
        background: #059669;
    }

    /* H4: Auto-reset countdown indicator */
    .reset-countdown {
        margin-top: 10px;
        font-size: 11px;
        color: #94a3b8;
        text-align: center;
        font-weight: 500;
    }

    /* M7: CSRF loading state / submit button guard */
    .csrf-loading-msg {
        font-size: 11px;
        color: #94a3b8;
        text-align: center;
        margin-top: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-weight: 500;
        animation: fadePulse 1.5s ease-in-out infinite;
    }

    @keyframes fadePulse {

        0%,
        100% {
            opacity: 1;
        }

        50% {
            opacity: 0.5;
        }
    }

    /* POS datalist suggestion hint */
    .pos-hint {
        font-size: 11px;
        color: #94a3b8;
        margin-top: 6px;
    }
</style>
