﻿/* Shared page-structure catalogue for Partner Support System.
   Tailwind (CDN) supplies the utility layer; these ui-* classes are the
   reusable structural blocks every listing page is built from. Written as
   plain CSS deliberately - there is no Tailwind build step in this solution,
   so @apply would be inert. */

/* Alpine hides x-cloak elements until it has initialised them. */
[x-cloak] {
    display: none !important;
}

.ui-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.ui-page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.ui-page-subtitle {
    margin-top: 0.125rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.ui-filter-panel,
.ui-table-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    padding: 1.125rem 1.25rem;
}

.ui-filter-panel {
    margin-bottom: 1rem;
}

.ui-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.ui-input,
.ui-select {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background-color: var(--surface);
    color: var(--text);
}

/* Native arrows ignore padding - draw our own chevron so it sits off the right edge. */
.ui-select {
    appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
}

.ui-select[multiple] {
    padding-right: 0.75rem;
    background-image: none;
}

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

/* Browser autofill paints its own blue fill - keep the themed surface and text instead. */
.ui-input:-webkit-autofill,
.ui-input:-webkit-autofill:hover,
.ui-input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-out 0s;
}

.ui-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset, 0 0 0 3px var(--ring);
}

.ui-input:disabled,
.ui-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Password fields get an eye button (site.js wraps them). Stored secrets opt out with data-no-eye -
   their value never reaches the page, so there is nothing to reveal. */
.ui-password-wrap {
    position: relative;
}

.ui-password-wrap input {
    padding-right: 2.5rem;
}

.ui-password-toggle {
    position: absolute;
    top: 50%;
    right: 0.5rem;
    display: flex;
    width: 1.75rem;
    height: 1.75rem;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    color: var(--text-muted);
}

.ui-password-toggle:hover {
    color: var(--text);
}

.ui-password-toggle svg {
    width: 1.125rem;
    height: 1.125rem;
}

/* Buttons always carry an icon beside the label - the gap is for that icon. */
/* Rounded-lg (not pill) buttons, Preline style. */
.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-height: 2.25rem;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.ui-btn svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.ui-btn--primary {
    background-color: var(--primary);
    color: var(--primary-fg);
}

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

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

.ui-btn--secondary:hover {
    background-color: var(--surface-2);
}

.ui-btn--success {
    background-color: var(--accent);
    color: #ffffff;
}

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

/* Small bordered "Full View ↗" / "View all ↗" link-button for card headers. */
.ui-btn--ghost {
    min-height: 32px;
    padding: 0.25rem 0.75rem;
    border-color: var(--border);
    background-color: var(--surface);
    color: var(--text);
    font-size: 0.8125rem;
}

.ui-btn--ghost:hover {
    background-color: var(--surface-2);
}

.ui-btn--danger {
    background-color: #dc2626;
    color: #ffffff;
}

.ui-btn--danger:hover {
    background-color: #b91c1c;
}

.ui-btn--icon {
    min-height: 36px;
    padding: 0.375rem 0.625rem;
}

/* Small borderless icon-only button (drawer close, open-in-tab, row actions). */
.ui-icon-btn {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.ui-icon-btn:hover {
    background-color: var(--surface-2);
    color: var(--text);
}

.ui-icon-btn--danger {
    padding: 0.25rem;
    color: var(--text-subtle);
}

.ui-icon-btn--danger:hover {
    background-color: #fef2f2;
    color: #dc2626;
}

/* Segmented control - a row of toggle tabs; the active one carries aria-pressed="true". */
.ui-segmented {
    display: flex;
    border-radius: 0.5rem;
    background-color: var(--surface-2);
    padding: 0.25rem;
}

.ui-segment {
    display: flex;
    flex: 1 1 0%;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border-radius: 0.375rem;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.ui-segment:hover {
    color: var(--text);
}

.ui-segment[aria-pressed="true"] {
    background-color: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Full-width "Load more" footer under an infinite list. */
.ui-load-more {
    border-top: 1px solid var(--border);
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.ui-load-more:hover {
    background-color: var(--surface-2);
}

/* A copyable external link shown as a tinted block (bot links, webhook URLs). */
.ui-link-block {
    display: block;
    word-break: break-all;
    border-radius: 0.5rem;
    background-color: var(--surface-2);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #0369a1;
}

.ui-link-block:hover {
    text-decoration: underline;
}

.ui-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: var(--overlay);
}

.ui-modal-panel {
    width: 100%;
    max-width: 40rem;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15);
}

.ui-modal-panel--sm {
    max-width: 24rem;
}

.ui-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text);
}

.ui-modal-icon-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 1.25rem 0.5rem;
    text-align: center;
}

.ui-modal-body {
    padding: 1.25rem;
}

.ui-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.ui-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 500;
}

.ui-badge--on {
    background-color: var(--status-closed-bg);
    color: var(--status-closed-fg);
}

.ui-badge--off {
    background-color: var(--status-muted-bg);
    color: var(--status-muted-fg);
}

.ui-badge--error {
    background-color: var(--status-overdue-bg);
    color: var(--status-overdue-fg);
}

.ui-badge--warn {
    background-color: var(--status-progress-bg);
    color: var(--status-progress-fg);
}

.ui-badge--info {
    background-color: var(--status-open-bg);
    color: var(--status-open-fg);
}

/* Card header: small title left, ghost action right. */
.ui-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

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

/* List row with a coloured leading bar; lifts on hover / when selected. */
.ui-list-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.625rem 0.75rem 0.625rem 1.125rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.ui-list-row::before {
    content: "";
    position: absolute;
    left: 0.375rem;
    top: 0.5rem;
    bottom: 0.5rem;
    width: 4px;
    border-radius: var(--radius-pill);
    background: var(--row-bar, var(--border-strong));
}

.ui-list-row:hover,
.ui-list-row.is-selected {
    border-color: var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-lift);
}

.ui-list-row--open { --row-bar: #22b8cf; }
.ui-list-row--progress { --row-bar: #f59f00; }
.ui-list-row--closed { --row-bar: var(--accent); }
.ui-list-row--overdue { --row-bar: #e5484d; }

/* A settings card - a form page rather than a listing. Header, stacked steps, footer. */
.ui-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    padding: 1.25rem;
}

.ui-section-header {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.ui-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.ui-section-subtitle {
    margin-top: 0.125rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Expand / collapse chevron for a card header; rotates when the card is collapsed. */
.ui-collapse-toggle {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    transition: background-color 0.15s, color 0.15s;
}

.ui-collapse-toggle:hover {
    background-color: rgb(241 245 249);
    color: var(--text);
}

.ui-collapse-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    transition: transform 0.2s;
}

.ui-collapse-toggle.is-collapsed svg {
    transform: rotate(-90deg);
}

.ui-section-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.ui-form-step {
    padding: 1.25rem 0;
}

.ui-form-step-heading {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.ui-step-num {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background-color: var(--primary);
    color: var(--primary-fg);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Label-over-value summary tile. */
.ui-stat {
    min-width: 0;
}

.ui-stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.ui-stat-value {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

table.dataTable tbody td {
    font-size: 0.875rem;
    color: var(--text);
    vertical-align: middle;
}

/* Quiet header - subtle grey band, muted label text. */
table.dataTable thead th {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    background-color: var(--surface-2);
    border-bottom: 1px solid var(--border);
    border-right: 0;
    vertical-align: middle;
}

table.dataTable thead th:last-child {
    border-right: 0;
}

/* Without scrollX, FixedHeader floats the table itself at z-index 104 - keep it under the appbar (30),
   mobile drawer (40-50) and modals (50). With scrollX it uses a z-index 3 wrapper, already below them. */
table.dataTable.fixedHeader-floating,
table.dataTable.fixedHeader-locked {
    z-index: 25;
}

table.dataTable thead th .dt-column-order::before,
table.dataTable thead th .dt-column-order::after {
    color: var(--text-subtle);
}

/* Row dividers only - no column rules. */
table.dataTable > tbody > tr > td {
    border-top: 1px solid var(--border);
    transition: background-color var(--dur-fast) var(--ease-out);
}

/* Row hover - DataTables 2 paints row states as an inset box-shadow, so override that too. */
table.dataTable > tbody > tr:hover > td {
    background-color: var(--surface-2);
    box-shadow: none;
}

/* ---- DataTables toolbar: length menu + Show Columns on the left, pager on the right ---- */
div.dt-container .dt-layout-row .dt-layout-start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

div.dt-container .dt-length,
div.dt-container .dt-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

div.dt-container .dt-length select {
    margin: 0 0.375rem;
    min-height: 2.25rem;
    padding: 0.25rem 2.25rem 0.25rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    /* Same custom chevron as .ui-select. */
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
}

/* Show Columns - solid primary button. */
div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.25rem;
    margin: 0;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: none;
    transition: background-color var(--dur-fast) var(--ease-out);
}

div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis:hover:not(.disabled),
div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis:focus:not(.disabled),
div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis:active:not(.disabled) {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
    color: var(--primary-fg);
    box-shadow: var(--shadow-sm);
}

/* Buttons wraps the label in its own <span> - lay the icon and text out on one line inside it. */
div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}

div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis svg {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
}

div.dt-container .dt-buttons > button.dt-button.ui-dt-colvis .dt-button-down-arrow {
    position: static;
    margin-left: 0.125rem;
    font-size: 0.625rem;
    color: var(--primary-fg);
}

/* Column picker dropdown. */
div.dt-button-collection {
    padding: 0.375rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

div.dt-button-collection .dt-button {
    border-radius: var(--radius-xs);
    font-size: 0.875rem;
    color: var(--text);
}

div.dt-button-collection .dt-button.dt-button-active::after {
    color: var(--primary);
}

/* Pager - joined bordered group, current page filled with the primary colour. */
div.dt-container .dt-paging nav {
    display: inline-flex;
}

div.dt-container .dt-paging .dt-paging-button {
    min-width: 2.5rem;
    min-height: 2.5rem;
    margin: 0 0 0 0.25rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
    background: var(--surface) !important;
    color: var(--text) !important;
    font-size: 0.875rem;
}

div.dt-container .dt-paging .dt-paging-button:first-child {
    margin-left: 0;
}

div.dt-container .dt-paging .dt-paging-button:hover {
    background: var(--surface-2) !important;
    color: var(--primary-hover) !important;
}

div.dt-container .dt-paging .dt-paging-button.current,
div.dt-container .dt-paging .dt-paging-button.current:hover {
    position: relative;
    border-color: var(--primary) !important;
    background: var(--primary) !important;
    color: var(--primary-fg) !important;
}

div.dt-container .dt-paging .dt-paging-button.disabled,
div.dt-container .dt-paging .dt-paging-button.disabled:hover {
    background: var(--surface) !important;
    color: var(--text-subtle) !important;
    cursor: default;
}

div.dt-container .dt-paging .ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    margin-left: 0.25rem;
    color: var(--text-subtle);
}

/* Dashboard counters - a clickable card per kind of waiting work. */
.ui-kpi-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .ui-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* KPI card - label + big number on the left, thin outline icon top-right. */
.ui-kpi-card {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.875rem;
    min-height: 44px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--surface);
    text-align: left;
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.ui-kpi-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lift);
}

.ui-kpi-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--text-subtle);
}

.ui-kpi-icon svg {
    width: 1.75rem;
    height: 1.75rem;
    stroke-width: 1.4;
}

/* Tone variants keep the icon quiet; the tone shows only as a tinted icon stroke. */
.ui-kpi-icon--blue { color: var(--status-open-fg); }
.ui-kpi-icon--amber { color: var(--status-progress-fg); }
.ui-kpi-icon--red { color: var(--status-overdue-fg); }

.ui-kpi-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.ui-kpi-value {
    margin-top: 0.5rem;
    font-size: 1.625rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text);
}

/* Top-bar bell - emails needing manual handling (js/shared/needs-manual-bell.js) */
.ui-bell {
    position: relative;
    margin-left: auto;
}

.ui-bell-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}

.ui-bell-trigger:hover,
.ui-bell-trigger[aria-expanded="true"] {
    background: var(--surface-2);
    color: var(--text);
}

.ui-bell-trigger svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ui-bell-badge {
    position: absolute;
    top: 0.125rem;
    right: 0.125rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.25rem;
    border-radius: var(--radius-pill);
    background: var(--badge-orange);
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
}

.ui-bell-badge[hidden],
.ui-bell-panel[hidden] { display: none; }

.ui-bell-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 1000;
    width: min(22rem, calc(100vw - 2rem));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.ui-bell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
}

.ui-bell-count {
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--danger-soft);
    color: var(--danger-fg);
    font-size: 0.75rem;
}

.ui-bell-list {
    max-height: 22rem;
    overflow-y: auto;
}

.ui-bell-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.ui-bell-item:hover { background: var(--surface-2); }

.ui-bell-item-top {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8125rem;
}

.ui-bell-item-from {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-bell-item-date {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: var(--text-subtle);
}

.ui-bell-item-subject {
    overflow: hidden;
    font-size: 0.8125rem;
    color: var(--text-muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ui-bell-item-status {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--danger-fg);
}

.ui-bell-empty {
    padding: 1.25rem 0.9rem;
    font-size: 0.8125rem;
    text-align: center;
    color: var(--text-subtle);
}

.ui-bell-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.ui-bell-footer:hover { background: var(--surface-2); }

.ui-bell-footer svg {
    width: 1rem;
    height: 1rem;
}

/* Global top loading bar (Azure DevOps style) - driven by AppShared.loadingBar, shown for any jQuery AJAX
   or page navigation. Replaces the DataTables "processing" box. */
.ui-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    overflow: hidden;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ui-loading-bar.is-active {
    opacity: 1;
}

.ui-loading-bar::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    background: var(--primary);
    animation: ui-loading-slide 1.1s ease-in-out infinite;
}

@keyframes ui-loading-slide {
    0% { left: -40%; width: 40%; }
    50% { width: 30%; }
    100% { left: 100%; width: 40%; }
}

/* The top bar is the loading indicator - hide DataTables' own processing box. */
div.dt-processing {
    display: none !important;
}

/* =====================================================================
   Dark theme — remaps the Tailwind neutral utilities used in views onto
   the theme tokens, so pages don't need per-element dark: variants.
   ===================================================================== */
:root[data-theme="dark"] .bg-white { background-color: var(--surface); }
:root[data-theme="dark"] .bg-slate-50 { background-color: var(--bg-subtle); }
:root[data-theme="dark"] .bg-slate-100,
:root[data-theme="dark"] .bg-slate-200 { background-color: var(--surface-2); }
:root[data-theme="dark"] .text-slate-900,
:root[data-theme="dark"] .text-slate-800,
:root[data-theme="dark"] .text-slate-700 { color: var(--text); }
:root[data-theme="dark"] .text-slate-600,
:root[data-theme="dark"] .text-slate-500 { color: var(--text-muted); }
:root[data-theme="dark"] .text-slate-400,
:root[data-theme="dark"] .text-slate-300 { color: var(--text-subtle); }
:root[data-theme="dark"] .hover\:text-slate-600:hover { color: var(--text); }
:root[data-theme="dark"] .border-slate-100,
:root[data-theme="dark"] .border-slate-200 { border-color: var(--border); }
:root[data-theme="dark"] .border-slate-300 { border-color: var(--border-strong); }
:root[data-theme="dark"] .bg-green-50 { background-color: var(--accent-soft); }
:root[data-theme="dark"] .text-green-700 { color: var(--status-closed-fg); }
:root[data-theme="dark"] .border-green-200 { border-color: var(--accent-tint); }
:root[data-theme="dark"] .bg-red-50 { background-color: var(--danger-soft); }
:root[data-theme="dark"] .text-red-600 { color: var(--danger-fg); }
:root[data-theme="dark"] .border-red-200 { border-color: var(--danger-soft); }

/* Settings modal — theme picker */
.ui-theme-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.ui-theme-option {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.625rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: border-color var(--dur-fast) var(--ease-out);
}

.ui-theme-option:has(input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.ui-theme-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ui-theme-swatch {
    display: block;
    height: 3.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.ui-theme-swatch--light { background: linear-gradient(90deg, #ffffff 0 30%, #f9fafb 30%); }
.ui-theme-swatch--dark { background: linear-gradient(90deg, #262626 0 30%, #171717 30%); }
:root[data-theme="dark"] .bg-slate-50\/60,
:root[data-theme="dark"] .bg-zinc-100\/40 { background-color: var(--bg-subtle); }
:root[data-theme="dark"] .bg-zinc-100,
:root[data-theme="dark"] .hover\:bg-slate-50:hover,
:root[data-theme="dark"] .hover\:bg-slate-100:hover { background-color: var(--surface-2); }
:root[data-theme="dark"] .aria-pressed\:bg-white[aria-pressed="true"] { background-color: var(--surface-2); }
:root[data-theme="dark"] .aria-pressed\:text-slate-900[aria-pressed="true"],
:root[data-theme="dark"] .hover\:text-slate-700:hover,
:root[data-theme="dark"] .hover\:text-black:hover,
:root[data-theme="dark"] .text-zinc-900,
:root[data-theme="dark"] .text-black { color: var(--text); }
:root[data-theme="dark"] .before\:text-slate-400::before { color: var(--text-subtle); }
:root[data-theme="dark"] .before\:bg-slate-200::before { background-color: var(--border); }
:root[data-theme="dark"] .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border); }
:root[data-theme="dark"] .border-zinc-300,
:root[data-theme="dark"] .focus\:border-zinc-300:focus { border-color: var(--border-strong); }
:root[data-theme="dark"] .ring-white { --tw-ring-color: var(--surface); }
:root[data-theme="dark"] .focus\:ring-zinc-900:focus,
:root[data-theme="dark"] .open\:ring-zinc-900[open],
:root[data-theme="dark"] .ring-zinc-900 { --tw-ring-color: var(--primary); }

/* App-wide hover tooltip for title attributes (js/shared/tooltip.js). */
.ui-tip {
  position: fixed;
  z-index: 9999;
  max-width: 320px;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  background: #222;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: pre-line;
  pointer-events: none;
}

.ui-tip[hidden] { display: none; }
