/* ─────────────────────────────────────────────────────────────
   Panel components — cards, stats, buttons, forms, tables, badges
   and the small pieces pages assemble from. Shared with tt-web.
   ───────────────────────────────────────────────────────────── */

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 22px;
    box-shadow: var(--shadow-xs);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin: -12px 0 18px;
}

/* Quiet context text opposite a card title. */
.card-note {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

/* A quiet "View all →" affordance for card headers. */
.card-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-solid);
    text-decoration: none;
    white-space: nowrap;
    transition: gap .18s ease;
}

.card-link:hover {
    gap: 10px;
}

/* A small tinted square carrying an icon — card titles, stat cards
   and list rows alike. */
.icon-tile {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-xs);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary-solid);
}

.icon-tile.sm { width: 28px; height: 28px; border-radius: 8px; }
.icon-tile.lg { width: 40px; height: 40px; border-radius: 11px; }

.icon-tile.indigo { background: var(--primary-soft); color: var(--primary-solid); }
.icon-tile.blue   { background: var(--info-soft);    color: var(--info); }
.icon-tile.green  { background: var(--success-soft); color: var(--success); }
.icon-tile.amber  { background: var(--warning-soft); color: var(--warning); }
.icon-tile.red    { background: var(--danger-soft);  color: var(--danger); }
.icon-tile.rose   { background: var(--rose-soft);    color: var(--rose); }
.icon-tile.purple { background: var(--purple-soft);  color: var(--purple); }
.icon-tile.teal   { background: var(--teal-soft);    color: var(--teal); }

/* ── Stat cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.stat-top,
.stat-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.stat-card-head {
    justify-content: space-between;
}

.stat-body {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 3px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-value {
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text-primary);
}

.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.info .stat-value    { color: var(--info); }
.stat-card.danger .stat-value  { color: var(--danger); }

/* A stat card's icon. Tone comes from the .icon-tile classes; this keeps
   working for cards that set --tone themselves. */
.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--tone-rgb, var(--primary-rgb)), 0.12);
    color: var(--tone, var(--primary-solid));
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.stat-delta.up   { background: var(--success-soft); color: var(--success); }
.stat-delta.down { background: var(--danger-soft);  color: var(--danger); }
.stat-delta.warn { background: var(--warning-soft); color: #B76E00; }
.stat-delta.info { background: var(--info-soft);    color: var(--info); }

.stat-foot {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 10px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: -0.01em;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .18s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn:disabled,
.btn.is-disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.20);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.26);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-color);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
}

/* Primary, stated as an outline — for row actions that should read
   as the safe choice next to a destructive one. */
.btn-outline {
    background: #ffffff;
    color: var(--primary-solid);
    border-color: var(--primary-soft-strong);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-soft);
    border-color: var(--primary-light);
}

.btn-outline-danger {
    background: #ffffff;
    color: var(--danger);
    border-color: #F7C9C4;
}

.btn-outline-danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 6px 16px rgba(240, 68, 56, 0.24);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 6px 16px rgba(18, 183, 106, 0.22);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12.5px;
    border-radius: 8px;
}

/* A square icon-only control, e.g. a row overflow menu. */
.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 9px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--bg-subtle);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Square icon-only button, sized to sit beside a 41px field. */
.btn-icon-square {
    width: 41px;
    height: 41px;
    padding: 0;
    flex-shrink: 0;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-weight: 700;
    font-size: 13.5px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    transition: all .18s ease;
    background: var(--bg-card);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control:disabled,
.form-control[readonly] {
    background: var(--field-bg);
    color: var(--text-secondary);
}

.invalid-feedback {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

/* Guidance under a field. */
.help-text {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.5;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 18px;
}

/* A row whose fields end flush, so the grid supplies the gap when they wrap. */
.form-row.spaced {
    row-gap: 18px;
}

/* A row of short fields — numbers and the like — that belong side by side
   rather than wrapping two-and-two. */
.form-row.tight {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0 14px;
}

.form-row.tight.spaced {
    row-gap: 18px;
}

/* Cards stacked as the steps of one form. */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* A form is read, not scanned, so it is kept to a comfortable measure. */
.form-stack.narrow {
    max-width: 780px;
}

/* The row a form ends on. */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Choice cards ──
   A radio set read as tiles. The input stays in the page rather than being
   display:none, so the set is still reachable by keyboard and readable by a
   screen reader; the selected state comes from the input itself. */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.choice-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.choice {
    position: relative;
    display: block;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease;
}

.choice input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.choice:hover {
    border-color: var(--primary-light);
}

.choice:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.choice:has(input:focus-visible) {
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.choice-name {
    display: block;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.choice-desc {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* A choice whose subject is a number. */
.choice-figure {
    display: block;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--text-primary);
}

.choice:has(input:checked) .choice-figure {
    color: var(--primary-solid);
}

.choice-unit {
    display: block;
    margin-top: 2px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.choice-grid.compact .choice {
    padding: 13px 10px;
    text-align: center;
}

/* ── Settings area ──
   A vertical menu beside the section being read. */
.settings-shell {
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 16px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.settings-nav-group + .settings-nav-group {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.settings-nav-label {
    display: block;
    padding: 8px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.settings-nav-item:hover {
    background: var(--sidebar-hover);
}

.settings-nav-item.active {
    background: var(--primary-soft);
    color: var(--primary-ink);
}

.settings-nav-icon {
    display: flex;
    flex-shrink: 0;
    color: var(--text-muted);
}

.settings-nav-item.active .settings-nav-icon {
    color: var(--primary-ink);
}

.settings-nav-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.settings-nav-title {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
}

.settings-nav-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-panel {
    min-width: 0;
    display: grid;
    gap: 20px;
}

@media (max-width: 900px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav { position: static; }
    .settings-nav-desc { display: none; }
}

/* What a saved profile will do, in a line of chips. */
.profile-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.profile-chip {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-ink);
    font-size: 11.5px;
    font-weight: 700;
}

/* A single on/off setting: what it does on the left, the toggle on the right. */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.setting-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.setting-label {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
}

.setting-help {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ── Toggle ── */
.switch-field {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 1;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background .18s ease;
}

.switch-track::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform .18s ease;
}

.switch input:checked ~ .switch-track {
    background: var(--primary);
}

.switch input:checked ~ .switch-track::before {
    transform: translateX(18px);
}

.switch input:focus-visible ~ .switch-track {
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.checkbox-group input[type="checkbox"],
.checkbox-group input[type="radio"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary-solid);
    cursor: pointer;
}

/* A compact select for card headers (period pickers and the like). */
.form-select-sm {
    padding: 7px 30px 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: var(--bg-card) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239AA5B8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-secondary);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

/* ── Alerts ── */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: var(--success-soft);
    color: #047B50;
    border: 1px solid rgba(18, 183, 106, 0.2);
}

.alert-error,
.alert-danger {
    background: var(--danger-soft);
    color: #C22B20;
    border: 1px solid rgba(240, 68, 56, 0.2);
}

.alert-warning {
    background: var(--warning-soft);
    color: #B76E00;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: var(--info-soft);
    color: #1B6FC7;
    border: 1px solid rgba(46, 144, 250, 0.2);
}

/* ── Item cards ── */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}

.item-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: var(--shadow-xs);
    transition: all .2s ease;
}

.item-card:hover {
    border-color: var(--primary-soft-strong);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.item-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.item-card-title {
    font-weight: 800;
    font-size: 15.5px;
    letter-spacing: -0.02em;
}

.item-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.item-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ── Tables ── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 13px 14px;
    text-align: left;
}

.table th {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    border-bottom: 1px solid var(--border-color);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.table td strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* Identifiers — admission numbers, employee ids — read as data, not prose. */
.table code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--field-bg);
    color: var(--nav-ink);
}

.table tbody tr {
    transition: background .15s ease;
}

.table tbody tr:hover {
    background: var(--bg-subtle);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* A card whose table runs to the card's own edges. */
.panel-flush {
    padding: 22px 22px 8px;
}

.panel-flush .table th:first-child,
.panel-flush .table td:first-child { padding-left: 4px; }

.panel-flush .table th:last-child,
.panel-flush .table td:last-child { padding-right: 4px; text-align: right; }

/* A caption under the main value in a table cell. */
.cell-sub {
    display: block;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* A progress meter and its figure, side by side in a cell. */
.cell-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 128px;
}

.cell-progress .meter {
    flex: 1;
}

.cell-progress-value {
    font-size: 12.5px;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
}

/* Buttons grouped in a table's action column. */
.row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

/* A person cell: round avatar plus name. */
.cell-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    background: var(--primary);
}

/* ── Section tabs ── */
.page-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}

.page-tabs::-webkit-scrollbar { display: none; }

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 16px;
    margin-bottom: -1px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: color .18s ease, border-color .18s ease;
}

.page-tab svg { color: var(--text-muted); transition: color .18s ease; }
.page-tab:hover { color: var(--text-primary); }

.page-tab.active,
.page-tab.active svg { color: var(--primary-solid); }
.page-tab.active { border-bottom-color: var(--primary-solid); }

/* ── Table toolbar (search + filters above a table) ── */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.field-search {
    display: flex;
    align-items: center;
    flex: 1 1 220px;
    max-width: 380px;
    height: 41px;
    padding: 0 12px 0 14px;
    background: var(--field-bg);
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    transition: border-color .18s ease, box-shadow .18s ease;
}

.field-search:focus-within {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.field-search > svg {
    flex-shrink: 0;
    color: var(--text-muted);
}

.field-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
    padding: 0 10px;
}

.field-search input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.field-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.toolbar-search-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 260px;
    max-width: 430px;
}

.toolbar-search-group .field-search {
    flex: 1;
    max-width: none;
}

.field-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.field-filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

.field-select {
    height: 41px;
    padding: 0 34px 0 14px;
    border: 1px solid #DDE5F2;
    border-radius: var(--radius-sm);
    background: #ffffff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2398A2B3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    max-width: 220px;
}

.field-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

/* ── Pagination ── */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 24px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0 16px 16px;
}

.pagination nav {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.pagination nav > a,
.pagination nav > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 38px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    line-height: 1;
}

.pagination nav > a:hover {
    background: var(--primary-soft);
    border-color: var(--primary-soft-strong);
    color: var(--primary-ink);
}

.pagination nav > span[aria-current="page"] > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 38px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 700;
    background: var(--primary);
    color: white;
    border: 1px solid transparent;
    line-height: 1;
}

.pagination nav > span[aria-current="page"] {
    padding: 0;
    border: none;
    background: none;
}

.pagination nav > span[aria-disabled="true"] {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination nav > span[aria-disabled="true"] > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 38px;
    border-radius: 9px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    line-height: 1;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

/* A tinted disc holding a line icon — never an emoji, which renders
   differently on every platform. */
.empty-state-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary-solid);
}

.empty-state-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.empty-state-text {
    max-width: 58ch;
    margin: 0 auto 20px;
    color: var(--text-secondary);
    font-size: 13.5px;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.5;
    white-space: nowrap;
}

.badge-primary   { background: var(--primary-soft); color: var(--primary-ink); }
.badge-success   { background: var(--success-soft); color: var(--success); }
.badge-warning   { background: var(--warning-soft); color: #B76E00; }
.badge-danger    { background: var(--danger-soft);  color: var(--danger); }
.badge-info      { background: var(--info-soft);    color: var(--info); }
.badge-secondary { background: var(--bg-subtle);    color: var(--text-secondary); border: 1px solid var(--border-color); }

/* A live "Active now" pill with a pulsing dot. */
.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulseDot 1.8s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .4; transform: scale(.8); }
}

/* ── Progress meters ── */
.meter {
    height: 7px;
    border-radius: 999px;
    background: var(--bg-subtle);
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.meter.green > span { background: var(--success); }
.meter.amber > span { background: var(--warning); }
.meter.red   > span { background: var(--danger); }
.meter.blue  > span { background: var(--info); }

/* ── Screenshot album ── */
.album-container {
    position: relative;
    overflow: hidden;
}

.album-slider {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-solid) transparent;
    padding: 8px 0;
}

.album-slider::-webkit-scrollbar { height: 6px; }
.album-slider::-webkit-scrollbar-track { background: transparent; }

.album-slider::-webkit-scrollbar-thumb {
    background-color: var(--primary-solid);
    border-radius: 3px;
}

.album-item {
    flex: 0 0 auto;
    width: calc((100% - 60px) / 6);
    min-width: 150px;
    max-width: 200px;
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--bg-subtle);
}

.album-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.album-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    color: var(--text-primary);
}

.slider-nav:hover {
    background: var(--primary-solid);
    color: white;
    border-color: var(--primary-solid);
}

.slider-nav.prev { left: -10px; }
.slider-nav.next { right: -10px; }

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Toolbars hand their width to the search box and let the filters wrap
       under it rather than pushing the row off screen. */
    .toolbar-search-group { max-width: none; }
    .field-filter { flex-wrap: wrap; }
    .field-filter .field-select { flex: 1 1 140px; max-width: none; }

    .album-item {
        width: calc((100% - 24px) / 3);
        min-width: 120px;
    }
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr; }
}
