/* SmartProxy Web UI */

/* ── Page Guide (contextual help banners) ── */
.page-guide { position: relative; margin-bottom: 1rem; }
.page-guide__show { display: none; }
.page-guide__content {
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 0.5rem;
    padding: 0.75rem 1rem; font-size: 0.8125rem; color: #1e40af;
}
.page-guide__header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.375rem; }
.page-guide__icon { color: #3b82f6; flex-shrink: 0; }
.page-guide__title { font-weight: 600; flex: 1; }
.page-guide__dismiss {
    color: #93c5fd; cursor: pointer; background: none; border: none;
    padding: 0.25rem; border-radius: 0.25rem; transition: color 0.15s;
}
.page-guide__dismiss:hover { color: #1e40af; }
.page-guide__body { color: #1e3a5f; line-height: 1.5; }
.page-guide__body ul { margin: 0.25rem 0 0 1.25rem; list-style: disc; }
.page-guide__body li { margin-bottom: 0.125rem; }
.page-guide__body code { background: #dbeafe; padding: 0.1em 0.35em; border-radius: 0.2rem; font-size: 0.75rem; }
.page-guide--dismissed .page-guide__content { display: none; }
.page-guide--dismissed .page-guide__show {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.75rem; height: 1.75rem; border-radius: 50%;
    background: #eff6ff; border: 1px solid #bfdbfe; color: #3b82f6;
    cursor: pointer; transition: background 0.15s;
}
.page-guide--dismissed .page-guide__show:hover { background: #dbeafe; }
:root {
    --brand-50: #f0f4ff;
    --brand-100: #dbe4ff;
    --brand-500: #3b5bdb;
    --brand-600: #364fc7;
    --brand-700: #2b44a8;
    --surface: #ffffff;
    --border: #e5e7eb;
    --dark-surface: #111827;
    --soft-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --sidebar-shadow: 1px 0 0 #e5e7eb;
}

/* Route changes focus the main landmark for assistive technology. The landmark
   itself is not interactive, so the browser's full-frame focus outline is
   distracting rather than useful; interactive descendants retain their rings. */
#content:focus {
    outline: none;
}

@media (max-width: 480px) {
    /* Four topbar controls plus the title do not fit safely at phone widths. The
       same health state remains available on the dashboard and via /health. */
    .app-status-pill,
    #cmdk-trigger {
        display: none !important;
    }
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #f9fafb;
    color: #374151;
}

.skip-link {
    position: fixed;
    left: 1rem;
    top: -3rem;
    z-index: 100;
    background: #111827;
    color: #ffffff;
    padding: 0.6rem 0.9rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 1rem;
}

h1, h2, h3, h4, h5, h6, .card-value {
    font-family: 'Inter', system-ui, sans-serif;
}

.app-sidebar {
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    color: #4b5563;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.75);
}

.app-sidebar__brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.375rem;
    background: #1f2937;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.app-topbar {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
}

.app-content {
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.app-status-pill,
.app-icon-button,
.app-user-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #4b5563;
    font-size: 0.8125rem;
    transition: border-color 0.15s;
}

.app-icon-button:hover,
.app-user-button:hover {
    border-color: #9ca3af;
    color: #111827;
}

.app-user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #1f2937;
    background: #e5e7eb;
}

/* Navigation active state */
.nav-link.active,
.mobile-nav-link.active {
    background: #f3f4f6;
    color: #111827;
    font-weight: 500;
    border-left: none;
}

.nav-link,
.mobile-nav-link {
    border-radius: 0.375rem;
    margin-bottom: 1px;
    color: #6b7280;
    font-size: 0.8125rem;
}

.nav-link:hover,
.mobile-nav-link:hover {
    background: #f9fafb;
    color: #111827;
}

/* Keyboard navigation visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}

/* Improve nav scrolling readability in long menus */
.app-sidebar nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.7) transparent;
}

.app-sidebar nav::-webkit-scrollbar {
    width: 8px;
}

.app-sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 9999px;
}

/* Cards */
.card {
    background: #ffffff;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: var(--soft-shadow);
    border: 1px solid #e5e7eb;
}

.card:hover {
    border-color: #d1d5db;
}

.card-header {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

/* Status badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 500;
}

.badge-healthy {
    background-color: #ecfdf5; /* emerald-50 */
    color: #047857; /* emerald-700 */
    border: 1px solid #d1fae5;
}

.badge-unhealthy {
    background-color: #fef2f2; /* red-50 */
    color: #b91c1c; /* red-700 */
    border: 1px solid #fee2e2;
}

.badge-degraded {
    background-color: #fffbeb; /* amber-50 */
    color: #b45309; /* amber-700 */
    border: 1px solid #fef3c7;
}

.badge-active {
    background-color: #eff6ff; /* blue-50 */
    color: #1d4ed8; /* blue-700 */
    border: 1px solid #dbeafe;
}

.badge-inactive {
    background-color: #f8fafc; /* slate-50 */
    color: #475569; /* slate-600 */
    border: 1px solid #e2e8f0;
}

/* badge-success, badge-danger, badge-warning, badge-info defined in
   Global polish section. Semantic variants below are page-specific. */
.badge-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #7c3aed;
}
.badge-cyan {
    background: rgba(6, 182, 212, 0.12);
    color: #0891b2;
}
.dark .badge-purple { color: #c4b5fd; }
.dark .badge-cyan   { color: #67e8f9; }

/* Table styles */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead {
    background-color: transparent;
}

.data-table th {
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

.data-table th:first-child { border-top-left-radius: 0.5rem; }
.data-table th:last-child { border-top-right-radius: 0.5rem; }

.data-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th[data-sort]:hover {
    color: #0f172a;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    color: #334155;
    transition: background-color 0.2s ease;
}

.data-table tbody tr:hover td {
    background-color: #f8fafc;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4375rem 0.875rem;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background-color 0.15s, border-color 0.15s;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: #111827;
    color: white;
}

.btn-primary:hover {
    background: #374151;
}

.btn-success {
    background: #059669;
    color: white;
}

.btn-success:hover {
    background: #047857;
}

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

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

.btn-secondary {
    background-color: #f1f5f9; /* slate-100 */
    color: #334155; /* slate-700 */
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid #cbd5e1; /* slate-300 */
    color: #475569;
}

.btn-outline:hover {
    background-color: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 0.375rem;
    color: #64748b;
    transition: all 0.2s;
    background-color: transparent;
    border: none;
    box-shadow: none;
}
.btn-icon:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

/* Form styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
}

.form-input {
    width: 100%;
    padding: 0.4375rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    transition: border-color 0.15s;
    background-color: #fff;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-select {
    width: 100%;
    padding: 0.625rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.form-select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Modal styles */
.modal-backdrop {
    background: rgba(15, 23, 42, 0.6);
}

.modal-content > div {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
    transform: scale(0.95);
    animation: modalPop 0.15s ease-out forwards;
}

@keyframes modalPop {
    to { transform: scale(1); }
}

.modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #0f172a;
}

.modal-close {
    color: #94a3b8;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
}

.modal-close:hover {
    color: #0f172a;
    background-color: #f1f5f9;
}

.modal-body {
    padding: 1.75rem;
}

.modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: #f8fafc;
    border-bottom-left-radius: 1.25rem;
    border-bottom-right-radius: 1.25rem;
}

/* Modal Overlay - for inline modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    padding: 1rem;
}

.modal-overlay .modal {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    border: 1px solid #e5e7eb;
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    animation: modalPop 0.15s ease-out forwards;
}

/* Toast styles */
.toast {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 280px;
    font-size: 0.8125rem;
    animation: slideIn 0.2s ease-out;
    border: 1px solid rgba(255,255,255,0.1);
    
}

.toast-success {
    background-color: rgba(236, 253, 245, 0.95);
    border-left: 4px solid #10b981;
    color: #065f46;
}

.toast-error {
    background-color: rgba(254, 242, 242, 0.95);
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.toast-warning {
    background-color: rgba(255, 251, 235, 0.95);
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.toast-info {
    background-color: rgba(239, 246, 255, 0.95);
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

.toast-exit {
    animation: toast-out 0.15s ease-in forwards;
}
@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(110%); opacity: 0; }
}

/* Loading spinner */
.spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid #e2e8f0;
    border-top-color: var(--brand-500);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Empty state defined in Global polish section */

/* Status dot */
.status-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    display: inline-block;
}

.status-dot-healthy { background-color: #10b981; }
.status-dot-unhealthy { background-color: #ef4444; }
.status-dot-degraded { background-color: #f59e0b; }

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.toolbar-actions {
    display: flex;
    gap: 0.75rem;
}

/* Search box */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.75rem;
    border-radius: 0.375rem; /* fully rounded */
    background: #ffffff;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    color: #94a3b8;
}

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

/* Chart container */
.chart-container {
    position: relative;
    height: 320px;
}

.dashboard-shell {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dashboard-hero {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 1rem;
}

.dashboard-hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
    gap: 1rem;
    position: relative;
    z-index: 1;
}

.dashboard-eyebrow { display: none; }

.dashboard-hero h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.dashboard-hero p {
    color: #6b7280;
    font-size: 0.8125rem;
}

.dashboard-hero__status { display: none; }
.dashboard-pulse { display: none; }
.dashboard-chip-row { display: none; }
.dashboard-chip { display: none; }
.dashboard-chip--success { display: none; }

.dashboard-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.dashboard-stat-card,
.dashboard-stat-card--alert,
.dashboard-stat-card--success {
    padding: 1rem;
    border-radius: 0.375rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    min-height: auto;
    box-shadow: none;
}

.dashboard-stat-card__label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.dashboard-stat-card__value {
    margin-top: 0.25rem;
    font-family: 'Inter', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.2;
    color: #111827;
}

.dashboard-panel {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.95);
    box-shadow: var(--soft-shadow);
    border-radius: 1.5rem;
}

.dashboard-panel--dark {
    background: #1e293b;
    border-color: rgba(51, 65, 85, 0.7);
}

.dashboard-action-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    border-radius: 0.375rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.dashboard-action-card:hover {
    
    background: white;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    .dashboard-hero {
        padding: 1.35rem;
        border-radius: 1.5rem;
    }
    .dashboard-hero__grid,
    .dashboard-stat-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-chip-row {
        justify-content: flex-start;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar-actions {
        justify-content: flex-end;
    }
    .data-table {
        display: block;
        overflow-x: auto;
    }

    .app-topbar .flex.items-center.justify-between {
        padding-left: 1rem;
        padding-right: 1rem;
        gap: 0.75rem;
    }

    .app-status-pill span:last-child {
        display: none;
    }
}

/* Confirmation dialog */
.confirm-dialog {
    text-align: center;
    padding: 2rem;
}

.confirm-dialog-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.25rem;
    color: #f59e0b;
}

.confirm-dialog-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

.confirm-dialog-message {
    color: #475569;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.confirm-dialog-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.75rem;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    border-radius: 0.375rem;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 1.25rem;
    width: 1.25rem;
    left: 0.25rem;
    bottom: 0.25rem;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.toggle input:checked + .toggle-slider {
    background-color: var(--brand-500);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(1.25rem);
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    z-index: 100;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background-color: rgba(15, 23, 42, 0.9);
    
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

.action-btn {
    padding: 0.4rem;
    border-radius: 0.375rem;
    color: #64748b;
    transition: all 0.2s ease;
    cursor: pointer;
}

.action-btn:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    transform: scale(1.05);
}

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

/* ==================== Dark Mode Styles ==================== */

.dark body {
    background-color: #111827;
    color: #d1d5db;
}

.dark .app-sidebar,
.dark .app-topbar,
.dark .app-status-pill,
.dark .app-icon-button,
.dark .app-user-button,
.dark .dashboard-hero,
.dark .dashboard-panel {
    background: rgba(15, 23, 42, 0.88) !important;
    border-color: rgba(51, 65, 85, 0.7) !important;
    color: #e2e8f0;
}

.dark .app-user-avatar,
.dark .app-sidebar__brand-mark {
    color: white;
}

.dark .nav-link,
.dark .mobile-nav-link {
    color: #cbd5e1;
}

.dark .nav-link:hover,
.dark .mobile-nav-link:hover,
.dark .nav-link.active,
.dark .mobile-nav-link.active {
    color: white;
}

.dark .dashboard-stat-card,
.dark .dashboard-action-card {
    background: rgba(30, 41, 59, 0.88);
    border-color: rgba(71, 85, 105, 0.8);
}

/* Dark mode cards */
.dark .card,
.dark .bg-white {
    background: rgba(30, 41, 59, 0.95) !important;
    border-color: rgba(51, 65, 85, 0.5) !important;
}

.dark .card-header {
    color: #94a3b8;
}

.dark .card-value {
    color: #f8fafc;
}

/* Dark mode text colors */
.dark .text-slate-800,
.dark .text-slate-700,
.dark .text-slate-600 {
    color: #cbd5e1 !important;
}

.dark .text-gray-900,
.dark .text-gray-800,
.dark .text-gray-700 {
    color: #e2e8f0 !important;
}

.dark .text-gray-600,
.dark .text-gray-500 {
    color: #94a3b8 !important;
}

/* Dark mode backgrounds */
.dark .bg-slate-50,
.dark .bg-gray-50 {
    background-color: #1e293b !important;
}

.dark .bg-slate-100,
.dark .bg-gray-100 {
    background-color: #334155 !important;
}

/* Dark mode borders */
.dark .border-gray-100,
.dark .border-gray-200,
.dark .border-slate-100,
.dark .border-slate-200 {
    border-color: #334155 !important;
}

/* Dark mode forms */
.dark .form-input,
.dark select,
.dark input:not([type="checkbox"]):not([type="radio"]),
.dark textarea {
    background-color: #1e293b !important;
    border-color: #475569 !important;
    color: #f1f5f9 !important;
}

.dark .form-input:focus,
.dark select:focus,
.dark input:focus,
.dark textarea:focus {
    border-color: #3b82f6 !important;
}

.dark .form-input::placeholder,
.dark input::placeholder,
.dark textarea::placeholder {
    color: #64748b !important;
}

/* Dark mode tables */
.dark table th {
    background-color: #1e293b !important;
    color: #94a3b8 !important;
}

.dark table td {
    border-color: #334155 !important;
}

.dark table tr:hover {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

/* Dark mode buttons */
.dark .btn-secondary {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

.dark .btn-secondary:hover {
    background-color: #475569 !important;
}

.dark .btn-outline {
    border-color: #475569 !important;
    color: #cbd5e1 !important;
}

.dark .btn-outline:hover {
    background-color: #334155 !important;
}

.dark .btn-icon:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

/* Dark mode action buttons */
.dark .action-btn {
    color: #94a3b8 !important;
}

.dark .action-btn:hover {
    background-color: #334155 !important;
    color: #f1f5f9 !important;
}

/* Dark mode badges - keep light backgrounds for contrast */
.dark .badge-healthy {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.3) !important;
}

.dark .badge-unhealthy {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.dark .badge-degraded {
    background-color: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

/* Dark mode main content area */
.dark main {
    background-color: #0f172a !important;
}

/* Dark mode modals */
.dark .modal-content,
.dark [role="dialog"] > div {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Dark mode sidebar - already dark */
.dark #sidebar {
    background-color: #0f172a;
    border-color: rgba(51, 65, 85, 0.3);
}

/* Dark mode header */
.dark header {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

/* Dark mode dropdown menus */
.dark #user-menu-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

.dark #user-menu-dropdown a:hover,
.dark #user-menu-dropdown button:hover {
    background-color: #334155 !important;
}

/* Dark mode hero sections - preserve gradient but darken */
.dark .bg-gradient-to-r {
    opacity: 0.95;
}

/* Ensure good contrast in stat cards */
.dark .text-2xl,
.dark .text-3xl,
.dark .text-4xl {
    color: #f8fafc !important;
}

/* ==================== UI/UX improvements (later additions) ==================== */

/* :focus-visible — visible keyboard focus on every interactive element.
   The default Tailwind reset removes outlines on hover/click but leaves
   keyboard users with no indicator of "where am I" while tabbing. */
.nav-link:focus-visible,
.mobile-nav-link:focus-visible,
.btn:focus-visible,
.btn-icon:focus-visible,
.action-btn:focus-visible,
.app-icon-button:focus-visible,
.app-user-button:focus-visible,
.app-status-pill:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: 0.75rem;
}
.dark .nav-link:focus-visible,
.dark .mobile-nav-link:focus-visible,
.dark .btn:focus-visible,
.dark .app-icon-button:focus-visible {
    outline-color: #818cf8;
}

/* Active sidebar item — make the current page obviously selected. The
   prior CSS only applied hover/visited styles so users couldn't tell
   which page they were on, especially after a hard refresh. */
.nav-link.active,
.mobile-nav-link.active {
    background: #f1f5f9;
    color: #0f172a !important;
    font-weight: 600;
}
.dark .nav-link.active,
.dark .mobile-nav-link.active {
    background: rgba(51, 65, 85, 0.5);
    color: #f1f5f9 !important;
}

/* Reduced-motion support — disable card hover lift, slide-in toasts,
   and spinner animation for users who request reduced motion. The
   current CSS uses cubic-bezier transitions everywhere, which is a
   real problem for vestibular-disorder users. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .card:hover { transform: none; }
    .btn:active { transform: none; }
    .toast { animation: none; opacity: 1; transform: none; }
}

/* Toast: dismissible, dark-mode visible, ARIA-ready. The ::before
   pseudo-element supplies a focusable close affordance via JS. */
.toast {
    position: relative;
    padding-right: 2.5rem;
}
.toast-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    opacity: 0.6;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}
.toast-close:hover { opacity: 1; background: rgba(0,0,0,0.05); }
.toast-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 1px;
    opacity: 1;
}
.dark .toast-success {
    background-color: rgba(6, 95, 70, 0.95);
    color: #d1fae5;
    border-left-color: #34d399;
}
.dark .toast-error {
    background-color: rgba(127, 29, 29, 0.95);
    color: #fee2e2;
    border-left-color: #f87171;
}
.dark .toast-warning {
    background-color: rgba(120, 53, 15, 0.95);
    color: #fef3c7;
    border-left-color: #fbbf24;
}
.dark .toast-info {
    background-color: rgba(30, 64, 175, 0.95);
    color: #dbeafe;
    border-left-color: #60a5fa;
}
.dark .toast-close:hover { background: rgba(255,255,255,0.08); }

/* Skeleton sub-types (animation defined in Global polish section below) */
.skeleton-line { height: 0.85rem; }
.skeleton-line + .skeleton-line { margin-top: 0.55rem; }
.skeleton-card { height: 6rem; border-radius: var(--radius-sm); }
.skeleton-row { height: 2.75rem; border-radius: var(--radius-sm); }

/* Command palette overlay. Activated with Cmd/Ctrl+K. */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.cmdk-panel {
    width: min(640px, 92vw);
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 32px 80px rgba(15, 23, 42, 0.30);
    border: 1px solid rgba(226, 232, 240, 0.9);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}
.dark .cmdk-panel {
    background: rgba(15, 23, 42, 0.98);
    border-color: rgba(71, 85, 105, 0.7);
}
.cmdk-input {
    width: 100%;
    border: 0;
    padding: 1.05rem 1.25rem;
    font-size: 1rem;
    background: transparent;
    color: inherit;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}
.cmdk-input:focus { outline: none; }
.dark .cmdk-input { border-bottom-color: rgba(71, 85, 105, 0.7); }
.cmdk-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.625rem;
    font-size: 0.925rem;
    color: #334155;
    cursor: pointer;
    user-select: none;
}
.cmdk-item[aria-selected="true"],
.cmdk-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}
.dark .cmdk-item { color: #cbd5e1; }
.dark .cmdk-item[aria-selected="true"],
.dark .cmdk-item:hover {
    background: rgba(51, 65, 85, 0.5);
    color: #f1f5f9;
}
.cmdk-empty {
    text-align: center;
    color: #94a3b8;
    padding: 2rem 1rem;
    font-size: 0.875rem;
}
.cmdk-hint {
    display: flex;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: rgba(248, 250, 252, 0.7);
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    color: #64748b;
    font-size: 0.75rem;
}
.dark .cmdk-hint {
    background: rgba(30, 41, 59, 0.7);
    border-top-color: rgba(71, 85, 105, 0.6);
    color: #94a3b8;
}
kbd.cmdk-kbd {
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(255, 255, 255, 0.8);
    font-family: 'ui-monospace', SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.7rem;
    color: #475569;
}
.dark kbd.cmdk-kbd {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(71, 85, 105, 0.6);
    color: #cbd5e1;
}

/* -------------------------------------------------------------------------
   Cohesive application shell
   ------------------------------------------------------------------------- */
:root {
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --surface-muted: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --focus-ring: rgba(59, 130, 246, 0.2);
    --radius-sm: 0.625rem;
    --radius-md: 0.875rem;
    --radius-lg: 1.125rem;
}

html {
    scrollbar-gutter: stable;
}

body {
    color: var(--text);
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
[role="button"],
a {
    -webkit-tap-highlight-color: transparent;
}

.app-sidebar {
    background: rgba(255, 255, 255, 0.985);
}

.app-sidebar nav {
    overscroll-behavior: contain;
}

.nav-search {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.75rem;
    padding: 0.65rem 0.75rem;
    color: #94a3b8;
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
    
}

.nav-search:focus-within {
    color: #334155;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.nav-search svg {
    width: 1rem;
    height: 1rem;
}

.nav-search__input {
    min-width: 0;
    padding: 0;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 0.8125rem;
}

.nav-search__input::placeholder {
    color: #94a3b8;
}

.nav-search__input::-webkit-search-cancel-button {
    cursor: pointer;
}

.nav-search__hint {
    min-width: 1.35rem;
    padding: 0.05rem 0.35rem;
    color: #94a3b8;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
    font-size: 0.6875rem;
    line-height: 1.25rem;
    text-align: center;
}

.nav-section {
    margin-top: 0.9rem;
}

.nav-section:first-of-type {
    margin-top: 0;
}

.nav-section__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.35rem 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background 0.15s;
}

.nav-section__toggle:hover {
    background: rgba(100, 116, 139, 0.08);
}

.nav-section__title {
    margin: 0;
    padding: 0;
    color: #64748b;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.5;
    text-transform: uppercase;
}

.nav-section__chevron {
    width: 1rem;
    height: 1rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
    flex-shrink: 0;
}

.nav-section__chevron--open {
    transform: rotate(0deg);
}

.nav-section__links {
    overflow: hidden;
}

.nav-section__links[hidden] {
    display: none;
}

.nav-section[hidden] {
    display: none;
}

.nav-search--empty::after {
    content: "No matching pages";
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    right: 0;
    padding: 0.65rem;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    text-align: center;
}

.nav-link,
.mobile-nav-link {
    min-height: 2.75rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-link[hidden],
.mobile-nav-link[hidden] {
    display: none !important;
}

.app-topbar {
    background: #ffffff;
}

.app-content {
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

/* Solid surfaces scan faster and render more cheaply than nested glass blur. */
.card,
.page-stat,
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.055);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.card {
    border-radius: var(--radius-lg);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.card:hover {
    transform: none;
    border-color: var(--border-strong);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.075);
}

.card-value,
.page-stat__value,
.data-table td,
.dt-mono {
    font-variant-numeric: tabular-nums;
}

.data-table {
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th {
    color: #475569;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.6875rem;
    letter-spacing: 0.055em;
}

.data-table td {
    border-bottom-color: #eef2f7;
}

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

.data-table tbody tr {
    transition: background-color 120ms ease;
}

.data-table tbody tr:hover td {
    background: #f8faff;
}

.btn,
.action-btn,
.btn-icon {
    min-height: 2.5rem;
}

.btn {
    border-radius: 0.7rem;
    font-weight: 650;
}

.page-loading {
    max-width: 90rem;
    margin: 0 auto;
    padding-top: 0.25rem;
}

.page-loading__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-loading__header > div {
    flex: 1;
}

.page-loading__icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-md);
}

.page-loading__title {
    width: min(18rem, 65%);
    height: 1.35rem;
}

.page-loading__subtitle {
    width: min(32rem, 85%);
    height: 0.8rem;
}

.page-loading__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.page-loading__stats > span {
    min-height: 7.5rem;
    border-radius: var(--radius-lg);
}

.page-state {
    display: flex;
    min-height: 50vh;
    max-width: 38rem;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.page-state__icon {
    display: grid;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1rem;
    place-items: center;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 1rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.page-state__eyebrow {
    margin-bottom: 0.4rem;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-state h2 {
    margin-bottom: 0.5rem;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 750;
}

.page-state > p:not(.page-state__eyebrow) {
    color: var(--text-muted);
}

.page-state__actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.dark {
    --surface: #111827;
    --surface-subtle: #172033;
    --surface-muted: #1e293b;
    --border: #334155;
    --border-strong: #475569;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
}

.dark .app-sidebar,
.dark .app-topbar {
    background: rgba(15, 23, 42, 0.97);
}

.dark .nav-search {
    color: #64748b;
    background: rgba(30, 41, 59, 0.96);
    border-color: #334155;
}

.dark .nav-search__input {
    color: #f8fafc;
}

.dark .nav-search__hint {
    color: #94a3b8;
    background: #0f172a;
    border-color: #334155;
}

.dark .data-table th,
.dark .data-table tbody tr:hover td {
    background: #182235;
}

.dark .data-table td {
    border-bottom-color: #273449;
}

.dark .page-state__icon {
    color: #fca5a5;
    background: rgba(127, 29, 29, 0.35);
    border-color: #7f1d1d;
}

@supports (content-visibility: auto) {
    .card,
    .table-container {
        content-visibility: auto;
        contain-intrinsic-size: auto 18rem;
    }
}

@media (max-width: 767px) {
    .app-topbar > div {
        min-height: 4rem;
        padding-inline: 1rem;
    }

    .app-content {
        padding: 1rem;
    }

    .page-header {
        gap: 1rem;
        margin-bottom: 1.25rem;
    }

    .page-header__actions,
    .page-state__actions {
        width: 100%;
        flex-direction: column;
    }

    .page-header__actions .btn,
    .page-state__actions .btn {
        width: 100%;
        justify-content: center;
    }

    .page-loading__stats {
        grid-template-columns: 1fr;
    }

    .page-loading__stats > span:nth-child(n + 2) {
        display: none;
    }

    .card {
        padding: 1rem;
        border-radius: var(--radius-md);
    }
}

/* Status indicator color states. Replaces the hardcoded green dot in
   the topbar so the UI reflects /health output. */
.app-status-pill[data-state="ok"]      .status-dot { background: #10b981; }
.app-status-pill[data-state="degraded"] .status-dot { background: #f59e0b; }
.app-status-pill[data-state="down"]    .status-dot { background: #ef4444; }
.app-status-pill[data-state="unknown"] .status-dot { background: #94a3b8; }
.status-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
    transition: background-color 0.3s ease;
}

/* ==================== Data table component ==================== */
/* Companion to internal/api/webui/js/data-table.js. Sortable headers,
   sticky thead, mobile card fallback, search, pagination. */

.data-table-wrap {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid #e5e7eb;
    box-shadow: var(--soft-shadow);
    overflow: hidden;
}
.dark .data-table-wrap {
    background: rgba(30, 41, 59, 0.92) !important;
    border-color: rgba(71, 85, 105, 0.7) !important;
}

.dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
}
.dark .dt-toolbar { border-bottom-color: rgba(71, 85, 105, 0.55); }

.dt-search {
    position: relative;
    flex: 1;
    max-width: 360px;
}
.dt-search svg {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.dt-search-input {
    width: 100%;
    padding: 0.55rem 0.7rem 0.55rem 2rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 0.6rem;
    background: #ffffff;
    font-size: 0.875rem;
    color: #0f172a;
}
.dt-search-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.15);
}
.dark .dt-search-input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.7);
    color: #f1f5f9;
}

.dt-status {
    color: #64748b;
    font-size: 0.8125rem;
    white-space: nowrap;
}
.dark .dt-status { color: #94a3b8; }

.dt-scroll {
    max-height: 70vh;
    overflow: auto;
}

/* Desktop: real <table> with sticky header. Mobile: hide table, show
   stacked cards. The breakpoint matches the existing sidebar's md:. */
.dt-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.dt-cards { display: none; list-style: none; padding: 0; margin: 0; }

@media (max-width: 640px) {
    .dt-table { display: none; }
    .dt-cards { display: block; }
}

.dt-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}
.dark .dt-table thead th {
    background: rgba(30, 41, 59, 0.95);
    color: #94a3b8;
    border-bottom-color: rgba(71, 85, 105, 0.7);
}

.dt-table tbody td {
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.dark .dt-table tbody td {
    color: #cbd5e1;
    border-bottom-color: rgba(51, 65, 85, 0.6);
}
.dt-table tbody tr:last-child td { border-bottom: 0; }
.dt-table tbody tr:hover td { background: rgba(248, 250, 252, 0.7); }
.dark .dt-table tbody tr:hover td { background: rgba(51, 65, 85, 0.4); }

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

/* Sortable header button — keep clickable target large + accessible. */
.dt-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    padding: 0;
}
.dt-sort-btn:hover { color: var(--brand-700); }
.dt-sort-btn:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 3px;
    border-radius: 0.25rem;
}
.dt-sort-arrow {
    color: var(--brand-500);
    font-size: 0.75rem;
    min-width: 0.7rem;
}

.dt-align-right  { text-align: right; }
.dt-align-center { text-align: center; }
.dt-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
}
.dt-truncate {
    max-width: 32ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dt-muted { color: #cbd5e1; }
.dark .dt-muted { color: #475569; }

/* Mobile card layout: every column becomes a labeled key/value pair. */
.dt-card {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
}
.dark .dt-card { border-bottom-color: rgba(51, 65, 85, 0.6); }
.dt-card-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}
.dt-card-label {
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    min-width: 6rem;
}
.dt-card-value {
    color: #0f172a;
    text-align: right;
    flex: 1;
    overflow-wrap: anywhere;
}
.dark .dt-card-label { color: #94a3b8; }
.dark .dt-card-value { color: #e2e8f0; }

.dt-empty {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: #64748b;
}
.dt-empty svg {
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    color: #cbd5e1;
}
.dt-empty p { margin: 0 0 0.5rem; }
.dark .dt-empty { color: #94a3b8; }
.dark .dt-empty svg { color: #475569; }

.dt-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(226, 232, 240, 0.7);
    background: rgba(248, 250, 252, 0.6);
}
.dark .dt-pager {
    border-top-color: rgba(71, 85, 105, 0.55);
    background: rgba(15, 23, 42, 0.6);
}
.dt-pager-info {
    color: #475569;
    font-size: 0.8125rem;
}
.dark .dt-pager-info { color: #cbd5e1; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8125rem; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ==================== Page chrome (page-chrome.js) ==================== */
/* Canonical page header / stat grid / toolbar. Pages should import
   pageHeader/statGrid/toolbar from page-chrome.js and use these classes
   instead of hand-rolling Tailwind utility chains, so the dashboard
   has one consistent look across all 29 pages. */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1.75rem;
    border-radius: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--soft-shadow);
}
.dark .page-header {
    background: var(--surface-muted) !important;
    border-color: var(--border) !important;
}

.page-header__main {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-width: 0;
}

.page-header__icon { display: none; }
.page-header__icon svg {
    width: 1.5rem;
    height: 1.5rem;
}

.page-header__text { min-width: 0; }
.page-header__eyebrow { display: none; }
.page-header__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}
.page-header__description {
    margin: 0.125rem 0 0;
    color: #6b7280;
    font-size: 0.8125rem;
}
.dark .page-header__eyebrow { display: none; }
.dark .page-header__title { color: #f1f5f9; }
.dark .page-header__description { color: #94a3b8; }

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.page-header__actions .btn { gap: 0.4rem; }

/* Page stats grid. Replaces the per-page ad-hoc Tailwind
   "rounded-xl shadow-sm border border-gray-100 p-4" patterns. */
.page-stats {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.page-stats[data-cols="1"] { grid-template-columns: 1fr; }
.page-stats[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) {
    .page-stats { grid-template-columns: 1fr; }
}

.page-stat {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.page-stat:hover { border-color: #d1d5db; }
.dark .page-stat {
    background: var(--surface-muted);
    border-color: var(--border);
}

.page-stat__icon {
    display: none;
    /* Uncomment below to enable stat icons:
    width: 2rem;
    height: 2rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    */
}
.page-stat__icon svg { width: 1.25rem; height: 1.25rem; }
.page-stat__icon--neutral { background: rgba(148, 163, 184, 0.18); color: #475569; }
.page-stat__icon--brand   { background: rgba(59, 91, 219, 0.12); color: var(--brand-700); }
.page-stat__icon--success { background: rgba(16, 185, 129, 0.16); color: #047857; }
.page-stat__icon--warning { background: rgba(245, 158, 11, 0.18); color: #b45309; }
.page-stat__icon--danger  { background: rgba(239, 68, 68, 0.16); color: #b91c1c; }
.page-stat__icon--info    { background: rgba(59, 130, 246, 0.16); color: #1d4ed8; }
.dark .page-stat__icon--neutral { background: rgba(148, 163, 184, 0.20); color: #cbd5e1; }
.dark .page-stat__icon--brand   { background: rgba(59, 91, 219, 0.22); color: #93a8f0; }
.dark .page-stat__icon--success { background: rgba(16, 185, 129, 0.22); color: #6ee7b7; }
.dark .page-stat__icon--warning { background: rgba(245, 158, 11, 0.22); color: #fcd34d; }
.dark .page-stat__icon--danger  { background: rgba(239, 68, 68, 0.22); color: #fca5a5; }
.dark .page-stat__icon--info    { background: rgba(59, 130, 246, 0.22); color: #93c5fd; }

.page-stat__body { display: flex; flex-direction: column; min-width: 0; }
.page-stat__label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #6b7280;
}
.page-stat__value {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    line-height: 1;
}
.page-stat__sub {
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: #94a3b8;
}
.dark .page-stat__label { color: #94a3b8; }
.dark .page-stat__value { color: #f1f5f9; }
.dark .page-stat__sub { color: #64748b; }

/* Page toolbar — search + filter selects + secondary actions. */
.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}
.dark .page-toolbar {
    background: rgba(30, 41, 59, 0.85) !important;
    border-color: rgba(71, 85, 105, 0.6) !important;
}

.page-toolbar__left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
}

.page-toolbar__right {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Canonical search input. Replaces both the legacy .search-box and
   ad-hoc Tailwind versions. The DataTable component uses its own
   .dt-search inside table headers but the visual treatment is aligned. */
.page-search {
    position: relative;
    flex: 1;
    max-width: 380px;
    min-width: 200px;
}
.page-search svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}
.page-search__input {
    width: 100%;
    padding: 0.55rem 0.85rem 0.55rem 2.3rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 0.65rem;
    background: #ffffff;
    color: #0f172a;
    font-size: 0.875rem;
}
.page-search__input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.15);
}
.dark .page-search__input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.7);
    color: #f1f5f9;
}

.page-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8125rem;
    color: #475569;
}
.dark .page-filter { color: #cbd5e1; }
.page-filter__label {
    font-weight: 600;
    color: #64748b;
}
.page-filter__select {
    padding: 0.45rem 0.65rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    background: #ffffff;
    color: #0f172a;
    font-size: 0.8125rem;
    cursor: pointer;
}
.dark .page-filter__select {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.7);
    color: #f1f5f9;
}

/* ==================== Date range picker (date-range.js) ==================== */
.date-range {
    background: var(--surface);
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
}
.dark .date-range {
    background: rgba(30, 41, 59, 0.85) !important;
    border-color: rgba(71, 85, 105, 0.6) !important;
}
.date-range__presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.date-range__preset {
    padding: 0.4rem 0.85rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    background: #ffffff;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.date-range__preset:hover {
    background: rgba(248, 250, 252, 1);
    color: #0f172a;
}
.date-range__preset.is-active {
    background: #111827;
    border-color: #111827;
    color: white;
}
.date-range__preset:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
}
.dark .date-range__preset {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.7);
    color: #cbd5e1;
}
.dark .date-range__preset:hover {
    color: #f1f5f9;
}
.dark .date-range__preset.is-active {
    color: white;
}

.date-range__custom {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(226, 232, 240, 0.7);
}
.dark .date-range__custom { border-top-color: rgba(71, 85, 105, 0.55); }
.date-range__label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dark .date-range__label { color: #94a3b8; }
.date-range__input {
    padding: 0.45rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(226, 232, 240, 0.95);
    font-size: 0.875rem;
    color: #0f172a;
    background: #ffffff;
}
.date-range__input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(109, 94, 252, 0.15);
}
.dark .date-range__input {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(71, 85, 105, 0.7);
    color: #f1f5f9;
}
.date-range .hidden { display: none !important; }

/* ==================== Form validation (form-validate.js) ==================== */
.form-input.is-invalid,
input.is-invalid,
textarea.is-invalid,
select.is-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}
.form-error {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    color: #dc2626;
    line-height: 1.3;
}
.dark .form-error { color: #fca5a5; }

/* Mobile table responsiveness */
@media (max-width: 768px) {
    .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table th, .data-table td { white-space: nowrap; }
    .modal-content { padding: 0.5rem !important; }
}

/* Touch device target sizes */
@media (hover: none) and (pointer: coarse) {
    .btn { min-height: 44px; }
    .btn-sm { min-height: 40px; }
    .action-btn { min-width: 44px; min-height: 44px; }
}

/* ── Global polish ─────────────────────────────────────── */

/* Smooth content transitions */
#content {
    transition: opacity 0.15s ease-out;
    will-change: opacity;
}

/* Loading overlay for async operations */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.6);
    border-radius: inherit;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.dark .loading-overlay {
    background: rgba(15, 23, 42, 0.6);
}

/* Empty state component */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}
.empty-state svg {
    width: 3rem;
    height: 3rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}
.empty-state h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
}
.empty-state p {
    font-size: 0.8125rem;
    color: #94a3b8;
    max-width: 20rem;
}
.dark .empty-state h3 { color: #e2e8f0; }
.dark .empty-state p { color: #64748b; }

/* Button loading spinner */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.5s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

/* Tabular numbers in data cells for alignment */
.tabular-nums, td {
    font-variant-numeric: tabular-nums;
}

/* Consistent badge/tag component */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 0.375rem;
    letter-spacing: 0.02em;
}
.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-danger  { background: rgba(239,68,68,0.12); color: #dc2626; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-info    { background: rgba(59,130,246,0.12); color: #2563eb; }
.badge-neutral { background: rgba(100,116,139,0.12); color: #64748b; }
.dark .badge-success { color: #34d399; }
.dark .badge-danger  { color: #f87171; }
.dark .badge-warning { color: #fbbf24; }
.dark .badge-info    { color: #60a5fa; }
.dark .badge-neutral { color: #94a3b8; }

/* Responsive stat cards */
@media (max-width: 768px) {
    .page-stats { grid-template-columns: repeat(2, 1fr) !important; }
    .page-stats[data-cols="3"] { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
    .page-stats { grid-template-columns: 1fr !important; }
}

/* Responsive modals */
@media (max-width: 640px) {
    .modal-content {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }
    .modal-content .flex.justify-end {
        flex-direction: column;
        gap: 0.5rem;
    }
    .modal-content .flex.justify-end .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Skeleton loading pulse */
.skeleton {
    background: linear-gradient(90deg, rgba(148,163,184,0.1) 25%, rgba(148,163,184,0.2) 50%, rgba(148,163,184,0.1) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Toast improvements */
.toast {
    animation: toast-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
