/* ============================================================
   UAESA Director Income Confirmation Letter — Front-End Styles
   File: uaesa-dcl.css
   Version: 1.1 (bug-fix pass — see changelog at top of PHP file)

   Consumed by:
     • class-uaesa-gf-director-income.php
     • uaesa-dcl.js
     • letter preview + dual-signature block
     • dialog overlays (terms / preview / verify)

   All rules are scoped to `.uaesa-dcl-wizard` or
   `.gfield_type_uaesa_dcl_selector` wherever possible — nothing
   leaks into the host theme.
   ============================================================ */

/* ============ TOKENS ============ */
.gfield_type_uaesa_dcl_selector,
.uaesa-dcl-wizard,
.md-menu,
.md-overlay,
.md-snackbar-container {
    --md-primary: #00A5A7;
    --md-on-primary: #FFFFFF;
    --md-primary-container: #6FF6FE;
    --md-on-primary-container: #002022;
    --md-secondary-container: #CCE8E9;
    --md-error: #BA1A1A;
    --md-error-container: #FFDAD6;
    --md-on-error-container: #410002;
    --md-success: #2E7D32;
    --md-success-container: #DCFCE7;
    --md-on-success-container: #052E16;
    --md-warning: #8C5000;
    --md-warning-container: #FFDDB3;
    --md-on-warning-container: #2E1500;
    --md-surface: #F4FBFB;
    --md-on-surface: #161D1D;
    --md-on-surface-variant: #3F4849;
    --md-surface-container-lowest: #FFFFFF;
    --md-surface-container-low: #EEF5F5;
    --md-surface-container: #E9EFEF;
    --md-surface-container-high: #E3E9E9;
    --md-surface-container-highest: #DDE4E4;
    --md-outline: #6F7979;
    --md-outline-variant: #BEC8C8;
    --md-inverse-surface: #2B3232;
    --md-inverse-on-surface: #ECF2F2;
    --md-elev-1: 0 1px 2px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.06);
    --md-elev-2: 0 1px 2px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.08);
    --md-elev-3: 0 4px 8px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
    --md-elev-5: 0 12px 24px rgba(0,0,0,.14), 0 4px 8px rgba(0,0,0,.08);
    --md-shape-xs: 4px;
    --md-shape-sm: 8px;
    --md-shape-md: 12px;
    --md-shape-lg: 16px;
    --md-shape-full: 9999px;
}

/* ============ HIDDEN NATIVE SELECT ============ */
.uaesa-hidden-select {
    position: absolute !important;
    left: -9999px !important;
    top: auto !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    clip: rect(0 0 0 0) !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
}

/* ============ DROPDOWN SHELL ============ */
.md-field-outlined {
    position: relative;
    margin: 16px 0 24px;
}

.md-field-outlined__container {
    position: relative;
    min-height: 56px;
    border: 1px solid var(--md-outline);
    border-radius: var(--md-shape-xs);
    background: var(--md-surface-container-lowest);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}

.md-field-outlined__container:hover {
    border-color: var(--md-on-surface);
}

.md-field-outlined__container:focus-within {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
}

.md-field-outlined.is-filled .md-field-outlined__container {
    border-color: var(--md-primary);
}

/* LABEL — ALWAYS floated to top of the border (M3 outlined style).
   This prevents the "Enterprise" text overlapping the placeholder text
   inside the trigger on the empty state. */
.md-field-outlined__label {
    position: absolute;
    left: 12px;
    top: 0;
    transform: translateY(-50%) scale(.75);
    transform-origin: left center;
    background: var(--md-surface-container-lowest);
    padding: 0 4px;
    font-size: 16px;
    color: var(--md-on-surface-variant);
    pointer-events: none;
    transition: color .15s;
    z-index: 2;
    line-height: 1;
    font-weight: 500;
    letter-spacing: .1px;
}

.md-field-outlined.is-focused .md-field-outlined__label,
.md-field-outlined.is-filled .md-field-outlined__label {
    color: var(--md-primary);
}

/* TRIGGER */
.md-field-outlined__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    min-height: 56px;
    font-size: 16px;
    color: var(--md-on-surface);
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    /* Make room for the floated label */
    padding-top: 20px;
    padding-bottom: 12px;
}

.md-field-outlined__trigger-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.md-field-outlined__trigger-icon {
    margin-left: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.md-field-outlined__trigger-icon svg {
    width: 24px;
    height: 24px;
    fill: var(--md-on-surface-variant);
    transition: transform .2s;
}

.md-field-outlined.is-focused .md-field-outlined__trigger-icon svg {
    transform: rotate(180deg);
}

/* ============ DROPDOWN MENU ============ */
.md-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--md-surface-container);
    border-radius: var(--md-shape-xs);
    box-shadow: var(--md-elev-2);
    max-height: 280px;
    overflow-y: auto;
    list-style: none;
    padding: 8px 0;
    margin: 0;
    z-index: 20;
    display: none;
}

.md-menu.open {
    display: block;
    animation: mdMenuIn .15s cubic-bezier(.4,0,.2,1);
}

@keyframes mdMenuIn {
    from { opacity: 0; transform: scale(.98); }
    to   { opacity: 1; transform: scale(1); }
}

.md-menu li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--md-on-surface);
    cursor: pointer;
    min-height: 48px;
    transition: background .12s;
}

.md-menu li:hover,
.md-menu li:focus {
    background: rgba(0,165,167,.08);
    outline: none;
}

.md-menu li .mi-name {
    display: block;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.25;
}

.md-menu li .mi-meta {
    display: block;
    font-size: 12px;
    color: var(--md-on-surface-variant);
    margin-top: 2px;
}

.md-menu li .mi-status {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 999px;
    letter-spacing: .4px;
    text-transform: uppercase;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.md-menu li .mi-status.ok   { background: var(--md-success-container); color: var(--md-on-success-container); }
.md-menu li .mi-status.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.md-menu li .mi-status.er   { background: var(--md-error-container);   color: var(--md-on-error-container); }

.md-menu li .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    display: inline-block;
}

/* ============ STEPPER ============ */
.uaesa-dcl-wizard {
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

.m3-stepper {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 20px 0 24px;
    margin: 0;
    list-style: none;
}

.m3-step {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    text-align: center;
    padding: 0 4px;
}

.m3-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(50% + 24px);
    right: calc(-50% + 24px);
    height: 1px;
    background: var(--md-outline-variant);
    z-index: 0;
}

.m3-step.is-complete:not(:last-child)::after {
    background: var(--md-primary);
}

.m3-step-indicator {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
    font-size: 14px;
    font-weight: 500;
    position: relative;
    z-index: 1;
    transition: background .25s, color .25s;
    flex-shrink: 0;
}

.m3-step-indicator svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.m3-step.is-active .m3-step-indicator,
.m3-step.is-complete .m3-step-indicator {
    background: var(--md-primary);
    color: var(--md-on-primary);
}

.m3-step-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .2px;
    color: var(--md-on-surface-variant);
    line-height: 1.25;
    max-width: 100%;
    word-break: break-word;
    hyphens: auto;
}

.m3-step.is-active .m3-step-label {
    color: var(--md-primary);
    font-weight: 600;
}

.m3-step.is-complete .m3-step-label {
    color: var(--md-on-surface);
}

/* Stepper responsive — tablet */
@media (min-width: 601px) and (max-width: 900px) {
    .m3-stepper { padding: 16px 0 20px; }
    .m3-step { gap: 6px; padding: 0 3px; }
    .m3-step-indicator { width: 34px; height: 34px; font-size: 12px; }
    .m3-step-indicator svg { width: 16px; height: 16px; }
    .m3-step-label { font-size: 10.5px; line-height: 1.2; }
    .m3-step:not(:last-child)::after {
        top: 17px;
        left: calc(50% + 20px);
        right: calc(-50% + 20px);
    }
}

/* Stepper responsive — mobile: vertical timeline
   (Fixes bug #3: horizontal connector lines no longer drift
   through labels on narrow viewports.) */
@media (max-width: 600px) {
    .m3-stepper {
        display: block;
        padding: 4px 0 8px;
        margin: 0;
        list-style: none;
        overflow: visible;
    }
    .m3-step {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 14px;
        padding: 0 0 20px 0;
        min-width: 0;
        position: relative;
        text-align: left;
    }
    .m3-step:last-child { padding-bottom: 0; }
    /* Hide the horizontal connector */
    .m3-step:not(:last-child)::after { display: none; }
    /* Vertical connector */
    .m3-step:not(:last-child)::before {
        content: '';
        position: absolute;
        left: 16px;
        top: 32px;
        bottom: 0;
        width: 2px;
        margin-left: -1px;
        background: var(--md-outline-variant);
        z-index: 0;
        pointer-events: none;
    }
    .m3-step.is-complete:not(:last-child)::before { background: var(--md-primary); }
    .m3-step-indicator {
        width: 32px;
        height: 32px;
        font-size: 13px;
        flex-shrink: 0;
        margin: 0;
        position: relative;
        z-index: 1;
    }
    .m3-step-indicator svg { width: 16px; height: 16px; }
    .m3-step-label {
        font-size: 13px;
        line-height: 32px;
        font-weight: 500;
        color: var(--md-on-surface-variant);
        min-width: 0;
        flex: 1;
        padding: 0;
        margin: 0;
    }
    .m3-step.is-active .m3-step-label { color: var(--md-primary); font-weight: 600; }
    .m3-step.is-complete .m3-step-label { color: var(--md-on-surface); }
}

/* ============ CARDS ============ */
.md-card {
    background: var(--md-surface-container-low);
    border-radius: var(--md-shape-md);
    padding: 20px;
    margin-bottom: 16px;
}

.md-card.md-card--outlined {
    background: var(--md-surface-container-lowest);
    border: 1px solid var(--md-outline-variant);
}

.md-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.md-card-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: var(--md-shape-sm);
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
}

.md-card-icon svg { width: 24px; height: 24px; }

.md-card-icon.ok   { background: var(--md-success-container); color: var(--md-on-success-container); }
.md-card-icon.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.md-card-icon.er   { background: var(--md-error-container);   color: var(--md-on-error-container); }

.md-card-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--md-on-surface);
    line-height: 1.35;
    margin: 0 0 2px;
}

.md-card-sub {
    font-size: 12px;
    color: var(--md-on-surface-variant);
    margin: 0;
    line-height: 1.45;
}

/* ============ DATA GRID ============ */
.md-data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px 24px;
}

.md-data-cell { display: flex; flex-direction: column; gap: 2px; }

.md-data-cell-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
}

.md-data-cell-value {
    font-size: 14px;
    color: var(--md-on-surface);
    font-variant-numeric: tabular-nums;
}

.md-data-cell-value.mono {
    font-family: 'Roboto Mono', ui-monospace, Menlo, monospace;
    font-size: 13px;
}

/* ============ CHIPS ============ */
.md-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--md-shape-full);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .4px;
    line-height: 1;
    white-space: nowrap;
}

.md-chip .chip-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.md-chip.ok   { background: var(--md-success-container); color: var(--md-on-success-container); }
.md-chip.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.md-chip.er   { background: var(--md-error-container);   color: var(--md-on-error-container); }
.md-chip.neu  { background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }

/* ============ BUTTONS ============ */
.md-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 24px;
    border-radius: var(--md-shape-full);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .1px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
    transition: box-shadow .15s, background .15s;
    -webkit-appearance: none;
    appearance: none;
}

.md-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.md-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
    box-shadow: none;
}

.md-btn--filled {
    background: #00A5A7;
    color: #fff;
    border: none;
}

.md-btn--filled:not(:disabled):hover {
    background: #008B8D;
    box-shadow: var(--md-elev-2);
}

.md-btn--outlined {
    background: transparent;
    color: #00A5A7;
    border: 1px solid #00A5A7;
}

.md-btn--outlined:not(:disabled):hover {
    background: rgba(0,165,167,.08);
}

.md-btn--text {
    background: transparent;
    color: #00A5A7;
    padding: 0 12px;
    border: none;
}

.md-btn--text:not(:disabled):hover {
    background: rgba(0,165,167,.08);
}

.md-btn--danger {
    background: #BA1A1A;
    color: #fff;
    border: 1px solid #BA1A1A;
}

.md-btn--danger:not(:disabled):hover {
    background: #8B0F0F;
    border-color: #8B0F0F;
}

/* Keyboard focus rings */
.md-btn:focus { outline: none; }
.md-btn:focus-visible {
    outline: 2px solid #00A5A7;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(0,165,167,.20);
}

.md-btn--filled:focus-visible {
    outline-color: #00A5A7;
    box-shadow: 0 0 0 4px rgba(0,165,167,.28);
}

.md-btn--danger:focus-visible {
    outline-color: #BA1A1A;
    box-shadow: 0 0 0 4px rgba(186,26,26,.22);
}

/* ============ STEP FOOTER ============ */
.m3-step-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--md-outline-variant);
    flex-wrap: wrap;
}

.m3-step-footer .spacer { flex: 1; }

.m3-step-footer .hint {
    font-size: 12px;
    color: var(--md-on-surface-variant);
}

/* ============ STEP PANELS ============ */
.m3-step-panel { display: none; }

.m3-step-panel.is-active {
    display: block;
    animation: mdStepIn .28s cubic-bezier(.4,0,.2,1) both;
}

@keyframes mdStepIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ============ FORM FIELDS ============ */
.md-field { margin-bottom: 14px; }

.md-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #3F4849;
    margin-bottom: 5px;
}

.md-input,
.md-textarea,
.md-select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--md-outline-variant);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: #161D1D;
    background: #fff;
    box-sizing: border-box;
    transition: border-color .15s, box-shadow .15s;
}

.md-textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.5;
}

.md-input:focus,
.md-textarea:focus,
.md-select:focus {
    outline: none;
    border-color: var(--md-primary);
    box-shadow: 0 0 0 3px rgba(0,165,167,.18);
}

/* ============ RADIO CARDS ============ */
.md-radio-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.md-radio-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--md-outline-variant);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.md-radio-card:hover {
    border-color: var(--md-primary);
    background: #F4FBFB;
}

.md-radio-card.is-selected {
    border-color: var(--md-primary);
    background: #F4FBFB;
    box-shadow: 0 0 0 3px rgba(0,165,167,.10);
}

.md-radio-card input[type="radio"] {
    accent-color: #00A5A7;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin: 2px 0 0;
    cursor: pointer;
}

.md-radio-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #002022;
    line-height: 1.3;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.md-radio-card-sub {
    font-size: 11.5px;
    color: #6F7979;
    margin-top: 3px;
    line-height: 1.5;
}

.md-radio-card.is-selected .md-radio-card-title {
    color: var(--md-primary);
}

/* ============ CHECKBOX ROWS ============ */
.md-checkbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--md-outline-variant);
    border-radius: 10px;
    background: #fff;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.md-checkbox-row:hover {
    border-color: var(--md-primary);
    background: #F4FBFB;
}

.md-checkbox-row.checked {
    border-color: var(--md-primary);
    background: #F4FBFB;
}

.md-checkbox-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #00A5A7;
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}

.md-checkbox-row-label { flex: 1; min-width: 0; }

.md-checkbox-row-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #002022;
    line-height: 1.3;
}

.md-checkbox-row-sub {
    font-size: 11.5px;
    color: #6F7979;
    margin-top: 2px;
    line-height: 1.5;
}

.md-checkbox-row-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--md-primary);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* ============ TABLES ============ */
.md-table-wrap {
    border-radius: 12px;
    border: 1px solid var(--md-outline-variant);
    overflow: hidden;
    background: #fff;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.md-table thead th {
    background: var(--md-surface-container-low);
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
    border-bottom: 1px solid var(--md-outline-variant);
    white-space: nowrap;
}

.md-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--md-surface-container-high);
    vertical-align: middle;
    color: #002022;
    background: #fff;
}

.md-table tbody tr:last-child td {
    border-bottom: none;
}

.md-table tbody tr:hover td {
    background: var(--md-surface-container-low);
}

/* ============ INCOME EDITOR ============ */
.income-row {
    display: grid;
    grid-template-columns: 1fr 160px 40px;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--md-surface-container-high);
}

.income-row:last-child { border-bottom: none; }

.income-row input.income-amount {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.income-row .income-delete {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--md-outline-variant);
    background: #fff;
    color: var(--md-error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s, border-color .15s;
}

.income-row .income-delete:hover {
    background: var(--md-error-container);
    border-color: var(--md-error);
}

.income-row .income-delete svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.income-total-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 0 0;
    margin-top: 8px;
    border-top: 2px solid var(--md-outline-variant);
    font-size: 16px;
    font-weight: 700;
    color: #002022;
}

/* ============ TOTALS ============ */
.md-totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--md-outline-variant);
    border-radius: var(--md-shape-md);
    overflow: hidden;
    border: 1px solid var(--md-outline-variant);
    margin-top: 16px;
}

.md-total-cell {
    background: #fff;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.md-total-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
}

.md-total-value {
    font-size: 20px;
    font-weight: 500;
    color: var(--md-on-surface);
    font-variant-numeric: tabular-nums;
}

.md-total-cell.grand {
    background: var(--md-success-container);
}

.md-total-cell.grand .md-total-value {
    color: var(--md-on-success-container);
    font-weight: 600;
}

/* ============ BANNERS ============ */
.md-banner {
    display: flex;
    gap: 14px;
    padding: 16px 18px;
    border-radius: var(--md-shape-md);
    margin-bottom: 16px;
    align-items: flex-start;
}

.md-banner.ok   { background: var(--md-success-container); color: var(--md-on-success-container); }
.md-banner.warn { background: var(--md-warning-container); color: var(--md-on-warning-container); }
.md-banner.er   { background: var(--md-error-container);   color: var(--md-on-error-container); }

.md-banner-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,.5);
}

.md-banner-icon svg { width: 22px; height: 22px; }

.md-banner-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
}

.md-banner-text {
    font-size: 12.5px;
    line-height: 1.5;
    margin: 0;
    opacity: .92;
}

/* ============ DIALOG ============ */
.md-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.42);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.md-overlay.open { display: flex; }

.md-dialog {
    background: #fff;
    border-radius: 16px;
    max-width: 640px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--md-elev-5);
    animation: dialogIn .25s;
    display: flex;
    flex-direction: column;
}

@keyframes dialogIn {
    from { opacity: 0; transform: scale(.95); }
    to   { opacity: 1; transform: scale(1); }
}

.md-dialog-head {
    padding: 20px 22px 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    border-radius: 16px 16px 0 0;
}

.md-dialog-head .ic {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--md-primary-container);
    color: var(--md-on-primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.md-dialog-head .ic svg { width: 22px; height: 22px; }

.md-dialog-title {
    font-size: 17px;
    font-weight: 600;
    color: #002022;
    margin: 0 0 4px;
}

.md-dialog-sub {
    font-size: 12.5px;
    color: #3F4849;
    margin: 0;
    line-height: 1.5;
}

.md-dialog-body {
    padding: 4px 22px 16px;
    flex: 1;
    min-height: 0;
}

.md-dialog-actions {
    padding: 12px 22px 20px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid var(--md-outline-variant);
}

/* ============ SNACKBAR ============ */
.md-snackbar-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 420px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.md-snackbar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--md-inverse-surface);
    color: var(--md-inverse-on-surface);
    border-radius: 6px;
    box-shadow: var(--md-elev-3);
    font-size: 14px;
    line-height: 1.4;
    transform: translateY(120%);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
}

.md-snackbar.show { transform: translateY(0); }
.md-snackbar.ok   { border-left: 3px solid #2E7D32; }
.md-snackbar.er   { border-left: 3px solid #BA1A1A; }
.md-snackbar.work { border-left: 3px solid #E65100; }

.md-snackbar__msg { flex: 1; }

.md-snackbar__action {
    background: none;
    border: none;
    color: #6FF6FE;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.md-snackbar__action:hover { background: rgba(255,255,255,.08); }

/* ============ SUB-STEPPER (Step 4) ============ */
.md-substep-stepper {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 0 0 20px;
    padding: 0 8px;
}

.md-substep {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    text-align: center;
    min-width: 0;
}

.md-substep:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 15px;
    left: calc(50% + 18px);
    right: calc(-50% + 18px);
    height: 2px;
    background: #E5EAEA;
    z-index: 0;
    transition: background .25s;
}

.md-substep.done:not(:last-child)::after { background: #00A5A7; }

.md-substep-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #E5EAEA;
    color: #6F7979;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    position: relative;
    z-index: 1;
    transition: background .25s, color .25s, box-shadow .25s;
    line-height: 1;
    flex-shrink: 0;
}

.md-substep-dot svg { width: 14px; height: 14px; fill: currentColor; }

.md-substep.active .md-substep-dot {
    background: #00A5A7;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(0,165,167,.15);
}

.md-substep.done .md-substep-dot {
    background: #00A5A7;
    color: #fff;
}

.md-substep-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    color: #6F7979;
    text-transform: uppercase;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.md-substep.active .md-substep-label { color: #00A5A7; }
.md-substep.done   .md-substep-label { color: #002022; }

.md-substep-body {
    border-top: 1px solid #EEF5F5;
    padding-top: 16px;
}

.md-substep-content-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.md-substep-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #EEF5F5;
    color: #6F7979;
}

.md-substep-icon.done {
    background: #DCFCE7;
    color: #2E7D32;
}

.md-substep-icon svg { width: 22px; height: 22px; }

.md-substep-meta { flex: 1; min-width: 200px; }

.md-substep-title {
    font-size: 14px;
    font-weight: 600;
    color: #002022;
    line-height: 1.3;
}

.md-substep-sub {
    font-size: 12px;
    color: #6F7979;
    line-height: 1.4;
    margin-top: 3px;
}

.md-substep-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.md-substep-progress-footer {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(0,165,167,.08);
    border: 1px dashed #80DEEA;
    border-radius: 8px;
    font-size: 12px;
    color: #00454A;
    line-height: 1.5;
}

.md-substep-progress-footer.all-done {
    background: rgba(46,125,50,.08);
    border-color: #A5D6A7;
    color: #052E16;
}

/* ============ SIGNATURE PAD ============ */
.sig-pad-wrap {
    border: 2px dashed var(--md-outline-variant);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
    position: relative;
    transition: border-color .15s, background .15s;
}

.sig-pad-wrap.has-stroke {
    border-color: #A5D6A7;
    border-style: solid;
    background: #F1F8E9;
}

.sig-canvas {
    display: block;
    width: 100%;
    height: 160px;
    border-radius: 8px;
    cursor: crosshair;
    touch-action: none;
    background:
        repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(0,165,167,.06) 19px, rgba(0,165,167,.06) 20px),
        #fff;
}

.sig-hint {
    font-size: 11px;
    color: #6F7979;
    margin-top: 8px;
    text-align: center;
}

.sig-clear {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #fff;
    border: 1px solid var(--md-outline-variant);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--md-error);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.sig-clear:hover {
    background: var(--md-error-container);
    border-color: var(--md-error);
}

/* ============ ACCOUNTANT AUTH CARD ============ */
.auth-card {
    background: linear-gradient(135deg, #E0F7FA, #F4FBFB);
    border: 1px solid #80DEEA;
    border-radius: 12px;
    padding: 16px;
}

.auth-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #6FF6FE;
    color: #002022;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 17px;
    flex-shrink: 0;
}

/* ============ LETTER PREVIEW ============ */
.letter-preview {
    background: #fff;
    border: 1px solid var(--md-outline-variant);
    border-radius: 10px;
    padding: 26px;
    font-size: 12.5px;
    line-height: 1.65;
    color: #1F2A2A;
    box-shadow: var(--md-elev-1);
    position: relative;
}

.letter-preview h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
    color: #002022;
}

.letter-preview .letter-meta {
    font-size: 11px;
    color: #6F7979;
    margin-bottom: 16px;
    border-bottom: 1px solid #EEF5F5;
    padding-bottom: 10px;
}

.letter-preview p { margin: 0 0 12px; }

.letter-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 12px;
}

.letter-preview table th {
    text-align: left;
    padding: 8px 10px;
    background: #F4FBFB;
    font-size: 10.5px;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #3F4849;
    border-bottom: 1px solid var(--md-outline-variant);
}

.letter-preview table td {
    padding: 8px 10px;
    border-bottom: 1px solid #EEF5F5;
    font-variant-numeric: tabular-nums;
}

.letter-preview table tr:last-child td {
    border-bottom: none;
    font-weight: 700;
    background: #F1F8E9;
}

.letter-preview .sig-block {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px dashed #BEC8C8;
}

.paid-seal {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 6px 12px;
    background: #2E7D32;
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(46,125,50,.3);
}

/* ============ DUAL SIGNATURE ============
   Accountant = LEFT column, left-aligned (all children)
   Director   = RIGHT column, right-aligned (all children)
   Both columns share the same top border and vertical rhythm.
   ============================================= */
.sig-block-title {
    font-size: 12.5px;
    color: #002022;
    margin-bottom: 10px;
}

.dual-sig-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 12px;
}

.sig-slot {
    padding-top: 8px;
    border-top: 1px solid #6F7979;
    min-width: 0;
}

.sig-slot-image img {
    max-height: 55px;
    max-width: 100%;
    padding-bottom: 4px;
}

.sig-slot-name {
    font-size: 12.5px;
    color: #002022;
    margin-top: 6px;
}

.sig-slot-role {
    font-size: 11.5px;
    color: #3F4849;
    margin-top: 2px;
}

.sig-slot-detail {
    font-size: 10.5px;
    color: #6F7979;
    margin-top: 2px;
    font-family: 'Roboto Mono', monospace;
    word-break: break-word;
}

.sig-slot-label {
    font-size: 9.5px;
    color: #00A5A7;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 700;
    margin-top: 8px;
}

.sig-slot-label.accountant { color: #7A3E00; }

/* ACCOUNTANT (left) — explicit left alignment on every child */
.sig-slot--accountant .sig-slot-image,
.sig-slot--accountant .sig-slot-name,
.sig-slot--accountant .sig-slot-role,
.sig-slot--accountant .sig-slot-detail,
.sig-slot--accountant .sig-slot-label {
    text-align: left;
}

/* DIRECTOR (right) — explicit right alignment on every child */
.sig-slot--director .sig-slot-image,
.sig-slot--director .sig-slot-name,
.sig-slot--director .sig-slot-role,
.sig-slot--director .sig-slot-detail,
.sig-slot--director .sig-slot-label {
    text-align: right;
}

/* Fallback-only block */
.sig-onbehalf-note {
    background: #FFF3E0;
    border: 1px dashed #FFCC80;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    color: #7A3E00;
    line-height: 1.55;
    margin-top: 14px;
}

.sig-seal-line {
    font-size: 10.5px;
    color: #6F7979;
    text-align: center;
    padding-top: 10px;
    margin-top: 14px;
    border-top: 1px dashed #BEC8C8;
}

.sig-footer {
    font-size: 10.5px;
    color: #2E7D32;
    text-align: center;
    padding-top: 10px;
    margin-top: 14px;
    border-top: 1px dashed #BEC8C8;
    font-weight: 600;
    letter-spacing: .3px;
}

.sig-awaiting {
    padding: 12px;
    background: #FFF3E0;
    border: 1px dashed #FFCC80;
    border-radius: 8px;
    font-size: 11.5px;
    color: #7A3E00;
}

/* ============ QR BLOCK ============ */
.qr-block {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--md-success-container);
    border-radius: 10px;
    flex-wrap: wrap;
    color: var(--md-on-success-container);
}

.qr-block img,
.qr-block svg {
    flex-shrink: 0;
    background: #fff;
    padding: 4px;
    border-radius: 4px;
    border: 1px solid #BEC8C8;
}

/* ============ ADDRESSEE CARDS ============ */
.addressee-card {
    background: #fff;
    border: 1px solid var(--md-outline-variant);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    position: relative;
}

.addressee-card .addressee-remove {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--md-error-container);
    color: var(--md-error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.addressee-card .addressee-remove:hover {
    background: #FFCDD2;
}

.addressee-card .addressee-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    color: #00A5A7;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.addressee-card .addressee-tag.extra { color: #8C5000; }

/* ============ MOBILE (≤720px) ============ */
@media (max-width: 720px) {
    .md-data-grid { grid-template-columns: 1fr; }

    .m3-step-indicator { width: 34px; height: 34px; font-size: 12px; }
    .m3-step-indicator svg { width: 16px; height: 16px; }

    .m3-step-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .m3-step-footer .md-btn { width: 100%; }
    .m3-step-footer .hint {
        text-align: center;
        order: -1;
        padding-bottom: 8px;
    }

    .md-radio-cards { grid-template-columns: 1fr; }

    .income-row { grid-template-columns: 1fr 110px 36px; }

    .md-dialog-actions .md-btn { width: 100%; }

    .md-totals { grid-template-columns: 1fr 1fr; }
    .md-total-cell { padding: 12px 14px; }
    .md-total-value { font-size: 17px; }

    .md-card { padding: 16px; }
    .md-card-header { gap: 10px; }

    .md-banner { padding: 14px; gap: 10px; }
    .md-banner-icon { width: 36px; height: 36px; }

    /* Dual-signature — stack and reset alignment on mobile */
    .dual-sig-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .sig-slot--accountant .sig-slot-image,
    .sig-slot--accountant .sig-slot-name,
    .sig-slot--accountant .sig-slot-role,
    .sig-slot--accountant .sig-slot-detail,
    .sig-slot--accountant .sig-slot-label,
    .sig-slot--director .sig-slot-image,
    .sig-slot--director .sig-slot-name,
    .sig-slot--director .sig-slot-role,
    .sig-slot--director .sig-slot-detail,
    .sig-slot--director .sig-slot-label {
        text-align: left;
    }

    .md-substep-label { font-size: 9.5px; }
    .md-substep-actions {
        width: 100%;
        margin-top: 6px;
    }
    .md-substep-actions .md-btn { flex: 1; }

    .md-dialog { border-radius: var(--md-shape-lg); max-height: 94vh; }

    .letter-preview { padding: 18px; }
    .paid-seal { position: static; display: inline-block; margin-bottom: 10px; }

    .qr-block { padding: 12px; gap: 10px; }
}

/* ============ SMALL MOBILE (≤380px) ============ */
@media (max-width: 380px) {
    .income-row { grid-template-columns: 1fr 96px 34px; gap: 6px; }
    .income-row .income-delete { width: 32px; height: 32px; }
    .income-row .income-delete svg { width: 14px; height: 14px; }

    .md-totals { grid-template-columns: 1fr; }
    .md-total-cell { padding: 10px 12px; }
    .md-total-value { font-size: 16px; }

    .m3-step { gap: 10px; padding-bottom: 16px; }
    .m3-step-indicator { width: 28px; height: 28px; font-size: 12px; }
    .m3-step-label { font-size: 12px; line-height: 28px; }
    .m3-step:not(:last-child)::before { left: 14px; top: 28px; }

    .sig-canvas { height: 130px; }

    .addressee-card { padding: 12px; }
}

/* ============ TINY (≤360px) ============ */
@media (max-width: 360px) {
    .md-card { padding: 12px; }
    .md-card-title { font-size: 15px; }
    .md-substep-content-row { gap: 10px; }
    .md-substep-icon { width: 36px; height: 36px; }
    .md-substep-icon svg { width: 18px; height: 18px; }
    .md-radio-card { padding: 12px; }
    .md-checkbox-row { padding: 10px 12px; }
    .md-btn { padding: 0 18px; font-size: 13px; }
}

/* ============ FOCUS / ACCESSIBILITY ============ */
.uaesa-dcl-wizard *:focus-visible,
.gfield_type_uaesa_dcl_selector *:focus-visible {
    outline-color: #00A5A7;
    outline-offset: 2px;
}

.md-field-outlined__trigger:focus { outline: none; }
.md-field-outlined__trigger:focus-visible {
    outline: 2px solid #00A5A7;
    outline-offset: -2px;
    border-radius: var(--md-shape-xs);
}

.md-radio-card input[type="radio"]:focus-visible,
.md-checkbox-row input[type="checkbox"]:focus-visible {
    outline: 2px solid #00A5A7;
    outline-offset: 2px;
}

/* ============ MODAL SCROLL LOCK ============
   Applied by JS as `document.body.classList.add('uaesa-modal-open')`.
   Scoped class prevents page-shift when closing. */
body.uaesa-modal-open {
    overflow: hidden;
}

/* ============ PRINT ============ */
@media print {
    .md-snackbar-container,
    .m3-step-footer,
    .md-btn,
    .md-overlay:not(.open),
    .md-field-outlined,
    .uaesa-hidden-select,
    .m3-stepper,
    .md-substep-stepper,
    .md-data-grid,
    .md-card-header,
    .md-totals,
    .qr-block {
        display: none !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
        margin: 0;
        padding: 20px;
    }

    .letter-preview {
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        page-break-inside: auto;
    }

    .letter-preview h3 { font-size: 18px; }
    .letter-preview table { page-break-inside: avoid; }

    .dual-sig-grid {
        page-break-inside: avoid;
        page-break-before: auto;
    }

    .paid-seal {
        position: static !important;
        display: inline-block !important;
        border: 1px solid #333 !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        margin-bottom: 12px;
    }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
    .md-snackbar { transform: none !important; }
    .md-menu.open,
    .m3-step-panel.is-active,
    .md-dialog,
    .md-substep.active .md-substep-dot {
        animation: none !important;
    }
}