/*
 * Portal palette
 *
 * The accent is a variable so the members area can carry the colours of the
 * association the member belongs to. Every rule below falls back to the WCA
 * blue, so the admin portal and WCA members are unchanged.
 */
:root {
    --portal-accent: #3993d0;
    --portal-accent-deep: #2d7ab8;
    --portal-accent-wash: #e0f2fe;
    --portal-accent-tint: #f0f9ff;
    --portal-accent-edge: #bae6fd;
}

/* An HCA member sees HCA's own red, so someone arriving from hcawindsor.com
   can tell whose portal they are in. A company in both stays on WCA. */
body.portal-hca {
    /* Deeper than the logo's red, so it never reads as an error message. */
    --portal-accent: #8f1620;
    --portal-accent-deep: #6b1018;
    --portal-accent-wash: #f9e9ea;
    --portal-accent-tint: #fdf6f6;
    --portal-accent-edge: #edc6c9;
    --portal-topbar: #8f1620;
}

/* ==========================================================================
 * WCA Portal UI
 * ==========================================================================
 * Shared design system for the admin and member portals.
 *
 * Consumed by resources/views/admin/* and resources/views/member/*. Layered on
 * top of the Bootstrap 3 + base.css
 *
 * Contents:
 *   1. List pages  - page shell, header, stat cards, filters, tables,
 *                    badges, alerts, empty state
 *   2. Detail/form - view header, info grid, section cards, form inputs,
 *                    sidebar action cards, print styles
 *   3. Shared      - buttons not owned by either half
 * ========================================================================== */


/* ==========================================================================
 * 1. LIST PAGES
 * ========================================================================== */

/* Applications Index Page Styling */

.back {
    margin-bottom: 1rem;
}

/* Breadcrumb trail (x-ui.breadcrumbs). Links keep the site's own link
   styles so it reads like the .back links on other pages. Long items
   truncate; the full text is in the title tooltip. */
.breadcrumbs {
    /* base.css styles every desktop <nav> as the white, centred site menu */
    display: block;
    position: static;
    padding: 0;
    background: none;
    margin-bottom: 1rem;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
    min-width: 0;
}

.breadcrumbs li + li::before {
    content: "\203A";
    margin: 0 0.6rem;
    color: #94a3b8;
}

.breadcrumbs a,
.breadcrumbs span {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.breadcrumbs [aria-current="page"] {
    color: #475569;
    font-weight: 600;
}

/* Page Container */
.applications-page {
    background: linear-gradient(135deg, #f8fafc 0%, var(--portal-accent-wash, #e0f2fe) 100%);
    min-height: 90vh;
    padding: 2rem 1rem;
}

.applications-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Page Header Layout */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    gap: 1.5rem;
}

.header-left {
    flex: 1;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.add-wrapper {
    display: flex;
    gap: 1rem;
}

/* View Toggle Styles */
.view-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.toggle-btn:hover {
    color: var(--portal-accent, #3993d0);
    background: rgba(57, 147, 208, 0.1);
}

.toggle-btn.active {
    background: white;
    color: var(--portal-accent, #3993d0);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* View Mode Toggling Logic */
#applications-view-container.grid-mode .applications-table-wrapper {
    display: none;
}

#applications-view-container.table-mode .applications-grid {
    display: none;
}

/* Table View Styles */
.applications-table-wrapper {
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    animation: fadeIn 0.3s ease;
    border: 1px solid #e2e8f0;
}

.applications-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.applications-table th {
    background: #f8fafc;
    padding: 1.25rem 1.5rem;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.applications-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.applications-table tr:last-child td {
    border-bottom: none;
}

.applications-table tr:hover td {
    background-color: #f8fafc;
}

.badge {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
    background-color: #f8fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #e2e8f0;
}

.badge.wca {
    background-color: var(--portal-accent, #3993d0);
    color: white;
}

.badge.hca {
    background-color: #d30025;
    color: #f8fafc;
}

.table-business-info .business-name {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.table-business-info .business-meta {
    font-size: 0.8125rem;
    color: #64748b;
}

.table-info .title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
}

.table-info .description {
    font-size: 0.8125rem;
    color: #64748b;
}

.table-date {
    font-size: 0.875rem;
    color: #475569;
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.table-btn-view,
.table-btn-approve,
.table-btn-reject,
.table-btn-public {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: white;
    padding: 0;
    border: none;
    font: inherit;
    cursor: pointer;
}

.inline-delete-form {
    display: flex;
    margin: 0;
}

/* Text variant - legacy Bootstrap tables */
.btn-inline-delete {
    padding: 0;
    background: none;
    border: none;
    color: #ef4444;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.btn-inline-delete:hover {
    color: #dc2626;
}

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

.table-btn-view { background-color: var(--portal-accent, #3993d0); }
.table-btn-view:hover { background-color: var(--portal-accent-deep, #2d7ab8); transform: translateY(-1px); }

.table-btn-approve { background-color: #10b981; }
.table-btn-approve:hover { background-color: #059669; transform: translateY(-1px); }

.table-btn-reject { background-color: #ef4444; }
.table-btn-reject:hover { background-color: #dc2626; transform: translateY(-1px); }

.table-btn-view svg,
.table-btn-approve svg,
.table-btn-public svg,
.table-btn-reject svg {
    width: 1rem;
    height: 1rem;
}

.text-right {
    text-align: right;
}

/* --------------------------------------------------------------------------
 * Responsive tables
 *
 * 1024px and below : the table scrolls sideways.
 * 767px and below  : every row becomes a card.
 * -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .applications-table {
        min-width: 720px;
    }
}

@media (max-width: 767px) {
    .applications-table-wrapper {
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    .applications-table,
    .applications-table tbody,
    .applications-table tr,
    .applications-table td {
        display: block;
        width: 100%;
    }

    /* Captions come from ::before now */
    .applications-table thead {
        display: none;
    }

    /* Must be reset: min-width survives the display change and would push the
       cards wider than the viewport, reproducing the very overflow this
       breakpoint exists to remove. */
    .applications-table {
        min-width: 0;
    }

    .applications-table tr {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        margin-bottom: 1rem;
        padding: 1rem 1.25rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    }

    .applications-table tr:last-child {
        margin-bottom: 0;
    }

    .applications-table tr:hover td {
        background-color: transparent;
    }

    .applications-table td {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.625rem 0;
        border-bottom: 1px solid #f1f5f9;
        text-align: right;
    }

    .applications-table tr td:last-child {
        border-bottom: none;
    }

    .applications-table td::before {
        content: '';
        flex-shrink: 0;
        font-size: 0.75rem;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: left;
    }

    .applications-table td:first-child .business-name {
        font-size: 1.0625rem;
    }

    .applications-table .table-actions {
        justify-content: flex-end;
        width: 100%;
    }

    .applications-table td:has(> .table-actions:not(:has(*))) {
        display: none;
    }

    /*
     * The applications index carries a card grid alongside its table, and that
     * grid already presents all eight columns properly. Force it below this
     * breakpoint whatever the saved preference, and hide the toggle -- an
     * 8-row stack per record is a worse read than the card.
     *
     * Scoped with :has() because every list page shares the
     * #applications-view-container id; an unscoped rule would hide the table on
     * the four pages that have no grid to fall back to. Where :has() is
     * unsupported the rule simply doesn't apply and the table stacks instead,
     * which is a fine degradation.
     */
    #applications-view-container:has(.applications-grid) .applications-table-wrapper {
        display: none !important;
    }

    #applications-view-container:has(.applications-grid) .applications-grid {
        display: grid !important;
    }

    .view-toggle {
        display: none;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .view-toggle {
        align-self: flex-start;
    }


}

@media (max-width: 592px) {
    .add-wrapper {
        flex-direction: column;
    }
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--stats-min, 250px), 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Compact: the same tiles, smaller, so more fit in a row. Set on the grid to
   shrink every tile in it, or on one tile as .stat-card.compact to mix sizes.
   --stats-min still wins when a caller passes min. */
.stats-grid.stats-compact {
    --stats-min: 150px;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Five or six tiles read as two even rows rather than a full row and a
   straggler. Opt in with stats-balanced; the tablet and phone rules below
   still take over on narrow screens. */
@media (min-width: 1025px) {
    .stats-grid.stats-balanced:not(.stats-fixed):has(> :nth-child(5)):not(:has(> :nth-child(7))) {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid.stats-balanced:not(.stats-fixed):has(> :nth-child(7)) {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    /* An explicit column count, from <x-ui.stats columns="N">. Desktop only:
       below this width the auto-fit and the tablet and phone rules reflow it. */
    .stats-grid.stats-fixed {
        grid-template-columns: repeat(var(--stats-cols), minmax(0, 1fr));
    }
}

.stat-card {
    background: white;
    border-radius: 6px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--stat-color-start), var(--stat-color-end));
}

.stat-card.total {
    --stat-color-start: var(--portal-accent, #3993d0);
    --stat-color-end: var(--portal-accent-deep, #2d7ab8);
}

.stat-card.pending {
    --stat-color-start: #f59e0b;
    --stat-color-end: #d97706;
}

.stat-card.approved {
    --stat-color-start: #10b981;
    --stat-color-end: #059669;
}

.stat-card.rejected {
    --stat-color-start: #ef4444;
    --stat-color-end: #dc2626;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stat-label {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-icon {
    width: 2rem;
    height: 2rem;
    opacity: 0.3;
}

.stat-value {
    color: #1e293b;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

/* Compact tile. The .stat-card.compact selectors are (0,3,0), which is what
   lets them beat the phone rule that shrinks .stat-value on its own. */
.stat-card.compact,
.stats-compact .stat-card {
    padding: 1rem;
}

.stat-card.compact:hover,
.stats-compact .stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.compact .stat-header,
.stats-compact .stat-card .stat-header {
    margin-bottom: 0.5rem;
}

.stat-card.compact .stat-label,
.stats-compact .stat-card .stat-label {
    font-size: 0.75rem;
}

.stat-card.compact .stat-icon,
.stats-compact .stat-card .stat-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.stat-card.compact .stat-value,
.stats-compact .stat-card .stat-value {
    font-size: 1.75rem;
}

/* Filters Section */
.filters-section {
    background: white;
    border-radius: 6px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 2rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-label {
    color: #334155;
    font-size: 0.875rem;
    font-weight: 600;
    margin-left: 0.25rem;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    color: #1e293b;
    transition: all 0.2s ease;
    outline: none;
}

.filter-input:focus,
.filter-select:focus {
    background-color: #ffffff;
    border-color: var(--portal-accent, #3993d0);
    box-shadow: 0 0 0 4px rgba(57, 147, 208, 0.15);
}

.filter-input::placeholder {
    color: #94a3b8;
}

/* A button in the filter row (Export to Excel) is the same height and corner
   radius as the selects beside it, instead of the shorter header button. */
.filters-grid .filter-group > .btn {
    padding: 0.75rem 1.25rem;
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 1rem;
    line-height: 1.5;
    white-space: nowrap;
}

.filters-grid .full-width {
    grid-column: 1 / -1;
}

.btn-clear-filters {
    padding: 0.75rem 1.5rem;
    background-color: #64748b;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-clear-filters:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

/* Applications Grid */
.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.application-card {
    background: white;
    border-radius: 6px;
    padding: 1.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    border: 2px solid transparent;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.application-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--portal-accent, #3993d0);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.business-info {
    flex: 1;
}

.business-name {
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
    line-height: 1.3;
}

.business-email {
    color: #64748b;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.business-email svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.business-phone {
    color: #64748b;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.business-phone svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Status Badge */
.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.status-badge.pending {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.status-badge.approved {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.status-badge.rejected {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.status-badge.pending_payment {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
}

.payment-status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.payment-status-badge.paid {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.payment-status-badge.unpaid {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #fef3c7;
}

.btn-public-link {
    background-color: #f1f5f9;
    color: #475569;
}

.btn-public-link:hover {
    background-color: #e2e8f0;
    color: #1e293b;
    transform: translateY(-2px);
}

.table-btn-public {
    background-color: #64748b;
}

.table-btn-public:hover {
    background-color: #475569;
    transform: translateY(-1px);
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background-color: currentColor;
}

/* Card Details */
.card-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-top: 1.25rem;
    border-top: 2px solid #f1f5f9;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #64748b;
    font-size: 0.875rem;
}

.detail-icon {
    width: 1.125rem;
    height: 1.125rem;
    color: var(--portal-accent, #3993d0);
    flex-shrink: 0;
}

.detail-label {
    font-weight: 600;
    color: #475569;
}

.detail-value {
    color: #1e293b;
    font-weight: 500;
}

.classification-badge {
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--portal-accent-wash, #e0f2fe) 0%, var(--portal-accent-edge, #bae6fd) 100%);
    color: #0c4a6e;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    min-width: 100px;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Poppins', sans-serif;
}

.btn-action svg {
    width: 1rem;
    height: 1rem;
}

.btn-view {
    background-color: var(--portal-accent, #3993d0);
    color: white;
}

.btn-view:hover {
    background-color: var(--portal-accent-deep, #2d7ab8);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(57, 147, 208, 0.3);
}

.btn-approve {
    background-color: #10b981;
    color: white;
}

.btn-approve:hover {
    background-color: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-reject {
    background-color: #ef4444;
    color: white;
}

.btn-reject:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
}

.btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.empty-icon {
    width: 6rem;
    height: 6rem;
    color: #cbd5e1;
    margin: 0 auto 1.5rem;
}

.empty-title {
    color: #1e293b;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.empty-message {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

/* Alert Messages */
.applications-container , .view-container {
    .alert {
        display: flex;
        align-items: center;
        gap: 1rem;
        padding: 1.25rem;
        border-radius: 12px;
        margin-bottom: 2rem;
        animation: slideDown 0.3s ease;
    }

    .alert-success {
        background-color: #ecfdf5;
        border: 2px solid #10b981;
        color: #065f46;
    }

    .alert-error {
        background-color: #fee2e2;
        border: 2px solid #ef4444;
        color: #991b1b;
    }

    /* Something is wrong but nothing has failed: the page still works and the
       admin can still save. Red would say the opposite. */
    .alert-warning {
        background-color: #fffbeb;
        border: 2px solid #f59e0b;
        color: #92400e;
    }

    /* Context, not an outcome: telling someone what page they are on is not
       a success, and green reads as one. */
    .alert-info {
        background-color: #eff6ff;
        border: 2px solid var(--portal-accent, #3993d0);
        color: #1e3a5f;
    }

    .alert-icon {
        width: 1.5rem;
        height: 1.5rem;
        flex-shrink: 0;
    }

    .alert-success .alert-icon {
        color: #10b981;
    }

    .alert-error .alert-icon {
        color: #ef4444;
    }

    .alert-warning .alert-icon {
        color: #f59e0b;
    }

    .alert-info .alert-icon {
        color: var(--portal-accent, #3993d0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .applications-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

@media (max-width: 768px) {
    .applications-page {
        padding: 1.5rem 1rem;
    }

    .page-title {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .applications-grid {
        grid-template-columns: 1fr;
    }

    .card-actions {
        flex-direction: column;
    }

    .btn-action {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .page-title {
        font-size: 1.75rem;
    }

    .page-title-icon {
        width: 2rem;
        height: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Small tiles are small so that two fit across a phone. */
    .stats-grid.stats-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-value {
        font-size: 2rem;
    }

    .application-card {
        padding: 1.25rem;
    }

    .business-name {
        font-size: 1.125rem;
    }
}


/* ==========================================================================
 * 2. DETAIL / FORM PAGES
 * ========================================================================== */

/* Application View Page Styling */

.application-view-page {
    background: linear-gradient(135deg, #f8fafc 0%, var(--portal-accent-wash, #e0f2fe) 100%);
    min-height: 100vh;
    padding: 2rem 1rem;
}

.view-container {
    max-width: 1000px;
    margin: 0 auto;
}

/* Header Section */
.view-header {
    background: white;
    padding: 2rem;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #e2e8f0;
    animation: slideDown 0.4s ease;
}

.applicant-primary-info h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.5rem 0;
}

.submission-meta {
    font-size: 0.9rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Errors Layout - Extended from Bootstrap */
.laravel-errors .alert, .laravel-messages .alert {
    margin-bottom: 0px;
}

/* Info Grid Layout */
.info-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Section Cards */
.view-section {
    background: white;
    border-radius: 6px;
    padding: 1.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--portal-accent, #3993d0);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.section-title svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Description List Styles */
.info-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full-width {
    grid-column: span 2;
}

/* --------------------------------------------------------------------------
 * Tooltip (x-ui.tooltip): an info icon that opens a longer explanation.
 * Classes are info-tip*, not ui-tooltip*: jQuery UI, loaded on these pages,
 * already styles .ui-tooltip with its own padding and shadow.
 * The popover is teleported to <body> and position:fixed, because form
 * sections clip their content and would cut off anything absolute.
 * -------------------------------------------------------------------------- */

.info-tip {
    display: inline-flex;
    vertical-align: middle;
    margin-left: 0.35rem;
}

.info-tip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    color: #64748b;
    cursor: help;
    transition: color 0.15s ease;
}

.info-tip-trigger svg {
    width: 1.125rem;
    height: 1.125rem;
}

.info-tip-trigger:hover,
.info-tip-trigger[aria-expanded="true"] {
    color: var(--portal-accent-deep, #2d7ab8);
}

.info-tip-trigger:focus-visible {
    outline: 2px solid var(--portal-accent, #3993d0);
    outline-offset: 2px;
}

.info-tip-pop {
    position: fixed;
    z-index: 10000;
    width: max-content;
    max-width: min(26rem, calc(100vw - 1rem));
    max-height: calc(100vh - 1rem);
    overflow-y: auto;
    padding: 0.75rem 0.875rem;
    background: #1e293b;
    color: #f8fafc;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.25), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    /* A global rule gives elements transition: all, which animated top and
       left from 0,0 the first time it opened. It is positioned, not animated. */
    transition: none;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    white-space: normal;
}

.info-tip-pop::before {
    content: '';
    position: absolute;
    left: calc(var(--arrow-x, 50%) - 6px);
    top: -6px;
    border: 6px solid transparent;
    border-top: 0;
    border-bottom-color: #1e293b;
}

.info-tip-pop.no-arrow::before {
    display: none;
}

.info-tip-pop.is-above::before {
    top: auto;
    bottom: -6px;
    border-top: 6px solid #1e293b;
    border-bottom: 0;
}

/* Ticket option card header: a button that folds the card, with a one line
   summary so a long list can be scanned without opening each card. */
.option-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.option-card-head.is-folded {
    margin-bottom: 0;
}

.option-card-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
    padding: 0;
    background: none;
    border: 0;
    text-align: left;
    color: #1e293b;
    cursor: pointer;
}

.option-card-toggle:focus-visible {
    outline: 2px solid var(--portal-accent, #3993d0);
    outline-offset: 3px;
    border-radius: 4px;
}

.option-card-chevron {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
    color: #64748b;
    transition: transform 0.15s ease;
}

.option-card-chevron.is-collapsed {
    transform: rotate(-90deg);
}

.option-card-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.6rem;
    min-width: 0;
}

.option-card-title small {
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 400;
}

.info-label-row {
    display: flex;
    align-items: center;
}

/* The icon is taller than the label text. Its extra height is pulled back out
   so a label with a tooltip is the same height as one without, and fields in
   the same row still line up. The button keeps its full size for tapping. */
.info-label-row .info-tip {
    margin-block: -0.4rem;
}

.info-tip-pop strong {
    font-weight: 600;
    color: #ffffff;
}

.info-tip-title {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    color: #ffffff;
}

.info-tip-pop ul {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-label.required::after {
    content: '*';
    font-size: 16px;
    color: #f79431;
}

.info-value {
    font-size: 1rem;
    color: #1e293b;
    font-weight: 500;
    line-height: 1.5;
}

.info-value a {
    color: var(--portal-accent, #3993d0);
    text-decoration: none;
}

.info-value a:hover {
    text-decoration: underline;
}

/* Reference Items */
.references-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reference-card {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-remove-ref {
    align-self: flex-start;
    margin-top: 1.5rem;
    padding: 0.5rem;
    color: #94a3b8;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove-ref:hover {
    color: #ef4444;
    background: #fef2f2;
}

.btn-remove-ref svg {
    width: 1.25rem;
    height: 1.25rem;
}

.dynamic-reference.removing {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.2s ease;
}

/* Form Styles */
.form-input,
.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: #1e293b;
    transition: all 0.2s ease;
    outline: none;
    margin-top: 0.25rem;
}

.form-input:focus,
.form-select:focus {
    background-color: #ffffff;
    border-color: var(--portal-accent, #3993d0);
    box-shadow: 0 0 0 3px rgba(57, 147, 208, 0.1);
}

.text-muted {
    color: #94a3b8;
    font-style: italic;
}

/* Sidebar Sections */
.sidebar-section {
    position: sticky;
    top: 2rem;
}

.action-card {
    background: white;
    border-radius: 6px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.payment-card {
    border-left: 4px solid #10b981;
}

.payment-card.unpaid {
    border-left-color: #f59e0b;
}

.link-card {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
}

.link-display {
    background: #ffffff;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
    margin-bottom: 1rem;
    color: #475569;
}

.btn-copy-link {
    background: var(--portal-accent, #3993d0);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.btn-copy-link:hover {
    background: var(--portal-accent-deep, #2d7ab8);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

/* Print Styles */
@media print {
    .top-bar {
        display: none !important;
    }

    .menu {
        display: none !important;
    }

    .admin-nav {
        display: none !important;
    }

    .applications-page, .back, .breadcrumbs, .header-actions, .view-toggle, .view-toggle + *, .sidebar-section, .btn-action {
        display: none !important;
    }

    .application-view-page {
        background: white;
        padding: 0;
    }

    .view-container {
        max-width: 100%;
        margin: 0;
    }

    .view-section {
        box-shadow: none;
        border: 1px solid #eee;
        break-inside: avoid;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    footer {
        display: none !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-list {
        grid-template-columns: 1fr;
    }

    .info-item.full-width {
        grid-column: span 1;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }
}


/* ==========================================================================
 * 3. SHARED
 * ========================================================================== */

/* "Add New" header button. Pairs with Bootstrap's .btn.btn-primary. */
.btn-add-new {
    border-radius: 8px;
    padding: 10px 20px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(65, 134, 186, 0.2);
}

.btn-add-new:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(65, 134, 186, 0.3);
}

/* A destructive action in a header: same shape as its neighbours, but white
   with red text, so it does not read as one more blue primary. Matches
   .btn-form-delete, which does the same job in a sidebar. Red on white is
   #b91c1c, 6.5:1. */
.btn-destructive {
    background-color: #ffffff;
    color: #b91c1c;
    border: 1px solid #fecaca;
    box-shadow: none;
}

.btn-destructive:hover,
.btn-destructive:focus {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    transform: translateY(-1px);
}

/* A second action beside a primary one: same shape, quieter. Used where both
   are reasonable but one is what most people came for. */
.btn-secondary {
    background-color: #ffffff;
    /* The deep accent, not the light one: #3993d0 on white is 3.36:1, under
       the 4.5:1 WCAG AA needs at this text size. The deep one is 4.58:1. */
    color: var(--portal-accent-deep, #2d7ab8);
    border: 1px solid var(--portal-accent, #3993d0);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
    color: var(--portal-accent-deep, #2d7ab8);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(57, 147, 208, 0.2);
}

/* --------------------------------------------------------------------------
 * Pagination
 *
 * Laravel's paginator is configured for Bootstrap markup in AppServiceProvider
 * (Paginator::useBootstrap()), so style both the Bootstrap 3 shape (bare <li>
 * + <a>) and the Bootstrap 4/5 shape (.page-item + .page-link).
 * -------------------------------------------------------------------------- */

.portal-pagination {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.portal-pagination nav {
    padding: 0;
}

.portal-pagination .pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.portal-pagination .pagination li,
.portal-pagination .pagination .page-item {
    list-style: none;
}

.portal-pagination .pagination li > a,
.portal-pagination .pagination li > span,
.portal-pagination .pagination .page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.625rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.portal-pagination .pagination li > a:hover,
.portal-pagination .pagination .page-link:hover {
    background: #f1f5f9;
    border-color: var(--portal-accent, #3993d0);
    color: #1e293b;
    text-decoration: none;
}

.portal-pagination .pagination .active > a,
.portal-pagination .pagination .active > span,
.portal-pagination .pagination .page-item.active .page-link {
    background: var(--portal-accent, #3993d0);
    border-color: var(--portal-accent, #3993d0);
    color: #ffffff;
}

.portal-pagination .pagination .disabled > a,
.portal-pagination .pagination .disabled > span,
.portal-pagination .pagination .page-item.disabled .page-link {
    background: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Laravel's Bootstrap-5 view carries a "results" summary alongside the links */
.portal-pagination p,
.portal-pagination .text-sm {
    font-size: 0.875rem;
    color: #64748b;
    margin: 0;
}

/* --------------------------------------------------------------------------
 * Form action buttons (x-ui.form-actions)
 * Replaces the inline styles these carried before they were componentised.
 * -------------------------------------------------------------------------- */

.btn-save {
    background-color: #1e3b25;
    border: none;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

.btn-save:hover {
    background-color: #0f172a;
    color: #ffffff;
}

.btn-save svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* .btn-action sets display:flex, which outranks the [hidden] default of
   display:none. Without this, hiding Save via the hidden property would do
   nothing at all. Scoped to .btn-action rather than a blanket [hidden] rule
   so it cannot surprise anything else on the page. */
.btn-action[hidden] {
    display: none !important;
}

/* Destructive, but not the loudest thing in the card: Save stays the filled
   button and this reads as a warning until hovered. */
.btn-form-delete {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    margin-bottom: 0.5rem;
}

.btn-form-delete:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

.btn-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    text-align: center;
    display: block;
    border-radius: 4px;
    padding: 0.75rem;
    text-decoration: none;
}

.btn-cancel:hover {
    background: #e2e8f0;
    color: #1e293b;
    text-decoration: none;
}


/* --------------------------------------------------------------------------
 * Check / radio rows (x-ui.field type="checkbox", x-ui.radio-group)
 *
 * .check-row is the canonical name; .permission-toggle is the original name,
 * kept because the member permission partial still emits it. These lived in
 * member-portal.css until shared components started rendering them, which left
 * them unstyled on admin pages.
 * -------------------------------------------------------------------------- */

.check-row,
.permission-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.check-row:hover,
.permission-toggle:hover {
    background: #ffffff;
    border-color: var(--portal-accent, #3993d0);
}

.check-row input[type="checkbox"],
.check-row input[type="radio"],
.permission-toggle input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--portal-accent, #3993d0);
    margin: 0;
}

.check-row span,
.permission-toggle span {
    font-size: 0.9375rem;
    color: #1e293b;
    cursor: pointer;
}

.check-row span .check-row-hint {
    display: block;
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 0.25em;
}

/* A selected radio row reads as selected, not just its dot */
.check-row.is-selected {
    background: var(--portal-accent-tint, #f0f9ff);
    border-color: var(--portal-accent, #3993d0);
}

.permission-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.permission-group-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.permission-note {
    font-size: 0.9375rem;
    color: #475569;
    padding: 0.875rem 1rem;
    background: var(--portal-accent-tint, #f0f9ff);
    border-left: 3px solid var(--portal-accent, #3993d0);
    border-radius: 6px;
}

/* Radio group: stacked by default, `inline` lays them out in a row */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.radio-group.is-inline {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.radio-group.is-inline .check-row {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
 * Collapsible sections (x-ui.section :collapsible)
 * -------------------------------------------------------------------------- */

.section-title.is-toggle {
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    transition: color 0.2s ease;
}

.section-title.is-toggle:hover {
    color: var(--portal-accent-deep, #2d7ab8);
}

.section-title.is-toggle:focus-visible {
    outline: 2px solid var(--portal-accent, #3993d0);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Pushes the chevron to the far right of the title row */
.section-title .section-spacer {
    flex: 1;
}

.section-chevron {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: #94a3b8;
    transition: transform 0.25s ease;
}

.section-title.is-toggle:hover .section-chevron {
    color: var(--portal-accent, #3993d0);
}

.section-chevron.is-collapsed {
    transform: rotate(-90deg);
}

/*
 * Height animation without a JS measure step: a 1fr -> 0fr grid row
 * transition. The inner wrapper needs overflow:hidden and min-height:0
 * for the row to actually shrink.
 */
.section-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.25s ease, margin-top 0.25s ease;
    margin-top: 1.5rem;
}

.section-body.is-collapsed {
    grid-template-rows: 0fr;
    margin-top: 0;
}

.section-body > .section-body-inner {
    overflow: hidden;
    min-height: 0;
}

/*
 * Non-collapsible sections keep the original spacing: .section-title already
 * carries margin-bottom:1.5rem, so the body must not add its own on top.
 */
.view-section > .section-body.is-static {
    display: block;
    transition: none;
    margin-top: 0;
}

/*
 * Collapsible cards. .action-card is a flex column with gap:1rem, so the body
 * must not add the section's margin-top on top of that gap -- and because the
 * slot is now wrapped, the gap no longer reaches the card's own children, so
 * the inner wrapper has to reinstate it.
 */
.action-card > .section-body {
    margin-top: 0;
}

.action-card > .section-body > .section-body-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (prefers-reduced-motion: reduce) {
    .section-body,
    .section-chevron {
        transition: none;
    }
}


/* --------------------------------------------------------------------------
 * File dropzone (x-ui.dropzone)
 *
 * Lived in member-portal.css until the admin company form started using it,
 * where it rendered completely unstyled -- including the rule that hides the
 * native input, so a raw file picker was showing through.
 *
 * Which of the two states shows is driven by .has-file on the dropzone, set by
 * portal-dropzone.js. Previously each caller inline-styled display on both
 * children, which meant the markup had to know about the JS.
 * -------------------------------------------------------------------------- */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.875rem;
    min-height: 220px;
    padding: 2rem 1.5rem;
    background:
        linear-gradient(#f8fafc, #f8fafc) padding-box,
        linear-gradient(135deg, #e2e8f0, #cbd5e1) border-box;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.dropzone:hover {
    border-color: var(--portal-accent, #3993d0);
    background: var(--portal-accent-tint, #f0f9ff);
}

/* The input is only visually hidden, so it still takes focus -- surface that */
.dropzone:focus-within {
    border-color: var(--portal-accent, #3993d0);
    background: var(--portal-accent-tint, #f0f9ff);
    box-shadow: 0 0 0 4px rgba(57, 147, 208, 0.15);
}

.dropzone.is-dragging {
    border-color: var(--portal-accent, #3993d0);
    border-style: solid;
    background: var(--portal-accent-wash, #e0f2fe);
    box-shadow: 0 0 0 4px rgba(57, 147, 208, 0.15);
}

/* Kept in the DOM so a normal form POST carries the file */
.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- idle state --- */

.dropzone-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.dropzone.has-file .dropzone-idle {
    display: none;
}

/* Circular badge, matching the dashboard tiles */
.dropzone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background: var(--portal-accent-wash, #e0f2fe);
    color: var(--portal-accent, #3993d0);
    transition: all 0.2s ease;
}

.dropzone-icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.dropzone:hover .dropzone-icon,
.dropzone.is-dragging .dropzone-icon,
.dropzone:focus-within .dropzone-icon {
    background: var(--portal-accent, #3993d0);
    color: #ffffff;
    transform: scale(1.05);
}

.dropzone-text {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #475569;
}

.dropzone-hint {
    font-size: 0.8125rem;
    color: #94a3b8;
}

/* Reads as a button without being one -- the whole zone is the click target */
.dropzone-browse {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
    padding: 0.5rem 1.125rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #1e293b;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.dropzone:hover .dropzone-browse {
    border-color: var(--portal-accent, #3993d0);
    color: var(--portal-accent, #3993d0);
}

/* --- preview state --- */

.dropzone-preview {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.dropzone.has-file .dropzone-preview {
    display: flex;
}

/* Chequerboard so transparent logos read correctly */
.dropzone-preview img {
    max-height: 150px;
    max-width: 100%;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
        linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.dropzone-fileinfo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
}

.dropzone-filename {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #475569;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropzone-filesize {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #94a3b8;
}

.dropzone-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.dropzone-replace,
.dropzone-remove {
    padding: 0.25rem 0.75rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropzone-replace {
    color: var(--portal-accent, #3993d0);
    border-color: var(--portal-accent-edge, #bae6fd);
}

.dropzone-replace:hover {
    background: var(--portal-accent-wash, #e0f2fe);
}

.dropzone-remove {
    color: #ef4444;
    border-color: #fecaca;
}

.dropzone-remove:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Read-only logo, for viewers without permission to change it */
.logo-readonly {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.logo-readonly img {
    max-height: 100px;
    padding: 0.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
}

@media (max-width: 767px) {
    .dropzone {
        min-height: 180px;
        padding: 1.5rem 1rem;
    }

    .dropzone-preview img {
        max-height: 110px;
    }
}

/* Document dropzones show a file card instead of a thumbnail */
.dropzone-filecard {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: var(--portal-accent, #3993d0);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
}

.dropzone-filecard svg {
    width: 1.5rem;
    height: 1.5rem;
}

.dropzone-open {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--portal-accent, #3993d0);
    text-decoration: underline;
}

.dropzone-open:hover {
    color: var(--portal-accent-deep, #2d7ab8);
}

/* --------------------------------------------------------------------------
 * Section toolbar -- a count plus an action, for sections that wrap a list
 * -------------------------------------------------------------------------- */

.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.section-count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Shows an already-saved external link above the field that replaces it */
.current-link {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--portal-accent-tint, #f0f9ff);
    border-left: 3px solid var(--portal-accent, #3993d0);
    border-radius: 6px;
}

.current-link-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.current-link a {
    font-size: 0.875rem;
    color: var(--portal-accent, #3993d0);
    word-break: break-all;
}

@media (max-width: 767px) {
    .section-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

/*
 * Typeahead. The list floats over the fields below it, so the section holding
 * it opts out of the clip .section-body-inner carries for the collapse
 * animation. Static sections only: a collapsible one needs that clip to shrink.
 * The z-index lifts the section over the ones after it in the page.
 */
.view-section.has-popover {
    position: relative;
    z-index: 2;
}

.view-section.has-popover > .section-body.is-static > .section-body-inner {
    overflow: visible;
}

.combobox {
    position: relative;
}

.combobox-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: 18rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.combobox-option {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem 0.625rem;
    border-radius: 6px;
    cursor: pointer;
}

.combobox-option strong {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
}

.combobox-option small {
    font-size: 0.8rem;
    color: #64748b;
}

.combobox-option.is-active {
    background: #eff6fc;
}

.combobox-option.is-active strong {
    color: var(--portal-accent, #3993d0);
}

.combobox-empty {
    padding: 0.5rem 0.625rem;
    font-size: 0.85rem;
    color: #64748b;
}
