/* Common Admin UI Styles — MintAgent-aligned design tokens */

:root {
    /* Shared admin palette */
    --ma-color-primary: #0284c7;
    --ma-color-primary-hover: #0369a1;
    --ma-color-primary-active: #075985;
    --ma-color-secondary: #64748b;
    --ma-color-secondary-hover: #475569;
    --ma-color-secondary-active: #334155;
    --ma-color-red: #c41e3a;
    --ma-color-red-hover: #9f1830;
    --ma-cream-orange: #fff7ed;
    --ma-cream-yellow: #fffbeb;
    --ma-color-success: #166534;
    --ma-color-success-hover: #14532d;
    --ma-color-success-muted-bg: #dcfce7;
    --ma-color-warning: #b45309;
    --ma-color-warning-hover: #92400e;
    --ma-color-warning-muted-bg: #fef3c7;
    --ma-color-danger: #b91c1c;
    --ma-color-danger-hover: #991b1b;
    --ma-color-danger-muted-bg: #fee2e2;
    --ma-gray-dark: #0f172a;
    --ma-gray-mid: #94a3b8;
    --ma-gray-light: #f8fafc;
    --ma-text-on-primary: #ffffff;
    --ma-text-heading: #0f172a;
    --ma-text-body: #334155;
    --ma-text-muted: #64748b;
    --ma-border: #e2e8f0;
    --ma-border-strong: #cbd5e1;
    --ma-surface-page: #f8fafc;
    --ma-surface-card: #ffffff;
    --ma-surface-muted: #f8fafc;
    --ma-surface-card-header: #f1f5f9;
    --ma-surface-table-header: #e2e8f0;
    --ma-surface-section: #ffffff;
    --ma-surface-dropdown-hover: #f1f5f9;
    --ma-primary-soft-bg: rgba(2, 132, 199, 0.12);
    --ma-header-bg: #0f172a;
    --ma-header-link-hover: rgba(255, 255, 255, 0.1);
    --ma-header-link-active: rgba(255, 255, 255, 0.18);
    --ma-radius-sm: 6px;
    --ma-radius-md: 6px;
    --ma-radius-lg: 8px;
    --ma-radius-pill: 999px;
    --ma-shadow-elevation-1: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.1);
    --ma-shadow-elevation-2: 0 4px 6px rgba(15, 23, 42, 0.07), 0 2px 4px rgba(15, 23, 42, 0.05);
    --ma-shadow-modal: 0 20px 50px rgba(15, 23, 42, 0.18), 0 8px 16px rgba(15, 23, 42, 0.08);
    --ma-shadow-gold-elevation: 0 2px 10px rgba(176, 125, 60, 0.18), 0 1px 2px rgba(15, 23, 42, 0.06);
    /* Premium product cards (collections grid) */
    --ma-shadow-card-luxury:
        0 18px 48px rgba(15, 23, 42, 0.07),
        0 4px 12px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    --ma-shadow-card-luxury-hover:
        0 28px 64px rgba(15, 23, 42, 0.11),
        0 12px 28px rgba(15, 23, 42, 0.07),
        0 0 0 1px rgba(107, 45, 66, 0.1);
    --ma-font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --ma-text-base: 1rem;
    --ma-transition-fast: 160ms ease;
    --ma-focus-ring: 0 0 0 3px rgba(2, 132, 199, 0.18);
    --ma-badge-info-bg: #e0f2fe;
    --ma-badge-info-text: #0369a1;
    --ma-dropdown-active-bg: #e0f2fe;
    --ma-dropdown-active-text: var(--ma-color-primary);
    --ma-tertiary-bg: #f8fafc;
    --ma-tertiary-hover: #f1f5f9;
    --ma-outline-disabled-text: #d1d5db;
    --ma-color-info: #0f766e;
    --ma-color-info-hover: #115e59;

    /* Responsive layout tokens (mobile-first: 640 / 768 / 1024 / 1280) */
    --ma-bp-sm: 640px;
    --ma-bp-md: 768px;
    --ma-bp-lg: 1024px;
    --ma-bp-xl: 1280px;
}

/* Shared: keep wide tables inside the viewport without breaking page width */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    max-width: 100%;
}

.table-scroll > table {
    margin-bottom: 0;
}

/*
 * Wide tables → stacked labeled cards on full mobile.
 * Requires data-label on each td. Mid-width keeps horizontal scroll via .table-scroll.
 */
@media (max-width: 768px) {
    .table-scroll:has(> .ma-table-cards),
    .credit-history-table-wrap:has(> .ma-table-cards) {
        overflow-x: visible;
        -webkit-overflow-scrolling: auto;
    }

    table.ma-table-cards {
        min-width: 0 !important;
        width: 100%;
        border: none;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    table.ma-table-cards thead {
        display: none;
    }

    table.ma-table-cards tbody {
        display: block;
    }

    table.ma-table-cards tbody tr {
        display: block;
        margin: 0 0 0.85rem;
        padding: 0.65rem 0.85rem;
        border: 1px solid var(--ma-border);
        border-radius: var(--ma-radius-md);
        background: var(--ma-surface-card);
        box-shadow: var(--ma-shadow-elevation-1);
    }

    table.ma-table-cards tbody td {
        display: grid;
        grid-template-columns: 7.5rem 1fr;
        gap: 0.35rem 0.75rem;
        align-items: start;
        width: 100%;
        padding: 0.4rem 0;
        border: none;
        white-space: normal;
        text-align: left !important;
        vertical-align: top;
        max-width: none;
    }

    table.ma-table-cards tbody td + td {
        border-top: 1px solid var(--ma-border);
    }

    table.ma-table-cards tbody td::before {
        content: attr(data-label);
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ma-text-muted);
        line-height: 1.35;
    }

    /* Single-cell empty / placeholder rows */
    table.ma-table-cards tbody td[colspan] {
        display: block;
        grid-template-columns: none;
    }

    table.ma-table-cards tbody td[colspan]::before {
        content: none;
    }

    table.ma-table-cards tbody td[data-label="Actions"] {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    table.ma-table-cards tbody td[data-label="Actions"] .history-row-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
        max-width: 19rem;
    }

    table.ma-table-cards tbody td[data-label="Actions"] .btn {
        width: auto;
        max-width: 9rem;
        flex: 1 1 auto;
        margin: 0 0 0;
    }

    table.ma-table-cards tbody td[data-label="Select"],
    table.ma-table-cards tbody td[data-label="Enabled"] {
        align-items: center;
    }
}

/* [hidden] must win over component display rules (e.g. flex placeholders) */
[hidden] {
    display: none !important;
}

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

body {
    font-family: var(--ma-font-sans);
    background: var(--ma-surface-page);
    color: var(--ma-text-body);
    line-height: 1.6;
    font-size: 15px;
}

/* Header Styles — hamburger via .is-nav-compact (JS overflow detect) */
.header {
    background: var(--ma-header-bg);
    color: var(--ma-text-on-primary);
    padding: 0.75rem 2rem;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem 1rem;
    box-shadow: var(--ma-shadow-elevation-1);
    position: relative;
    z-index: 200;
}

.header-brand-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.1rem;
    margin-right: 0.5rem;
    flex: 0 0 auto;
    min-width: 0;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.header-brand {
    color: inherit;
    text-decoration: none;
}

.header-brand:hover,
.header-brand:focus {
    text-decoration: none;
    opacity: 0.92;
}

.header .nav-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.header .user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-left: auto;
    flex: 0 0 auto;
}

.header-lookup {
    margin: 0 0.35rem 0 0;
}

.header-lookup-input {
    width: 14rem;
    max-width: 40vw;
    padding: 0.35rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--ma-radius-md);
    background: rgba(255, 255, 255, 0.12);
    color: var(--ma-text-on-primary);
    font-size: 0.85rem;
}

.header-lookup-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.header-lookup-input:focus {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 1px;
    background: rgba(255, 255, 255, 0.2);
}

.header.is-nav-compact .header-lookup-input {
    width: 9rem;
}

.header .user-email {
    font-size: 0.75rem;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.85);
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header .user-email--menu {
    display: none;
}

.header-menu-toggle {
    display: none;
    appearance: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--ma-radius-sm);
    width: 2.5rem;
    height: 2.5rem;
    padding: 0.5rem;
    margin: 0;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    flex: 0 0 auto;
}

.header-menu-toggle:hover {
    background: var(--ma-header-link-hover);
}

.header-menu-bar {
    display: block;
    width: 1.15rem;
    height: 2px;
    background: var(--ma-text-on-primary);
    border-radius: 1px;
}

/* Navigation Links — hover subtle; active clearly selected */
.nav-link, .nav-links a {
    color: var(--ma-text-on-primary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--ma-radius-sm);
    white-space: nowrap;
    transition: background-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast), color var(--ma-transition-fast);
}

.nav-link:hover, .nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-link.active, .nav-links a.active {
    background: rgba(2, 132, 199, 0.5);
    box-shadow: inset 3px 0 0 #38bdf8;
    font-weight: 600;
}

.nav-link.active:hover, .nav-links a.active:hover {
    background: rgba(2, 132, 199, 0.62);
}

/* Navigation Dropdown */
.nav-dropdown {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.nav-dropdown-toggle {
    color: var(--ma-text-on-primary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    padding-bottom: 0.75rem; /* Extra bottom padding to reach dropdown */
    border-radius: var(--ma-radius-sm);
    transition: background-color var(--ma-transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-dropdown-toggle.active {
    background: rgba(2, 132, 199, 0.5);
    box-shadow: inset 3px 0 0 #38bdf8;
    font-weight: 600;
}

.nav-dropdown-toggle.active:hover {
    background: rgba(2, 132, 199, 0.62);
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform var(--ma-transition-fast);
}

.nav-dropdown:hover .dropdown-arrow,
.nav-dropdown.is-open .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--ma-surface-card);
    min-width: 200px;
    border-radius: var(--ma-radius-md);
    box-shadow: var(--ma-shadow-elevation-2);
    z-index: 1000;
    padding: 0.5rem 0;
    border: 1px solid var(--ma-border);
    transition: opacity var(--ma-transition-fast), visibility var(--ma-transition-fast);
    margin-top: -1px; /* Overlap slightly to maintain hover */
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.is-open .nav-dropdown-menu {
    visibility: visible;
    opacity: 1;
}

/* Extend hover area */
.nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
}

.nav-dropdown-menu a {
    color: var(--ma-text-heading);
    text-decoration: none;
    padding: 0.75rem 1rem;
    display: block;
    transition: background-color var(--ma-transition-fast);
}

.nav-dropdown-menu a:hover {
    background: var(--ma-surface-dropdown-hover);
}

.nav-dropdown-menu a.active {
    background: var(--ma-dropdown-active-bg);
    color: var(--ma-dropdown-active-text);
}

/* User site link */
.user-site-link {
    color: var(--ma-cream-yellow);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--ma-radius-sm);
    transition: background-color var(--ma-transition-fast);
    margin-right: 0.5rem;
}

.user-site-link:hover {
    background: var(--ma-primary-soft-bg);
}

/* Logout icon button */
.logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-sm);
    background: transparent;
    color: var(--ma-text-on-primary);
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--ma-transition-fast), border-color var(--ma-transition-fast), color var(--ma-transition-fast);
}

.logout-btn:hover {
    background: var(--ma-header-link-hover);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fecaca;
}

.logout-icon {
    display: block;
    flex-shrink: 0;
}

/* Assistant chat toggle (header) */
.admin-chat-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-sm);
    background: transparent;
    color: var(--ma-text-on-primary);
    cursor: pointer;
    transition: background-color var(--ma-transition-fast), border-color var(--ma-transition-fast), color var(--ma-transition-fast);
}

.admin-chat-toggle:hover,
.admin-chat-toggle[aria-expanded="true"] {
    background: var(--ma-header-link-hover);
    border-color: rgba(255, 255, 255, 0.2);
    color: #bae6fd;
}

.admin-chat-toggle-icon {
    display: block;
    flex-shrink: 0;
}

/* Assistant slide-out chat panel */
:root {
    --admin-chat-width: 26rem;
}

.admin-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--ma-transition-fast);
}

.admin-chat-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.admin-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1101;
    display: flex;
    flex-direction: column;
    width: var(--admin-chat-width, 26rem);
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: var(--ma-surface-card);
    border-left: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow-modal);
    transform: translateX(100%);
    transition: transform 220ms ease;
    color: var(--ma-text-body);
}

.admin-chat-panel.is-open {
    transform: translateX(0);
}

body.admin-chat-pinned.admin-chat-open {
    padding-right: var(--admin-chat-width, 26rem);
    box-sizing: border-box;
}

body.admin-chat-pinned .admin-chat-panel {
    box-shadow: none;
    transition: none;
}

body.admin-chat-pinned .admin-chat-backdrop {
    display: none !important;
}

.admin-chat-resize {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 100%;
    margin-left: -7px;
    cursor: col-resize;
    touch-action: none;
    background: transparent;
}

.admin-chat-resize-grabber {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 2.75rem;
    border-radius: var(--ma-radius-pill);
    border: 1px solid var(--ma-border-strong);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
    color: var(--ma-text-muted);
    transition:
        background-color var(--ma-transition-fast),
        border-color var(--ma-transition-fast),
        color var(--ma-transition-fast),
        box-shadow var(--ma-transition-fast),
        transform var(--ma-transition-fast);
}

.admin-chat-resize-grip {
    display: block;
    width: 4px;
    height: 1.15rem;
    background-image: radial-gradient(circle, currentColor 1.1px, transparent 1.25px);
    background-size: 4px 5px;
    background-position: center;
    background-repeat: repeat-y;
    opacity: 0.9;
}

.admin-chat-resize:hover .admin-chat-resize-grabber,
.admin-chat-resize:focus-visible .admin-chat-resize-grabber,
body.admin-chat-resizing .admin-chat-resize-grabber {
    border-color: var(--ma-color-primary);
    color: var(--ma-color-primary);
    background: var(--ma-primary-soft-bg);
    box-shadow: var(--ma-focus-ring);
    transform: scale(1.05);
}

.admin-chat-resize:focus-visible {
    outline: none;
}

body.admin-chat-resizing {
    cursor: col-resize;
    user-select: none;
}

body.admin-chat-resizing iframe {
    pointer-events: none;
}

.admin-chat-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 0 0 auto;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--ma-border);
    background: var(--ma-surface-card-header);
}

.admin-chat-panel-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ma-text-heading);
}

.admin-chat-panel-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: 0 0 auto;
}

.admin-chat-close,
.admin-chat-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-sm);
    background: transparent;
    color: var(--ma-text-muted);
    cursor: pointer;
    transition: background-color var(--ma-transition-fast), color var(--ma-transition-fast), border-color var(--ma-transition-fast);
}

.admin-chat-close:hover,
.admin-chat-pin:hover {
    background: var(--ma-surface-dropdown-hover);
    border-color: var(--ma-border);
    color: var(--ma-text-heading);
}

.admin-chat-pin.is-pinned {
    color: var(--ma-color-primary);
}

.admin-chat-pin.is-pinned:hover {
    color: var(--ma-color-primary-hover);
}

.admin-chat-pin-icon {
    display: block;
}

.admin-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--ma-surface-page);
}

.admin-chat-message {
    display: flex;
    max-width: 100%;
}

.admin-chat-message--assistant {
    justify-content: flex-start;
}

.admin-chat-message--user {
    justify-content: flex-end;
}

.admin-chat-message-bubble {
    max-width: 92%;
    padding: 0.7rem 0.85rem;
    border-radius: var(--ma-radius-lg);
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow-elevation-1);
    color: var(--ma-text-body);
    font-size: 0.9375rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.admin-chat-message--assistant .admin-chat-message-bubble {
    border-bottom-left-radius: 2px;
}

.admin-chat-message--user .admin-chat-message-bubble {
    background: var(--ma-primary-soft-bg);
    border-color: rgba(2, 132, 199, 0.25);
    color: var(--ma-text-heading);
    border-bottom-right-radius: 2px;
}

.admin-chat-composer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
}

.admin-chat-input {
    width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 2.75rem;
    max-height: 8rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--ma-border-strong);
    border-radius: var(--ma-radius-md);
    font: inherit;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--ma-text-body);
    background: var(--ma-surface-card);
    transition: border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.admin-chat-input:focus {
    outline: none;
    border-color: var(--ma-color-primary);
    box-shadow: var(--ma-focus-ring);
}

.admin-chat-input:disabled {
    background: var(--ma-surface-muted);
    color: var(--ma-text-muted);
    cursor: not-allowed;
}

.admin-chat-composer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.admin-chat-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.5rem;
    padding: 0.45rem 0.9rem;
    border-radius: var(--ma-radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--ma-transition-fast), border-color var(--ma-transition-fast), color var(--ma-transition-fast), opacity var(--ma-transition-fast);
}

.admin-chat-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.admin-chat-btn--primary {
    background: var(--ma-color-primary);
    border-color: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
}

.admin-chat-btn--primary:hover:not(:disabled) {
    background: var(--ma-color-primary-hover);
    border-color: var(--ma-color-primary-hover);
}

.admin-chat-btn--secondary {
    background: var(--ma-surface-card);
    border-color: var(--ma-border-strong);
    color: var(--ma-text-body);
}

.admin-chat-btn--secondary:hover:not(:disabled) {
    background: var(--ma-tertiary-hover);
    border-color: var(--ma-color-secondary);
}

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

body.admin-chat-overlay {
    overflow: hidden;
}

@media (max-width: 640px) {
    body.admin-chat-pinned.admin-chat-open {
        padding-right: 0;
    }

    body.admin-chat-pinned .admin-chat-panel.is-open {
        width: 100vw;
        max-width: 100vw;
    }

    .admin-chat-resize {
        display: none;
    }
}

/* Compact header (JS overflow detect → .is-nav-compact) */
.header.is-nav-compact {
    padding: 0.75rem 1rem;
}

.header.is-nav-compact .header-brand-block {
    margin-right: 0;
}

.header.is-nav-compact h1 {
    font-size: 1.15rem;
}

.header.is-nav-compact .user-email--desktop {
    display: none;
}

.header.is-nav-compact .header-menu-toggle {
    display: inline-flex;
    order: -1;
    position: relative;
    z-index: 2;
}

.header.is-nav-compact .nav-links {
    display: none;
    position: absolute;
    top: calc(100% - 0.35rem);
    left: 1rem;
    right: auto;
    width: max-content;
    min-width: 15.5rem;
    max-width: min(22rem, calc(100vw - 2rem));
    flex-direction: column;
    align-items: stretch;
    flex: none;
    gap: 0.15rem;
    padding: 0.35rem 0.35rem 0.4rem;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--ma-radius-md);
    background: var(--ma-header-bg);
    box-shadow: var(--ma-shadow-elevation-2);
    order: initial;
    z-index: 300;
}

.header.is-nav-compact.is-nav-open .nav-links {
    display: flex;
}

.header.is-nav-compact.is-nav-open .header-menu-toggle {
    background: var(--ma-header-link-active);
}

.header.is-nav-compact .user-email--menu {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    max-width: none;
    margin: -0.35rem -0.35rem 0.2rem;
    padding: 0.85rem 1rem;
    border-top: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.8rem;
    line-height: 1.25;
    white-space: nowrap;
}

.header.is-nav-compact .nav-links > a,
.header.is-nav-compact .nav-dropdown-toggle {
    width: 100%;
    box-sizing: border-box;
}

.header.is-nav-compact .nav-dropdown {
    display: block;
    width: 100%;
}

/* Compact Export: open via .is-open (click/tap); hover still works on pointer devices */
.header.is-nav-compact .nav-dropdown-menu {
    position: static;
    visibility: hidden;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    overflow-y: hidden;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    pointer-events: none;
    transition: opacity var(--ma-transition-fast), visibility var(--ma-transition-fast), max-height var(--ma-transition-fast);
}

.header.is-nav-compact .nav-dropdown:hover .nav-dropdown-menu,
.header.is-nav-compact .nav-dropdown:focus-within .nav-dropdown-menu,
.header.is-nav-compact .nav-dropdown.is-open .nav-dropdown-menu {
    visibility: visible;
    opacity: 1;
    max-height: min(20rem, 55vh);
    overflow-y: auto;
    padding: 0.1rem 0 0.25rem 0.65rem;
    pointer-events: auto;
}

.header.is-nav-compact .nav-dropdown-menu a {
    color: var(--ma-text-on-primary);
}

.header.is-nav-compact .nav-dropdown-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ma-text-on-primary);
}

.header.is-nav-compact .nav-dropdown-menu a.active {
    background: rgba(2, 132, 199, 0.5);
    box-shadow: inset 3px 0 0 #38bdf8;
    color: var(--ma-text-on-primary);
    font-weight: 600;
}

.header.is-nav-compact .nav-dropdown-menu a.active:hover {
    background: rgba(2, 132, 199, 0.62);
}

.header.is-nav-compact .user-info {
    margin-left: auto;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Button Styles — MintAgent matrix (text-only; no decorative icons per product spec) */
.btn {
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-sm);
    cursor: pointer;
    font-size: var(--ma-text-base);
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: background-color var(--ma-transition-fast), border-color var(--ma-transition-fast), color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.btn-primary {
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
}

.btn-primary:hover {
    background: var(--ma-color-primary-hover);
}

.btn-primary:active {
    background: var(--ma-color-primary-active);
}

.btn-success {
    background: var(--ma-color-success);
    color: var(--ma-text-on-primary);
}

.btn-success:hover {
    background: var(--ma-color-success-hover);
}

.btn-warning {
    background: var(--ma-color-warning);
    color: var(--ma-text-on-primary);
}

.btn-warning:hover {
    background: var(--ma-color-warning-hover);
}

.btn-danger {
    background: transparent;
    color: var(--ma-color-danger);
    border-color: var(--ma-color-danger);
}

.btn-danger:hover {
    background: var(--ma-color-danger);
    color: var(--ma-text-on-primary);
}

.btn-secondary {
    background: var(--ma-surface-card);
    color: var(--ma-text-body);
    border-color: var(--ma-border-strong);
}

.btn-secondary:hover {
    background: var(--ma-surface-muted);
    border-color: var(--ma-color-secondary);
}

.btn-secondary:active {
    background: #e2e8f0;
}

/* Neutral tertiary */
.btn-tertiary {
    background: var(--ma-tertiary-bg);
    color: var(--ma-text-heading);
    border-color: var(--ma-border);
}

.btn-tertiary:hover {
    background: var(--ma-tertiary-hover);
}

/* MintAgent outline */
.btn-outline {
    background: var(--ma-surface-card);
    color: var(--ma-text-heading);
    border-color: var(--ma-border-strong);
}

.btn-outline:hover {
    background: var(--ma-surface-muted);
}

.btn-outline:disabled,
.btn-outline[disabled] {
    color: var(--ma-outline-disabled-text);
    border-color: var(--ma-border);
    background: var(--ma-surface-card);
    cursor: not-allowed;
    opacity: 0.85;
}

.btn:disabled,
.btn[disabled]:not(.btn-outline) {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-small, .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.9rem 1.75rem;
    font-size: 1.05rem;
}

.btn-pill {
    border-radius: var(--ma-radius-pill);
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-bottom: 1rem;
}

.form-group.checkbox-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.form-group.checkbox-group input[type="checkbox"] {
    flex: 0 0 1.25rem;
    width: 1.25rem;
    padding: 0;
}

.form-group.checkbox-group label {
    margin-bottom: 0;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-lg {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    accent-color: var(--ma-color-primary);
}

.form-group label,
.form-action-label {
    display: block;
    margin-bottom: 0;
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Base look for every admin form control. :where() keeps specificity at zero, so a component
   class (header lookup, chat box, user picker) still overrides it without !important. */
:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea) {
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    font-size: var(--ma-text-base);
    font-family: inherit;
    line-height: 1.4;
    background: var(--ma-surface-card);
    color: var(--ma-text-body);
    transition: border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

:where(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):where(:focus) {
    outline: none;
    border-color: var(--ma-color-primary);
    box-shadow: var(--ma-focus-ring);
}

:where(input, select, textarea):where(:disabled) {
    background: var(--ma-surface-card-header);
    color: var(--ma-text-muted);
    cursor: not-allowed;
}

.form-group input,
.form-group select,
.form-group textarea,
#spend-table input.spend-cost,
#spend-table input.spend-desc,
#product-table input.product-sku,
#product-table input.product-name,
#product-table input.product-shopify-id,
#product-table input.product-credits,
#product-table select.product-category {
    width: 100%;
}

.controls select,
.user-select select,
.search-box select,
.toolbar select,
.controls input[type="date"],
.label-report-date-wrap input[type="date"] {
    width: auto;
    min-width: 12rem;
}

/* Keep numeric validation while presenting number fields as plain text boxes. */
input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

#spend-table input.spend-cost {
    min-width: 4.5rem;
    max-width: 6rem;
}

#spend-table input.spend-desc {
    min-width: 12rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Shared card and section styles */
.section,
.card {
    background: var(--ma-surface-card);
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-elevation-1);
    overflow: hidden;
    border: 1px solid var(--ma-border);
}

.card {
    margin-bottom: 1.5rem;
}

.section-header,
.card-header {
    background: var(--ma-surface-card-header);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ma-border);
}

.section-header h2,
.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ma-text-heading);
}

.card-subtitle {
    margin-top: 0.125rem;
    color: var(--ma-text-muted);
    font-size: 0.9rem;
    line-height: 1.25;
}

.section-content,
.card-content {
    padding: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 1rem;
    align-items: start;
}

.form-grid > .form-group {
    margin-bottom: 0;
}

/* Match labeled fields: action groups include an explicit hidden label row. */
.form-grid > .form-actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.375rem;
    margin-top: 0;
    align-self: start;
}

.form-action-label {
    visibility: hidden;
}

.form-action-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.content-stack > * + * {
    margin-top: 1rem;
}

.preview-panel {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.preview-panel h4 {
    margin-bottom: 0.5rem;
    color: var(--ma-text-heading);
}

.schedule-preview-table {
    width: min(100%, 30rem);
    table-layout: fixed;
}

.schedule-preview-table .schedule-preview-period {
    width: 13.333%;
}

.schedule-preview-table .schedule-preview-date {
    width: 30%;
}

.schedule-preview-table .schedule-preview-credits {
    width: 26.667%;
}

.compact-preview-table {
    width: min(100%, 20rem);
    table-layout: fixed;
}

.help-text {
    margin-bottom: 0.5rem;
    color: var(--ma-text-muted);
    font-size: 0.9rem;
}

.field-warning {
    margin: 0;
    color: var(--ma-color-warning);
    font-size: 0.85rem;
    line-height: 1.3;
}

.subsection-heading hr {
    margin: 0 0 0.75rem;
    border: 0;
    border-top: 1px solid var(--ma-border);
}

.subsection-heading h4 {
    color: var(--ma-text-heading);
    font-size: 1rem;
    font-weight: 600;
}

/* Table Styles */
table {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--ma-border-strong);
    border-radius: var(--ma-radius-lg);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--ma-surface-card);
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--ma-border);
}

th {
    background: var(--ma-surface-table-header);
    font-weight: 600;
    color: var(--ma-text-heading);
    border-bottom: 1px solid var(--ma-border-strong);
}

tbody tr:last-child td {
    border-bottom: 0;
}

tr:hover {
    background: var(--ma-surface-dropdown-hover);
}

.table-compact th,
.table-compact td {
    padding: 0.35rem 0.5rem;
}

pre {
    overflow-x: auto;
    padding: 1rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-muted);
    color: var(--ma-text-body);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
}

.table-cell-top {
    text-align: left;
    vertical-align: top;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.45);
}

.modal-content {
    background-color: var(--ma-surface-card);
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--ma-radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--ma-shadow-modal);
    border: 1px solid var(--ma-border);
}

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

.modal-header h3 {
    font-size: 1.5rem;
    color: var(--ma-text-heading);
}

/* Full-bleed card header on modals (matches page cards) */
.modal-content.modal-card {
    padding: 0;
    overflow: hidden;
}

.modal-content.modal-card > .modal-header.card-header {
    margin: 0;
    background: var(--ma-surface-card-header);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-lg) var(--ma-radius-lg) 0 0;
}

.modal-content.modal-card > .modal-header.card-header .card-title,
.modal-content.modal-card > .modal-header.card-header h3 {
    margin: 0;
    padding: 0;
    border-bottom: none;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ma-text-heading);
}

.modal-content.modal-card > .modal-card-body,
.modal-content.modal-card > form {
    padding: 1.75rem 2rem 2rem;
}

.modal-content.modal-card > .modal-body {
    padding: 1.5rem 2rem;
}

.modal-content.modal-card > .modal-footer,
.modal-content.modal-card > .modal-footer.form-actions {
    margin: 0;
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
}

.modal-body {
    padding: 2rem;
}

.close {
    color: var(--ma-gray-mid);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color var(--ma-transition-fast);
}

.close:hover {
    color: var(--ma-text-heading);
}

/* Support lookup + coin tables (shared by Lookup and Collections) */
.admin-lookup-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    max-width: 36rem;
}

.admin-lookup-form input[type="search"] {
    flex: 1 1 auto;
    min-width: 0;
}

.admin-lookup-section {
    margin-bottom: 1rem;
}

.admin-audit-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    align-items: start;
    gap: 0.75rem 1rem;
}

.admin-audit-filters input[type="number"] {
    min-height: 2.5rem;
}

.admin-audit-filters .form-group {
    margin-bottom: 0;
}

.admin-audit-filter-actions {
    display: flex;
    gap: 0.5rem;
    align-self: end;
}

.admin-lookup-count {
    font-weight: 400;
    color: var(--ma-text-muted);
}

.coin-table-row {
    cursor: pointer;
}

.coin-table-row td[data-label="ID"] a {
    color: inherit;
    text-decoration: none;
}

.coin-table-name,
.coin-table-subtitle {
    display: block;
}

.coin-table-subtitle {
    font-size: 0.8rem;
    color: var(--ma-text-muted);
}

/* Message Styles */
.error-message {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--ma-border);
}

.success-message {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    margin-bottom: 1rem;
    border: 1px solid var(--ma-border);
}

.section-messages:empty {
    display: none;
}

.error-message:focus,
.success-message:focus {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

/* Status Badges */
.user-role, .status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--ma-radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.user-role.admin, .status-badge.active {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
}

.user-role.user {
    background: var(--ma-badge-info-bg);
    color: var(--ma-badge-info-text);
}

.user-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--ma-radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
}

.user-status.active {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
}

.user-status.inactive, .status-badge.inactive {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
}

/* Health Status */
.health-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--ma-radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.health-status.healthy {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
}

.health-status.degraded {
    background: var(--ma-color-warning-muted-bg);
    color: var(--ma-color-warning);
}

.health-status.unhealthy {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
}

.health-status.skipped {
    background: var(--ma-color-neutral-muted-bg, #f1f5f9);
    color: var(--ma-text-muted, #64748b);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Loading Styles */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--ma-text-muted);
}

/* Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
        gap: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .page-header h2 {
        font-size: 1.35rem;
    }

    .page-header .controls-actions {
        width: 100%;
    }

    .page-header .controls-actions .btn {
        flex: 1 1 auto;
    }
    
    .action-buttons {
        flex-direction: column;
    }

    .form-row,
    .coin-image-upload-row {
        grid-template-columns: 1fr;
    }

    .coin-image-upload-area .coin-image-slots {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .btn {
        flex: 1 1 auto;
    }

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

    .modal-content {
        margin: 1rem auto;
        padding: 1.25rem;
        width: calc(100% - 1.5rem);
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }

    .modal-content.modal-card {
        padding: 0;
    }

    .modal-header h3 {
        font-size: 1.2rem;
    }

    .report-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .report-toolbar .export-buttons {
        width: 100%;
    }

    .report-toolbar .export-buttons .btn {
        flex: 1 1 auto;
    }
    
    .table-content {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
}

/* Page-specific common styles */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 2rem;
    color: var(--ma-text-heading);
    margin: 0;
}

.page-header .subtitle,
.subtitle {
    margin: 0.35rem 0 0;
    color: var(--ma-text-muted);
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.4;
}

.text-muted {
    color: var(--ma-text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.card-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ma-text-heading);
}

.card-header .text-muted,
.card-header .card-subtitle,
.card-header .label-report-intro {
    margin: 0.35rem 0 0;
}

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

.stat-card {
    background: var(--ma-surface-card);
    padding: 1.5rem;
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-elevation-1);
    border: 1px solid var(--ma-border);
}

.stat-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast), transform var(--ma-transition-fast);
}

.stat-card-link:hover {
    border-color: var(--ma-color-primary);
    box-shadow: var(--ma-shadow-elevation-2);
    transform: translateY(-1px);
}

.stat-card h3 {
    color: var(--ma-text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ma-text-heading);
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.users-table, .data-table {
    background: var(--ma-surface-card);
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-elevation-1);
    overflow: hidden;
    border: 1px solid var(--ma-border);
}

/* User management: wider layout; scroll early for wide table, cards on narrow */
.admin-users-layout {
    max-width: 1680px;
    width: 100%;
}

.admin-users-layout .users-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    margin: 0 -0.15rem;
    padding-bottom: 0.15rem;
}

.admin-users-layout #users-table {
    width: 100%;
    min-width: 68rem;
    table-layout: auto;
    margin: 0;
}

.admin-users-layout #users-table th,
.admin-users-layout #users-table td {
    white-space: nowrap;
    vertical-align: top;
}

.admin-users-layout #users-table th:nth-child(7) {
    white-space: normal;
    line-height: 1.2;
}

.admin-users-layout #users-table td.users-col-name-email {
    white-space: normal;
}

.users-th-email {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    margin-top: 0.2rem;
}

.users-col-name-email {
    min-width: 12rem;
    max-width: 22rem;
}

.users-cell-name {
    display: block;
    font-weight: 600;
    color: var(--ma-text-heading);
    line-height: 1.35;
}

.users-cell-email {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    line-height: 1.35;
    word-break: break-word;
}

.users-name-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.users-name-link:hover .users-cell-name {
    color: var(--ma-color-primary, #2563eb);
    text-decoration: underline;
}

.users-row-clickable {
    cursor: pointer;
}

.users-row-clickable:hover {
    background: var(--ma-surface-muted, rgba(0, 0, 0, 0.03));
}

.admin-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    margin-left: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #2563eb;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    vertical-align: middle;
}

.admin-user-detail-layout .admin-user-detail-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
}

.admin-user-detail-layout .admin-user-detail-header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-end;
}

.admin-user-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--ma-surface-muted, #f3f4f6);
    color: var(--ma-text-heading);
    font-size: 0.8rem;
    font-weight: 600;
}

.admin-user-pill--active {
    background: #dcfce7;
    color: #166534;
}

.admin-user-pill--inactive {
    background: #fee2e2;
    color: #991b1b;
}

.admin-user-pill--muted {
    background: transparent;
    border: 1px solid var(--ma-border, #e5e7eb);
    color: var(--ma-text-muted);
    font-weight: 500;
}

.admin-user-detail-readonly {
    margin: 0;
    color: var(--ma-text-muted);
}

.admin-user-detail-divider {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid var(--ma-border, #e5e7eb);
}

.admin-user-detail-section-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

.admin-user-notif-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.admin-user-notif-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.admin-user-notif-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--ma-text-muted);
    cursor: pointer;
}

/* Stacked user cards below table-scroll breakpoint */
@media (max-width: 768px) {
    .admin-users-layout .users-table-wrap {
        overflow-x: visible;
        margin: 0;
    }

    .admin-users-layout #users-table {
        min-width: 0;
        width: 100%;
    }

    .admin-users-layout #users-table thead {
        display: none;
    }

    .admin-users-layout #users-table tbody {
        display: block;
    }

    .admin-users-layout #users-table tr {
        display: block;
        margin: 0 0 0.85rem;
        padding: 0.65rem 0.85rem;
        border: 1px solid var(--ma-border);
        border-radius: var(--ma-radius-md);
        background: var(--ma-surface-card);
        box-shadow: var(--ma-shadow-elevation-1);
    }

    .admin-users-layout #users-table td {
        display: grid;
        grid-template-columns: 7.5rem 1fr;
        gap: 0.35rem 0.75rem;
        align-items: start;
        width: 100%;
        padding: 0.4rem 0;
        border: none;
        white-space: normal;
        vertical-align: top;
    }

    .admin-users-layout #users-table td + td {
        border-top: 1px solid var(--ma-border);
    }

    .admin-users-layout #users-table td::before {
        content: attr(data-label);
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ma-text-muted);
        line-height: 1.35;
    }

    .admin-users-layout #users-table td.users-col-name-email {
        max-width: none;
    }

    .admin-users-layout #users-table .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.4rem;
        width: 100%;
    }

    .admin-users-layout #users-table .action-buttons .btn {
        width: auto;
        flex: 0 0 auto;
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
        line-height: 1.25;
    }
}

.modal-content.credit-modal-content {
    max-width: 1200px;
    width: 96%;
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content.credit-modal-content > .modal-header {
    flex-shrink: 0;
}

.modal-content.credit-modal-content > .modal-card-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal-content.credit-modal-content > .modal-card-body > p,
.modal-content.credit-modal-content .credit-adjust-card {
    flex-shrink: 0;
}

.credit-adjust-card {
    margin: 1rem 0 1.5rem;
}

.credit-adjust-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.credit-adjust-header .card-title {
    margin: 0;
}

.credit-adjust-body {
    padding-top: 0.85rem;
}

.credit-adjust-error {
    margin: 0 0 0.75rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
}

.credit-adjust-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 4fr 2fr;
    gap: 0.65rem 0.75rem;
    align-items: end;
}

.credit-adjust-form-row .form-group {
    margin-bottom: 0;
}

.coin-credits-heading {
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
}

/* Coin actions: action list on the left, one action panel on the right */
.coin-actions-layout {
    display: grid;
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.coin-actions-nav {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    position: sticky;
    top: 1rem;
}

.coin-actions-nav-group {
    margin: 0.75rem 0.6rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ma-text-muted);
}

.coin-actions-nav-group:first-child {
    margin-top: 0.25rem;
}

.coin-actions-nav-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--ma-radius-sm);
    color: var(--ma-text-muted);
    text-decoration: none;
}

.coin-actions-nav-item.is-available {
    color: var(--ma-text-heading);
}

.coin-actions-nav-item:hover {
    background: var(--ma-surface-dropdown-hover);
}

.coin-actions-nav-item.is-active {
    background: var(--ma-primary-soft-bg);
    color: var(--ma-color-primary-active);
    font-weight: 600;
}

.coin-actions-nav-state {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    white-space: nowrap;
}

.coin-actions-nav-item.is-available .coin-actions-nav-state {
    color: var(--ma-color-success);
}

.coin-actions-panel .card-content > p {
    margin-bottom: 1rem;
}

.coin-identity-form + .coin-identity-form {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ma-border);
}

.coin-identity-prompt {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.coin-identity-attest {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 768px) {
    .coin-actions-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .coin-actions-nav {
        position: static;
    }
}

.coin-credits-table {
    margin-bottom: 0.5rem;
}

.credit-adjust-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    padding-bottom: 0.1rem;
}

.credit-adjust-actions .btn {
    flex: 0 0 auto;
}

@media (max-width: 700px) {
    .credit-adjust-form-row {
        grid-template-columns: 1fr 1fr;
    }

    .credit-adjust-note,
    .credit-adjust-actions {
        grid-column: 1 / -1;
    }
}

.credit-history-table-wrap {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
}

#credit-history-table {
    table-layout: auto;
    width: 100%;
    min-width: 42rem;
}

/* ~20% tighter rows than default table padding (0.75rem → 0.6rem) */
#credit-history-table th,
#credit-history-table td {
    padding: 0.6rem;
}

#credit-history-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

#credit-history-table .credit-col-when {
    width: 10.5rem;
}

#credit-history-table .credit-col-credits {
    width: 7.5rem;
}

#credit-history-table .credit-col-action {
    width: 12rem;
}

#credit-history-table .credit-col-balance-after {
    width: 6.5rem;
}

#credit-history-table .credit-col-note {
    width: 16rem;
    min-width: 10rem;
}

#credit-history-table th:nth-child(1),
#credit-history-table td:nth-child(1) {
    white-space: nowrap;
}

#credit-history-table th:nth-child(2),
#credit-history-table td:nth-child(2) {
    white-space: nowrap;
    text-align: center;
}

#credit-history-table th:nth-child(3),
#credit-history-table td:nth-child(3) {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
}

#credit-history-table th:nth-child(4) {
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    vertical-align: bottom;
}

#credit-history-table td:nth-child(4) {
    white-space: nowrap;
    text-align: center;
}

#credit-history-table th:nth-child(5),
#credit-history-table td:nth-child(5) {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;
    max-width: 20rem;
}

#credit-history-table .credit-note-with-ref {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    max-width: 100%;
}

#credit-history-table .credit-note-text {
    min-width: 0;
    flex: 1 1 auto;
}

#credit-history-table .credit-ref-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    margin: 0 0 0 auto;
    padding: 0;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-sm);
    background: var(--ma-surface-card);
    color: var(--ma-color-primary);
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}

#credit-history-table .credit-ref-btn:hover {
    border-color: var(--ma-color-primary);
    background: var(--ma-primary-soft-bg);
}

#credit-history-table .credit-ref-btn:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.credit-ref-popover {
    position: fixed;
    z-index: 1200;
    max-width: min(28rem, calc(100vw - 1rem));
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ma-border-strong);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-2, 0 8px 24px rgba(15, 23, 42, 0.16));
    color: var(--ma-text-body);
}

.credit-ref-popover code {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.table-header {
    background: var(--ma-surface-card);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ma-border-strong);
}

.table-header h3 {
    font-size: 1.2rem;
    color: var(--ma-text-heading);
}

.table-content {
    overflow-x: auto;
}

/* Login page — full viewport, gray ramp into page surface */
body.admin-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(
        168deg,
        var(--ma-gray-light) 0%,
        var(--ma-gray-mid) 42%,
        var(--ma-gray-dark) 83%,
        var(--ma-surface-page) 100%
    );
}

/* Login page specific styles */
.login-container {
    background: var(--ma-surface-card);
    padding: 2rem;
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-modal);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--ma-border);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--ma-text-heading);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--ma-text-muted);
    font-size: 0.9rem;
}

.login-btn {
    width: 100%;
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    border: none;
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--ma-transition-fast);
}

.login-btn:hover {
    background: var(--ma-color-primary-hover);
}

/* Breadcrumb above a page header: either "← Root" or the parent hierarchy ("Root › Parent"). */
.back-link {
    text-align: left;
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ma-text-muted);
}

.back-link a {
    color: var(--ma-color-primary);
    text-decoration: none;
}

.back-link a:hover {
    color: var(--ma-color-primary-hover);
    text-decoration: underline;
}

.back-link .back-link-sep {
    margin: 0 0.4rem;
    color: var(--ma-text-muted);
}

/* -------------------------------------------------------------------------
   Admin: collection coin detail (/admin/collections/details)
   Matches credit-settings card chrome; compact label/value rows
   ------------------------------------------------------------------------- */
.container.admin-coin-details {
    max-width: 1200px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: clip; /* keep wide tab strip / hero from creating page-level L/R scroll */
    padding-bottom: 2.5rem;
}

.admin-coin-detail-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    gap: 0.75rem;
    min-height: 2.5rem;
}

.admin-coin-detail-messages {
    margin: -0.75rem 0 1.25rem;
}

.admin-coin-detail-messages:empty {
    display: none;
}

.admin-coin-detail-grading-status {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    color: var(--ma-text-heading);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--ma-shadow-elevation-1);
}

.admin-coin-detail-grading-spinner {
    width: 0.95rem;
    height: 0.95rem;
    border: 2px solid rgba(2, 132, 199, 0.25);
    border-top-color: var(--ma-color-primary);
    border-radius: 50%;
    animation: admin-coin-detail-spin 0.75s linear infinite;
}

.admin-coin-detail-grading-label {
    letter-spacing: 0.01em;
}

@keyframes admin-coin-detail-spin {
    to { transform: rotate(360deg); }
}

.admin-coin-details .detail-status {
    padding: 1rem 1.25rem;
    color: var(--ma-text-muted);
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    box-shadow: var(--ma-shadow-elevation-1);
    font-size: 0.95rem;
}

.admin-coin-detail-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.25rem 1.75rem;
    padding: 1.25rem 1.5rem;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.admin-coin-detail-thumbs {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-muted);
    border: 1px solid var(--ma-border);
}

.admin-coin-detail-thumbs figure {
    margin: 0;
    text-align: center;
}

.admin-coin-detail-thumbs img {
    display: block;
    width: 104px;
    height: 104px;
    object-fit: contain;
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
}

.admin-coin-detail-thumbs .admin-coin-detail-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 104px;
    height: 104px;
    box-sizing: border-box;
    margin: 0 auto;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ma-text-muted);
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
}

.admin-coin-detail-thumbs figcaption {
    margin-top: 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ma-text-muted);
    text-transform: none;
}

.admin-coin-detail-title-block {
    flex: 1 1 220px;
    min-width: 0;
}

.admin-coin-detail-title {
    margin: 0 0 0.45rem 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--ma-text-heading);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.admin-coin-detail-mint {
    font-weight: 600;
    color: var(--ma-color-primary);
}

.admin-coin-detail-subtitle {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ma-text-muted);
    line-height: 1.5;
}

.admin-coin-detail-serial {
    margin: 0.35rem 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ma-text-body);
    line-height: 1.4;
}

.admin-coin-detail-serial-chip {
    display: inline-flex;
    align-items: center;
    margin: 0.45rem 0 0;
    padding: 0.35rem 0.65rem;
    max-width: 100%;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-sm);
    background: var(--ma-surface-muted);
    color: var(--ma-text-body);
    font: inherit;
    cursor: pointer;
    transition: background var(--ma-transition-fast), border-color var(--ma-transition-fast);
}

.admin-coin-detail-serial-chip:hover {
    background: var(--ma-primary-soft-bg);
    border-color: rgba(2, 132, 199, 0.35);
}

.admin-coin-detail-serial-chip:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.admin-coin-detail-serial-chip.is-copied {
    background: var(--ma-color-success-muted-bg);
    border-color: rgba(22, 101, 52, 0.28);
}

.admin-coin-detail-serial-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--ma-text-heading);
    line-height: 1.2;
}

.admin-coin-detail-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.admin-coin-detail-status-pill {
    display: inline-block;
    margin-top: 0;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ma-badge-info-text);
    background: var(--ma-badge-info-bg);
    border: 1px solid rgba(2, 132, 199, 0.25);
    border-radius: var(--ma-radius-pill);
}

.admin-coin-detail-grade-pill {
    color: var(--ma-color-primary);
    background: var(--ma-surface-card);
    border-color: rgba(2, 132, 199, 0.35);
    box-shadow: var(--ma-shadow-elevation-1);
    letter-spacing: 0.03em;
}

.admin-coin-detail-failure {
    margin: 0 0 1.25rem;
    padding: 0.9rem 1.15rem;
    border: 1px solid rgba(185, 28, 28, 0.28);
    border-radius: var(--ma-radius-lg);
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
    box-shadow: var(--ma-shadow-elevation-1);
}

.admin-coin-detail-failure-title {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.admin-coin-detail-failure-message {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ma-text-heading);
    line-height: 1.45;
    white-space: pre-wrap;
}

.admin-coin-detail-failure-meta {
    margin: 0.45rem 0 0;
    font-size: 0.85rem;
    color: var(--ma-color-danger);
}

.admin-coin-detail-failure-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
}

.admin-detail-list {
    margin: 0;
    padding-left: 1.15rem;
    text-align: left;
}

.admin-detail-list li {
    margin: 0.2rem 0;
}

.admin-detail-fun-facts {
    padding: 1rem 1.25rem 1.15rem;
}

.admin-detail-fun-facts .admin-detail-list {
    padding-left: 1.25rem;
    color: var(--ma-text-heading);
    font-size: 0.95rem;
    line-height: 1.55;
}

.admin-detail-fun-facts .admin-detail-list li {
    margin: 0.55rem 0;
    padding-left: 0.15rem;
}

.admin-detail-fun-facts .admin-detail-list li:first-child {
    margin-top: 0;
}

.admin-detail-fun-facts .admin-detail-list li:last-child {
    margin-bottom: 0;
}

.admin-coin-detail-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 0.85rem;
    padding: 0;
}

.admin-coin-detail-image-card {
    margin: 0;
    padding: 0.65rem;
    text-align: center;
    background: var(--ma-surface-muted);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    cursor: pointer;
    transition: border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.admin-coin-detail-image-card:hover,
.admin-coin-detail-image-card:focus-visible {
    border-color: var(--ma-color-primary);
    box-shadow: var(--ma-shadow-elevation-1);
    outline: none;
}

.admin-coin-detail-image-card img {
    display: block;
    width: 100%;
    height: 240px;
    object-fit: contain;
    background: var(--ma-surface-card);
    border-radius: var(--ma-radius-sm);
}

.admin-coin-detail-image-card figcaption {
    margin-top: 0.45rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    line-height: 1.3;
}

.admin-coin-detail-image-card--qr {
    position: relative;
}

.admin-coin-detail-image-hint {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    opacity: 0;
    transition: opacity var(--ma-transition-fast);
}

.admin-coin-detail-image-card--qr:hover .admin-coin-detail-image-hint,
.admin-coin-detail-image-card--qr:focus-visible .admin-coin-detail-image-hint {
    opacity: 0.9;
}

.admin-detail-value--stacked {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
}

.admin-detail-value-main {
    font-weight: 600;
}

.admin-detail-value-sub {
    font-size: 0.78rem;
    color: var(--ma-text-muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    word-break: break-all;
}

.admin-detail-lightbox[hidden] {
    display: none !important;
}

.admin-detail-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.admin-detail-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.admin-detail-lightbox-dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    width: min(96vw, 1040px);
    max-width: min(96vw, 1040px);
    padding: 1.25rem 1rem 1rem;
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-modal);
    box-sizing: border-box;
}

.admin-detail-lightbox-close {
    position: absolute;
    top: 0.35rem;
    right: 0.55rem;
    z-index: 3;
    border: none;
    background: transparent;
    color: var(--ma-text-muted);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
}

.admin-detail-lightbox-close:hover {
    color: var(--ma-text-heading);
}

.admin-detail-lightbox-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
}

.admin-detail-lightbox-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    min-width: 8rem;
    min-height: 8rem;
    margin: 0 auto;
    background: var(--ma-surface-muted);
    border-radius: var(--ma-radius-md);
    overflow: hidden;
    pointer-events: none;
}

.admin-detail-lightbox-stage img {
    display: block;
    max-width: 100%;
    max-height: min(72vh, 720px);
    object-fit: contain;
    -webkit-user-drag: none;
    pointer-events: none;
}

.admin-detail-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    box-sizing: border-box;
    width: 2.75rem;
    height: 2.75rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--ma-border-strong);
    border-radius: 50%;
    background: color-mix(in srgb, var(--ma-surface-card) 88%, var(--ma-text-heading) 12%);
    color: var(--ma-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.admin-detail-lightbox-prev {
    left: 0.25rem;
}

.admin-detail-lightbox-next {
    right: 0.25rem;
}

.admin-detail-lightbox-nav:hover,
.admin-detail-lightbox-nav:focus-visible {
    opacity: 1;
    color: var(--ma-color-primary);
    border-color: color-mix(in srgb, var(--ma-color-primary) 35%, var(--ma-border-strong));
    background: var(--ma-surface-card);
}

.admin-detail-lightbox-caption {
    margin: 0.15rem 0 0;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ma-text-muted);
}

/* Tab navigation + panel table layout.
 * Always one row: when tabs don't fit, overflow scroll (no wrap / no scrollbar). */
.admin-detail-tabs-shell {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0; /* allow shell to shrink; tabs scroll inside instead of widening the page */
    margin: 0 0 1.25rem;
    border-bottom: 1px solid var(--ma-border);
    box-sizing: border-box;
}

.admin-detail-tabs {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0.25rem 0.35rem;
    min-width: 0;
    margin: 0;
    padding: 0.25rem 0 0.75rem;
    border-bottom: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* legacy Edge */
    cursor: default;
}

.admin-detail-tabs::-webkit-scrollbar {
    display: none; /* Chrome / Safari */
}

.admin-detail-tabs.is-overflowing {
    cursor: grab;
}

.admin-detail-tabs.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.admin-detail-tabs.is-dragging .admin-detail-tab {
    pointer-events: none; /* avoid accidental tab activation while dragging */
}

.admin-detail-tab-edge {
    flex: 0 0 1.85rem;
    align-self: center;
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 2rem;
    margin: 0 0 0.5rem;
    padding: 0;
    border: 0;
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-muted);
    color: var(--ma-color-secondary-active);
    cursor: pointer;
    opacity: 1;
    transition: color var(--ma-transition-fast), background var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.admin-detail-tab-edge:hover,
.admin-detail-tab-edge:focus-visible {
    color: var(--ma-color-primary);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
    outline: none;
}

.admin-detail-tab-edge:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(2, 132, 199, 0.35), var(--ma-shadow-elevation-1);
}

.admin-detail-tab-edge[hidden] {
    display: none !important;
}

.admin-detail-tab-edge-icon {
    display: block;
    box-sizing: border-box;
    width: 0.55rem;
    height: 0.55rem;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    flex-shrink: 0;
}

.admin-detail-tab-edge--start .admin-detail-tab-edge-icon {
    transform: rotate(-135deg);
    margin-left: 0.12rem;
}

.admin-detail-tab-edge--end .admin-detail-tab-edge-icon {
    transform: rotate(45deg);
    margin-right: 0.12rem;
}

.admin-detail-tabs-shell.has-start-cue .admin-detail-tab-edge--start {
    margin-right: 0.15rem;
}

.admin-detail-tabs-shell.has-end-cue .admin-detail-tab-edge--end {
    margin-left: 0.15rem;
}

.admin-detail-tab {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-md);
    padding: 0.4rem 0.7rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ma-text-body);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color var(--ma-transition-fast), border-color var(--ma-transition-fast), background var(--ma-transition-fast);
}

.admin-detail-tab:hover {
    color: var(--ma-text-heading);
    background: var(--ma-surface-muted);
}

.admin-detail-tab.is-active {
    color: var(--ma-color-primary);
    border-color: var(--ma-border-strong);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
}

.admin-detail-panels {
    margin-bottom: 2rem;
    min-width: 0;
    max-width: 100%;
}

.admin-detail-panel[hidden] {
    display: none !important;
}

.admin-coin-details .admin-detail-panel.card {
    margin-bottom: 0;
}

.admin-coin-details .admin-detail-panel .card-content {
    padding: 0.65rem 1.25rem 0.85rem;
}

.admin-coin-details .admin-detail-panel[data-tab-panel="images"] .card-content,
.admin-coin-details .admin-detail-panel[data-tab-panel="fun-facts"] .card-content,
.admin-coin-details .admin-detail-panel[data-tab-panel="provenance"] .card-content,
.admin-coin-details .admin-detail-panel[data-tab-panel="notifications"] .card-content {
    padding: 1rem 1.25rem 1.15rem;
}

.admin-coin-notifications-count {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.admin-coin-notifications-table-wrap {
    margin: 0;
}

.admin-coin-notifications-table th.admin-coin-notifications-th-stacked .admin-coin-notifications-th-line {
    display: block;
    line-height: 1.25;
}

.admin-coin-notifications-table th.admin-coin-notifications-th-stacked .admin-coin-notifications-th-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--ma-text-muted, #64748b);
}

.admin-coin-notifications-title,
.admin-coin-notifications-type {
    font-weight: 500;
    color: var(--ma-text-heading);
    line-height: 1.35;
}

.admin-coin-notifications-description,
.admin-coin-notifications-id {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--ma-text-muted);
    line-height: 1.35;
}

.admin-coin-notifications-table td.admin-coin-notifications-title-cell,
.admin-coin-notifications-table td.admin-coin-notifications-type-cell,
.admin-coin-notifications-table td.admin-coin-notifications-status-cell {
    vertical-align: top;
    white-space: normal;
}

.admin-coin-notifications-table td.admin-coin-notifications-title-cell {
    max-width: 28rem;
}

.admin-coin-notifications-status-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    max-width: 14rem;
}

.admin-coin-notifications-status-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.02em;
    border-radius: var(--ma-radius-pill);
    border: 1px solid transparent;
    white-space: nowrap;
}

.admin-coin-notifications-status-pill--working {
    color: var(--ma-badge-info-text);
    background: var(--ma-badge-info-bg);
    border-color: rgba(2, 132, 199, 0.25);
}

.admin-coin-notifications-status-pill--action-required {
    color: var(--ma-color-warning);
    background: var(--ma-color-warning-muted-bg);
    border-color: rgba(180, 83, 9, 0.28);
}

.admin-coin-notifications-status-pill--in-inbox {
    color: #0f766e;
    background: #ccfbf1;
    border-color: rgba(15, 118, 110, 0.25);
}

.admin-coin-notifications-status-pill--unread {
    color: #3730a3;
    background: #e0e7ff;
    border-color: rgba(55, 48, 163, 0.22);
}

.admin-coin-notifications-status-pill--viewed,
.admin-coin-notifications-status-pill--engaged {
    color: var(--ma-color-secondary-hover);
    background: var(--ma-tertiary-bg);
    border-color: var(--ma-border);
}

.admin-coin-notifications-status-pill--cleared,
.admin-coin-notifications-status-pill--archived {
    color: var(--ma-text-muted);
    background: var(--ma-surface-card-header);
    border-color: var(--ma-border);
}

.admin-coin-notifications-stack-main {
    font-weight: 500;
    color: var(--ma-text-heading);
    line-height: 1.35;
}

.admin-coin-notifications-stack-sub {
    margin-top: 0.2rem;
    font-size: 0.8rem;
    color: var(--ma-text-muted);
    line-height: 1.35;
}

.admin-provenance {
    max-width: 52rem;
}

.admin-provenance > .admin-detail-rows {
    margin-bottom: 1.25rem;
}

.admin-provenance-status,
.admin-provenance-empty {
    margin: 0;
    color: var(--ma-text-muted);
    font-size: 0.9rem;
}

.admin-provenance-summary {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ma-text-muted);
}

.admin-provenance-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.admin-provenance-item {
    display: grid;
    grid-template-columns: 1.1rem minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: start;
    position: relative;
    padding: 0 0 1.15rem 0;
    margin: 0;
}

.admin-provenance-item:last-child {
    padding-bottom: 0;
}

/* Connecting line behind the dots, centered on the rail column.
   Extends from this item's dot center through the gap to the next item's dot center. */
.admin-provenance-item:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 0.45rem;
    top: calc(0.9rem + 0.35rem);
    bottom: calc(-0.9rem - 0.35rem);
    width: 2px;
    background: rgba(2, 132, 199, 0.28);
    z-index: 0;
}

.admin-provenance-dot {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    z-index: 1;
    width: 0.7rem;
    height: 0.7rem;
    margin-top: 0.9rem;
    justify-self: center;
    box-sizing: border-box;
    border-radius: 50%;
    /* Prior: empty fill */
    background: var(--ma-surface-card);
    border: 2px solid var(--ma-color-primary);
}

.admin-provenance-item.is-current .admin-provenance-dot {
    /* Current: solid blue fill */
    background: var(--ma-color-primary);
    border-color: var(--ma-color-primary);
}

.admin-provenance-details {
    grid-column: 2;
    margin: 0;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    overflow: hidden;
}

.admin-provenance-item.is-current .admin-provenance-details {
    border-color: rgba(2, 132, 199, 0.35);
    box-shadow: var(--ma-shadow-elevation-1);
}

.admin-provenance-summary-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    list-style: none;
    background: var(--ma-surface-muted);
    user-select: none;
}

.admin-provenance-summary-row::-webkit-details-marker {
    display: none;
}

.admin-provenance-item.is-current .admin-provenance-summary-row {
    background: var(--ma-primary-soft-bg);
}

/* Same chevron treatment as credit-settings .collapsible-arrow */
.admin-provenance-chevron {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-top: 0.35rem solid transparent;
    border-bottom: 0.35rem solid transparent;
    border-left: 0.45rem solid var(--ma-text-muted);
    transition: transform var(--ma-transition-fast);
}

.admin-provenance-details[open] .admin-provenance-chevron {
    transform: rotate(90deg);
    border-left-color: var(--ma-color-primary);
}

.admin-provenance-role {
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ma-badge-info-text);
    padding: 0.15rem 0.45rem;
    border-radius: var(--ma-radius-sm);
    background: var(--ma-badge-info-bg);
    border: 1px solid rgba(2, 132, 199, 0.25);
}

.admin-provenance-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.admin-provenance-name .admin-detail-owner {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    align-items: flex-start;
    min-width: 0;
    max-width: 100%;
}

.admin-provenance-name .admin-detail-owner-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ma-text-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.admin-provenance-name .admin-detail-owner-email {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.admin-provenance-range {
    flex: 0 0 auto;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    white-space: nowrap;
}

/* Must beat .admin-coin-details .admin-detail-rows { padding: 0 } — body uses both classes. */
.admin-coin-details .admin-provenance-body.admin-detail-rows,
.admin-provenance-body {
    padding: 0.5rem 0.9rem 0.85rem;
    border-top: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
    box-sizing: border-box;
}

.admin-coin-details .admin-provenance-body .admin-detail-row,
.admin-provenance-body .admin-detail-row {
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

.admin-provenance-body .admin-detail-row .admin-detail-label,
.admin-provenance-body .admin-detail-row .admin-detail-value {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

@media (max-width: 640px) {
    .admin-provenance-summary-row {
        flex-wrap: wrap;
    }

    .admin-provenance-range {
        width: 100%;
        padding-left: 1.1rem; /* align under name (past chevron) */
        white-space: normal;
    }

    .admin-coin-details .admin-provenance-body.admin-detail-rows,
    .admin-provenance-body {
        padding: 0.55rem 0.9rem 0.95rem;
    }

    .admin-coin-details .admin-provenance-body .admin-detail-row,
    .admin-provenance-body .admin-detail-row {
        padding: 0.55rem 0;
    }
}

.admin-coin-details .admin-detail-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    max-width: 52rem;
}

.admin-coin-details .admin-detail-row {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    align-items: baseline;
    column-gap: 0.85rem;
    row-gap: 0.2rem;
    padding: 0.5rem 0;
    margin: 0;
    border-radius: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    border: none;
    border-bottom: 1px solid var(--ma-border);
    background: transparent;
}

.admin-coin-details .admin-detail-row:last-child {
    border-bottom: none;
}

.admin-coin-details .admin-detail-row .admin-detail-label {
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
}

.admin-coin-details .admin-detail-row .admin-detail-value {
    color: var(--ma-text-heading);
    font-weight: 500;
    text-align: left;
    word-break: break-word;
}

.admin-coin-details .admin-detail-value.admin-detail-multiline,
.admin-coin-details .admin-detail-value.admin-detail-notes {
    text-align: left;
    white-space: pre-wrap;
    display: block;
}

.admin-coin-details .admin-detail-owner {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-start;
}

.admin-coin-details .admin-detail-owner-name {
    color: var(--ma-text-heading);
    font-weight: 500;
}

.admin-coin-details .admin-detail-owner-email {
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

.admin-coin-details .admin-detail-subgrade {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
}

.admin-coin-details .admin-detail-subgrade-grade {
    color: var(--ma-text-heading);
    font-weight: 500;
}

.admin-coin-details .admin-detail-subgrade-desc {
    color: var(--ma-text-body);
    font-weight: 400;
    white-space: pre-wrap;
}

.admin-coin-details .admin-detail-grade-signal {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
}

.admin-coin-details .admin-detail-grade-signal-outcome {
    color: var(--ma-text-heading);
    font-weight: 500;
}

.admin-coin-details .admin-detail-grade-signal-meta,
.admin-coin-details .admin-detail-grade-signal-note {
    color: var(--ma-text-body);
    font-weight: 400;
    white-space: pre-wrap;
}

.admin-coin-details .admin-detail-grade-signal-k {
    color: var(--ma-text-muted);
    font-weight: 500;
    margin-right: 0.25rem;
}

@media (max-width: 600px) {
    .admin-coin-details .admin-detail-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
        padding: 0.55rem 0;
    }

    .admin-coin-details .admin-provenance-body .admin-detail-row {
        padding: 0.55rem 0;
    }

    .admin-coin-details .admin-detail-row .admin-detail-value {
        text-align: left;
    }

    .admin-coin-detail-thumbs img {
        width: 88px;
        height: 88px;
    }

    .admin-coin-detail-thumbs .admin-coin-detail-no-img {
        width: 88px;
        height: 88px;
    }
}

/* Coin jobs tab — workflow cards + vertical flame graph */
.admin-coin-jobs {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.admin-coin-jobs-empty {
    margin: 0;
}

.admin-job-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.admin-job-card {
    border: 1px solid var(--border-color, #d8dee9);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.admin-job-card-summary {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.95rem 1rem;
    cursor: pointer;
    list-style: none;
    background: inherit;
    outline: none;
    border-radius: 12px;
    transition: background-color 0.15s ease;
}

.admin-job-card[open] > .admin-job-card-summary {
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.admin-job-card:not([open]) > .admin-job-card-summary:hover {
    background: rgba(248, 250, 252, 0.9);
}

.admin-job-card-summary:focus {
    outline: none;
}

.admin-job-card-summary:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.45);
}

.admin-job-card-summary::-webkit-details-marker {
    display: none;
}

.admin-job-card-chevron {
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(-45deg);
    transition: transform 0.18s ease;
}

.admin-job-card[open] .admin-job-card-chevron {
    transform: rotate(45deg);
}

.admin-job-card-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.admin-job-card-title {
    font-weight: 600;
    color: #0f172a;
}

.admin-job-card-timestamp {
    font-size: 0.85rem;
    color: #64748b;
}

.admin-job-card-id-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.12rem;
    min-width: 0;
}

.admin-job-card-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
    font-size: 0.82rem;
    color: #64748b;
    white-space: nowrap;
}

.admin-job-card-follow-up {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
    white-space: nowrap;
    text-align: right;
}

.admin-job-card-follow-up:hover {
    text-decoration: underline;
    color: #1d4ed8;
}

.admin-job-card-status {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.admin-job-card-status.is-completed {
    color: #166534;
    background: #dcfce7;
}

.admin-job-card-status.is-processing {
    color: #1d4ed8;
    background: #dbeafe;
}

.admin-job-card-status.is-failed {
    color: #b91c1c;
    background: #fee2e2;
}

.admin-job-card-status.is-cancelled {
    color: #64748b;
    background: #f1f5f9;
}

.admin-job-card-status.is-pending {
    color: #92400e;
    background: #fef3c7;
}

.admin-job-card-body {
    padding: 0.85rem 1rem 1rem;
}

.admin-job-flame {
    --graph-height: 280px;
    --graph-width: 520px;
}

.admin-job-flame-layout {
    display: grid;
    gap: 0.5rem;
}

.admin-job-flame-layout--vertical {
    grid-template-columns: 5.75rem 1fr;
    height: var(--graph-height);
    align-items: stretch;
}

.admin-job-flame-layout--horizontal {
    grid-template-columns: 1fr;
}

.admin-job-flame-axis {
    position: relative;
    border-right: 1px dashed rgba(148, 163, 184, 0.55);
    height: var(--graph-height);
    padding: 0.35rem 0.25rem 0.35rem 0.15rem;
    box-sizing: border-box;
    overflow: visible;
}

.admin-job-flame-axis--horizontal {
    position: relative;
    border-right: none;
    border-top: 1px dashed rgba(148, 163, 184, 0.55);
    height: 1.35rem;
    margin-top: 0.15rem;
    padding: 0 0.5rem;
    box-sizing: border-box;
    overflow: visible;
    width: 100%;
}

.admin-job-flame-axis-mark {
    position: absolute;
    right: 0.35rem;
    transform: translateY(-50%);
    font-size: 0.72rem;
    color: #94a3b8;
    white-space: nowrap;
}

.admin-job-flame-axis-mark--edge-start {
    transform: translateY(0);
}

.admin-job-flame-axis-mark--edge-end {
    transform: translateY(-100%);
}

.admin-job-flame-axis-mark--horizontal {
    top: auto;
    bottom: 0;
    right: auto;
    transform: translateX(-50%);
    font-size: 0.7rem;
}

.admin-job-flame-axis-mark--horizontal.admin-job-flame-axis-mark--edge-start {
    transform: translateX(0);
}

.admin-job-flame-axis-mark--horizontal.admin-job-flame-axis-mark--edge-end {
    transform: translateX(-100%);
}

.admin-job-flame-canvas-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding-bottom: 0.15rem;
}

.admin-job-flame--vertical .admin-job-flame-canvas-scroll {
    padding-bottom: 0.35rem;
}

.admin-job-flame-canvas {
    position: relative;
    height: var(--graph-height);
    padding: 0.35rem 0.15rem 0.35rem 0;
    background:
        linear-gradient(180deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px) 0 0 / 100% 12.5%;
    border-radius: 10px;
    overflow: visible;
}

.admin-job-flame-canvas--horizontal {
    height: auto;
    overflow: visible;
    background:
        linear-gradient(90deg, rgba(148, 163, 184, 0.28) 1px, transparent 1px) 0 0 / 12.5% 100%;
}

.admin-job-flame--full-width {
    width: 100%;
}

.admin-job-flame--full-width .admin-job-flame-canvas-scroll {
    overflow-x: hidden;
}

.admin-job-flame--full-width .admin-job-flame-canvas--horizontal {
    width: 100%;
}

.admin-job-flame-bar {
    position: absolute;
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    border: 1px solid transparent;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 2px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-job-flame-bar--compact {
    padding: 0;
    border-radius: 6px;
    min-height: 10px;
}

.admin-job-flame-bar:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 12px rgba(15, 23, 42, 0.12);
    z-index: 2;
}

.admin-job-flame--horizontal .admin-job-flame-bar:hover {
    transform: none;
    filter: brightness(1.04);
}

.admin-job-flame-bar--parent {
    border-width: 3px;
    font-weight: 600;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.14), 0 1px 2px rgba(15, 23, 42, 0.08);
}

.admin-job-flame-bar--clickable {
    cursor: pointer;
}

.admin-job-flame-bar--clickable:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.55);
    outline-offset: 2px;
}

.admin-job-flame-bar-parent-main {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
}

.admin-job-flame-bar-parent-main .admin-job-flame-bar-label {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

.admin-job-flame-bar-parent-main .admin-job-flame-bar-meta {
    flex: 0 0 auto;
    text-align: right;
    white-space: nowrap;
    margin-left: auto;
}

.admin-job-flame-entry {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.12rem;
    overflow: visible;
    z-index: 1;
}

.admin-job-flame-entry .admin-job-flame-bar {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
}

.admin-job-flame-entry:hover .admin-job-flame-bar {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 12px rgba(15, 23, 42, 0.12);
    z-index: 2;
}

.admin-job-flame--horizontal .admin-job-flame-entry:hover .admin-job-flame-bar {
    transform: none;
    filter: brightness(1.04);
}

.admin-job-flame-entry--timeline {
    box-sizing: border-box;
}

.admin-job-flame-entry--align-end {
    /* Anchor meta to the bar's right edge; allow it to grow left past the bar. */
    align-items: flex-end;
}

.admin-job-flame-entry--align-end .admin-job-flame-meta-outside {
    width: max-content;
    max-width: 36rem;
    box-sizing: border-box;
    text-align: right;
    padding-left: 0;
    padding-right: 0.1rem;
}

.admin-job-flame-entry--align-end .admin-job-flame-meta-outside--error {
    width: max-content;
    max-width: 36rem;
    min-width: 0;
    align-items: flex-end;
    text-align: right;
}

.admin-job-flame-entry--align-end .admin-job-flame-bar-error-text,
.admin-job-flame-entry--align-end .admin-job-flame-bar-error-code {
    display: block;
    width: auto;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    text-align: right;
    align-self: flex-end;
}

.admin-job-flame-entry--align-end .admin-job-flame-bar-error-code {
    white-space: nowrap;
}

.admin-job-flame-entry--compact-label {
    font-size: 0.72rem;
}

.admin-job-flame-entry--compact-label .admin-job-flame-bar-label {
    font-size: inherit;
}

.admin-job-flame-bar--title-only {
    justify-content: center;
    padding: 0.3rem 0.4rem;
    overflow: visible;
}

.admin-job-flame-bar--title-only .admin-job-flame-bar-label {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

.admin-job-flame-meta-outside {
    font-size: 0.72rem;
    line-height: 1.2;
    color: #64748b;
    white-space: nowrap;
    width: max-content;
    max-width: none;
    padding-left: 0.1rem;
}

.admin-job-flame-meta-outside--error {
    color: #9f1239;
    white-space: normal;
    /* Cap length, but do not clamp to the bar width — text may extend past the rectangle. */
    width: max-content;
    max-width: 36rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.08rem;
}

.admin-job-flame-meta-outside--error .admin-job-flame-bar-error-code {
    align-self: flex-start;
    font-size: 0.64rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(159, 18, 57, 0.78);
    white-space: nowrap;
}

.admin-job-flame-meta-outside--parent-terminal {
    max-width: 100%;
    width: 100%;
    padding: 0.15rem 0.15rem 0;
    box-sizing: border-box;
}

.admin-job-flame-meta-outside--parent-terminal .admin-job-flame-bar-error-text {
    display: block;
    white-space: normal;
    overflow: visible;
    -webkit-line-clamp: unset;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
}

.admin-job-flame-parent-wrap {
    position: absolute;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    z-index: 1;
}

.admin-job-flame-parent-wrap .admin-job-flame-bar--parent {
    position: relative;
    top: auto;
    left: auto;
    width: 100%;
}

.admin-job-flame-bar--inline {
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.35rem 0.55rem;
}

.admin-job-flame-bar-inline-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    white-space: nowrap;
}

.admin-job-flame-bar--inline .admin-job-flame-bar-label {
    flex: 0 0 auto;
}

.admin-job-flame-bar--inline .admin-job-flame-bar-meta {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-job-flame-bar-error--inline {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-job-flame-bar-label {
    font-size: 0.82rem;
    line-height: 1.2;
    color: #0f172a;
    font-weight: 600;
}

.admin-job-flame-bar-meta {
    font-size: 0.72rem;
    color: rgba(15, 23, 42, 0.72);
}

.admin-job-flame-bar-error {
    font-size: 0.72rem;
    color: #9f1239;
    line-height: 1.25;
}

.admin-job-flame-bar-error-icon {
    width: 0.95rem;
    height: 0.95rem;
    flex: 0 0 auto;
    margin-top: 0.1rem;
    color: #9f1239;
}

.admin-job-flame-bar-error-body {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    min-width: 0;
    flex: 1 1 auto;
}

.admin-job-flame-bar-error-text {
    display: block;
}

.admin-job-flame-bar-error-code {
    align-self: flex-end;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: rgba(159, 18, 57, 0.78);
    white-space: nowrap;
}

.admin-job-flame-callout {
    position: absolute;
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    max-width: 42%;
    padding: 0.28rem 0.5rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    z-index: 3;
    pointer-events: none;
}

.admin-job-flame-callout-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-job-flame-callout-meta {
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.2;
    white-space: nowrap;
}

.admin-job-flame-callout-error {
    font-size: 0.68rem;
    color: #9f1239;
    line-height: 1.2;
    white-space: normal;
}

.admin-job-flame-callout.is-completed {
    border-color: #86efac;
}

.admin-job-flame-callout.is-processing {
    border-color: #93c5fd;
}

.admin-job-flame-callout.is-failed {
    border-color: #fca5a5;
}

.admin-job-flame-callout.is-cancelled {
    border-color: #cbd5e1;
}

.admin-job-flame-callout.is-pending {
    border-color: #fcd34d;
}

.admin-job-flame-bar.is-completed {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: #86efac;
}

.admin-job-flame-bar.is-processing {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #93c5fd;
    animation: admin-job-flame-pulse 1.8s ease-in-out infinite;
}

.admin-job-flame-bar.is-failed {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-color: #fca5a5;
}

.admin-job-flame-bar.is-cancelled {
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-color: #cbd5e1;
}

.admin-job-flame-bar.is-pending {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: #fcd34d;
}

.admin-job-flame-bar.is-unknown {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-color: #cbd5e1;
}

/* Parent bars: slightly darker fill + stronger border vs child lanes */
.admin-job-flame-bar--parent.is-completed {
    background: linear-gradient(135deg, #bbf7d0, #86efac);
    border-color: #22c55e;
}

.admin-job-flame-bar--parent.is-processing {
    background: linear-gradient(135deg, #bfdbfe, #93c5fd);
    border-color: #3b82f6;
}

.admin-job-flame-bar--parent.is-failed {
    background: linear-gradient(135deg, #fecaca, #fca5a5);
    border-color: #ef4444;
}

.admin-job-flame-bar--parent.is-cancelled {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-color: #94a3b8;
}

.admin-job-flame-bar--parent.is-pending {
    background: linear-gradient(135deg, #fde68a, #fbbf24);
    border-color: #f59e0b;
}

.admin-job-flame-bar--parent.is-unknown {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-color: #94a3b8;
}

@keyframes admin-job-flame-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.05); }
}

.admin-job-flame-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    font-size: 0.78rem;
    color: #64748b;
}

.admin-job-flame-legend--panel {
    margin: 0 0 0.25rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
}

.admin-job-jobs-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
}

.admin-job-jobs-toolbar-btn {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.admin-job-jobs-toolbar-btn:hover {
    background: #f1f5f9;
}

.admin-job-jobs-toolbar-btn:active {
    background: #e2e8f0;
}

.admin-job-flame-legend-statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}

.admin-job-flame-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.admin-job-flame-swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 3px;
    display: inline-block;
}

.admin-job-flame-swatch.is-completed { background: #86efac; }
.admin-job-flame-swatch.is-processing { background: #93c5fd; }
.admin-job-flame-swatch.is-failed { background: #fca5a5; }
.admin-job-flame-swatch.is-cancelled { background: #cbd5e1; }
.admin-job-flame-swatch.is-pending { background: #fcd34d; }

/* Job payload drawer */
.admin-job-payload-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
}

.admin-job-payload-drawer.is-open {
    display: block;
}

.admin-job-payload-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.admin-job-payload-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: min(52.5rem, 100%);
    height: 100%;
    background: #fff;
    border-left: 1px solid #d8dee9;
    box-shadow: -12px 0 32px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.admin-job-payload-drawer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.admin-job-payload-drawer-header-main {
    min-width: 0;
    flex: 1 1 auto;
}

.admin-job-payload-drawer-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
}

.admin-job-payload-nav {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.admin-job-payload-nav-btn {
    width: 2rem;
    height: 2rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-job-payload-nav-btn:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #94a3b8;
}

.admin-job-payload-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.admin-job-payload-nav-pos {
    font-size: 0.72rem;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    min-width: 2.6rem;
    text-align: center;
}

.admin-job-payload-drawer-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 650;
    color: #0f172a;
}

.admin-job-payload-drawer-subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.8rem;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.admin-job-payload-drawer-meta {
    margin-top: 0.45rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: #475569;
}

.admin-job-payload-drawer-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
}

.admin-job-payload-drawer-close:hover {
    color: #0f172a;
}

.admin-job-payload-drawer-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 0.9rem 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-job-payload-banner {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.35;
}

.admin-job-payload-banner--truncation {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
}

.admin-job-payload-banner--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.admin-job-payload-banner--muted {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #64748b;
}

.admin-job-payload-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.admin-job-payload-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    max-width: 100%;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.74rem;
    color: #334155;
}

.admin-job-payload-chip-key {
    font-weight: 650;
    color: #64748b;
}

.admin-job-payload-chip-val {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 18rem;
}

.admin-job-payload-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
}

.admin-job-payload-tabs {
    display: inline-flex;
    gap: 0.25rem;
    padding: 0.15rem;
    border-radius: 8px;
    background: #f1f5f9;
}

.admin-job-payload-tab {
    border: none;
    background: transparent;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}

.admin-job-payload-tab.is-active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.admin-job-payload-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-left: auto;
}

.admin-job-payload-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
}

.admin-job-payload-btn:hover {
    background: #f8fafc;
}

.admin-job-payload-find {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 12rem;
    min-width: 10rem;
}

.admin-job-payload-find input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
}

.admin-job-payload-find-count {
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
}

.admin-job-payload-tree {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #0b1220;
    color: #e2e8f0;
    padding: 0.65rem 0.75rem;
    overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    min-height: 14rem;
}

.admin-job-json-node {
    margin-left: 0.85rem;
}

.admin-job-json-node > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.admin-job-json-node > summary::-webkit-details-marker {
    display: none;
}

.admin-job-json-toggle {
    display: inline-block;
    width: 0.7rem;
    color: #94a3b8;
}

.admin-job-json-key {
    color: #93c5fd;
}

.admin-job-json-punct {
    color: #94a3b8;
}

.admin-job-json-string { color: #86efac; }
.admin-job-json-number { color: #fcd34d; }
.admin-job-json-bool { color: #c4b5fd; }
.admin-job-json-null { color: #fb7185; }

.admin-job-json-leaf {
    margin-left: 0.85rem;
}

.admin-job-json-mark {
    background: rgba(250, 204, 21, 0.35);
    border-radius: 2px;
    color: inherit;
}

.admin-job-json-hidden {
    display: none !important;
}

@media (max-width: 768px) {
    .admin-job-payload-drawer-panel {
        width: 100%;
    }

    .admin-job-payload-actions {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .admin-job-jobs-toolbar {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }

    .admin-job-card-summary {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }

    .admin-job-card-id-col,
    .admin-job-card-status {
        grid-column: 2;
        justify-self: start;
    }

    .admin-job-card-id-col {
        align-items: flex-start;
    }

    .admin-job-card-follow-up {
        text-align: left;
    }

    .admin-job-flame-layout {
        grid-template-columns: 1fr;
    }

    .admin-job-flame-axis {
        display: none;
    }
}

/* Label report (unfulfilled orders CSV) */
.label-report-card {
    margin-bottom: 2rem;
}

.label-report-intro {
    margin: 0 0 1.25rem;
    color: var(--ma-text-muted);
}

.label-report-field {
    margin-bottom: 1.25rem;
}

.label-report-field-label {
    display: block;
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.label-report-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: flex-end;
}

.label-report-date-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--ma-text-muted);
    font-weight: 500;
}

.label-report-date-wrap input[type="date"] {
    min-width: 11rem;
}

.label-report-date-wrap input[type="date"]:disabled {
    background: var(--ma-surface-muted, #f8fafc);
    color: var(--ma-text-muted, #64748b);
    border-color: var(--ma-border, #e2e8f0);
    cursor: default;
    opacity: 1;
    -webkit-text-fill-color: var(--ma-text-muted, #64748b);
}

.label-report-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1.5rem;
    padding-top: 0.35rem;
}

.label-report-presets .btn-sm {
    margin: 0;
}

.label-report-presets-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--ma-text-muted);
    margin-right: 0.5rem;
}

.label-report-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    margin-top: 0.35rem;
}

.label-report-download-note {
    margin: 0.75rem 0 0;
    padding: 0.65rem 0.85rem;
    max-width: 44rem;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--ma-text-body);
    background: var(--ma-surface-muted);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
}

.label-report-download-note kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    font-size: 0.8em;
    border: 1px solid #ced4da;
    border-radius: 3px;
    background: var(--ma-surface-card);
}

.label-report-error {
    color: #b91c1c;
    font-weight: 600;
    margin-top: 0.75rem;
}

.report-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
    justify-content: space-between;
}

/* Controls and Search */
.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
    background: var(--ma-surface-card);
    padding: 1.25rem 1.5rem;
    border-radius: var(--ma-radius-lg);
    border: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow-elevation-1);
    box-sizing: border-box;
}

.search-box {
    display: flex;
    flex: 1 1 280px;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.controls-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
}

.search-box input, .search-box select {
    padding: 0.55rem 0.75rem;
    min-height: 2.5rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    color: var(--ma-text-body);
    font-family: inherit;
    font-size: var(--ma-text-base);
    transition: border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.search-box input:focus,
.search-box select:focus {
    outline: none;
    border-color: var(--ma-color-primary);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-focus-ring);
}

.search-box input {
    width: min(220px, 100%);
}

/* Log entries */
.log-entry {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--ma-border);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-level {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.log-level.info {
    background: var(--ma-badge-info-bg);
    color: var(--ma-color-primary);
}

.log-level.warn {
    background: var(--ma-color-warning-muted-bg);
    color: var(--ma-color-warning);
}

.log-level.error {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
}

.log-time {
    color: var(--ma-text-muted);
    font-size: 0.8rem;
}

/* User items */
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--ma-border);
}

.user-item:last-child {
    border-bottom: none;
}

/* Backup items */
.backup-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--ma-border);
}

.backup-item:last-child {
    border-bottom: none;
}

.backup-status {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.backup-status.completed {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
}

.backup-status.failed {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
}

/* Extended Admin UI Styles - Additional common styles */

/* Import Page Specific Styles */
.import-container {
    max-width: 1500px;
    margin: 0 auto;
}

.import-section {
    background: var(--ma-surface-card);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--ma-text-heading);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--ma-surface-section);
}

.upload-area {
    border: 2px dashed var(--ma-border-strong);
    border-radius: var(--ma-radius-lg);
    padding: 2rem;
    text-align: center;
    background: var(--ma-surface-muted);
    margin-bottom: 1.5rem;
    transition: border-color var(--ma-transition-fast), background var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--ma-color-primary);
    background: color-mix(in srgb, var(--ma-color-primary) 6%, var(--ma-surface-muted));
}

.upload-area.drag-over {
    border-color: var(--ma-color-primary);
    background: color-mix(in srgb, var(--ma-color-primary) 10%, var(--ma-surface-card));
    box-shadow: var(--ma-focus-ring);
}

.upload-area h3,
.upload-area h4 {
    margin: 0 0 0.35rem;
    color: var(--ma-text-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.upload-area > p {
    margin: 0.35rem 0;
    color: var(--ma-text-muted);
}

.file-input-wrapper {
    display: inline-block;
    position: relative;
    margin: 0.75rem 0;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: inline-block;
    padding: 0.55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--ma-radius-sm);
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    cursor: pointer;
    font-size: var(--ma-text-base);
    font-weight: 500;
    font-family: inherit;
    text-align: center;
    transition: background-color var(--ma-transition-fast), border-color var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.file-input-label:hover {
    background: var(--ma-color-primary-hover);
}

.file-input-label:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ma-surface-section);
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.file-name {
    font-weight: 500;
    color: var(--ma-text-heading);
}

.file-size {
    color: var(--ma-text-muted);
    font-size: 0.9rem;
}

.remove-file {
    color: var(--ma-color-danger);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.remove-file:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Preview and progress styles */
.preview-section {
    display: none;
}

.preview-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.preview-table {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.preview-table table {
    width: 100%;
    border-collapse: collapse;
}

.preview-table th {
    background: var(--ma-surface-section);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--ma-text-heading);
}

.preview-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--ma-surface-section);
}

.preview-table tr:hover {
    background: var(--ma-surface-muted);
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--ma-surface-section);
    border-radius: 12px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: var(--ma-color-primary);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ma-text-on-primary);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Import options */
.import-options {
    background: var(--ma-surface-muted);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.option-group {
    margin-bottom: 1rem;
}

.option-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--ma-text-heading);
}

.option-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

.option-group select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    color: var(--ma-text-body);
    font-size: var(--ma-text-base);
    font-family: inherit;
}

.option-group select:focus {
    outline: none;
    border-color: var(--ma-color-primary);
    box-shadow: var(--ma-focus-ring);
}

/* Alert styles */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}
.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* History table */
.import-history {
    margin-top: 2rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    background: var(--ma-surface-section);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
}

.history-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--ma-surface-section);
}

/* Status badges extended */
.status-success {
    background: #d4edda;
    color: #155724;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-failed {
    background: #f8d7da;
    color: #721c24;
}

/* Financial Statement specific */
.financial-summary {
    background: var(--ma-surface-card);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 2rem;
    margin-bottom: 2rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.summary-item {
    text-align: center;
}

.summary-label {
    font-size: 0.9rem;
    color: var(--ma-text-muted);
    margin-bottom: 0.5rem;
}

.summary-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ma-text-heading);
}

.summary-value.positive {
    color: var(--ma-color-success);
}

.summary-value.negative {
    color: var(--ma-color-danger);
}

.coin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.coin-card {
    background: var(--ma-surface-card);
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-lg);
    padding: 1rem;
    transition: box-shadow var(--ma-transition-fast), transform var(--ma-transition-fast);
}



.coin-name {
    font-weight: 600;
    color: var(--ma-text-heading);
}

.profit-loss {
    font-size: 0.9rem;
    font-weight: 600;
}

.profit-loss.positive {
    color: var(--ma-color-success);
}

.profit-loss.negative {
    color: var(--ma-color-danger);
}

/* Collection specific styles */
.user-select {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.user-select label {
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
}

.user-select select {
    min-width: 16rem;
}

/* Empty state styles */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--ma-text-muted);
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* Coin images */
.coin-images {
    display: flex;
    gap: 0.5rem;
}

.coin-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--ma-border-strong);
}

.no-image {
    width: 40px;
    height: 40px;
    background: var(--ma-surface-section);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--ma-text-muted);
}

/* Action buttons variations */
.action-btns {
    display: flex;
    gap: 0.5rem;
}

/* Ensure consistent button sizes in tables */
.action-buttons .btn,
.action-btns .btn {
    white-space: nowrap;
}

/* Recent activity styles */
.recent-activity {
    background: var(--ma-surface-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.activity-list {
    margin-top: 1rem;
}

.activity-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--ma-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-user {
    font-weight: 500;
    color: var(--ma-text-heading);
}

.activity-action {
    color: var(--ma-text-muted);
}

.activity-time {
    font-size: 0.8rem;
    color: var(--ma-gray-mid);
}

/* System health styles */
.system-health {
    background: var(--ma-surface-card);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.health-indicators {
    margin-top: 1rem;
}

.health-item {
    padding: 0.75rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--ma-border);
}

.health-item:last-child {
    border-bottom: none;
}

.health-label {
    font-weight: 500;
    color: var(--ma-text-heading);
}

/* Dashboard specific stat value */
.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--ma-text-heading);
}

.stat-value-datetime {
    font-size: 1.25rem;
    line-height: 1.3;
}

.stat-breakdown {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--ma-text-muted);
}

.dashboard-system-health {
    margin-bottom: 2rem;
}

.health-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 1.25rem;
}

.dashboard-system-health .health-stat-card {
    margin: 0;
    box-shadow: none;
}

.dashboard-system-health .health-stat-card .stat-value {
    margin: 0.75rem 0 0.5rem;
    display: flex;
    align-items: center;
    min-height: 2.5rem;
}

.health-stat-desc {
    margin: 0;
    font-size: 0.85rem;
    color: var(--ma-text-muted);
    line-height: 1.35;
}

.health-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem 2rem;
    align-items: center;
}

.health-check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.health-check-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ma-text-muted);
}

.health-last-checked {
    margin: 1rem 0 0;
    font-size: 0.9rem;
    color: var(--ma-text-muted);
}

.health-last-checked {
    margin: 1rem 0 0;
    font-size: 0.9rem;
    color: var(--ma-text-muted);
}

/* Image Gallery Modal Styles */
.image-gallery {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
}

.gallery-content {
    background-color: var(--ma-surface-card);
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.gallery-header {
    background: var(--ma-text-heading);
    color: var(--ma-text-on-primary);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.gallery-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.gallery-header .close {
    color: var(--ma-text-on-primary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.gallery-header .close:hover {
    color: #bdc3c7;
}

.gallery-images {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

.image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--ma-surface-section);
    border-radius: 8px;
    background: var(--ma-surface-muted);
}

.image-label {
    font-weight: 600;
    color: var(--ma-text-heading);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.gallery-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.image-placeholder {
    width: 200px;
    height: 200px;
    background: var(--ma-surface-section);
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ma-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* Coins grid — premium product-card presentation (admin collections) */
.coins-grid {
    display: grid;
    /* 260px (was 300): keeps 2-up a bit longer once grade stacks under images at ≤768 */
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: clamp(1.5rem, 2.5vw, 2.25rem);
    margin-bottom: 2.5rem;
    align-items: stretch;
}

.coin-card {
    background: var(--ma-surface-card);
    border-radius: var(--ma-radius-lg);
    box-shadow: var(--ma-shadow-elevation-1);
    border: 1px solid var(--ma-border);
    overflow: hidden;
    transition: transform var(--ma-transition-fast), box-shadow var(--ma-transition-fast);
}

.coin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ma-shadow-elevation-2);
}

.coin-images {
    width: 100%;
    height: 220px;
    background: var(--ma-surface-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--ma-border);
    overflow: hidden;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
}

.coin-image-side {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.coin-image-side .image-label {
    position: absolute;
    top: 0.35rem;
    left: 0.35rem;
    background: rgba(15, 23, 42, 0.72);
    color: var(--ma-text-on-primary);
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.coin-image-side img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--ma-radius-md);
}

.coin-image-frame {
    position: relative;
    width: min(100%, 9.5rem);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin-image-pulse {
    width: 78%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #cfd4dc;
    animation: coin-image-pulse 1.4s ease-in-out infinite;
}

.coin-image-frame .coin-display-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: var(--ma-radius-md);
}

.coin-image-frame.has-image .coin-display-image {
    opacity: 1;
}

.coin-image-frame.has-image .coin-image-pulse {
    display: none;
}

@keyframes coin-image-pulse {
    0%, 100% {
        opacity: 0.45;
        transform: scale(0.96);
    }
    50% {
        opacity: 0.9;
        transform: scale(1);
    }
}

.coin-image-side .no-image {
    color: var(--ma-text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 0.5rem;
}

.coin-header {
    background: var(--ma-surface-card);
    padding: 1rem 1.15rem;
    border-bottom: none;
}

.coin-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ma-text-heading);
    margin-bottom: 0.4rem;
    letter-spacing: -0.02em;
    line-height: 1.35;
}

.coin-subtitle {
    color: var(--ma-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.45;
}

.coin-content {
    padding: 1rem 1.15rem;
}

.coin-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.detail-item {
    font-size: 0.9rem;
}

.detail-label {
    color: var(--ma-text-muted);
    font-weight: 500;
}

.detail-value {
    color: var(--ma-text-heading);
}

.coin-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.more-images-btn {
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--ma-radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--ma-transition-fast);
}

.more-images-btn:hover {
    background: var(--ma-color-primary-hover);
}

.coin-actions-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Collections grid cards: flat Gemini card chrome */
.coins-grid > .coin-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    border-radius: var(--ma-radius-lg);
    border: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow-elevation-1);
    transition:
        transform var(--ma-transition-fast),
        box-shadow var(--ma-transition-fast),
        border-color var(--ma-transition-fast);
}

.coins-grid > .coin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ma-shadow-elevation-2);
    border-color: var(--ma-border-strong);
}

.coins-grid > .coin-card .coin-images {
    flex-shrink: 0;
    border-bottom: 1px solid var(--ma-border);
    position: relative;
    overflow: hidden;
    z-index: 0;
    height: auto;
    min-height: 220px;
    padding: 1rem 1.15rem 0.85rem;
    background: var(--ma-surface-muted);
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: 0.65rem 0.75rem;
}

.coins-grid > .coin-card .coin-image-side {
    flex: 1 1 0;
    min-width: 0;
    height: 180px;
}

.coins-grid > .coin-card .coin-image-side img {
    border-radius: var(--ma-radius-md);
    filter: none;
}

.coins-grid > .coin-card .coin-header {
    flex: 1 1 auto;
    min-height: 4.25rem;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.35rem;
    padding: 1rem 1.25rem 0.75rem;
    background: var(--ma-surface-card);
}

.coins-grid > .coin-card .coin-header.coin-header--no-catalog {
    min-height: 0;
    flex: 0 0 auto;
    padding-top: 0.5rem;
    padding-bottom: 0.35rem;
}

/* Status + grade share one flex row under the images (status overlays on desktop). */
.coins-grid > .coin-card .coin-pills-row {
    flex: 1 0 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-sizing: border-box;
    min-height: 2.15rem;
    padding: 0.15rem 0;
}

/* Status badge — absolute overlay on desktop (>768); static in pills row ≤768 */
.coins-grid > .coin-card .coin-state-pill {
    position: absolute;
    left: 50%;
    top: 0.75rem;
    bottom: auto;
    transform: translateX(-50%);
    z-index: 4;
    max-width: calc(100% - 2rem);
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.3rem 0.75rem;
    border-radius: var(--ma-radius-pill);
    border: 1px solid var(--ma-border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: var(--ma-shadow-elevation-1);
    backdrop-filter: none;
}

.coins-grid > .coin-card .coin-state-pill--imported {
    color: #92400e;
    background: var(--ma-color-warning-muted-bg);
    border-color: rgba(180, 83, 9, 0.25);
}

.coins-grid > .coin-card .coin-state-pill--graded {
    color: #14532d;
    background: var(--ma-color-success-muted-bg);
    border-color: rgba(22, 101, 52, 0.25);
}

.coins-grid > .coin-card .coin-grade-pill-row {
    flex: 0 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 0;
    padding: 0;
    background: transparent;
}

.coins-grid > .coin-card .coin-grade-pill-row--empty {
    visibility: hidden;
}

.coins-grid > .coin-card .coin-grade-pill-row--ungraded {
    visibility: visible;
}

.coins-grid > .coin-card .coin-grade-ungraded {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ma-text-muted);
}

.coins-grid > .coin-card .coin-grade-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: calc(100% - 0.5rem);
    padding: 0.35rem 0.9rem;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--ma-color-primary);
    background: var(--ma-surface-card);
    border: 1px solid rgba(2, 132, 199, 0.35);
    border-radius: var(--ma-radius-pill);
    box-shadow: var(--ma-shadow-elevation-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.coins-grid > .coin-card .coin-state-pill--holder-purchased {
    color: #075985;
    background: var(--ma-badge-info-bg);
    border-color: rgba(2, 132, 199, 0.25);
}

.coins-grid > .coin-card .coin-state-pill--registered {
    color: #5b21b6;
    background: #ede9fe;
    border-color: rgba(139, 92, 246, 0.3);
}

.coins-grid > .coin-card .coin-state-pill--identified {
    color: var(--ma-text-heading);
    background: var(--ma-surface-card);
    border-color: var(--ma-border-strong);
}

.coins-grid > .coin-card .coin-state-pill--identifying {
    color: #075985;
    background: var(--ma-badge-info-bg);
    border-color: rgba(14, 165, 233, 0.35);
}

.coins-grid > .coin-card .coin-state-pill--rejected {
    color: #9f1239;
    background: var(--ma-color-danger-muted-bg);
    border-color: rgba(185, 28, 28, 0.3);
}

.coins-grid > .coin-card .coin-identifying-status {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    gap: 0.65rem;
    min-height: 2.25rem;
    padding: 0.35rem 0.15rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--ma-color-primary);
    letter-spacing: 0;
    text-align: center;
}

.coins-grid > .coin-card .coin-identifying-spinner {
    flex-shrink: 0;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid rgba(2, 132, 199, 0.2);
    border-top-color: var(--ma-color-primary);
    border-radius: 50%;
    animation: coin-identifying-spin 0.75s linear infinite;
}

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

.coins-grid > .coin-card.coin-card--identifying .coin-actions {
    display: flex;
    justify-content: center;
}

.coins-grid > .coin-card.coin-card--identifying .coin-actions-buttons {
    display: none;
}

.coins-grid > .coin-card .coin-title {
    width: 100%;
    margin-bottom: 0;
    text-align: left;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.35;
    color: var(--ma-text-heading);
}

.coins-grid > .coin-card .coin-subtitle {
    width: 100%;
    margin-top: 0;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: none;
    color: var(--ma-text-muted);
    opacity: 1;
}

.coins-grid > .coin-card .coin-notes {
    margin-bottom: 0.85rem;
    font-size: 0.9rem;
    color: var(--ma-text-muted);
    line-height: 1.45;
}

.coins-grid > .coin-card .coin-content {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.85rem 1.25rem 1.15rem;
    border-top: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
}

.coins-grid > .coin-card .coin-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.coins-grid > .coin-card .coin-actions-buttons {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}

.coins-grid > .coin-card .coin-actions-buttons .btn {
    border-radius: var(--ma-radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.45rem 0.9rem;
    box-shadow: none;
}

.coins-grid > .coin-card .coin-actions-buttons .btn-danger {
    background: transparent;
    color: var(--ma-color-danger);
    border-style: solid;
    border-color: var(--ma-color-danger);
}

.coins-grid > .coin-card .coin-actions-buttons .btn-danger:hover {
    background: var(--ma-color-danger);
    border-color: var(--ma-color-danger);
    color: var(--ma-text-on-primary);
}

/* Collections page: roomier layout when grid is present */
body:has(#coinsGrid) .container {
    max-width: 1420px;
}

body:has(#coinsGrid) .user-selection-message {
    border-radius: var(--ma-radius-lg);
    border: 1px solid var(--ma-border);
    box-shadow: var(--ma-shadow-elevation-1);
}

body:has(#coinsGrid) .pagination button {
    border-radius: var(--ma-radius-sm);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-color: var(--ma-border);
    transition: background var(--ma-transition-fast), color var(--ma-transition-fast), border-color var(--ma-transition-fast);
}

body:has(#coinsGrid) .pagination button:hover:not(:disabled) {
    transform: none;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding: 1rem;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
    color: var(--ma-text-heading);
    border-radius: var(--ma-radius-sm);
    cursor: pointer;
    transition: background var(--ma-transition-fast), color var(--ma-transition-fast), border-color var(--ma-transition-fast);
}

.pagination button:hover:not(:disabled) {
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    border-color: var(--ma-color-primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    border-color: var(--ma-color-primary);
}

.pagination span {
    padding: 0.5rem;
    color: var(--ma-text-muted);
}

/* Gallery specific styles */
.gallery-image-container {
    background: var(--ma-surface-card);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gallery-image-container h4 {
    color: var(--ma-text-heading);
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.gallery-image-container img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.upload-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ma-surface-section);
}

.upload-section input[type="file"] {
    display: none;
}

.upload-label {
    display: inline-block;
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.upload-label:hover {
    background: var(--ma-color-primary-hover);
}

/* Image preview styles */
.image-preview {
    max-width: 100px;
    max-height: 100px;
    border-radius: 4px;
    border: 1px solid var(--ma-border-strong);
    object-fit: cover;
}

/* Message styles — aligned with shared error-message / success-message */
#messages .error,
#messages .error-message {
    background: var(--ma-color-danger-muted-bg);
    color: var(--ma-color-danger);
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--ma-border);
}

#messages .success,
#messages .success-message {
    background: var(--ma-color-success-muted-bg);
    color: var(--ma-color-success);
    padding: 0.75rem;
    border-radius: var(--ma-radius-md);
    margin-bottom: 1rem;
    border: 1px solid var(--ma-border);
}

/* Collections Page Specific Styles */
.coin-type-selector {
    display: flex;
    gap: 1.5rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--ma-surface-muted);
    border-radius: 6px;
    border: 1px solid var(--ma-surface-section);
}

.coin-type-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--ma-text-heading);
}

.coin-type-selector input[type="radio"] {
    margin: 0;
    accent-color: var(--ma-color-primary);
}

.owner-info {
    margin-top: 0.5rem;
    text-align: center;
}

.owner-tag {
    display: inline-block;
    background: var(--ma-dropdown-active-bg);
    color: var(--ma-dropdown-active-text);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #bbdefb;
}

.value-display {
    font-weight: 600;
    color: var(--ma-color-success);
}

.value-negative {
    color: var(--ma-color-danger);
}

/* Collection-specific detail styling */

/* Additional images toggle */
.additional-images-toggle {
    background: var(--ma-surface-section);
    border: 1px solid #bdc3c7;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--ma-text-heading);
    transition: background 0.3s ease;
}

.additional-images-toggle:hover {
    background: #d5dbdb;
}

/* Import modal specific styles */
.import-progress {
    background: var(--ma-badge-info-bg);
    padding: 1rem;
    border-radius: var(--ma-radius-md);
    border: 1px solid rgba(2, 132, 199, 0.2);
    margin-top: 1rem;
}

.import-results {
    background: var(--ma-surface-muted);
    padding: 1rem;
    border-radius: var(--ma-radius-md);
    border: 1px solid var(--ma-border);
    margin-top: 1rem;
}

.csv-info {
    background: var(--ma-surface-muted);
    padding: 1rem;
    border-radius: var(--ma-radius-md);
    border: 1px solid var(--ma-border);
    font-size: 0.85rem;
    color: var(--ma-text-muted);
    margin-top: 0.5rem;
}

.csv-info ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.csv-info li {
    margin-bottom: 0.25rem;
}

.help-text.help-text--warning {
    color: var(--ma-color-warning);
}

/* User selection message */
.user-selection-message {
    text-align: center;
    margin: 2rem auto;
    max-width: 600px;
}

.user-selection-message .card-content {
    padding: 2.5rem 2rem;
}

.user-selection-message .card-title {
    margin-bottom: 0.75rem;
}

.user-selection-message p {
    margin: 0;
    color: var(--ma-text-muted);
    font-size: 1rem;
    line-height: 1.5;
}

.modal-content.coin-modal-content {
    max-width: 760px;
    max-height: none;
    margin: 3vh auto;
}

.modal-content.coin-modal-content #coinForm {
    margin: 0;
}

.modal-content.coin-modal-content #coinForm > .form-group {
    margin-bottom: 1.25rem;
}

.modal-content.coin-modal-content .coin-images-heading {
    margin: 0.5rem 0 0.5rem;
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 1.1rem;
    color: var(--ma-text-heading);
}

.modal-content.coin-modal-content .coin-images-help {
    margin: 0 0 1.25rem;
}

.modal-content.coin-modal-content .coin-image-upload-group {
    margin-bottom: 0.5rem;
}

.modal-content.coin-modal-content .coin-image-upload-area {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    min-height: 16rem;
    padding: 1.25rem;
    margin-bottom: 0;
    position: relative;
    gap: 1rem;
}

.modal-content.coin-modal-content .upload-area h3 {
    margin-top: 0;
    margin-bottom: 0.35rem;
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 1rem;
}

.modal-content.coin-modal-content .coin-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.75rem;
    padding-top: 0.25rem;
}

.coin-image-upload-area {
    margin-bottom: 0.75rem;
}

.coin-image-upload-area .coin-upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
}

.coin-image-upload-area .coin-image-hidden-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.coin-image-upload-area .coin-image-slots {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
}

.coin-image-upload-area.has-file .coin-image-slots {
    display: grid;
}

.coin-image-slot {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    min-height: 11rem;
    padding: 0.65rem;
    border: 1px dashed var(--ma-border-subtle, #c8c8c8);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--ma-surface-card, #fff) 92%, var(--ma-color-primary, #3366cc) 4%);
}

.coin-image-slot-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ma-text-heading, #222);
}

.coin-image-slot-empty {
    display: none;
    margin: auto 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--ma-text-muted, #777);
}

.coin-image-slot.is-empty .coin-image-slot-empty {
    display: block;
}

.coin-image-upload-area.has-file {
    border-style: solid;
    border-color: var(--ma-color-primary);
    background: color-mix(in srgb, var(--ma-color-primary) 6%, var(--ma-surface-card));
    padding: 0.75rem 1rem 1rem;
}

/* Keep prompt visible when only one new image is selected so the second can still be dropped. */
.coin-image-upload-area.has-file.has-both:not(.ready-for-second):not(.needs-new-files) .coin-upload-prompt {
    display: none;
}

.coin-image-upload-area.ready-for-second .coin-upload-prompt,
.coin-image-upload-area.needs-new-files .coin-upload-prompt {
    display: flex;
    padding-bottom: 0.25rem;
}

.coin-image-preview:empty {
    display: none;
}

.coin-image-upload-area .file-input-label {
    margin: 0.75rem 0 0.25rem;
}

.coin-image-dropzone-actions {
    display: none;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.coin-image-upload-area.has-file .coin-image-dropzone-actions {
    display: flex;
}

.coin-image-upload-area:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.coin-image-upload-area .coin-image-preview {
    display: none;
    margin: 0;
    width: 100%;
    min-height: 9rem;
    align-items: center;
    justify-content: center;
}

.coin-image-upload-area.has-file .coin-image-preview:not(:empty) {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.coin-image-preview .coin-preview-caption {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    text-align: center;
}

.coin-image-preview .image-preview {
    display: block;
    max-width: 100%;
    max-height: 12rem;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--ma-radius-md);
    border: 1px solid var(--ma-border);
    background: var(--ma-surface-card);
}

.coin-image-preview .image-preview-filename {
    max-width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ma-text-muted);
    text-align: center;
    border: none;
}

/* Enhanced form styling for collections */
.form-group label,
.form-action-label {
    font-weight: 600;
    color: var(--ma-text-heading);
    margin-bottom: 0.5rem;
    display: block;
}

.form-group select[multiple] {
    min-height: 120px;
}

.form-group .help-text {
    font-size: 0.8rem;
    color: var(--ma-text-muted);
    margin-top: 0.25rem;
    font-style: italic;
}

/* Collection coin card specific enhancements */

/* Improved modal content for large forms */
.modal-content {
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3:not(.card-title) {
    color: var(--ma-text-heading);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ma-surface-section);
    font-size: 1.2rem;
}

.modal-content #coinForm {
    margin: 20px;
}

/* Responsive improvements for collections */
@media (max-width: 768px) {
    .coin-type-selector {
        flex-direction: column;
        gap: 1rem;
    }

    /*
     * coins-grid ≤768: stack obverse above reverse; status + grade live in
     * .coin-pills-row (flex-basis 100%) so leftover space beside max-width
     * images cannot pull the status pill onto the reverse image row.
     * Desktop >768 keeps absolute status overlay on .coin-images.
     */
    .coins-grid > .coin-card .coin-images {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        min-height: 0;
    }

    .coins-grid > .coin-card .coin-image-side {
        flex: 0 0 100%;
        width: 100%;
        max-width: 160px;
        height: auto;
        min-height: 140px;
    }

    .coins-grid > .coin-card .coin-pills-row {
        flex: 0 0 100%;
        width: 100%;
        min-height: 0;
        padding: 0;
    }

    .coins-grid > .coin-card .coin-state-pill {
        position: static;
        left: auto;
        top: auto;
        bottom: auto;
        transform: none;
        z-index: auto;
        max-width: none;
        flex: 0 1 auto;
        align-self: center;
        box-shadow: none;
    }

    .coins-grid > .coin-card .coin-grade-pill-row {
        flex: 0 1 auto;
        width: auto;
        align-self: center;
    }
    
    .coin-card .coin-actions {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .coin-actions-buttons {
        justify-content: center;
        width: 100%;
    }

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

    .user-item {
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem;
        align-items: flex-start;
    }

    .modal-content.coin-modal-content .coin-form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .modal-content.coin-modal-content .coin-form-actions .btn {
        width: 100%;
    }
}

/* Narrow phones: tighten stacked image size (stacking already at ≤768) */
@media (max-width: 480px) {
    .coin-card .coin-images {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .coin-card .coin-image-side {
        width: 100%;
        max-width: 120px;
    }

    .coins-grid > .coin-card .coin-image-side {
        max-width: 120px;
        min-height: 120px;
    }
}

/* Financial Statement Styles */
.financial-statement-print-hint {
    margin: 0 0 0.65rem;
    padding: 0 0.15rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    line-height: 1.35;
    text-align: right;
}

.financial-statement-page .financial-statement-controls .card-content {
    padding: 1rem 1.25rem;
}

.financial-statement-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.export-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.financial-statement-result {
    margin-top: 1.25rem;
}

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

.statement-meta {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    line-height: 1.45;
}

.statement-meta-label {
    font-weight: 400;
    color: var(--ma-text-muted);
}

.statement-meta-value {
    font-weight: 600;
    color: var(--ma-text-body);
}

.statement-counts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2.5rem;
    margin: 0.65rem 0 0;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--ma-text-muted);
    line-height: 1.45;
}

.statement-count {
    display: inline-block;
    white-space: nowrap;
}

.statement-table-wrap {
    overflow-x: auto;
    padding: 0;
    min-width: 0;
    max-width: 100%;
}

.statement-table {
    width: 100%;
    border-collapse: collapse;
}

/* Overflow-detect cards (class toggled in JS when table would scrollbar). */
.statement-table-wrap.is-card-view {
    overflow-x: visible;
    /* .statement-table-wrap zeros card-content padding — restore room around nested cards. */
    padding: 1.15rem 1.15rem 0.65rem;
}

.statement-table-wrap.is-card-view .statement-table {
    min-width: 0 !important;
    width: 100%;
}

.statement-table-wrap.is-card-view .statement-table thead {
    display: none;
}

.statement-table-wrap.is-card-view .statement-table tbody,
.statement-table-wrap.is-card-view .statement-table tfoot {
    display: block;
}

.statement-table-wrap.is-card-view .statement-table tbody tr,
.statement-table-wrap.is-card-view .statement-table tfoot tr {
    display: block;
    margin: 0 0 0.85rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
}

.statement-table-wrap.is-card-view .statement-table tbody tr:last-child {
    margin-bottom: 0.85rem;
}

.statement-table-wrap.is-card-view .statement-table tfoot tr.totals-row {
    background: var(--ma-surface-muted);
    border-color: var(--ma-border-strong);
    margin-bottom: 0;
}

.statement-table-wrap.is-card-view .statement-table tbody td,
.statement-table-wrap.is-card-view .statement-table tfoot td {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0.35rem 0.75rem;
    align-items: start;
    width: 100%;
    padding: 0.4rem 0;
    border: none;
    white-space: normal;
    text-align: left !important;
    vertical-align: top;
    max-width: none;
}

.statement-table-wrap.is-card-view .statement-table tbody td + td,
.statement-table-wrap.is-card-view .statement-table tfoot td + td {
    border-top: 1px solid var(--ma-border);
}

.statement-table-wrap.is-card-view .statement-table tbody td::before,
.statement-table-wrap.is-card-view .statement-table tfoot td::before {
    content: attr(data-label);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ma-text-muted);
    line-height: 1.35;
}

.statement-table-wrap.is-card-view .statement-table .stmt-card-hide {
    display: none !important;
}

.statement-table-wrap.is-card-view .statement-table .stmt-totals-heading::before {
    content: none;
}

.statement-table-wrap.is-card-view .statement-table .stmt-totals-heading {
    display: block;
    grid-template-columns: none;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ma-text-heading);
    padding-top: 0.1rem;
    padding-bottom: 0.55rem;
    margin-bottom: 0;
    border-bottom: 1px solid var(--ma-border-strong);
}

/* Avoid double rule: heading border-bottom + next visible cell border-top. */
.statement-table-wrap.is-card-view .statement-table tfoot td[data-label="Acq. Cost"] {
    border-top: none !important;
}

/* Year + Denomination share one card row (same pattern as import coins table). */
.statement-table-wrap.is-card-view .statement-table tbody td.stmt-col-coin {
    border-bottom: 1px solid var(--ma-border);
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-year-cell {
    float: left;
    clear: left;
    width: auto;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 7.5rem) auto;
    gap: 0.35rem 0.5rem;
    align-items: start;
    border-top: none !important;
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-year-cell::before {
    content: "Year / Denomination";
    white-space: normal;
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-denom-cell {
    float: left;
    width: auto;
    max-width: 100%;
    display: block;
    grid-template-columns: none;
    border-top: none !important;
    padding-left: 0;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-denom-cell::before {
    content: "\00a0·\00a0";
    display: inline;
    font-size: inherit;
    font-weight: 400;
    color: var(--ma-text-muted);
    line-height: inherit;
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-denom-cell:empty {
    display: none;
}

.statement-table-wrap.is-card-view .statement-table tbody td.stmt-denom-cell + td {
    clear: both;
}

.statement-table th {
    background: var(--ma-surface-muted);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ma-text-heading);
    border-bottom: 1px solid var(--ma-border-strong);
    white-space: nowrap;
}

.statement-table th.text-right,
.statement-table td.text-right {
    text-align: right;
}

.statement-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--ma-border);
    color: var(--ma-text-body);
    font-size: 0.9rem;
    vertical-align: middle;
}

.statement-table .stmt-col-serial {
    white-space: nowrap;
}

.statement-table .stmt-col-coin {
    font-weight: 600;
    color: var(--ma-text-heading);
}

.statement-table .stmt-col-grade {
    white-space: nowrap;
}

.statement-table .profit {
    color: var(--ma-color-success);
    font-weight: 600;
}

.statement-table .loss {
    color: var(--ma-color-danger);
    font-weight: 600;
}

.statement-table .totals-row {
    background: var(--ma-surface-muted);
    font-weight: 700;
    border-top: 2px solid var(--ma-border-strong);
}

.statement-table .totals-row td {
    padding: 0.9rem 1rem;
    border-bottom: none;
    color: var(--ma-text-heading);
}

.financial-statement-page .loading,
.financial-statement-page .error,
.financial-statement-page .empty-state {
    margin-top: 1.25rem;
}

/* Print styles for financial statements — prefer landscape (print preview default). */
.financial-statement-page {
    page: financial-statement;
}

@page financial-statement {
    size: landscape;
    margin: 0.5in;
}

@media print {
    .header,
    .financial-statement-controls,
    .financial-statement-print-hint,
    .export-buttons,
    .nav-links,
    .logout-btn,
    .admin-chat-toggle,
    .admin-chat-backdrop,
    .admin-chat-panel,
    .admin-chat-resize,
    .page-header {
        display: none !important;
    }

    body.admin-chat-pinned.admin-chat-open {
        padding-right: 0 !important;
    }

    .container {
        margin: 0;
        padding: 0;
        max-width: none;
    }

    .financial-statement-result.card {
        box-shadow: none;
        border: 1px solid #000;
    }

    /* Always print as a normal table, not cards. */
    .statement-table-wrap.is-card-view {
        overflow-x: visible;
    }

    .statement-table-wrap.is-card-view .statement-table thead {
        display: table-header-group;
    }

    .statement-table-wrap.is-card-view .statement-table tbody,
    .statement-table-wrap.is-card-view .statement-table tfoot {
        display: table-row-group;
    }

    .statement-table-wrap.is-card-view .statement-table tbody tr,
    .statement-table-wrap.is-card-view .statement-table tfoot tr {
        display: table-row;
        margin: 0;
        padding: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    .statement-table-wrap.is-card-view .statement-table tbody td,
    .statement-table-wrap.is-card-view .statement-table tfoot td {
        display: table-cell;
        grid-template-columns: none;
        padding: 0.5rem;
        border-bottom: 1px solid #000;
        text-align: left !important;
        float: none;
        width: auto;
        max-width: none;
    }

    .statement-table-wrap.is-card-view .statement-table tbody td::before,
    .statement-table-wrap.is-card-view .statement-table tfoot td::before {
        content: none;
    }

    .statement-table-wrap.is-card-view .statement-table .stmt-card-hide {
        display: table-cell !important;
    }

    .statement-card-header {
        background: var(--ma-surface-muted) !important;
        color: #000 !important;
        border-bottom: 2px solid #000;
    }

    .statement-table th {
        background: var(--ma-surface-muted) !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .statement-table .profit,
    .statement-table .loss {
        color: #000 !important;
    }
}

/* Import Page Specific Styles */
.stat-label {
    font-size: 0.8rem;
    color: var(--ma-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    border-left: 4px solid #17a2b8;
}

/* Enhanced responsive design */
@media (max-width: 768px) {
    .statement-table {
        font-size: 0.85rem;
    }
    
    .financial-statement-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .financial-statement-page .export-buttons {
        width: auto;
        max-width: 12rem;
        flex-direction: column;
        align-items: stretch;
    }

    .financial-statement-page .export-buttons .btn {
        flex: 0 0 auto;
        width: 100%;
        max-width: 12rem;
    }
    
    .controls {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
    }

    .search-box {
        flex: 1 1 auto;
        width: 100%;
    }

    .search-box input,
    .search-box select {
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
    }

    .controls-actions {
        width: 100%;
    }

    .controls-actions .btn {
        flex: 1 1 auto;
    }
    
    .user-select {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
    }

    .user-select select {
        min-width: 0;
        width: 100%;
        max-width: 100%;
    }
}

/* Credit settings page */
.container.credit-settings-page {
    max-width: 1600px;
}

/* Section / field help copy: under title or label, smaller, muted, indented */
.credit-settings-page .help-text.section-desc,
.credit-settings-page .help-text.field-desc {
    margin: 0;
    padding-left: 0.5rem;
    color: var(--ma-text-muted);
    font-size: 0.8rem;
    font-style: normal;
    font-weight: 400;
    line-height: 1.35;
}

.credit-settings-page .page-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.credit-settings-page .page-header .help-text.section-desc {
    margin-top: 0;
    max-width: 48rem;
}

.credit-settings-page .card-header-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.credit-settings-page .card-header-text .card-title {
    margin: 0;
}

.credit-settings-page .collapsible-heading {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.credit-settings-page .collapsible-heading .card-title,
.credit-settings-page .collapsible-heading > span:first-child {
    margin: 0;
}

.credit-settings-page .form-grid {
    align-items: stretch;
}

.credit-settings-page .form-group > label {
    margin-bottom: 0;
}

/* Stretch groups in a grid row, then pin controls under the help text so input tops align */
.credit-settings-page .form-grid > .form-group > .help-text.field-desc {
    margin-bottom: auto;
}

.credit-settings-page .preview-panel > .help-text.section-desc {
    margin: 0.15rem 0 0.65rem;
}

.credit-settings-page .table-form-group {
    margin: 0;
}

.credit-settings-page #grantRuleForm .form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

.credit-settings-page #settingsForm > .form-group {
    min-width: 0;
}

.credit-settings-page #settingsForm .form-actions {
    align-items: flex-start;
    align-self: stretch;
}

.credit-settings-page #settingsForm .form-actions > .btn {
    margin-top: auto;
}

.credit-settings-page #spend-table {
    width: 100%;
    table-layout: fixed;
}

@media (min-width: 1100px) {
    .credit-settings-page #spend-table {
        width: 75%;
    }
}

.credit-settings-page #spend-table .spend-col-enabled,
.credit-settings-page #spend-table .spend-col-action {
    width: 8.333%;
}

.credit-settings-page #spend-table .spend-col-credits,
.credit-settings-page #spend-table .spend-col-controls {
    width: 16.667%;
}

.credit-settings-page #spend-table .spend-col-description {
    width: 50%;
}

.credit-settings-page #spend-table th:first-child,
.credit-settings-page #spend-table td:first-child {
    text-align: center;
    white-space: nowrap;
}

.credit-settings-page #spend-table th:last-child,
.credit-settings-page #spend-table td:last-child {
    white-space: nowrap;
}

/* Shopify grant product import preview — nested card inside Grant Products */
.credit-settings-page .shopify-import-preview {
    margin: 0.75rem 0 1.25rem;
    padding: 0;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-lg);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
    overflow: hidden;
}

.credit-settings-page .shopify-import-preview > .shopify-import-card-header {
    padding: 0.75rem 1rem;
}

.credit-settings-page .shopify-import-preview > .shopify-import-card-header .card-title {
    margin: 0;
    font-size: 1.05rem;
}

.credit-settings-page .shopify-import-body {
    padding: 0.75rem;
}

.credit-settings-page .shopify-import-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem 1rem;
    margin: 0 0 0.65rem;
    padding: 0;
}

.credit-settings-page .shopify-import-body > .table-scroll {
    margin: 0;
}

.credit-settings-page .shopify-import-counts {
    font-size: 0.85rem;
    color: #57606a;
    justify-self: start;
    min-width: 0;
}

.credit-settings-page .shopify-match-filters {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    justify-self: center;
}

.credit-settings-page .shopify-import-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-self: end;
    justify-content: flex-end;
}

.credit-settings-page #shopifyImportSelectedBtn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    cursor: wait;
}

.credit-settings-page #shopifyImportSelectedBtn.is-loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: credit-settings-btn-spin 0.75s linear infinite;
}

@keyframes credit-settings-btn-spin {
    to { transform: rotate(360deg); }
}

.credit-settings-page .shopify-match-filter.is-on {
    background: #ddf4ff;
    border-color: #54aeff;
}

.credit-settings-page .shopify-match-partial {
    background: #fff8c5;
    color: #9a6700;
}

.credit-settings-page .shopify-match-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 0;
}

.credit-settings-page .shopify-match-by {
    display: block;
    margin: 0;
    font-size: 0.75rem;
    color: #57606a;
    line-height: 1.25;
}

.credit-settings-page .shopify-identity-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    min-width: 0;
    max-width: 100%;
}

.credit-settings-page .shopify-field-current {
    display: block;
    font-size: 0.85rem;
    color: #9a6700;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    background: #eaeef2;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    max-width: 100%;
}

.credit-settings-page .shopify-field-current.shopify-field-current-plain {
    background: transparent;
    color: inherit;
    padding: 0;
}

.credit-settings-page .shopify-field-current.shopify-field-chosen,
.credit-settings-page .shopify-field-value.shopify-field-chosen {
    background: #dafbe1;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
    color: inherit;
}

.credit-settings-page .shopify-field-choice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    align-items: center;
}

.credit-settings-page .shopify-choice-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
}

.credit-settings-page .shopify-field-value {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.credit-settings-page .shopify-field-value.shopify-field-mismatch {
    background: #fff8c5;
    padding: 0.1rem 0.25rem;
    border-radius: 3px;
}

.credit-settings-page #shopify-preview-table {
    width: 100%;
    min-width: 72rem;
    table-layout: fixed;
}

.credit-settings-page #shopify-preview-table th,
.credit-settings-page #shopify-preview-table td {
    padding: 0.5rem 0.4rem;
}

.credit-settings-page #shopify-preview-table .shopify-col-name,
.credit-settings-page #shopify-preview-table td.shopify-col-name {
    width: auto;
    min-width: 10rem;
    overflow-wrap: break-word;
    word-break: normal;
}

.credit-settings-page .shopify-col-select {
    width: 2.25rem;
}

.credit-settings-page .shopify-col-match {
    width: 6.75rem;
}

.credit-settings-page .shopify-col-sku {
    width: 13rem;
}

.credit-settings-page #shopify-preview-table .shopify-col-sku,
.credit-settings-page #shopify-preview-table td.shopify-col-sku {
    white-space: nowrap;
}

.credit-settings-page #shopify-preview-table td.shopify-col-sku .shopify-field-value,
.credit-settings-page #shopify-preview-table td.shopify-col-sku .shopify-field-current {
    white-space: nowrap;
}

.credit-settings-page .shopify-col-variant-id {
    width: 11.5rem;
}

.credit-settings-page #shopify-preview-table td.shopify-col-variant-id,
.credit-settings-page #shopify-preview-table td.shopify-col-product-id {
    overflow: hidden;
}

.credit-settings-page .shopify-col-product-id {
    width: 10rem;
}

.credit-settings-page .shopify-col-type {
    width: 10rem;
}

.credit-settings-page #shopify-preview-table .shopify-col-type,
.credit-settings-page #shopify-preview-table td.shopify-col-type {
    white-space: nowrap;
}

.credit-settings-page .shopify-col-credits {
    width: 4.75rem;
}

.credit-settings-page .shopify-col-row-actions {
    width: 5.5rem;
}

.credit-settings-page .shopify-col-row-actions .btn {
    width: 100%;
    justify-content: center;
}

.credit-settings-page .shopify-credits-na,
.credit-settings-page .product-credits-na {
    color: #57606a;
}

.credit-settings-page .shopify-col-category {
    width: 8.5rem;
}

.credit-settings-page #shopify-preview-table .shopify-col-category,
.credit-settings-page #shopify-preview-table td.shopify-col-category {
    overflow: visible;
}

.credit-settings-page #shopify-preview-table select.shopify-category {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding-right: 1.75rem;
    text-overflow: clip;
}

/* Keep a high floor so columns stay readable and .table-scroll kicks in well before 768 cards. */
@media (min-width: 769px) and (max-width: 1200px) {
    .credit-settings-page #shopify-preview-table {
        min-width: 64rem;
    }

    .credit-settings-page #shopify-preview-table th,
    .credit-settings-page #shopify-preview-table td {
        padding: 0.4rem 0.32rem;
    }
}

@media (min-width: 769px) and (max-width: 960px) {
    .credit-settings-page #shopify-preview-table {
        min-width: 60rem;
    }

    .credit-settings-page #shopify-preview-table th,
    .credit-settings-page #shopify-preview-table td {
        padding: 0.35rem 0.28rem;
    }
}

.credit-settings-page .shopify-match-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.credit-settings-page .shopify-match-new {
    background: #ddf4ff;
    color: #0550ae;
}

.credit-settings-page .shopify-match-existing {
    background: #eaeef2;
    color: #24292f;
}

.credit-settings-page .shopify-match-exclude {
    background: #ffebe9;
    color: #cf222e;
}

.credit-settings-page .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.credit-settings-page #grantRuleForm .form-grid > .form-group {
    grid-column: span 6;
}

.credit-settings-page #grantRuleForm #fieldStartInclusive,
.credit-settings-page #grantRuleForm #fieldEndExclusive {
    grid-row: 2;
    grid-column: span 2;
}

.credit-settings-page #grantRuleForm #fieldDescription {
    grid-row: 2;
    grid-column: span 6;
}

.credit-settings-page #grantRuleForm #grantRuleActions {
    grid-row: 2;
    grid-column: span 2;
    align-items: flex-start;
    align-self: stretch;
}

.credit-settings-page #grantRuleForm #grantRuleActions .form-action-buttons {
    margin-top: auto;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="login_credit"] #fieldRuleKey,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="login_credit"] #fieldScheduleType {
    grid-row: 1;
    grid-column: span 4;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="login_credit"] #fieldInterval,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="login_credit"] #fieldCredits {
    grid-row: 1;
    grid-column: span 2;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="identified_collection_tier"] #fieldRuleKey,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="identified_collection_tier"] #fieldMinIdentified,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="identified_collection_tier"] #fieldCredits {
    grid-row: 1;
    grid-column: span 4;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="coin_import"] #fieldRuleKey,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="coin_import"] #fieldCredits {
    grid-row: 1;
    grid-column: span 6;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldRuleKey,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldPurchaseScopeType,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldPurchaseScopeKey,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldPurchaseAwardMode {
    grid-row: 1;
    grid-column: span 3;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"][data-purchase-mode="every_n"] #fieldPurchaseEveryN,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"][data-purchase-mode="every_n"] #fieldPurchaseCredits {
    grid-row: 2;
    grid-column: span 3;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldPurchaseTiers {
    grid-row: 2;
    grid-column: span 9;
}

.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldStartInclusive,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldEndExclusive,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #fieldDescription,
.credit-settings-page #grantRuleForm .form-grid[data-rule-key="product_purchase_grant"] #grantRuleActions {
    grid-row: 3;
}

.credit-settings-page #grantRuleForm .purchase-tier-columns,
.credit-settings-page #grantRuleForm .purchase-tier-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.credit-settings-page #grantRuleForm .purchase-tier-columns {
    margin-bottom: 0.25rem;
    color: var(--ma-text-muted);
    font-size: 0.85rem;
}

.credit-settings-page #grantRuleForm .purchase-tier-row {
    margin-bottom: 0.5rem;
}

.credit-settings-page #grantRuleForm .purchase-tier-remove {
    justify-self: start;
}

.credit-settings-page #grantRuleForm #addPurchaseTier {
    align-self: flex-start;
    background: var(--ma-primary-soft-bg);
    color: var(--ma-color-primary-active);
    border-color: color-mix(in srgb, var(--ma-color-primary) 55%, var(--ma-border));
    font-weight: 600;
}

.credit-settings-page #grantRuleForm #addPurchaseTier:hover {
    background: var(--ma-badge-info-bg);
    border-color: var(--ma-color-primary);
}

.credit-settings-page .product-purchase-preview-table {
    width: 50%;
    table-layout: fixed;
    line-height: 1.1;
}

.credit-settings-page .product-purchase-preview-table th,
.credit-settings-page .product-purchase-preview-table td {
    width: 33.333%;
}

.credit-settings-page input[type="checkbox"] {
    appearance: none;
    display: inline-grid;
    place-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border: 1.5px solid color-mix(in srgb, var(--ma-color-primary) 45%, var(--ma-border));
    border-radius: 0.35rem;
    background: #fff;
    cursor: pointer;
    vertical-align: middle;
}

.credit-settings-page input[type="checkbox"]::before {
    content: "";
    width: 0.65rem;
    height: 0.65rem;
    clip-path: polygon(14% 44%, 0 59%, 38% 100%, 100% 18%, 84% 4%, 37% 70%);
    background: var(--ma-color-primary);
    transform: scale(0);
    transition: transform var(--ma-transition-fast);
}

.credit-settings-page input[type="checkbox"]:checked {
    background: #fff;
}

.credit-settings-page input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.credit-settings-page input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.credit-settings-page #product-table {
    table-layout: fixed;
    width: 100%;
}

.credit-settings-page #product-table th,
.credit-settings-page #product-table td {
    padding: 0.45rem 0.35rem;
    vertical-align: middle;
}

.credit-settings-page #product-table .product-col-enabled {
    width: 2.5rem;
    text-align: center;
    padding-left: 0.35rem;
    padding-right: 0.15rem;
}

.credit-settings-page #product-table .product-col-sku {
    width: 22%;
}

.credit-settings-page #product-table .product-col-name {
    width: auto;
}

.credit-settings-page #product-table .product-col-category {
    width: 8.25rem;
}

.credit-settings-page #product-table .product-col-credits {
    width: 3.15rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
    text-align: center;
}

.credit-settings-page #product-table th.product-col-credits {
    font-size: 0.8rem;
    letter-spacing: -0.01em;
}

.credit-settings-page #product-table .product-col-variant {
    width: 8.75rem;
}

.credit-settings-page #product-table .product-col-shopify {
    width: 8.75rem;
}

/* Shrink-wrap actions with a real rem width — table-layout:fixed ignores 1% shrink-to-fit */
.credit-settings-page #product-table .product-col-actions {
    width: 10.75rem;
    min-width: 10.75rem;
    white-space: nowrap;
    padding-left: 0.35rem;
    padding-right: 0.45rem;
    text-align: right;
}

.credit-settings-page #product-table .product-row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    max-width: none;
}

.credit-settings-page #product-table input.product-sku,
.credit-settings-page #product-table input.product-name,
.credit-settings-page #product-table input.product-shopify-id,
.credit-settings-page #product-table select.product-category {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.5rem 0.55rem;
}

.credit-settings-page #product-table input.product-credits {
    width: 2.15rem;
    min-width: 2.15rem;
    max-width: 2.15rem;
    padding: 0.5rem 0.15rem;
    box-sizing: border-box;
    text-align: center;
}

/* Input/select values only — more characters visible before truncation */
@media (max-width: 1100px) {
    .credit-settings-page #product-table input.product-sku,
    .credit-settings-page #product-table input.product-name,
    .credit-settings-page #product-table input.product-shopify-id,
    .credit-settings-page #product-table input.product-credits,
    .credit-settings-page #product-table select.product-category {
        font-size: 0.78rem;
        padding: 0.4rem 0.3rem;
    }

    .credit-settings-page #product-table .product-col-category {
        width: 6.75rem;
    }

    /* Don't add extra pad for the native arrow — that creates the empty gap before it */
    .credit-settings-page #product-table select.product-category {
        padding-right: 0.2rem;
    }

    .credit-settings-page #product-table .product-col-sku {
        width: 26%;
    }

    .credit-settings-page #product-table .product-col-shopify {
        width: 7rem;
    }
}

.credit-settings-page #product-table tbody tr:nth-child(even) {
    background: var(--ma-surface-muted);
}

.credit-settings-page #product-table tbody tr:hover {
    background: var(--ma-surface-dropdown-hover) !important;
}

/*
 * Mid widths: keep data columns on one line; park Update/Delete on a full-width
 * second line of the row before resorting to scroll/cards.
 */
@media (min-width: 769px) and (max-width: 1480px) {
    .credit-settings-page .table-scroll:has(> #product-table) {
        overflow-x: visible;
    }

    .credit-settings-page #product-table,
    .credit-settings-page #product-table thead,
    .credit-settings-page #product-table tbody {
        display: block;
        width: 100%;
    }

    .credit-settings-page #product-table thead tr,
    .credit-settings-page #product-table tbody tr {
        display: grid;
        grid-template-columns:
            2.5rem
            minmax(0, 1.35fr)
            minmax(0, 1.45fr)
            8.25rem
            3.15rem
            8.75rem;
        column-gap: 0.4rem;
        row-gap: 0.35rem;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        padding: 0.4rem 0.35rem 0.5rem;
        border-bottom: 1px solid var(--ma-border);
    }

    .credit-settings-page #product-table thead tr {
        background: var(--ma-surface-table-header);
        border-bottom-color: var(--ma-border-strong);
    }

    .credit-settings-page #product-table thead th,
    .credit-settings-page #product-table tbody td {
        width: auto !important;
        max-width: none;
        min-width: 0;
        border-bottom: none;
        padding: 0.2rem 0.15rem;
    }

    .credit-settings-page #product-table .product-col-enabled {
        text-align: center;
    }

    .credit-settings-page #product-table .product-col-actions {
        grid-column: 1 / -1;
        width: auto !important;
        white-space: normal;
        text-align: left;
        padding-top: 0.1rem;
        padding-right: 0.15rem;
    }

    .credit-settings-page #product-table thead .product-col-actions {
        display: none;
    }

    .credit-settings-page #product-table .product-row-actions {
        justify-content: flex-start;
    }

    .credit-settings-page #product-table tbody tr:last-child {
        border-bottom: none;
    }
}

/* Mid-width + small value font: Category + Product ID can stay tighter */
@media (min-width: 769px) and (max-width: 1100px) {
    .credit-settings-page #product-table thead tr,
    .credit-settings-page #product-table tbody tr {
        grid-template-columns:
            2.5rem
            minmax(0, 1.35fr)
            minmax(0, 1.45fr)
            6.75rem
            3.15rem
            7rem;
    }
}

.credit-settings-page .grant-rules-subheader {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.credit-settings-page .grant-rules-subheader .card-subtitle {
    margin: 0;
    min-width: 0;
}

.credit-settings-page .grant-rule-summary-banner {
    margin: 0 0 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid color-mix(in srgb, var(--ma-color-primary) 35%, var(--ma-border));
    border-left: 0.35rem solid var(--ma-color-primary);
    border-radius: var(--ma-radius-md);
    background: color-mix(in srgb, var(--ma-color-primary) 10%, var(--ma-surface-card));
    color: var(--ma-text-heading);
    font-size: 0.98rem;
    font-weight: 600;
    font-style: italic;
    line-height: 1.45;
}

.credit-settings-page .grant-rules-header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

.credit-settings-page .grant-rule-editor-card {
    padding: 1rem;
    border: 1px solid var(--ma-border-strong);
    border-radius: var(--ma-radius-lg);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-1);
}

.credit-settings-page .grant-rule-idle-actions {
    display: flex;
    align-items: center;
}

.credit-settings-page .existing-rules-section {
    margin-top: 1.25rem;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}

.credit-settings-page .existing-rules-toggle {
    display: inline-flex;
    width: auto;
    max-width: 100%;
    align-items: flex-start;
    gap: 0.625rem;
    margin: 0 0 0.5rem;
    padding: 0.25rem;
    border: 0;
    background: transparent;
    color: var(--ma-text-heading);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.credit-settings-page .existing-rules-table-card {
    position: relative;
    background: transparent;
}

.credit-settings-page .existing-rules-table-controls {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin: 0 0 0.5rem;
}

.credit-settings-page .existing-rules-type-filters {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.credit-settings-page .existing-rules-type-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-width: 5.5rem;
    border: 1px solid var(--ma-border-strong);
    background: var(--ma-badge-info-bg);
    color: var(--ma-color-primary-active);
    font-weight: 600;
}

.credit-settings-page .existing-rules-type-filter .notification-count {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.72rem;
    flex-shrink: 0;
}

.credit-settings-page .existing-rules-type-filter.is-off .notification-count {
    opacity: 0.85;
}

.credit-settings-page .existing-rules-type-filter.is-off {
    background: var(--ma-surface-card);
    color: var(--ma-text-muted);
    border-color: var(--ma-border);
    font-weight: 500;
    opacity: 0.75;
}

.credit-settings-page .existing-rules-type-filter:hover {
    border-color: var(--ma-color-primary);
}

.credit-settings-page .existing-rules-disabled-filter {
    background: var(--ma-surface-card);
    color: var(--ma-text-muted);
    border-color: var(--ma-border);
    font-weight: 500;
}

.credit-settings-page .existing-rules-disabled-filter:hover {
    background: var(--ma-surface-muted);
    color: var(--ma-text-body);
    border-color: var(--ma-border-strong);
}

.credit-settings-page .existing-rules-toggle:hover {
    background: transparent;
    color: var(--ma-color-primary-active);
}

.credit-settings-page .existing-rules-toggle:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
    border-radius: var(--ma-radius-sm);
}

.credit-settings-page .collapsible-card-toggle {
    display: flex;
    width: 100%;
    align-items: flex-start;
    gap: 0.625rem;
    border: 0;
    border-bottom: 1px solid var(--ma-border);
    color: var(--ma-text-heading);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.credit-settings-page .collapsible-card-toggle:hover {
    background: var(--ma-surface-table-header);
}

.credit-settings-page .collapsible-card-toggle:focus-visible {
    outline: none;
    box-shadow: inset var(--ma-focus-ring);
}

.credit-settings-page .collapsible-arrow {
    width: 0;
    height: 0;
    margin-top: 0.45rem;
    flex: 0 0 auto;
    border-top: 0.35rem solid transparent;
    border-bottom: 0.35rem solid transparent;
    border-left: 0.45rem solid currentColor;
    transition: transform var(--ma-transition-fast);
}

.credit-settings-page .collapsible-toggle[aria-expanded="true"] .collapsible-arrow {
    transform: rotate(90deg);
}

.credit-settings-page .notification-count {
    display: inline-flex;
    width: 1.5rem;
    height: 1.5rem;
    align-items: center;
    justify-content: center;
    border-radius: var(--ma-radius-pill);
    background: var(--ma-color-primary);
    color: var(--ma-text-on-primary);
    font-size: 0.78rem;
    line-height: 1;
}

.credit-settings-page .collapsible-card-toggle > .notification-count,
.credit-settings-page .existing-rules-toggle > .notification-count {
    margin-top: 0.15rem;
    margin-left: auto;
    flex: 0 0 auto;
}

.credit-settings-page .grant-rule-replace-banner {
    margin: 0;
    max-width: 22rem;
    text-align: right;
    color: var(--ma-color-warning);
    background: var(--ma-color-warning-muted-bg);
    border: 1px solid color-mix(in srgb, var(--ma-color-warning) 35%, var(--ma-border));
    border-radius: var(--ma-radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    line-height: 1.3;
    flex-shrink: 0;
}

.credit-settings-page #grantRuleForm.grant-rule-form-readonly input:disabled,
.credit-settings-page #grantRuleForm.grant-rule-form-readonly select:disabled,
.credit-settings-page #grantRuleForm.grant-rule-form-readonly button:disabled {
    background: var(--ma-surface-muted);
    color: var(--ma-text-muted);
    cursor: default;
    opacity: 1;
}

.credit-settings-page #grantRuleForm.grant-rule-form-readonly .purchase-tier-remove,
.credit-settings-page #grantRuleForm.grant-rule-form-readonly #addPurchaseTier {
    display: none;
}

.credit-settings-page #grant-rule-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
}

.credit-settings-page #grant-rule-table thead th {
    padding: 0.65rem 0.75rem;
    border-top: 1px solid var(--ma-border-strong);
    border-bottom: 1px solid var(--ma-border-strong);
    background: var(--ma-surface-table-header);
    vertical-align: middle;
}

.credit-settings-page #grant-rule-table thead th:first-child {
    border-left: 1px solid var(--ma-border-strong);
    border-top-left-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table thead th:last-child {
    border-right: 1px solid var(--ma-border-strong);
    border-top-right-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table thead tr:hover,
.credit-settings-page #grant-rule-table thead tr:hover > th {
    background: var(--ma-surface-table-header);
}

.credit-settings-page #grant-rule-table .grant-rule-type-column {
    display: none;
}

.credit-settings-page #grant-rule-table .grant-rule-config-column {
    width: auto;
    min-width: 18rem;
}

.credit-settings-page #grant-rule-table .grant-rule-rule-column {
    width: 14rem;
    min-width: 0;
    overflow-wrap: anywhere;
}

.credit-settings-page #grant-rule-table .grant-rule-actions-column,
.credit-settings-page #grant-rule-table .grant-rule-actions {
    width: auto;
    min-width: 17rem;
    white-space: nowrap;
    vertical-align: top;
    text-align: right;
}

.credit-settings-page #grant-rule-table .grant-rule-actions .btn + .btn {
    margin-left: 0.35rem;
}

/*
 * Grant rules ≤1099px: thead no longer fits — use labeled cards.
 * Type on each card; hide grouping bands (desktop/wide still uses bands).
 */
@media (max-width: 1099px) {
    .credit-settings-page .table-scroll:has(> #grant-rule-table.ma-table-cards) {
        overflow-x: visible;
        -webkit-overflow-scrolling: auto;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards {
        table-layout: auto;
        min-width: 0 !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards thead {
        display: none !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody {
        display: block;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-type-band {
        display: none !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row-alt,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row:hover,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row.is-section-collapsed {
        display: block !important;
        margin: 0 0 0.75rem !important;
        padding: 0.55rem 0.75rem !important;
        background: var(--ma-surface-card) !important;
        border: 1px solid var(--ma-border);
        border-radius: var(--ma-radius-md);
        box-shadow: var(--ma-shadow-elevation-1);
        pointer-events: auto;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row > td,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-type-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-enabled-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-rule-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-config-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-actions,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-actions-column {
        display: grid !important;
        grid-template-columns: 5.25rem minmax(0, 1fr);
        gap: 0.3rem 0.65rem;
        align-items: start;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0.35rem 0 !important;
        text-align: left !important;
        white-space: normal !important;
        vertical-align: top;
        overflow: visible !important;
        pointer-events: auto;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody td::before {
        content: attr(data-label);
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--ma-text-muted);
        line-height: 1.35;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row.is-section-collapsed > td {
        padding: 0.35rem 0 !important;
        border-bottom-color: transparent;
        border-left-color: transparent;
        border-right-color: transparent;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row > td + td {
        border-top: 1px solid var(--ma-border) !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-row-cell {
        display: block;
        overflow: visible !important;
        max-height: none !important;
        opacity: 1 !important;
        width: 100%;
        min-width: 0;
        min-height: 1.35rem;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Type"],
    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Enabled"],
    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Actions"] {
        align-items: center;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-type-value {
        display: inline-block;
        font-weight: 600;
        color: var(--ma-text-heading);
        line-height: 1.35;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Enabled"] .grant-rule-row-cell {
        display: flex;
        align-items: center;
        min-height: 1.5rem;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-enabled {
        flex: 0 0 1.25rem;
        width: 1.25rem !important;
        height: 1.25rem !important;
        margin: 0;
        padding: 0;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-description:empty {
        display: none;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-date-range {
        margin-top: 0;
        line-height: 1.35;
        font-size: 0.85rem;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-date-value {
        font-size: 0.9rem;
        font-weight: 600;
        white-space: nowrap;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-config,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-summary {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0.45rem 0.6rem;
        border: 1px solid color-mix(in srgb, var(--ma-color-primary) 25%, var(--ma-border));
        border-radius: var(--ma-radius-md);
        background: color-mix(in srgb, var(--ma-color-primary) 8%, var(--ma-surface-muted));
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: normal;
        font-family: inherit;
        font-size: 0.9rem;
        font-weight: 500;
        line-height: 1.4;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Actions"] .grant-rule-row-cell {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
        max-width: none;
        width: 100%;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Actions"] .btn {
        width: auto;
        flex: 0 1 auto;
        max-width: 9rem;
        margin: 0 !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards td[data-label="Actions"] .btn + .btn {
        margin-left: 0 !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-disabled > td:not(.grant-rule-actions) {
        opacity: 1;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-disabled > td:not(.grant-rule-actions) .grant-rule-row-cell {
        opacity: 0.45;
    }

    .credit-settings-page .existing-rules-section:not(.show-disabled) #grant-rule-table.ma-table-cards tbody tr.grant-rule-disabled {
        display: none !important;
    }

    .credit-settings-page #grant-rule-table .grant-rule-actions-column,
    .credit-settings-page #grant-rule-table .grant-rule-actions {
        min-width: 0;
        white-space: normal;
    }
}

/* Narrow phones: tighter cards, closer label|value, smaller config JSON */
@media (max-width: 449px) {
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row-alt,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row:hover,
    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row.is-section-collapsed {
        padding: 0.4rem 0.4rem !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody tr.grant-rule-row > td,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-type-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-enabled-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-rule-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-config-column,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-actions,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-actions-column {
        grid-template-columns: 3.35rem minmax(0, 1fr);
        gap: 0.2rem 0.3rem;
        padding: 0.3rem 0 !important;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards tbody td::before {
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-config,
    .credit-settings-page #grant-rule-table.ma-table-cards .grant-rule-summary {
        padding: 0.35rem 0.45rem;
        font-size: 0.85rem;
        line-height: 1.35;
    }

    .credit-settings-page .shopify-import-preview > .shopify-import-card-header {
        padding: 0.45rem 0.5rem;
    }

    .credit-settings-page .shopify-import-preview > .shopify-import-card-header .card-title {
        font-size: 0.9rem;
    }

    .credit-settings-page .shopify-import-body {
        padding: 0.4rem;
    }

    .credit-settings-page .shopify-import-toolbar {
        padding: 0;
        gap: 0.45rem;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody tr {
        padding: 0.4rem 0.4rem;
        margin-bottom: 0.55rem;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody td {
        grid-template-columns: 4.75rem minmax(0, 1fr);
        gap: 0.2rem 0.35rem;
        padding: 0.28rem 0;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-col-select {
        grid-template-columns: 4.75rem auto;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody td::before {
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .credit-settings-page #product-table.ma-table-cards tbody tr {
        padding: 0.35rem 0.4rem;
        margin-bottom: 0.5rem;
    }

    .credit-settings-page #product-table.ma-table-cards tbody td,
    .credit-settings-page #product-table.ma-table-cards .product-col-enabled,
    .credit-settings-page #product-table.ma-table-cards td[data-label="Actions"] {
        grid-template-columns: 4.75rem minmax(0, 1fr);
        gap: 0.2rem 0.3rem;
        padding: 0.28rem 0;
    }

    .credit-settings-page #product-table.ma-table-cards .product-col-enabled {
        grid-template-columns: 4.75rem auto;
    }

    .credit-settings-page #product-table.ma-table-cards tbody td::before {
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-sku,
    .credit-settings-page #product-table.ma-table-cards input.product-name,
    .credit-settings-page #product-table.ma-table-cards input.product-shopify-id,
    .credit-settings-page #product-table.ma-table-cards input.product-credits,
    .credit-settings-page #product-table.ma-table-cards select.product-category {
        padding: 0.4rem 0.4rem;
        font-size: 0.8rem;
    }

    .credit-settings-page #product-table.ma-table-cards select.product-category {
        max-width: 8rem !important;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-shopify-id {
        max-width: 8.75rem !important;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-credits {
        width: 2.35rem !important;
        min-width: 2.35rem !important;
        max-width: 2.35rem !important;
        padding: 0.4rem 0.2rem;
    }

    .credit-settings-page #grantProductsContent.card-content {
        padding: 0.5rem 0.2rem 0.55rem;
    }
}

@media (min-width: 1100px) {
    .credit-settings-page .existing-rules-table-controls {
        position: absolute;
        top: 0;
        right: 0;
        z-index: 2;
        box-sizing: border-box;
        height: 2.85rem;
        margin: 0;
        padding: 0 0.75rem;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
        border-top: 1px solid transparent;
        border-top-right-radius: var(--ma-radius-lg);
    }

    .credit-settings-page .existing-rules-type-filters {
        flex-wrap: nowrap;
        justify-content: flex-end;
    }
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band > th,
.credit-settings-page #grant-rule-table tbody tr.grant-rule-row > td {
    border-bottom: 1px solid var(--ma-border);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band > th,
.credit-settings-page #grant-rule-table tbody tr.grant-rule-row > td.grant-rule-enabled-column {
    border-left: 1px solid var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band > th,
.credit-settings-page #grant-rule-table tbody tr.grant-rule-row > td:last-child {
    border-right: 1px solid var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band > th {
    padding: 0.5rem 0.75rem;
    text-align: left;
    vertical-align: middle;
    border-bottom-color: var(--ma-border-strong);
    background: var(--ma-surface-card-header);
    color: var(--ma-text-heading);
    font-weight: 600;
    box-shadow: inset 6px 0 0 var(--ma-color-primary);
}

.credit-settings-page #grant-rule-table .grant-rule-type-band-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    padding: 0;
    border: 1.5px solid var(--ma-color-primary);
    border-radius: 2px;
    background: transparent;
    color: var(--ma-color-primary);
    cursor: pointer;
    line-height: 1;
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle:hover {
    background: var(--ma-primary-soft-bg);
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle:focus-visible {
    outline: none;
    box-shadow: var(--ma-focus-ring);
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon {
    position: relative;
    display: block;
    width: 0.55rem;
    height: 0.55rem;
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon::before,
.credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon::after {
    content: '';
    position: absolute;
    background: currentColor;
    border-radius: 1px;
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon::before {
    left: 0;
    right: 0;
    top: 50%;
    height: 1.5px;
    transform: translateY(-50%);
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon::after {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1.5px;
    transform: translateX(-50%) scaleY(0);
    transform-origin: center;
    transition: transform var(--ma-transition-fast);
}

.credit-settings-page #grant-rule-table .grant-rule-type-toggle[aria-expanded="false"] .grant-rule-type-toggle-icon::after {
    transform: translateX(-50%) scaleY(1);
}

.credit-settings-page #grant-rule-table .grant-rule-type-band-label {
    min-width: 0;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band.is-collapsed > th {
    border-bottom-color: var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band-next > th {
    border-top: 2px solid var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table .grant-rule-row-cell {
    overflow: hidden;
    max-height: 40rem;
    opacity: 1;
    transition: max-height 220ms ease, opacity 180ms ease;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row > td {
    transition: padding 220ms ease, border-bottom-color 180ms ease;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row.is-section-collapsed > td {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom-color: transparent;
    border-left-color: transparent;
    border-right-color: transparent;
    pointer-events: none;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row.is-section-collapsed .grant-rule-row-cell {
    max-height: 0;
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .credit-settings-page #grant-rule-table .grant-rule-row-cell,
    .credit-settings-page #grant-rule-table tbody tr.grant-rule-row > td,
    .credit-settings-page #grant-rule-table .grant-rule-type-toggle-icon::after {
        transition: none;
    }
}

.credit-settings-page #grant-rule-table tbody tr:last-child > td {
    border-bottom: 1px solid var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table tbody tr:last-child > td.grant-rule-enabled-column {
    border-bottom-left-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table tbody tr:last-child > td:last-child {
    border-bottom-right-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table:not(:has(tbody tr)) thead th {
    border-bottom: 1px solid var(--ma-border-strong);
}

.credit-settings-page #grant-rule-table:not(:has(tbody tr)) thead th:first-child {
    border-bottom-left-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table:not(:has(tbody tr)) thead th:last-child {
    border-bottom-right-radius: var(--ma-radius-lg);
}

.credit-settings-page #grant-rule-table .grant-rule-description {
    color: var(--ma-text-body);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
}

.credit-settings-page #grant-rule-table .grant-rule-date-range {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.1rem 0.35rem;
    color: var(--ma-text-muted);
    font-size: 0.85rem;
    text-align: left;
    margin-top: 0.15rem;
}

.credit-settings-page #grant-rule-table .grant-rule-date-line {
    white-space: nowrap;
}

.credit-settings-page #grant-rule-table .grant-rule-date-value {
    color: var(--ma-color-primary);
    font-size: 1rem;
    font-weight: 600;
}

.credit-settings-page #grant-rule-table .grant-rule-config,
.credit-settings-page #grant-rule-table .grant-rule-summary {
    margin: 0;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--ma-text-body);
    text-align: left;
}

.credit-settings-page #grant-rule-table .grant-rule-enabled-column {
    width: 5.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    text-align: center;
    vertical-align: top;
    white-space: nowrap;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row {
    background: var(--ma-surface-card);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row-alt {
    background: var(--ma-surface-muted);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-disabled > td:not(.grant-rule-actions) {
    opacity: 0.4;
}

.credit-settings-page .existing-rules-section:not(.show-disabled) #grant-rule-table tbody tr.grant-rule-disabled {
    display: none;
}

.credit-settings-page .existing-rules-section:not(.show-disabled) #grant-rule-table tbody tr.grant-rule-type-band[data-has-enabled="false"] {
    display: none;
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band:hover,
.credit-settings-page #grant-rule-table tbody tr.grant-rule-type-band:hover > th {
    background: var(--ma-surface-card-header);
}

.credit-settings-page #grant-rule-table tbody tr.grant-rule-row:hover {
    background: var(--ma-surface-dropdown-hover) !important;
}

@media (max-width: 768px) {
    .credit-settings-page table.ma-table-cards {
        table-layout: auto;
        width: 100% !important;
    }

    .credit-settings-page table.ma-table-cards colgroup {
        display: none;
    }

    .credit-settings-page table.ma-table-cards thead {
        display: none !important;
    }

    /* Spend actions: label | value on one row (writable fields stay easy to scan) */
    .credit-settings-page #spend-table.ma-table-cards tbody td {
        grid-template-columns: 9.5rem minmax(0, 1fr);
        gap: 0.35rem 0.75rem;
        align-items: center;
        text-align: left !important;
    }

    .credit-settings-page #spend-table.ma-table-cards tbody td::before {
        display: block;
        line-height: 1.25;
    }

    .credit-settings-page #spend-table.ma-table-cards input.spend-cost,
    .credit-settings-page #spend-table.ma-table-cards input.spend-desc {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    .credit-settings-page #spend-table.ma-table-cards td[data-label="Actions"] {
        grid-template-columns: 9.5rem minmax(0, 1fr);
        align-items: center;
    }

    .credit-settings-page #spend-table.ma-table-cards td[data-label="Actions"] .btn {
        width: auto;
        max-width: 9rem;
        margin: 0;
    }

    .credit-settings-page .shopify-import-toolbar {
        grid-template-columns: 1fr;
        justify-items: stretch;
        padding: 0;
        gap: 0.55rem;
    }

    .credit-settings-page .shopify-import-preview > .shopify-import-card-header {
        padding: 0.55rem 0.65rem;
    }

    .credit-settings-page .shopify-import-preview > .shopify-import-card-header .card-title {
        font-size: 0.95rem;
    }

    .credit-settings-page .shopify-import-body {
        padding: 0.55rem;
    }

    .credit-settings-page .shopify-import-counts,
    .credit-settings-page .shopify-match-filters,
    .credit-settings-page .shopify-import-actions {
        justify-self: stretch;
    }

    .credit-settings-page .shopify-match-filters {
        justify-content: flex-start;
    }

    .credit-settings-page .shopify-import-actions {
        width: 100%;
    }

    .credit-settings-page .shopify-import-actions .btn {
        flex: 1 1 auto;
    }

    .credit-settings-page .toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Parent↔child: drop default 1.5rem card-content sides when product rows are cards */
    .credit-settings-page #grantProductsContent.card-content {
        padding: 0.65rem 0.35rem 0.7rem;
    }

    .credit-settings-page table.ma-table-cards .form-group.table-form-group {
        width: 100%;
        margin: 0;
    }

    .credit-settings-page table.ma-table-cards input[type="text"],
    .credit-settings-page table.ma-table-cards input[type="number"],
    .credit-settings-page table.ma-table-cards select {
        width: 100%;
        max-width: none;
        min-width: 0;
        box-sizing: border-box;
    }

    /* Shopify preview cards: reset desktop col widths; tighten label|value */
    .credit-settings-page #shopify-preview-table.ma-table-cards {
        min-width: 0 !important;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody tr {
        padding: 0.5rem 0.55rem;
        margin-bottom: 0.7rem;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody td,
    .credit-settings-page #shopify-preview-table.ma-table-cards [class*="shopify-col-"] {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards tbody td {
        grid-template-columns: 5.75rem minmax(0, 1fr);
        gap: 0.3rem 0.5rem;
        align-items: start;
        padding: 0.35rem 0;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-col-select {
        grid-template-columns: 5.75rem auto;
        align-items: center;
        justify-items: start;
        text-align: left !important;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-col-select input {
        margin: 0;
        justify-self: start;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-match-cell {
        width: 100%;
        min-width: 0;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-identity-cell,
    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-field-value,
    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-field-current,
    .credit-settings-page #shopify-preview-table.ma-table-cards td.shopify-col-type {
        white-space: normal;
        overflow-wrap: break-word;
        word-break: normal;
        min-width: 0;
        max-width: 100%;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards td.shopify-col-sku .shopify-field-value,
    .credit-settings-page #shopify-preview-table.ma-table-cards td.shopify-col-sku .shopify-field-current,
    .credit-settings-page #shopify-preview-table.ma-table-cards td.shopify-col-product-id .shopify-field-value,
    .credit-settings-page #shopify-preview-table.ma-table-cards td.shopify-col-product-id .shopify-field-current {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .credit-settings-page #shopify-preview-table.ma-table-cards .shopify-field-choice {
        flex-wrap: wrap;
        white-space: normal;
    }

    .credit-settings-page #product-table.ma-table-cards .product-col-enabled {
        grid-template-columns: 5.5rem auto;
        align-items: center;
        justify-items: start;
        text-align: left !important;
    }

    .credit-settings-page #product-table.ma-table-cards .product-col-enabled input {
        margin: 0;
        justify-self: start;
    }

    /* Grant products: desktop column % widths crush card cells — force full-width rows */
    .credit-settings-page #product-table.ma-table-cards tbody td,
    .credit-settings-page #product-table.ma-table-cards [class*="product-col-"] {
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
    }

    .credit-settings-page #product-table.ma-table-cards tbody tr {
        padding: 0.45rem 0.5rem;
        margin-bottom: 0.65rem;
    }

    .credit-settings-page #product-table.ma-table-cards tbody td {
        grid-template-columns: 5.5rem minmax(0, 1fr);
        gap: 0.25rem 0.4rem;
        align-items: center;
        padding: 0.32rem 0;
    }

    .credit-settings-page #product-table.ma-table-cards tbody td::before {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-sku,
    .credit-settings-page #product-table.ma-table-cards input.product-name {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
    }

    .credit-settings-page #product-table.ma-table-cards select.product-category {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 8.5rem !important;
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-credits {
        width: 2.5rem !important;
        min-width: 2.5rem !important;
        max-width: 2.5rem !important;
        padding: 0.45rem 0.25rem;
        font-size: 0.85rem;
        text-align: center;
    }

    .credit-settings-page #product-table.ma-table-cards input.product-shopify-id {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 9.25rem !important;
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
    }

    .credit-settings-page #product-table.ma-table-cards .product-credits-field {
        width: auto;
        max-width: 2.5rem;
    }

    .credit-settings-page #product-table.ma-table-cards tbody tr,
    .credit-settings-page #product-table.ma-table-cards tbody tr:nth-child(even),
    .credit-settings-page #product-table.ma-table-cards tbody tr:hover {
        background: var(--ma-surface-card) !important;
    }

    .credit-settings-page #product-table.ma-table-cards td[data-label="Actions"] {
        grid-template-columns: 5.5rem minmax(0, 1fr);
        align-items: center;
    }

    .credit-settings-page #product-table.ma-table-cards td[data-label="Actions"] .product-row-actions {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
        max-width: none;
        width: 100%;
    }

    .credit-settings-page #product-table.ma-table-cards td[data-label="Actions"] .btn {
        width: auto;
        flex: 0 1 auto;
        max-width: 9rem;
        margin: 0;
    }

    .credit-settings-page #product-table.ma-table-cards .product-credits-na {
        display: inline-block;
        line-height: 1.4;
    }

    .credit-settings-page #spend-table.ma-table-cards td[data-label="Actions"] .btn {
        width: auto;
        flex: 0 1 auto;
        max-width: 9rem;
        margin: 0;
    }

    .credit-settings-page #grantRuleForm .form-grid {
        grid-template-columns: 1fr;
    }

    .credit-settings-page #grantRuleForm .form-grid > .form-group,
    .credit-settings-page #grantRuleForm .form-grid > .form-actions {
        grid-row: auto !important;
        grid-column: 1 / -1 !important;
    }

    .credit-settings-page #grantRuleForm .purchase-tier-columns,
    .credit-settings-page #grantRuleForm .purchase-tier-row {
        grid-template-columns: 1fr;
    }

    .credit-settings-page #grantRuleForm .purchase-tier-columns span:last-child {
        display: none;
    }

    .credit-settings-page .product-purchase-preview-table {
        width: 100%;
    }

    .credit-settings-page .grant-rules-subheader {
        flex-direction: column;
        align-items: stretch;
    }

    .credit-settings-page .grant-rules-header-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .credit-settings-page #product-table .product-col-actions {
        white-space: normal;
    }
}
/* Collections: hide Advanced Search below --ma-bp-lg (1024px) */
@media (max-width: 1024px) {
    .advanced-search-btn {
        display: none !important;
    }
}

/* Collection Advanced Search page */
.collection-advanced-search-page .back-link {
    margin: 0 0 0.5rem;
}

.collection-advanced-search-page .page-header {
    margin-bottom: 1rem;
}

.collection-search-filters .card-content {
    padding: 0.85rem 1rem;
}

.adv-search-primary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 0.75rem 1rem;
    align-items: start;
}

.adv-search-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    margin: 0;
}

.adv-search-field > label,
.adv-search-range > legend {
    margin: 0;
    padding: 0;
    font-weight: 600;
    color: var(--ma-text-heading);
    font-size: 0.85rem;
    line-height: 1.25;
}

.adv-search-field > input,
.adv-search-field > select {
    width: 100%;
    height: 2.625rem;
}

.adv-search-field .user-picker-control {
    min-height: 2.625rem;
    padding-top: 0;
    padding-bottom: 0;
}

.adv-search-more {
    margin-top: 0.75rem;
}

.adv-search-more > summary {
    cursor: pointer;
    width: max-content;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--ma-color-primary);
}

.adv-search-more-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.75rem 1rem;
    margin-top: 0.6rem;
}

.adv-search-range {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
}

.adv-search-range-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ma-text-muted);
    font-size: 0.85rem;
}

.adv-search-range-inputs input {
    flex: 1 1 0;
    min-width: 0;
}

.adv-search-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.collection-search-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
}

.collection-search-local-note {
    flex: 1 1 14rem;
    margin: 0;
    color: var(--ma-text-muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.adv-search-active {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: 0.75rem 0;
}

.adv-search-active-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ma-text-muted);
}

.adv-search-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.3rem 0.2rem 0.6rem;
    border: 1px solid var(--ma-border);
    border-radius: 999px;
    background: var(--ma-primary-soft-bg);
    font-size: 0.8rem;
    color: var(--ma-text-heading);
}

.adv-search-chip--plain {
    padding-right: 0.6rem;
}

.adv-search-chip button {
    border: none;
    background: transparent;
    color: var(--ma-text-muted);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.2rem;
}

.adv-search-chip button:hover {
    color: var(--ma-text-heading);
}

.adv-search-results .card-content {
    padding: 0.85rem 1rem;
}

.adv-search-refine {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem 0.75rem;
    align-items: start;
}

.adv-search-field--wide {
    grid-column: 1 / -1;
}

.user-picker-count {
    color: var(--ma-text-muted);
    font-size: 0.8em;
}

.collection-search-meta {
    margin: 0.75rem 0 0.5rem;
    color: var(--ma-text-muted);
    font-size: 0.9rem;
}

.user-picker {
    position: relative;
}

/* The picker's dropdown hangs below the field, so its card must not clip it. */
.card:has(.user-picker) {
    overflow: visible;
}

.card:has(.user-picker) > .card-header:first-child {
    border-radius: var(--ma-radius-lg) var(--ma-radius-lg) 0 0;
}

.user-picker-control {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
}

.user-picker-control:focus-within {
    border-color: var(--ma-color-primary);
    box-shadow: 0 0 0 3px var(--ma-primary-soft-bg);
}

.user-picker.is-disabled .user-picker-control {
    background: var(--ma-surface-muted);
    cursor: not-allowed;
}

.user-picker-control input,
.user-picker-control input:focus {
    box-shadow: none;
}

.user-picker-control input {
    flex: 1 1 10rem;
    min-width: 8rem;
    border: none;
    outline: none;
    background: transparent;
    padding: 0.25rem;
    font: inherit;
    color: var(--ma-text-body);
}

/* Holds the clear button; sits after the input although it comes first in the markup. */
.user-picker-actions {
    display: contents;
}

.user-picker-clear {
    order: 2;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--ma-text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 0.25rem;
}

.user-picker-clear:hover {
    color: var(--ma-text-heading);
}

.user-picker-control input {
    order: 1;
    text-overflow: ellipsis;
}

.user-picker-dropdown {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid var(--ma-border);
    border-radius: var(--ma-radius-md);
    background: var(--ma-surface-card);
    box-shadow: var(--ma-shadow-elevation-2, 0 8px 24px rgba(15, 23, 42, 0.12));
}

.user-picker-dropdown li {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    color: var(--ma-text-body);
}

.user-picker-dropdown li:hover,
.user-picker-dropdown li:focus {
    background: var(--ma-surface-dropdown-hover);
}

.user-picker-dropdown li.is-selected {
    font-weight: 600;
    background: var(--ma-primary-soft-bg);
}

.user-picker-dropdown li.user-picker-note {
    cursor: default;
    color: var(--ma-text-muted);
    background: none;
}

.search-box .user-picker,
.user-select .user-picker {
    flex: 0 1 22rem;
    min-width: 16rem;
}

.search-box .user-picker-control input {
    width: auto;
    min-height: 0;
    padding: 0.25rem;
}

.collection-search-table .cell-primary {
    font-weight: 500;
    color: var(--ma-text-heading);
}

.collection-search-table .cell-secondary {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: var(--ma-text-muted);
    line-height: 1.3;
}

.collection-search-table th.is-sortable {
    cursor: pointer;
    user-select: none;
}

.collection-search-table th.is-sortable:hover {
    color: var(--ma-color-primary);
}

.collection-search-table .stmt-col-actions {
    width: 2.75rem;
    text-align: right;
    white-space: nowrap;
}

.collection-search-detail-btn.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: var(--ma-radius-md);
    color: var(--ma-color-primary);
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
}

.collection-search-detail-btn.btn-icon:hover {
    background: var(--ma-primary-soft-bg);
    border-color: var(--ma-border);
}

.collection-search-table-wrap--scroll {
    max-height: min(70vh, 40rem);
    overflow-y: auto;
}

.collection-advanced-search-page .statement-table-wrap.table-scroll {
    overflow-x: auto;
}

#searchBtn.is-loading {
    opacity: 0.75;
    cursor: wait;
}

#resultsMeta,
#resultsContainer {
    scroll-margin-top: 0.75rem;
}
@media (max-width: 768px) {
    .adv-search-primary,
    .adv-search-more-grid {
        grid-template-columns: 1fr;
    }

    .adv-search-refine {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
