/* ============================================
   Reports Module — Global Styles
   Aligns with app.css design system (CSS vars).
   ============================================ */

/* ── Reports hub cards ── */
.reports-hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.reports-hub-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: transform var(--motion-duration-base, 200ms) var(--motion-ease, ease),
                box-shadow var(--motion-duration-base, 200ms) var(--motion-ease, ease),
                border-color var(--motion-duration-base, 200ms) var(--motion-ease, ease);
}

.reports-hub-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--primary) 25%, var(--border-color));
}

.reports-hub-card .icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 0.25rem;
}

.reports-hub-card .icon.giving { background: linear-gradient(135deg, #10b981, #059669); }
.reports-hub-card .icon.events { background: linear-gradient(135deg, #6366f1, #4338ca); }
.reports-hub-card .icon.members { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.reports-hub-card .icon.merch { background: linear-gradient(135deg, #f59e0b, #b45309); }

.reports-hub-card h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.reports-hub-card p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Date Range Picker ── */
.date-range-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
}

.date-range-picker .presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.date-range-picker .preset-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 999px;
    font-size: 0.825rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 150ms ease;
}

.date-range-picker .preset-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.date-range-picker .preset-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.date-range-picker .inputs {
    display: flex;
    gap: 0.75rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.date-range-picker .inputs label {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    gap: 0.25rem;
    font-weight: 600;
}

.date-range-picker .inputs input[type="date"] {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-card);
}

/* ── Report cards / chart wrapper ── */
.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.report-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.report-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 12px);
    gap: 0.5rem;
    text-align: center;
}

/* Direct-child icon only — the previous `.report-empty-state i` selector
   also styled icons inside CTA buttons (e.g. "Add your first widget",
   "Open Report Builder"), blowing them up to 2.75rem and making the
   buttons huge (Admin Bug #3 + #5). */
.report-empty-state > i {
    font-size: 2.75rem;
    display: block;
    color: var(--text-muted);
}

/* ── Tabular results ── */
.report-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    background: var(--bg-card);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 0;
}

/* Admin Bug #1 (dark mode): align report tables with the rest of the
   admin design system (matches `.data-table` in app.css). The previous
   rule used `background: var(--text-primary)` which inverts in dark mode
   to a near-white header behind white text. */
.report-table thead th {
    background: var(--bg-body);
    color: var(--text-secondary);
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.report-table tbody tr:nth-child(even) {
    background: transparent;
}

.report-table tbody tr:hover td {
    background: var(--bg-table-hover);
}

.report-table tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    vertical-align: middle;
}

/* ── Export Dropdown ── */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown .menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    box-shadow: var(--shadow-lg, 0 12px 32px rgba(15, 23, 42, 0.15));
    z-index: 100;
    overflow: hidden;
    padding: 0.25rem;
}

.export-dropdown .menu button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 0;
    background: transparent;
    text-align: left;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: var(--radius-sm, 6px);
}

.export-dropdown .menu button:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.export-dropdown .menu button i {
    font-size: 1.1rem;
}

/* ── Builder steps ──────────────────────────────────────────────
 * Centered horizontal stepper: numbered circles connected by dotted
 * lines, with the step label rendered directly beneath each circle.
 * Three states drive color and weight:
 *   - .done    completed step  (filled primary circle, check icon)
 *   - .active  current step    (outlined primary circle, halo)
 *   - default  upcoming step   (muted)
 * The connector is drawn via a ::after pseudo on each <li>; the last
 * item hides its connector so the rail stops at the final circle.
 */
.builder-steps {
    list-style: none;
    margin: 0 auto 1.75rem;
    padding: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    max-width: 920px;
}

.builder-steps li {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 0.25rem;
    gap: 0.5rem;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--text-secondary, #6b7280);
    font-size: 0.8rem;
    line-height: 1.2;
    transition: color 150ms ease;
}

.builder-steps li::after {
    content: "";
    position: absolute;
    top: 18px; /* vertically centered on the 36px circle */
    left: calc(50% + 22px);
    right: calc(-50% + 22px);
    height: 0;
    border-top: 2px dotted var(--border-color, #d1d5db);
    z-index: 0;
}

.builder-steps li:last-child::after {
    display: none;
}

.builder-steps .step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-main, #f3f4f6);
    color: var(--text-secondary, #6b7280);
    border: 2px solid var(--border-color, #d1d5db);
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.builder-steps li.done {
    color: var(--text, #111827);
}

.builder-steps li.done .step-number {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.builder-steps li.active {
    color: var(--primary);
    font-weight: 600;
}

.builder-steps li.active .step-number {
    background: #fff;
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light, rgba(99, 102, 241, 0.15));
}

/* Once the previous step is done (or active for the current connector),
 * the rail becomes solid + branded so progress reads clearly. */
.builder-steps li.done::after,
.builder-steps li.active::after {
    border-top-style: solid;
    border-top-color: var(--primary);
}

@media (max-width: 640px) {
    .builder-steps {
        margin-bottom: 1.25rem;
    }
    .builder-steps li {
        font-size: 0.7rem;
    }
    .builder-steps .step-number {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }
    .builder-steps li::after {
        top: 15px;
        left: calc(50% + 18px);
        right: calc(-50% + 18px);
    }
}

/* ── Builder cards & form rows ── */
.builder-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.builder-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.builder-card h4 {
    margin: 1rem 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.builder-card .text-muted {
    color: var(--text-muted);
}

.domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.domain-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    cursor: pointer;
    color: var(--text-primary);
    font-weight: 600;
    transition: all 150ms ease;
    font-size: 0.95rem;
}

.domain-card i {
    font-size: 1.85rem;
    color: var(--primary);
    transition: color 150ms ease;
}

.domain-card:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.domain-card.selected {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-dark);
    box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.25);
}

.domain-card.selected i {
    color: #fff;
}

.metric-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.metric-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 150ms ease;
}

.metric-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.metric-item input {
    margin: 0;
    accent-color: var(--primary);
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

@media (max-width: 768px) {
    .filter-row {
        grid-template-columns: 1fr;
    }
}

.builder-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    margin-top: 0.75rem;
    align-items: end;
}

.builder-form-row label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.builder-form-row label.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    padding-bottom: 0.4rem;
}

.builder-form-row label.checkbox-row input {
    accent-color: var(--primary);
}

.builder-nav {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.builder-preview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
}

/* ── Saved reports ── */
.saved-reports-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.saved-reports-section > h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.saved-reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.85rem;
}

.saved-report-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    transition: all 150ms ease;
}

.saved-report-card:hover {
    border-color: color-mix(in srgb, var(--primary) 30%, var(--border-color));
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.saved-report-card .title {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
}

.saved-report-card .title i {
    font-size: 1.5rem;
    color: var(--primary);
}

.saved-report-card .title h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.saved-report-card .title p {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.saved-report-card .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.saved-report-card .actions {
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
    padding-top: 0.4rem;
}

.saved-report-empty {
    padding: 1.5rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius, 8px);
}

/* Reusable chip/pill */
.reports-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.18rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.reports-chip.shared {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}

.reports-chip.owner {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

/* Page-level layout for report pages */
.report-page-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ============================================
   Reports Builder - revamped controls (v2)
   ============================================ */

/* Filter row layout: field + operator + value + remove button. */
.rb-filter-row {
    grid-template-columns: minmax(180px, 1.2fr) minmax(150px, 1fr) minmax(180px, 1.4fr) auto;
    gap: 0.65rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.6rem;
    align-items: end;
}

.filter-list .rb-filter-row:last-child { margin-bottom: 0; }

.rb-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.rb-field-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.rb-field-actions {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 1px;
}

/* Custom-styled native select / input that match the rest of the admin UI
   without relying on Bootstrap's form-select which clashes with our spacing. */
.rb-select,
.rb-input {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 38px;
    padding: 0 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.2;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.rb-select {
    padding-right: 2rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='%23667085' d='M8 11L3 6h10z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 14px;
    cursor: pointer;
}

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

.rb-input::placeholder { color: var(--text-muted); }

/* Toggle switch - replaces native checkboxes everywhere in the builder. */
.rb-toggle {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    background: var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    transition: background 150ms ease;
    flex-shrink: 0;
}

.rb-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.rb-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 150ms ease;
}

.rb-toggle.on { background: var(--primary); }
.rb-toggle.on .rb-toggle-thumb { transform: translateX(16px); }

/* Metric tile shows the toggle on the right; selected state highlights it. */
.metric-item {
    justify-content: space-between;
}

.metric-item.selected {
    background: var(--primary-light);
    border-color: var(--primary);
}

.metric-item .metric-label {
    font-weight: 600;
    color: var(--text-primary);
}

/* Toggle row: label on the left, switch flush right. */
.builder-form-row label.toggle-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0.55rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius, 8px);
}

/* ============================================
   Report Dashboard - draggable/resizable grid
   ============================================ */

.report-dashboard-grid {
    background: transparent;
    min-height: 200px;
    /* Counter gridstack's per-item half-margin so widgets align to the
     * page edges. With margin:12 in JS, gridstack adds 6px on every side
     * of each widget; pulling the grid -6px outward keeps the outer edges
     * flush while preserving the 12px gap _between_ widgets (Bug 3). */
    margin: 0 -6px;
    transition: background-color var(--motion-duration-base) ease, border-color var(--motion-duration-base) ease;
    border-radius: var(--radius-lg, 12px);
    border: 1px dashed transparent;
    padding: 4px 0;
}

/* Belt-and-braces: never let a widget collapse to zero in either mode.
 * GridStack should size these via gs-h, but during the static→editable
 * toggle there's a brief window where the inline height is cleared and
 * recomputed; without a min-height the widget visually disappears. */
.report-dashboard-grid .grid-stack-item {
    min-height: 96px;
}

.report-dashboard-grid .grid-stack-item > .grid-stack-item-content {
    inset: 0;
    min-height: 96px;
}

.report-dashboard-grid.is-editing {
    background: linear-gradient(180deg, rgba(37,99,235,0.04), rgba(37,99,235,0.02));
    border-color: rgba(37,99,235,0.25);
}

.dashboard-editing-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    background: rgba(245,158,11,0.12);
    border: 1px solid rgba(245,158,11,0.40);
    color: #b45309;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
}

.dashboard-editing-pill i { font-size: 0.78rem; }

.dashboard-widget {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow var(--motion-duration-base) ease, transform var(--motion-duration-base) ease;
}

.report-dashboard-grid.is-editing .dashboard-widget {
    box-shadow: var(--shadow-md);
}

.report-dashboard-grid.is-editing .dashboard-widget:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.dashboard-widget-empty {
    border-style: dashed;
}

.dashboard-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    min-height: 48px;
}

.report-dashboard-grid.is-editing .widget-drag-handle {
    cursor: move;
    background: linear-gradient(180deg, var(--bg-secondary), var(--bg-table-hover, var(--bg-secondary)));
}

.dashboard-widget-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
}

.dashboard-widget-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.dashboard-widget-title-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dashboard-widget-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.dashboard-widget-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.1;
    margin-top: 1px;
}

.dashboard-widget-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.btn-icon-only {
    width: 30px;
    height: 30px;
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: background-color var(--motion-duration-fast) ease, color var(--motion-duration-fast) ease, border-color var(--motion-duration-fast) ease;
}

.btn-icon-only:hover:not(:disabled) {
    background: var(--bg-table-hover, var(--bg-secondary));
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-icon-only.btn-icon-danger:hover:not(:disabled) {
    background: rgba(220,38,38,0.10);
    color: var(--danger, #dc2626);
    border-color: rgba(220,38,38,0.35);
}

.btn-icon-only:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

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

.bi.spin {
    display: inline-block;
    animation: spinReport 0.9s linear infinite;
}

.dashboard-widget-body {
    flex: 1;
    padding: 0.85rem 1rem;
    /* Admin Bug #3: never scroll the widget body — the chart inside
       must resize to fit whatever height GridStack assigns to the
       widget. The previous `overflow: auto` produced a vertical scroll
       bar instead of letting ApexCharts re-render at the new size. */
    overflow: hidden;
    min-height: 0;
    min-width: 0;
    position: relative;
}

/* Admin Bug #3: force ApexCharts (and any chart canvas) to fill the
   widget body so resizing the widget actually resizes the chart. */
.dashboard-widget-body > .apexcharts-canvas,
.dashboard-widget-body .apexcharts-canvas,
.dashboard-widget-body .apexcharts-svg {
    width: 100% !important;
    height: 100% !important;
}
.dashboard-widget-body > * {
    max-width: 100%;
}

.dashboard-widget-footer {
    padding: 0.4rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    text-align: right;
    font-size: 0.72rem;
}

.dashboard-widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 2rem 1rem;
}

.dashboard-widget-error {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(245,158,11,0.06);
    border: 1px solid rgba(245,158,11,0.30);
    border-radius: var(--radius, 8px);
}

.dashboard-widget-error i { font-size: 1.25rem; flex-shrink: 0; }

/* Gridstack tweaks */
.grid-stack > .grid-stack-item > .ui-resizable-handle {
    opacity: 0;
    transition: opacity 150ms ease;
}

.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-handle {
    opacity: 0.65;
    /* Make the resize hit-target large enough to grab reliably (Bug 3). */
    z-index: 5;
}

.report-dashboard-grid.is-editing .grid-stack-item:hover > .ui-resizable-handle {
    opacity: 1;
}

/* Edge handles get a thicker hit area; corner handles a square. */
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-e,
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-w {
    width: 10px;
}

.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-n,
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-s {
    height: 10px;
}

.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-se,
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-sw,
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-ne,
.report-dashboard-grid.is-editing .grid-stack-item > .ui-resizable-nw {
    width: 14px;
    height: 14px;
}

.grid-stack-placeholder > .placeholder-content {
    background: var(--primary-light);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg, 12px);
}

/* ============================================
   Add Widget Modal
   ============================================ */

.add-widget-modal {
    max-width: 1080px;
    width: 96vw;
}

.add-widget-modal-body {
    /* The pm-modal-body provides the scroll container; the source list manages its own internal scroll. */
    padding: 0 !important;
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    min-height: 480px;
}

.add-widget-source {
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 70vh;
}

.add-widget-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.75rem 0.75rem 0;
}

.add-widget-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--motion-duration-fast) ease, color var(--motion-duration-fast) ease;
}

.add-widget-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    border-color: var(--border-color);
}

.add-widget-search {
    position: relative;
    padding: 0.75rem;
}

.add-widget-search i {
    position: absolute;
    left: 1.4rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.add-widget-search input {
    padding-left: 2rem;
    background: var(--bg-card);
}

.add-widget-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.add-widget-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: border-color var(--motion-duration-fast) ease, box-shadow var(--motion-duration-fast) ease, background-color var(--motion-duration-fast) ease;
}

.add-widget-item:hover {
    border-color: var(--primary);
}

.add-widget-item.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
}

.add-widget-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.add-widget-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.add-widget-item-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-widget-item-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-widget-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.add-widget-empty i {
    font-size: 1.75rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.add-widget-preview {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    max-height: 70vh;
    overflow-y: auto;
}

.add-widget-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.add-widget-preview-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.add-widget-preview-title i { color: var(--primary); font-size: 1rem; }

.add-widget-preview-subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.add-widget-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.add-widget-controls .form-select,
.add-widget-controls select.form-select {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 0.82rem;
    padding: 0.35rem 1.75rem 0.35rem 0.6rem;
}

.add-widget-controls .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
    outline: none;
}

.add-widget-controls .preset-btn {
    padding: 0.3rem 0.7rem;
    font-size: 0.78rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--motion-duration-fast) ease;
}

.add-widget-controls .preset-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.add-widget-preview-chart {
    flex: 1;
    min-height: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
}

.add-widget-preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--text-muted);
}

.add-widget-preview-empty i { font-size: 2rem; opacity: 0.5; }

@media (max-width: 768px) {
    .add-widget-modal-body {
        grid-template-columns: 1fr;
        max-height: 80vh;
    }
    .add-widget-source {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 40vh;
    }
}

/* Empty state - large variant */
.report-empty-state.large {
    padding: 3.5rem 1.5rem;
    text-align: center;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 12px);
}

.report-empty-state-illustration {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), rgba(37,99,235,0.05));
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.report-empty-state.large h3 { margin-bottom: 0.5rem; }
.report-empty-state.large p {
    color: var(--text-secondary);
    max-width: 460px;
    margin: 0 auto 1.25rem;
}

/* ============================================
   Report Builder - chart type tile picker
   ============================================ */

.chart-type-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    margin: 0.5rem 0 0.25rem;
}

.chart-type-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--motion-duration-fast) ease, background-color var(--motion-duration-fast) ease, transform var(--motion-duration-fast) ease;
}

.chart-type-tile i {
    font-size: 1.6rem;
    color: var(--primary);
}

.chart-type-tile span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-type-tile:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.chart-type-tile.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.20);
}

/* ============================================
   Saved Reports - toolbar, skeleton, card head
   ============================================ */

.saved-reports-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    margin-bottom: 1rem;
}

.saved-reports-search {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 480px;
    display: flex;
    align-items: center;
}

.saved-reports-search > i.bi-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.saved-reports-search input {
    padding-left: 2.25rem;
    padding-right: 2.5rem;
}

.saved-reports-search .btn-icon-only {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
}

.saved-report-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: border-color var(--motion-duration-base) ease, box-shadow var(--motion-duration-base) ease, transform var(--motion-duration-base) ease;
}

.saved-report-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.18);
}

.saved-report-card-head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.saved-report-card-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}

.saved-report-card-title { min-width: 0; flex: 1; }
.saved-report-card-title h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-report-card-title p {
    margin: 0.15rem 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.saved-report-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.saved-report-card-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: auto;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.saved-run-preview {
    margin-top: 1rem;
    border: 1px solid var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.10);
}

/* Skeleton loader */
.saved-report-skeleton {
    pointer-events: none;
}
.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, var(--bg-secondary) 0%, var(--border-color) 50%, var(--bg-secondary) 100%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeletonShimmer 1.4s infinite linear;
}
.skeleton-line + .skeleton-line { margin-top: 0.6rem; }
.skeleton-line-lg { height: 18px; width: 60%; }
.skeleton-line-sm { height: 10px; width: 40%; }
@keyframes skeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ============================================================================
   Report Pages - shared styles (Event/Finance/Merch/Organization,
   single-tenant + Group/Enterprise variants).

   Prefix: .rpt-* to avoid clashes with global .filter-bar/.metric-card
   defined in app.css. All values use CSS vars so light + dark mode just work.
   ============================================================================ */

.rpt-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-bottom: 2rem;
}

.rpt-error {
    padding: 0.85rem 1rem;
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.rpt-error i { font-size: 1rem; }

.rpt-info {
    padding: 0.85rem 1rem;
    background: var(--info-light);
    color: var(--info);
    border: 1px solid color-mix(in srgb, var(--info) 25%, transparent);
    border-radius: var(--radius);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

/* -- Toolbar (filter row) ------------------------------------------------- */
.rpt-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    align-items: end;
    padding: 1rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
}

.rpt-toolbar__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.rpt-toolbar__field--grow { grid-column: span 2; }

@media (max-width: 720px) {
    .rpt-toolbar__field--grow { grid-column: auto; }
}

.rpt-toolbar__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.rpt-toolbar__actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: end;
}

/* Make sure native form controls inside the toolbar follow the theme. The
   .form-control class in app.css already handles the look - we just make sure
   they fill the column and don't shrink awkwardly. */
.rpt-toolbar .form-control,
.rpt-toolbar select.form-control,
.rpt-toolbar input.form-control {
    width: 100%;
}

.rpt-toolbar input[type="date"].form-control,
.rpt-toolbar input[type="datetime-local"].form-control {
    min-height: 40px;
    color-scheme: light dark;
}

/* -- Actions row (export buttons etc.) ------------------------------------ */
.rpt-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

/* -- Metrics grid --------------------------------------------------------- */
/* Aligned with the global `.stat-card` style used on Users / Merch / Assets
   so report summary cards have a consistent look (idle, hover, accents). */
.rpt-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.rpt-metric {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    box-shadow: var(--shadow-sm);
    position: relative;
    isolation: isolate;
    transition: transform var(--motion-duration-base) var(--motion-spring),
                box-shadow var(--motion-duration-base) var(--motion-ease),
                border-color var(--motion-duration-base) var(--motion-ease);
}

.rpt-metric::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 58%);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-duration-base) var(--motion-ease);
}

.rpt-metric:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--primary) 18%, var(--border-color));
}

.rpt-metric:hover::after {
    opacity: 1;
}

.rpt-metric__label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: 0.05rem;
}

.rpt-metric__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rpt-metric__sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Optional accent bar variants */
.rpt-metric--accent { padding-left: 1.55rem; }
.rpt-metric--accent::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 4px;
    border-radius: 2px;
    background: var(--primary);
    z-index: 1;
}
.rpt-metric--accent.rpt-metric--success::before { background: var(--success); }
.rpt-metric--accent.rpt-metric--warning::before { background: var(--warning); }
.rpt-metric--accent.rpt-metric--info::before    { background: var(--info); }
.rpt-metric--accent.rpt-metric--danger::before  { background: var(--danger); }

/* -- Section card (table containers etc.) -------------------------------- */
.rpt-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.rpt-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: color-mix(in srgb, var(--bg-secondary) 50%, var(--bg-card));
}

.rpt-section__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rpt-section__title i { color: var(--primary); font-size: 1rem; }

.rpt-section__sub {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

.rpt-section__body { padding: 1rem 1.25rem; }
.rpt-section__body--flush { padding: 0; }

/* -- Tables (in section card) -------------------------------------------- */
.rpt-section .table-wrap { overflow-x: auto; }

.rpt-section table.rpt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.rpt-section table.rpt-table thead th {
    text-align: left;
    padding: 0.7rem 1.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: color-mix(in srgb, var(--bg-secondary) 60%, var(--bg-card));
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.rpt-section table.rpt-table tbody td {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.rpt-section table.rpt-table tbody tr:first-child td { border-top: none; }
.rpt-section table.rpt-table tbody tr:hover { background: var(--bg-table-hover); }

.rpt-section .text-end,
.rpt-section .num { text-align: right; font-variant-numeric: tabular-nums; }

/* -- Empty/loading states inside a section ------------------------------- */
.rpt-empty {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.rpt-empty i {
    display: block;
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.rpt-loading {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.rpt-loading::before {
    content: "";
    display: inline-block;
    width: 16px; height: 16px;
    margin-right: 0.5rem;
    vertical-align: -3px;
    border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: rpt-spin 0.7s linear infinite;
}

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

/* -- Two-column layout for section cards --------------------------------- */
.rpt-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

@media (max-width: 900px) {
    .rpt-grid-2 { grid-template-columns: 1fr; }
}

/* -- Inline forms on settings panels (Church Roles etc.) ----------------- */
.rpt-inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.rpt-inline-form .form-control { min-width: 0; }
.rpt-inline-form .form-control--narrow { max-width: 120px; }
/* ───── Reports — Under Development placeholder ───── */
.rpt-coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1.5rem;
    min-height: 60vh;
    gap: 1rem;
    background: var(--bg-card);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-sm);
}
.rpt-coming-soon__art {
    width: min(280px, 70vw);
}
.rpt-coming-soon__art svg {
    width: 100%;
    height: auto;
    display: block;
}
.rpt-coming-soon__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.rpt-coming-soon__sub {
    margin: 0;
    max-width: 520px;
    color: var(--text-secondary);
    line-height: 1.55;
    font-size: 0.95rem;
}
.rpt-coming-soon__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    margin-top: 0.5rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
}

/* ────────────────────────────────────────────────────────────
   Tag chip picker (EventReports.razor)
   ──────────────────────────────────────────────────────────── */
.rpt-tag-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.rpt-tag-picker__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.rpt-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem 0.3rem 0.6rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chip-color, var(--primary)) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--chip-color, var(--primary)) 35%, transparent);
    color: var(--chip-color, var(--primary));
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
}

.rpt-tag-chip i {
    font-size: 0.85rem;
}

.rpt-tag-chip__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    margin-left: 0.15rem;
    transition: background 0.15s ease;
}

.rpt-tag-chip__remove:hover {
    background: color-mix(in srgb, var(--chip-color, var(--primary)) 25%, transparent);
}

.rpt-tag-picker__select {
    width: 100%;
}

.rpt-tag-picker__clear {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 0.35rem;
}

.rpt-tag-picker__clear:hover {
    color: var(--danger, #dc2626);
    background: color-mix(in srgb, var(--danger, #ef4444) 10%, transparent);
}

/* ───── Org sub-report (drill-down) ───── */
.rpt-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}

.rpt-breadcrumb__crumb {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid transparent;
    padding: 0.3rem 0.6rem;
    border-radius: 0.45rem;
    font-weight: 600;
    line-height: 1;
}

.rpt-breadcrumb__crumb--link {
    color: var(--text-secondary);
    cursor: pointer;
    border-color: var(--border-color);
    transition: all 0.15s ease;
}

.rpt-breadcrumb__crumb--link:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.rpt-breadcrumb__crumb--current {
    color: var(--text-primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.rpt-breadcrumb__sep {
    color: var(--text-secondary);
    opacity: 0.6;
    font-weight: 400;
}

.rpt-breadcrumb__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.rpt-breadcrumb__btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.rpt-subject {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
}

.rpt-subject__avatar {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 18%, var(--bg-secondary));
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    overflow: hidden;
}

.rpt-subject__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rpt-subject__meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.rpt-subject__name {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.rpt-subject__sub {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rpt-subject__sub i {
    color: var(--primary);
    margin-right: 0.2rem;
}

.rpt-subject__role { font-weight: 600; color: var(--text-primary); }

.rpt-subject__dot { opacity: 0.5; }

/* User cell with avatar in tables */
.rpt-user-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.rpt-user-cell__avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 15%, var(--bg-secondary));
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.78rem;
    overflow: hidden;
}

.rpt-user-cell__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rpt-user-cell__name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Clickable rows */
.rpt-table--clickable tbody tr {
    cursor: pointer;
    transition: background 0.12s ease;
}

.rpt-table--clickable tbody tr:hover {
    background: color-mix(in srgb, var(--primary) 8%, transparent) !important;
}

/* =====================================================================
   Mobile responsive overrides (= 640px)
   Stacks toolbar fields, makes the Run-Report action full-width,
   tightens the rpt-subject row, allows breadcrumb to wrap nicely,
   and converts the descendants table into card form.
   ===================================================================== */
@media (max-width: 640px) {
    .rpt-toolbar {
        grid-template-columns: 1fr;
        padding: 0.85rem 0.9rem;
        gap: 0.65rem;
    }
    .rpt-toolbar__field--grow { grid-column: auto; }
    .rpt-toolbar__actions {
        justify-content: stretch;
    }
    .rpt-toolbar__actions .btn {
        width: 100%;
        justify-content: center;
    }

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

    .rpt-subject {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.85rem;
        padding: 0.9rem 1rem;
    }
    .rpt-subject__avatar { width: 48px; height: 48px; font-size: 1rem; }
    .rpt-subject__name { font-size: 1.05rem; }
    .rpt-subject__sub { font-size: 0.78rem; gap: 0.35rem; }
    .rpt-subject__dot { display: none; }

    .rpt-breadcrumb {
        font-size: 0.78rem;
        gap: 0.25rem;
    }
    .rpt-breadcrumb__crumb {
        padding: 0.25rem 0.5rem;
        max-width: 11ch;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .rpt-breadcrumb__crumb--current { max-width: 18ch; }

    .rpt-metrics {
        grid-template-columns: 1fr !important;
    }

    /* Convert org descendants table into card-list on mobile */
    .rpt-section .table-wrap { overflow-x: visible; }
    .rpt-section table.rpt-table,
    .rpt-section table.rpt-table thead,
    .rpt-section table.rpt-table tbody,
    .rpt-section table.rpt-table tr,
    .rpt-section table.rpt-table td {
        display: block;
        width: 100%;
    }
    .rpt-section table.rpt-table thead { display: none; }
    .rpt-section table.rpt-table tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg, 12px);
        padding: 0.85rem 1rem;
        margin-bottom: 0.65rem;
        box-shadow: var(--shadow-sm);
    }
    .rpt-section table.rpt-table tbody tr:hover { background: var(--bg-card); }
    .rpt-section table.rpt-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.3rem 0;
        border: none;
        font-size: 0.85rem;
        gap: 0.75rem;
        white-space: normal;
    }
    .rpt-section table.rpt-table tbody td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.68rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        min-width: 90px;
    }
    .rpt-section table.rpt-table tbody td.text-end { justify-content: space-between; }
    .rpt-section table.rpt-table tbody td:first-child {
        justify-content: flex-start;
        padding-bottom: 0.55rem;
        margin-bottom: 0.4rem;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
    }
    .rpt-section table.rpt-table tbody td:first-child::before { display: none; }
}

/* =====================================================================
   Mobile responsive overrides (= 640px)
   Stacks toolbar fields, makes the Run-Report action full-width,
   tightens the rpt-subject row, allows breadcrumb to wrap nicely,
   and converts the descendants table into card form.
   ===================================================================== */
@media (max-width: 640px) {
    .rpt-toolbar {
        grid-template-columns: 1fr;
        padding: 0.85rem 0.9rem;
        gap: 0.65rem;
    }
    .rpt-toolbar__field--grow { grid-column: auto; }
    .rpt-toolbar__actions {
        justify-content: stretch;
    }
    .rpt-toolbar__actions .btn {
        width: 100%;
        justify-content: center;
    }

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

    .rpt-subject {
        flex-direction: row;
        align-items: flex-start;
        gap: 0.85rem;
        padding: 0.9rem 1rem;
    }
    .rpt-subject__avatar { width: 48px; height: 48px; font-size: 1rem; }
    .rpt-subject__name { font-size: 1.05rem; }
    .rpt-subject__sub { font-size: 0.78rem; gap: 0.35rem; }
    .rpt-subject__dot { display: none; }

    .rpt-breadcrumb {
        font-size: 0.78rem;
        gap: 0.25rem;
    }
    .rpt-breadcrumb__crumb {
        padding: 0.25rem 0.5rem;
        max-width: 11ch;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .rpt-breadcrumb__crumb--current { max-width: 18ch; }

    .rpt-metrics {
        grid-template-columns: 1fr !important;
    }

    /* Convert org descendants table into card-list on mobile */
    .rpt-section .table-wrap { overflow-x: visible; }
    .rpt-section table.rpt-table,
    .rpt-section table.rpt-table thead,
    .rpt-section table.rpt-table tbody,
    .rpt-section table.rpt-table tr,
    .rpt-section table.rpt-table td {
        display: block;
        width: 100%;
    }
    .rpt-section table.rpt-table thead { display: none; }
    .rpt-section table.rpt-table tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg, 12px);
        padding: 0.85rem 1rem;
        margin-bottom: 0.65rem;
        box-shadow: var(--shadow-sm);
    }
    .rpt-section table.rpt-table tbody tr:hover { background: var(--bg-card); }
    .rpt-section table.rpt-table tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.3rem 0;
        border: none;
        font-size: 0.85rem;
        gap: 0.75rem;
        white-space: normal;
    }
    .rpt-section table.rpt-table tbody td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.68rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        min-width: 90px;
    }
    .rpt-section table.rpt-table tbody td.text-end { justify-content: space-between; }
    .rpt-section table.rpt-table tbody td:first-child {
        justify-content: flex-start;
        padding-bottom: 0.55rem;
        margin-bottom: 0.4rem;
        border-bottom: 1px solid var(--border-color);
        font-weight: 600;
    }
    .rpt-section table.rpt-table tbody td:first-child::before { display: none; }
}
