/* Auth Pages */
.auth-container {
    width: 100%;
    max-width: 420px;
    margin: 4rem auto;
    padding: 0 1.5rem;
}

.auth-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-md);
}

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

.auth-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.auth-icon svg {
    width: 48px;
    height: 48px;
    color: var(--accent-color);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.auth-info {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    color: var(--text-secondary);
    text-align: center;
}

.auth-info p {
    margin: 0;
}

.auth-footer {
    text-align: center;
}

.auth-note {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.auth-error {
    margin: 0 0 1rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    box-shadow: inset 0 0 0 1px var(--danger);
    color: var(--danger);
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: left;
}

/* ── Login modal ───────────────────────── */

.auth-modal {
    position: relative;
    max-width: 380px;
    padding: 2rem 1.75rem 1.75rem;
    text-align: center;
}

.auth-modal-close {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.auth-modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); }

.auth-mark {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 0.875rem;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-color);
}

.auth-mark svg { width: 1.375rem; height: 1.375rem; }

.auth-modal-title {
    margin: 0 0 0.375rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-modal-sub {
    margin: 0 0 1.5rem;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.auth-modal-note {
    margin: -0.75rem 0 1.25rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.auth-modal .form-group { text-align: left; }

.auth-code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.25rem;
    letter-spacing: 0.4em;
    text-align: center;
    text-indent: 0.4em;
}

.auth-submit {
    width: 100%;
    justify-content: center;
    margin-top: 0.25rem;
    padding: 0.6875rem 1rem;
    font-size: 0.9375rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.auth-submit:hover { box-shadow: var(--shadow-md); }

.auth-submit:disabled {
    opacity: 0.65;
    cursor: default;
    box-shadow: none;
}

.auth-modal-foot {
    margin: 1rem 0 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.auth-modal-foot button,
.auth-modal-foot a {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
}

.auth-modal-foot button:hover,
.auth-modal-foot a:hover { text-decoration: underline; }

.auth-dev {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.auth-dev-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.auth-dev-btn {
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-dev-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.auth-dev-btn.is-admin { color: var(--accent-color); }

.auth-dev-code {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    margin-bottom: 1rem;
    padding: 0.625rem;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

.auth-dev-code .auth-dev-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--text-primary);
}

.auth-note a {
    color: var(--accent-color);
    text-decoration: none;
}

.auth-note a:hover {
    text-decoration: underline;
}

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

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.1875rem 0.5rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    vertical-align: middle;
}

/* Add `badge-dot` for a leading status dot */
.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-sm {
    font-size: 0.6875rem;
    padding: 0.125rem 0.4375rem;
    gap: 0.3125rem;
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-info {
    background: var(--accent-light);
    color: var(--accent-color);
}

.badge-muted {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-content.modal-sm { max-width: 400px; }
.modal-content.modal-lg { max-width: 700px; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* ── Panel modal ─────────────────────────
   For modals that own their scrolling internally (fixed header and action bar,
   scrolling body). `overflow: hidden` is what keeps the chrome clipped to the
   rounded corners instead of squaring off the top edge on scroll. */
.modal-shell {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-shell .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

/* Event names run long -- truncate rather than wrap the header to two lines */
.modal-shell .modal-title {
    display: block;
    font-size: 1.0625rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-shell .modal-close {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    transition: background 0.15s, color 0.15s;
}

.modal-shell .modal-close:hover { background: var(--bg-tertiary); }

.modal-shell .modal-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1.25rem;
}

/* Detail mode scrolls inside its own panes, so this one must not scroll */
.modal-shell .modal-detail-pane {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-shell .modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    padding: 3rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-shell .modal-loading .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: modal-spin 0.7s linear infinite;
}

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

.modal-shell .modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.625rem;
    flex-shrink: 0;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 560px) {
    .modal-shell .modal-scroll { padding: 1rem; }
    .modal-shell .modal-foot { padding: 0.75rem 1rem; }
    .modal-shell .modal-foot .btn { flex: 1; justify-content: center; }
}

/* ── Tabbed detail pane ──────────────────
   Side nav + scrolling panel, used by the event and organization detail
   modals (and by their full-page fallbacks). The pane itself never scrolls:
   .tab-panel does, so the nav stays put. Needs a bounded height from its
   container -- inside a modal that comes from .modal-detail-pane.

   NOTE: css/manage.css carries its own verbatim copy of these tab-shell rules
   (extracted for the manage-console migration). Same values, so load order is
   harmless today -- but the two should be collapsed onto this one when that
   migration lands. */
.tab-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
}
.tab-nav {
    flex-shrink: 0;
    width: 200px;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    background: var(--bg-secondary);
    overflow-y: auto;
}
.tab-nav-item {
    padding: 0.625rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border: none;
    background: none;
    text-align: left;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.tab-nav-item i { font-size: 0.875rem; }
.tab-nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary, rgba(0,0,0,0.04));
}
.tab-nav-item.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    background: var(--bg-primary);
    font-weight: 600;
}
/* Count of what's inside the tab, pushed to the far edge */
.tab-nav-count {
    margin-left: auto;
    padding: 0.0625rem 0.375rem;
    border-radius: 100px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
}
.tab-nav-item.active .tab-nav-count { background: var(--accent-light); color: var(--accent-color); }
.tab-nav-divider {
    height: 1px;
    background: var(--bg-tertiary);
    margin: 0.5rem 1.25rem;
}
.tab-panel {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
    overflow-y: auto;
}
@media (max-width: 640px) {
    .tab-layout { flex-direction: column; }
    .tab-nav {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--bg-tertiary);
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
    }
    .tab-nav-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
    }
    .tab-nav-item.active { border-bottom-color: var(--accent-color); border-left-color: transparent; }
    .tab-nav-count { margin-left: 0; }
    .tab-nav-divider { display: none; }
    .tab-panel { padding: 1rem; }
}

/* Tables */
.table-container {
    overflow-x: auto;
}

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

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

th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
}

tr:hover td {
    background: var(--bg-secondary);
}

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

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── Pane primitives ─────────────────────
   Section heads, tables and inline add-rows for the bodies of a .tab-panel
   (organization detail, and anything else built the same way). Named apart
   from list.css's page-level table so a pane can sit on any page. */
.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.pane-head h3 {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0;
}
.pane-head + .pane-note { margin-top: -0.375rem; }

.pane-table-wrap {
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}
.pane-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}
.pane-table thead th {
    padding: 0.5rem 0.875rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    text-align: left;
    white-space: nowrap;
    position: static;
}
.pane-table td {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    vertical-align: middle;
    border-bottom: none;
}
.pane-table tbody tr:not(:last-child) td { border-bottom: 1px solid var(--bg-tertiary); }
.pane-table tbody tr:hover td { background: var(--bg-secondary); }
.pane-table td:last-child { text-align: right; }

.pane-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pane-sub {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pane-muted { font-size: 0.8125rem; color: var(--text-secondary); white-space: nowrap; }
.pane-you {
    margin-left: 0.375rem;
    padding: 0.0625rem 0.3125rem;
    border-radius: 100px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pane-empty-row td {
    padding: 2rem 1rem !important;
    text-align: center !important;
    color: var(--text-secondary);
    font-size: 0.875rem;
}
.pane-table tbody tr.pane-empty-row:hover td { background: transparent; }

/* Compact select that sits inside a table cell */
.role-select {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    background: var(--bg-primary);
    cursor: pointer;
}

/* Destructive text button -- reads lighter than an outlined danger button */
.btn.btn-danger-text {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--danger);
}
.btn.btn-danger-text:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); }

/* Outlined destructive action: visible without shouting like solid .btn-danger */
.btn.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn.btn-danger-outline:hover { background: var(--danger); color: #fff; }

/* Inline "add a row" form above a pane table */
.member-add {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
    flex-wrap: wrap;
    padding: 0.875rem 1rem;
    margin-bottom: 0.375rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}
.member-add .form-label { margin-bottom: 0.25rem; }
.member-add-field { flex: 1; min-width: 200px; }
.member-add-field input,
.member-add-role select { width: 100%; background: var(--bg-primary); }
.member-add-role { width: 130px; }
.member-add .btn { flex-shrink: 0; }
.member-add-help {
    margin: 0 0 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .pane-table { table-layout: auto; }
    .pane-table col { width: auto !important; }
    .pane-table thead { display: none; }
    .pane-table, .pane-table tbody, .pane-table tr, .pane-table td { display: block; width: 100%; }
    .pane-table tbody tr { padding: 0.75rem 0.875rem; }
    .pane-table tbody tr:not(:last-child) { border-bottom: 1px solid var(--bg-tertiary); }
    .pane-table tbody tr:not(:last-child) td { border-bottom: none; }
    .pane-table td, .pane-table td:last-child { padding: 0.1875rem 0; text-align: left; }
    .pane-table td[data-label]::before {
        content: attr(data-label) " · ";
        font-size: 0.6875rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
    }
    .member-add-field, .member-add-role { width: 100%; flex: 1 1 100%; }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Avatar / Initials */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ============================================
   SECTIONED FORMS
   Used by grouped forms rendered via
   events/_form_field.html (page + modal).
   ============================================ */

/* One quiet column of grouped fields. No cards, no icons, no per-section blurb:
   a group is just a small label with a rule under it. The fields are the content;
   everything else was chrome competing with them. */
.form-sections {
    max-width: 620px;
}

.modal-shell .form-sections { max-width: none; }

.form-section + .form-section { margin-top: 1.75rem; }

.form-section-head {
    margin-bottom: 0.875rem;
    padding-bottom: 0.4375rem;
    border-bottom: 1px solid var(--bg-tertiary);
}

.form-section-head h3 {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.875rem 1rem;
}

.fld { min-width: 0; }
.fld-span-1 { grid-column: span 1; }
.fld-span-2 { grid-column: span 2; }

.fld .form-label {
    display: flex;
    align-items: baseline;
    gap: 0.1875rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.3125rem;
}

.fld-req { color: var(--danger); font-weight: 700; }

.fld input,
.fld select,
.fld textarea { background: var(--bg-primary); }

.fld.has-error input,
.fld.has-error select,
.fld.has-error textarea { border-color: var(--danger); }

.fld textarea { min-height: 76px; }

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3125rem;
    line-height: 1.45;
}

/* ── Checkboxes ──────────────────────────
   Native checkboxes render as bare white squares on dark backgrounds, so
   they are redrawn here and share one look across toggles and choice lists. */
.form-sections input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.0625rem;
    height: 1.0625rem;
    margin: 0;
    flex-shrink: 0;
    display: inline-grid;
    place-content: center;
    border: 1.5px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.form-sections input[type="checkbox"]::before {
    content: "";
    width: 0.625rem;
    height: 0.625rem;
    background: #fff;
    transform: scale(0);
    transition: transform 0.12s ease-out;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}

.form-sections input[type="checkbox"]:hover { border-color: var(--accent-color); }

.form-sections input[type="checkbox"]:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.form-sections input[type="checkbox"]:checked::before { transform: scale(1); }

.form-sections input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Boolean fields render as a clickable row instead of a bare checkbox */
.fld-toggle .toggle-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6875rem;
    margin: 0;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.fld-toggle .toggle-row:hover { border-color: var(--accent-color); }
.fld-toggle .toggle-row:has(input:checked) {
    border-color: var(--accent-color);
    background: var(--accent-light);
}

.toggle-text { display: flex; flex-direction: column; gap: 0.1875rem; }

.toggle-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-help {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.45;
}

/* ── Choice groups (multi-select org picker etc.) ── */
.choice-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.375rem;
}

.choice-head .form-label { margin-bottom: 0; }

.fld-choices .choice-filter {
    width: 150px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
}

.choice-box {
    max-height: 160px;
    overflow-y: auto;
    padding: 0.375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

/* The widget's own wrapper becomes the multi-column track */
.choice-box > div {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.0625rem 0.5rem;
}

.choice-box > div > div { min-width: 0; }
.choice-box .is-hidden { display: none; }

.choice-empty {
    margin: 0;
    padding: 0.625rem 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.choice-box label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.choice-box label:hover { background: var(--bg-secondary); }

/* ── Media / file upload ─────────────────
   The native control shows browser-locale text ("Sin archivos seleccionados")
   that can't be restyled, so it is hidden and driven by our own button. The
   field reads as a thumbnail + its controls rather than a bare input. */
.fld-media .media-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Thumbnail doubles as a click target for the file input */
.fld-media .media-thumb {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 84px;
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.fld-media .media-thumb:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.fld-media .media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fld-media .media-thumb-icon { width: 20px; height: 20px; stroke-width: 1.2; }

.fld-media .media-body {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
    flex: 1;
    min-width: 0;
}

.fld-media .media-name {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Plain text actions -- buttons here read as heavier than the field itself */
.fld-media .media-link {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-color);
    cursor: pointer;
}

.fld-media .media-link:hover { text-decoration: underline; }

/* Native input + the clear checkbox are driven entirely by the controls above */
.fld-media .media-input,
.fld-media .media-clear {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Validation summary above a sectioned form */
.form-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.08);
    font-size: 0.8125rem;
    color: var(--text-primary);
}

.form-alert > .ic { color: var(--danger); margin-top: 0.0625rem; }

.form-alert-info {
    border-color: var(--bg-tertiary);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.form-alert-info > .ic { color: var(--text-muted); }
.form-alert strong { display: block; margin-bottom: 0.25rem; }
.form-alert ul { margin: 0; padding-left: 1.125rem; }
.form-alert li { margin-top: 0.125rem; }
.form-alert-field { font-weight: 600; }

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

@media (max-width: 560px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .fld-span-1, .fld-span-2 { grid-column: span 1; }
    .form-section { padding: 1rem; }
}

/* ============================================
   SVG ICONS
   Shared geometry for inline/sprite icons; the
   stroke lives here so every icon has the same
   weight and the paths stay clean.
   ============================================ */

.ic {
    display: block;
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* ============================================
   ICON ALIGNMENT
   bootstrap-icons puts `vertical-align: -.125em`
   on the ::before glyph, which sits fine next to
   inline text but pushes the icon below centre
   inside flex containers (buttons, chips, headings).
   ============================================ */

.btn > i,
.icon-btn > i,
.cell-link > i,
.form-section-head h3 > i,
.form-alert > i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.btn > i::before,
.icon-btn > i::before,
.cell-link > i::before,
.form-section-head h3 > i::before,
.form-alert > i::before {
    vertical-align: 0;
    line-height: 1;
}
