:root {
    --sidebar-bg: #ffffff;
    --sidebar-text: #374151;
    --sidebar-muted: #9ca3af;
    --sidebar-hover-bg: #f9fafb;
    --sidebar-active-bg: #f3f4f6;
    --sidebar-active-text: #111827;
    --sidebar-border: #e5e7eb;
    --sidebar-brand-text: #111827;
    --topnav-bg: #ffffff;
    --topnav-text: #111827;
    --topnav-border: #e5e7eb;
    --topnav-muted: #6b7280;
    --topnav-hover: #f3f4f6;
    --content-bg: #f8fafc;
    --surface-bg: #ffffff;
    --surface-border: #e5e7eb;
    --surface-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-text: #ffffff;
    --accent-subtle: #eff6ff;
    --accent-subtle-text: #1d4ed8;
    --alert-success-bg: #dcfce7;
    --alert-success-text: #166534;
    --alert-success-border: #bbf7d0;
    --alert-error-bg: #fee2e2;
    --alert-error-text: #991b1b;
    --alert-error-border: #fecaca;
    /* Match operations form tokens */
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-border-focus: var(--accent);
    --input-shadow-focus: rgba(37, 99, 235, 0.15);
    --divider: var(--surface-border);
}

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

/* Allow scroll everywhere but hide scrollbars (admin-wide) */
* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
*::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--content-bg);
    -webkit-font-smoothing: antialiased;
}

body.dashboard-stage-body {
    overflow: hidden;
    color-scheme: dark;
    --tv-font-display: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --tv-font-body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --tv-bg: #0d1117;
    --tv-bg-soft: #151a22;
    --tv-surface: #1b1f29;
    --tv-surface-2: #242a36;
    --tv-border: #2e3542;
    --tv-text: #e8eefc;
    --tv-muted: #97a4bd;
    --tv-rail: #303849;
    --tv-progress-start: #c1352b;
    --tv-progress-end: #df5247;
    --tv-accent-bg: rgba(193, 53, 43, 0.24);
    --tv-accent-border: rgba(223, 82, 71, 0.36);
    --tv-success-bg: rgba(22, 163, 74, 0.24);
    --tv-success-text: #86efac;
    --tv-info-bg: rgba(59, 130, 246, 0.24);
    --tv-info-text: #93c5fd;
    --tv-warning-bg: rgba(245, 158, 11, 0.25);
    --tv-warning-text: #fcd34d;
    --tv-neutral-bg: rgba(100, 116, 139, 0.24);
    --tv-neutral-text: #e2e8f0;
    --tv-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
    min-height: 100vh;
    background: #0a0a0a;
    color: var(--tv-text);
    font-family: var(--tv-font-body);
}

body.dashboard-stage-body[data-tv-mode='light'] {
    --tv-bg: #eef2f7;
    --tv-bg-soft: #f4f7fb;
    --tv-surface: #ffffff;
    --tv-surface-2: #f7f9fd;
    --tv-border: #dbe3ef;
    --tv-text: #101827;
    --tv-muted: #66758f;
    --tv-rail: #d9e0eb;
    --tv-progress-start: #c1352b;
    --tv-progress-end: #df5247;
    --tv-accent-bg: #faecea;
    --tv-accent-border: #eaa29c;
    --tv-success-bg: #eafaf0;
    --tv-success-text: #166534;
    --tv-info-bg: #e8f0ff;
    --tv-info-text: #1d4ed8;
    --tv-warning-bg: #fff6e8;
    --tv-warning-text: #b45309;
    --tv-neutral-bg: #edf1f6;
    --tv-neutral-text: #475569;
    --tv-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    background:
        radial-gradient(ellipse at 15% 0%, rgba(59, 130, 246, 0.08), transparent 30%),
        radial-gradient(ellipse at 90% 0%, rgba(100, 116, 139, 0.06), transparent 32%),
        linear-gradient(180deg, #f3f6fa 0%, #edf2f8 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Button-styled links: no hover underline (global rule above is for prose links only) */
a.btn:hover,
a[class^="btn-"]:hover,
a[class*=" btn-"]:hover,
a.billing-mod-icon-btn:hover {
    text-decoration: none;
}

.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.dashboards-selector-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-filter-form {
    display: flex;
    align-items: end;
    gap: 12px;
}

.dashboard-filter-form label {
    min-width: 280px;
}

.dashboard-tenant-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1;
    min-width: 280px;
}

.dashboard-tenant-label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.dashboard-tenant-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboards-table td:last-child,
.dashboards-table th:last-child {
    text-align: right;
}

.dashboard-launch-btn,
.dashboard-launch-btn:hover,
.dashboard-launch-btn:focus {
    color: #fff;
}

.dashboards-catalog .page-header h1 {
    font-size: clamp(1.4rem, 1.05rem + 1vw, 1.8rem);
    letter-spacing: -0.01em;
}

.dashboards-catalog--feedback .page-header {
    margin-bottom: 12px;
}

.dashboards-catalog--feedback .page-header__main {
    max-width: 72ch;
}

.dashboards-catalog--feedback .card {
    border-radius: 10px;
}

.dashboards-catalog-kpis {
    margin: 0 0 14px;
}

.dashboards-catalog-kpis .fb-fd-kpi-value {
    font-size: 1rem;
}

.dashboards-catalog-kpis .fb-fd-kpi-meta {
    font-size: 11px;
}

.dashboards-catalog .page-subtitle {
    font-size: 0.92rem;
    line-height: 1.35;
    color: var(--text-muted);
    max-width: 72ch;
}

.dashboards-catalog .dashboard-filter-form label {
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.dashboards-catalog .dashboard-filter-form select {
    font-size: 0.88rem;
}

.dashboards-catalog .dashboard-tenant-summary {
    gap: 10px;
}

.dashboards-catalog .dashboard-tenant-summary strong {
    display: block;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.25;
}

.dashboards-catalog .dashboard-tenant-pills .mgmt-pill {
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.1;
}

.dashboards-catalog .dashboards-table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboards-catalog--feedback .dashboards-table thead th {
    font-size: 10px;
}

.dashboards-catalog .dashboards-table tbody td {
    font-size: 0.92rem;
    font-weight: 400;
    line-height: 1.35;
    color: var(--text-secondary);
}

.dashboards-catalog--feedback .dashboards-table tbody td,
.dashboards-catalog--feedback .dashboards-table tbody td.small {
    font-size: 13px;
    color: var(--text-primary);
}

.dashboards-catalog .dashboards-table tbody td strong {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.dashboards-catalog--feedback .dashboards-table tbody td strong {
    font-size: 13px;
    font-weight: 500;
}

.dashboards-catalog .dashboards-table tbody td:nth-child(2) {
    max-width: 68ch;
}

.dashboards-catalog .dashboards-table tbody td:nth-child(3),
.dashboards-catalog .dashboards-table tbody td:nth-child(4) {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.dashboards-loop-card {
    margin-top: 1.25rem;
}

.dashboards-catalog--feedback .dashboards-loop-card {
    margin-top: 0;
}

.dashboards-loop-head {
    padding: 1rem 1.25rem 0.85rem;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.dashboards-loop-title {
    margin: 0 0 0.3rem;
    font-size: 0.96rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.dashboards-loop-subtitle {
    margin: 0;
}

.dashboards-loop-form {
    padding: 1rem 1.25rem 1.1rem;
}

.dashboards-loop-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.dashboards-catalog .loop-check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.dashboards-catalog .loop-board-check {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #c1352b;
}

.dashboards-loop-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: center;
}

.dashboards-loop-interval-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.dashboards-loop-interval {
    min-width: 120px;
    font-size: 0.85rem;
    padding: 0.28rem 0.58rem;
    border-radius: 6px;
}

.dashboards-loop-launch-icon {
    margin-right: 5px;
}

.dashboards-loop-hint {
    font-size: 0.78rem;
    color: var(--text-muted, #97a4bd);
}

.tv-board {
    padding: 12px 18px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.tv-board__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 0 18px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.tv-board__headline {
    flex: 1;
    min-width: 0;
}

.tv-board__eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--tv-progress-start);
}

.tv-board h1 {
    margin: 0;
    font-family: var(--tv-font-display);
    font-size: clamp(1.7rem, 2.55vw, 2.65rem);
    font-weight: 600;
    line-height: 1.04;
    letter-spacing: -0.02em;
    color: var(--tv-text);
}

.tv-board__subtitle {
    margin: 4px 0 0;
    max-width: 780px;
    font-size: 0.95rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--tv-muted);
}

.tv-board__hero-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
    margin: 0 0 16px;
    flex-shrink: 0;
}

.tv-board__hero-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 9px 13px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.03) 60%, rgba(10,15,30,0.35) 100%);
    backdrop-filter: blur(18px) saturate(1.6);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    box-shadow: 0 4px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}

.tv-board__hero-card--trend-up {
    border-color: rgba(34, 197, 94, 0.25);
    border-top-color: rgba(34, 197, 94, 0.45);
    background: linear-gradient(145deg, rgba(34,197,94,0.13) 0%, rgba(34,197,94,0.05) 50%, rgba(10,15,30,0.35) 100%);
    backdrop-filter: blur(18px) saturate(1.7);
    -webkit-backdrop-filter: blur(18px) saturate(1.7);
    box-shadow: 0 4px 28px rgba(34,197,94,0.12), 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(34,197,94,0.2);
}

.tv-board__hero-card--trend-down {
    border-color: rgba(239, 68, 68, 0.25);
    border-top-color: rgba(239, 68, 68, 0.45);
    background: linear-gradient(145deg, rgba(239,68,68,0.13) 0%, rgba(239,68,68,0.05) 50%, rgba(10,15,30,0.35) 100%);
    backdrop-filter: blur(18px) saturate(1.7);
    -webkit-backdrop-filter: blur(18px) saturate(1.7);
    box-shadow: 0 4px 28px rgba(239,68,68,0.12), 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(239,68,68,0.2);
}

.tv-board__hero-card--trend-flat {
    border-color: rgba(245, 158, 11, 0.25);
    border-top-color: rgba(245, 158, 11, 0.45);
    background: linear-gradient(145deg, rgba(245,158,11,0.13) 0%, rgba(245,158,11,0.05) 50%, rgba(10,15,30,0.35) 100%);
    backdrop-filter: blur(18px) saturate(1.7);
    -webkit-backdrop-filter: blur(18px) saturate(1.7);
    box-shadow: 0 4px 28px rgba(245,158,11,0.10), 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(245,158,11,0.2);
}

.tv-board__hero-card span,
.tv-strip-card span {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--tv-muted);
}

.tv-board__hero-card strong {
    display: block;
    font-family: var(--tv-font-display);
    margin-top: 4px;
    font-size: clamp(1.65rem, 2.35vw, 2.3rem);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--tv-text);
}

.tv-board__hero-card small,
.tv-strip-card small {
    display: block;
    margin-top: 4px;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--tv-muted);
    line-height: 1.2;
}

.tv-board__hero-trend {
    margin-top: 7px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.tv-board__hero-trend i {
    font-size: 0.7rem;
    line-height: 1;
}

.tv-board__hero-trend--up {
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(20, 83, 45, 0.35);
}

.tv-board__hero-trend--down {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.45);
    background: rgba(127, 29, 29, 0.3);
}

.tv-board__hero-trend--flat {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(120, 53, 15, 0.3);
}

.tv-board__controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tv-board__tenant-form select,
.tv-board__size-select,
.tv-board__back-link,
.tv-board__clock,
.tv-board__updated,
.tv-board__fullscreen-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.10);
    border-top-color: rgba(255,255,255,0.18);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: linear-gradient(160deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0.04) 100%);
    color: var(--tv-text);
    cursor: pointer;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.08);
    backdrop-filter: blur(14px) saturate(1.5);
    -webkit-backdrop-filter: blur(14px) saturate(1.5);
}

.tv-board__tenant-form select {
    min-width: 140px;
}

.tv-board__size-select {
    min-width: 118px;
}

.tv-board__back-link,
.tv-board__fullscreen-toggle {
    width: 44px;
    padding: 0;
    text-decoration: none;
}

.tv-board__fullscreen-toggle:hover,
.tv-board__back-link:hover {
    background: var(--tv-surface-2);
    text-decoration: none;
}

.tv-board__fullscreen-toggle:active,
.tv-board__back-link:active {
    background: rgba(255,255,255,0.13);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
}

.tv-board__fullscreen-toggle:focus-visible,
.tv-board__back-link:focus-visible {
    outline: 2px solid rgba(255,255,255,0.35);
    outline-offset: 2px;
}

.tv-board__fullscreen-toggle:focus:not(:focus-visible),
.tv-board__back-link:focus:not(:focus-visible) {
    outline: none;
}

.tv-board__clock {
    cursor: default;
    min-width: 90px;
}

.tv-board__updated {
    min-width: 160px;
}

.tv-board__updated strong {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--tv-muted);
    letter-spacing: 0.01em;
}

.tv-board__countdown {
    display: inline-block;
    width: 3ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tv-board__clock-suffix {
    color: var(--tv-muted);
    font-weight: 600;
}

.tv-board__back-link i,
.tv-board__mode-toggle i,
.tv-board__clock i,
.tv-board__updated i {
    font-size: 0.98rem;
    line-height: 1;
}

.tv-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.tv-flow {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.tv-flow__left,
.tv-flow__right {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
}

.tv-flow__left {
    grid-column: 1 / span 1;
    contain: layout style paint;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.tv-flow__right {
    grid-column: 2 / span 3;
}

.tv-flow__left .tv-panel:first-child  { flex: 1; min-height: 0; }
.tv-flow__left .tv-panel:last-child   { flex: 1; min-height: 0; }

.tv-flow__left .tv-panel:first-child {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.tv-flow__right .tv-panel:first-child  { flex: 1; min-height: 0; }

.tv-stat-list {
    display: grid;
    gap: 5px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.tv-stat-item {
    padding: 6px 11px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    border: 1px solid rgba(255,255,255,0.07);
    border-top: 1px solid rgba(255,255,255,0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tv-stat-item--accent {
    background: linear-gradient(180deg, var(--tv-accent-bg), var(--tv-surface-2));
    border-color: var(--tv-accent-border);
}

.tv-stat-item span {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--tv-muted);
}

.tv-stat-item strong {
    display: block;
    margin-top: 2px;
    font-size: 1.45rem;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--tv-text);
}

.tv-chart-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.tv-chart-wrap--status {
    min-height: 100px;
    contain: layout style paint;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.tv-chart-wrap--ops {
    min-height: 100px;
}

.tv-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    image-rendering: crisp-edges;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    line-height: 0;
    font-size: 0;
}

.tv-status-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
}

.tv-status-list__row {
    display: grid;
    grid-template-columns: 120px 1fr 42px;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.07);
}

.tv-status-list__label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--tv-text);
}

.tv-status-list__bar {
    height: 10px;
    border-radius: 999px;
    background: var(--tv-rail);
    overflow: hidden;
}

.tv-status-list__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--tv-progress-start), var(--tv-progress-end));
}

.tv-status-list__count {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--tv-text);
    text-align: right;
}

.tv-operations-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.tv-strip-card {
    padding: 14px 16px;
    border-radius: 10px;
    background: linear-gradient(120deg, #161c2a 0%, #1f2940 100%);
    border: 1px solid #33405d;
    box-shadow: var(--tv-shadow);
}

body.dashboard-stage-body[data-tv-mode='light'] .tv-strip-card {
    background: linear-gradient(120deg, #1f2937 0%, #273a55 100%);
    border-color: #324a70;
}

.tv-strip-card span {
    color: rgba(226, 232, 240, 0.75);
}

.tv-strip-card strong {
    display: block;
    margin-top: 9px;
    font-size: 1.35rem;
    line-height: 1.1;
    color: #f8fafc;
}

.tv-strip-card small {
    color: rgba(226, 232, 240, 0.62);
}

.tv-panel {
    min-width: 0;
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,0.07);
    border-top: 1px solid rgba(255,255,255,0.14);
    background: linear-gradient(155deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 55%, rgba(8,12,24,0.4) 100%);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    box-shadow: 0 2px 12px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tv-panel--span-2 {
    grid-column: span 2;
}

.tv-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.tv-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.tv-panel__head h2 {
    margin: 0;
    font-family: var(--tv-font-display);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1.1;
    color: var(--tv-text);
}

.tv-panel__head span,
.tv-muted {
    font-size: 0.84rem;
    font-weight: 400;
    color: var(--tv-muted);
}

.tv-snapshot-carousel {
    position: static;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    border-radius: 10px;
    isolation: isolate;
    contain: paint;
    background: var(--tv-surface);
}

.tv-snapshot-card {
    position: static;
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 100%;
    padding: 22px;
    border-radius: 10px;
    border: 0;
    background: transparent;
}

.tv-snapshot-card.is-active {
    display: flex;
}

.tv-snapshot-card--accent {
    background: linear-gradient(180deg, color-mix(in srgb, var(--tv-accent-bg) 65%, transparent), transparent 78%);
}

.tv-snapshot-card span {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--tv-muted);
}

.tv-snapshot-card strong {
    display: block;
    margin-top: 14px;
    font-family: var(--tv-font-display);
    font-size: clamp(2.65rem, 3.6vw, 3.45rem);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--tv-text);
}

.tv-snapshot-card small {
    margin-top: 14px;
    font-size: 1.02rem;
    font-weight: 400;
    color: var(--tv-muted);
    line-height: 1.28;
}

.tv-snapshot-card__meta {
    margin-top: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--tv-text);
}

.tv-snapshot-card--status {
    justify-content: flex-start;
    gap: 10px;
}

.tv-snapshot-card--status strong {
    margin-top: 0;
    font-size: clamp(1.65rem, 2.2vw, 2.25rem);
}

.tv-snapshot-card--status .tv-chart-wrap {
    flex: 1;
    min-height: 86px;
}

.tv-snapshot-card--status .tv-chart-legend {
    margin-top: 0;
    max-height: 128px;
}

.tv-snapshot-card--status .tv-chart-legend__row {
    padding: 4px 8px;
    grid-template-columns: 88px 1fr 28px;
}

.tv-snapshot-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding-top: 10px;
    flex-shrink: 0;
}

.tv-snapshot-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--tv-border);
}

.tv-snapshot-dot.is-active {
    width: 22px;
    background: var(--tv-progress-start);
}

.tv-table-wrap {
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

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

.tv-table th,
.tv-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--tv-border);
    vertical-align: middle;
    color: var(--tv-text);
}

.tv-table thead tr {
    border-top: 1px solid var(--tv-border);
}

.tv-table th {
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tv-muted);
}

.tv-table td {
    font-size: 0.96rem;
    font-weight: 400;
    line-height: 1.18;
}

.tv-table td strong {
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: 0;
}

.tv-table td .tv-muted {
    font-size: 0.88rem;
    font-weight: 400;
}

.tv-table th:nth-child(3),
.tv-table td:nth-child(3) {
    text-align: center;
}

.tv-table__qty {
    font-weight: 500;
    color: var(--tv-text);
}

.tv-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tv-progress__bar {
    width: 140px;
    height: 10px;
    border-radius: 999px;
    background: var(--tv-rail);
    overflow: hidden;
}

.tv-progress__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #16a34a, #22c55e);
}

.tv-status-row__bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--tv-progress-start), var(--tv-progress-end));
}

.tv-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 118px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tv-status--neutral { background: var(--tv-neutral-bg); color: var(--tv-neutral-text); }
.tv-status--warning { background: var(--tv-warning-bg); color: var(--tv-warning-text); }
.tv-status--info { background: var(--tv-info-bg); color: var(--tv-info-text); }
.tv-status--success { background: var(--tv-success-bg); color: var(--tv-success-text); }
.tv-status--accent { background: var(--tv-accent-bg); color: var(--tv-progress-start); }
.tv-status--muted { background: var(--tv-neutral-bg); color: var(--tv-muted); }

.tv-status-list,
.tv-list,
.tv-event-list {
    display: grid;
    gap: 5px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    align-content: start;
}

.tv-status-row {
    display: grid;
    grid-template-columns: 130px 1fr 52px;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--tv-border);
    border-radius: 10px;
    background: var(--tv-surface-2);
}

.tv-status-row__label,
.tv-status-row__value {
    color: var(--tv-text);
}

.tv-status-row__bar {
    height: 12px;
    border-radius: 999px;
    background: var(--tv-rail);
    overflow: hidden;
}

.tv-list__item,
.tv-event-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 7px 11px;
    border-radius: 8px;
    background: var(--tv-surface-2);
    border: 1px solid var(--tv-border);
}

.tv-list__metrics {
    display: grid;
    justify-items: end;
    gap: 2px;
}

.tv-event-item {
    grid-template-columns: 155px 1fr auto 1fr;
}

.tv-event-item__time,
.tv-event-item__type {
    color: var(--tv-muted);
}

/* Thin scrollbars for TV panel content areas */
.tv-stat-list::-webkit-scrollbar,
.tv-table-wrap::-webkit-scrollbar,
.tv-event-list::-webkit-scrollbar,
.tv-chart-legend::-webkit-scrollbar { width: 3px; }
.tv-stat-list::-webkit-scrollbar-track,
.tv-table-wrap::-webkit-scrollbar-track,
.tv-event-list::-webkit-scrollbar-track,
.tv-chart-legend::-webkit-scrollbar-track { background: transparent; }
.tv-stat-list::-webkit-scrollbar-thumb,
.tv-table-wrap::-webkit-scrollbar-thumb,
.tv-event-list::-webkit-scrollbar-thumb,
.tv-chart-legend::-webkit-scrollbar-thumb { background: var(--tv-border); border-radius: 3px; }

@media (max-width: 1280px) {
    .tv-flow {
        grid-template-columns: 1fr;
    }

    .tv-flow__left,
    .tv-flow__right {
        grid-column: auto;
    }

    .tv-board__hero-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tv-detail-grid {
        grid-template-columns: 1fr;
    }

    .tv-event-item {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .dashboards-selector-card,
    .dashboard-tenant-summary,
    .tv-board__header {
        flex-direction: column;
        align-items: stretch;
    }

    .tv-board__hero-strip,
    .tv-stat-list,
    .tv-detail-grid {
        grid-template-columns: 1fr;
    }

    .tv-snapshot-card {
        padding: 14px;
    }

    .tv-board__controls {
        justify-content: flex-start;
    }

    .tv-chart-legend__row {
        grid-template-columns: 110px 1fr 44px;
    }
}

.sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    height: 60px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    color: var(--accent);
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sidebar-brand-name {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--sidebar-brand-text);
    letter-spacing: -0.01em;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    line-height: 1.15;
}

.sidebar-brand-tagline {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.brand-name {
    font-weight: 700;
    text-transform: uppercase;
}

.brand-name-accent {
    color: var(--brand-secondary);
}

[data-theme="white"][data-mode="dark"] .btn.btn-primary,
[data-theme="white"][data-mode="dark"] button.btn-primary {
    background: var(--opero-red-80);
    border-color: var(--opero-red-80);
}

[data-theme="white"][data-mode="dark"] .btn.btn-primary:hover,
[data-theme="white"][data-mode="dark"] button.btn-primary:hover {
    background: rgba(193, 53, 43, 0.92);
    border-color: rgba(193, 53, 43, 0.92);
}

[data-theme="white"][data-mode="dark"] .form-group .check-label input[type="checkbox"],
[data-theme="white"][data-mode="dark"] .form-group label.check-label input[type="checkbox"] {
    accent-color: var(--opero-red);
}

.sidebar-section {
    padding: 8px 0 6px;
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar-section::-webkit-scrollbar { display: none; }

/* Bootstrap sets ul,ol { padding-left: 2rem } — flush sidebar links to the rail */
.sidebar .sidebar-nav {
    list-style: none;
    flex-shrink: 0;
    padding-left: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 20px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 450;
    border-radius: 0;
    transition: background 0.12s, color 0.12s;
    position: relative;
}

.sidebar-nav li a .nav-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    opacity: .85;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-brand-text);
    text-decoration: none;
}
.sidebar-nav li a:hover .nav-icon { opacity: 1; }

.sidebar-nav li.active a {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 500;
}
.sidebar-nav li.active a .nav-icon { opacity: 1; }

.sidebar-nav li.active a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

/* Collapsible sidebar groups (Management layout) — no box borders; flush with nav rail */
.sidebar-nav-group {
    border: none;
    margin: 0;
    padding: 0;
    width: 100%;
    min-width: 0;
}
/* Keep collapse width stable when expanding (Bootstrap sets height on .collapsing) */
.sidebar-nav-group .collapse {
    width: 100%;
    min-width: 0;
}
.sidebar-nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 20px;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sidebar-muted);
    cursor: pointer;
    text-align: left;
    line-height: 1.3;
}
.sidebar-nav-group-toggle:hover {
    color: var(--sidebar-text);
    background: var(--sidebar-hover-bg);
}
.sidebar-nav-group-toggle:focus {
    outline: none;
}
.sidebar-nav-group-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.sidebar-nav-group-chevron {
    flex-shrink: 0;
    font-size: 12px;
    opacity: 0.75;
}
.sidebar-nav-group-toggle:not(.collapsed) .sidebar-nav-group-chevron {
    transform: rotate(-180deg);
}
.sidebar-nav-group .collapse > .sidebar-nav {
    padding-bottom: 4px;
    width: 100%;
}
/* Nested group links — indented under parent heading */
.sidebar-nav-group .collapse > .sidebar-nav li a,
.sidebar-nav--nested li a {
    padding: 7px 20px 7px 36px;
    font-size: 13.5px;
    font-weight: 450;
}
.sidebar-nav-group .collapse > .sidebar-nav li.active a::before {
    left: 0;
}

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--sidebar-border);
    color: var(--sidebar-muted);
    font-size: 11px;
    flex-shrink: 0;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.main-area-header {
    background: var(--topnav-bg);
    border-bottom: 1px solid var(--topnav-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--topnav-border);
}

.main-area-header:has(.nav-subbar) > .topnav {
    border-bottom: none;
}

/* Billing (and future) section sub-navigation — mirrors operations nav-subbar */
.nav-subbar {
    border-top: 1px solid var(--topnav-border);
    padding: 5px 24px 3px;
    background: color-mix(in srgb, var(--content-bg) 92%, var(--topnav-border) 8%);
}

[data-mode="dark"] .nav-subbar {
    background: #1f2328;
}

.nav-subbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 2px;
    max-width: 100%;
}

.nav-subbar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px 4px;
    font-size: 12.5px;
    font-weight: 400;
    color: var(--text-primary);
    border-radius: 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.nav-subbar-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

.nav-subbar-link.is-active {
    font-weight: 500;
    border-bottom-color: var(--accent);
}

.nav-subbar-divider {
    align-self: center;
    width: 1px;
    height: 18px;
    margin: 0 4px;
    background: var(--topnav-border);
    flex-shrink: 0;
}

.nav-subbar-link--secondary {
    opacity: 0.88;
}

[data-mode="dark"] .nav-subbar-link {
    color: #e5e7eb;
}

[data-mode="dark"] .nav-subbar-link:hover,
[data-mode="dark"] .nav-subbar-link.is-active {
    color: #f9fafb;
}

@media (max-width: 768px) {
    .nav-subbar {
        padding: 5px 16px 5px 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-subbar::-webkit-scrollbar {
        display: none;
    }

    .nav-subbar-inner {
        flex-wrap: nowrap;
    }
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topnav-breadcrumb {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.topnav-right { display: flex; align-items: center; gap: 4px; }
.topnav-right .notification-wrapper { margin-right: 8px; }
.topnav-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--topnav-muted);
    transition: background 0.12s, color 0.12s;
    position: relative;
    text-decoration: none;
}
.topnav-btn .bi { font-size: 18px; line-height: 1; }
.topnav-btn:hover {
    background: var(--topnav-hover);
    color: var(--topnav-text);
    text-decoration: none;
}

/* Bootstrap tooltip — match operations/public/css/app.css */
.tooltip {
    position: absolute;
    z-index: 5000;
    display: block;
    margin: 0;
    font-size: 12px;
    line-height: 1.3;
    opacity: 0;
    pointer-events: none;
}

.tooltip.show {
    opacity: 1;
}

.tooltip .tooltip-inner {
    max-width: 220px;
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--surface-bg);
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
    text-align: center;
}

[data-mode="dark"] .tooltip .tooltip-inner {
    background: color-mix(in srgb, var(--surface-bg) 92%, #000 8%);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.tooltip .tooltip-arrow {
    position: absolute;
    width: 0.8rem;
    height: 0.4rem;
}

.tooltip .tooltip-arrow::before {
    content: "";
    position: absolute;
    border-color: transparent;
    border-style: solid;
}

.tooltip[data-popper-placement^="top"] .tooltip-arrow {
    bottom: calc(-0.4rem + 1px);
}
.tooltip[data-popper-placement^="top"] .tooltip-arrow::before {
    top: -1px;
    border-width: 0.4rem 0.4rem 0;
    border-top-color: var(--surface-border);
}

.tooltip[data-popper-placement^="bottom"] .tooltip-arrow {
    top: calc(-0.4rem + 1px);
}
.tooltip[data-popper-placement^="bottom"] .tooltip-arrow::before {
    bottom: -1px;
    border-width: 0 0.4rem 0.4rem;
    border-bottom-color: var(--surface-border);
}

.tooltip[data-popper-placement^="left"] .tooltip-arrow {
    right: calc(-0.4rem + 1px);
    width: 0.4rem;
    height: 0.8rem;
}
.tooltip[data-popper-placement^="left"] .tooltip-arrow::before {
    left: -1px;
    border-width: 0.4rem 0 0.4rem 0.4rem;
    border-left-color: var(--surface-border);
}

.tooltip[data-popper-placement^="right"] .tooltip-arrow {
    left: calc(-0.4rem + 1px);
    width: 0.4rem;
    height: 0.8rem;
}
.tooltip[data-popper-placement^="right"] .tooltip-arrow::before {
    right: -1px;
    border-width: 0.4rem 0.4rem 0.4rem 0;
    border-right-color: var(--surface-border);
}

.dropdown-wrapper { position: relative; }
.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    box-shadow: var(--surface-shadow), 0 8px 24px rgba(0,0,0,.12);
    min-width: 220px;
    overflow: hidden;
    display: none;
    z-index: 200;
}
.dropdown-panel.open { display: block; }
.dropdown-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--surface-border);
}
.dropdown-header-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.theme-swatches {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
}
.theme-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s;
    position: relative;
}
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch-lg { width: 38px; height: 38px; }
.theme-swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--surface-bg), 0 0 0 4px var(--accent);
}
.theme-swatch[data-theme-target="violet"] {
    background: linear-gradient(135deg, #1e1b4b 50%, #7c3aed 50%);
}
.theme-swatch[data-theme-target="slate"] {
    background: linear-gradient(135deg, #0f172a 50%, #0d9488 50%);
}
.theme-swatch[data-theme-target="white"] {
    background: linear-gradient(135deg, #ffffff 50%, #111827 50%);
    border: 1px solid #d1d5db;
}

.mode-btns {
    display: flex;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    overflow: hidden;
}
.mode-btn {
    flex: 1;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
    text-align: center;
    height: auto;
}
.mode-btn:not(:last-child) {
    border-right: 1px solid var(--surface-border);
}
.mode-btn:hover { background: var(--topnav-hover); color: var(--text-primary); }
.mode-btn.active {
    background: var(--accent);
    color: var(--accent-text);
}

.user-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--topnav-user-bg, #e4e4e7);
    color: var(--topnav-user-text, #27272a);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.user-btn:hover {
    opacity: 1;
    background: var(--topnav-user-bg-hover, var(--topnav-user-bg, #d4d4d8));
}
.user-info {
    padding: 12px 14px;
    border-bottom: 1px solid var(--surface-border);
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-email { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.dropdown-item {
    display: block;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: background 0.1s;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-family: inherit;
}
.dropdown-item:hover {
    background: var(--topnav-hover);
    text-decoration: none;
    color: var(--text-primary);
}
.dropdown-item.danger { color: color-mix(in srgb, var(--danger, #ef4444) 85%, var(--text-primary)); }
.dropdown-item.danger:hover {
    background: color-mix(in srgb, var(--danger, #ef4444) 16%, var(--surface-bg));
    color: color-mix(in srgb, var(--danger, #ef4444) 92%, var(--text-primary));
}

.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 28px 32px;
    max-width: none;
    width: 100%;
}

.page-header { margin-bottom: 24px; }
.page-header:has(.page-header__main) {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
}
.page-header__main {
    min-width: 0;
    flex: 1 1 240px;
}
.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}
.page-header__actions .btn {
    white-space: nowrap;
}
.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.page-header .page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 3px;
    line-height: 1.5;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 18px 20px;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin-top: 2px;
}

.card {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h2,
.sub-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.card > .sub-title:first-child,
.card > h2.sub-title:first-child {
    margin-top: 0;
}

/* Read-only metadata tiles (e.g. tenant subscription summary) */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
    margin-bottom: 4px;
}
.meta-field {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface-bg);
    min-width: 0;
}
.meta-field__label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}
.meta-field__value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 450;
    line-height: 1.4;
    word-break: break-word;
}
.meta-field__value pre {
    margin: 0;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.meta-field--full {
    grid-column: 1 / -1;
}
@media (max-width: 1100px) {
    .meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 560px) {
    .meta-grid {
        grid-template-columns: 1fr;
    }
}

.tenant-subscription-divider {
    margin: 20px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--surface-border);
}

/* Card title row + action (e.g. tenant detail “Manage …” modals) */
.card-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    margin-bottom: 12px;
}
.card-section-head .sub-title {
    margin-bottom: 0;
}

.modal-body .form-grid {
    margin-top: 0;
}
.modal-body > p.muted:first-child {
    margin-top: 0;
}

.attention-banner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px 24px;
    align-items: start;
    text-align: left;
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--accent) 10%, var(--surface-bg)) 0%,
        color-mix(in srgb, var(--accent) 6%, var(--surface-bg)) 100%
    );
    border-color: color-mix(in srgb, var(--accent) 24%, var(--surface-border));
}

.attention-banner__body {
    min-width: 0;
}

.attention-banner__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.attention-banner__summary {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-secondary);
    max-width: 65ch;
}

.attention-banner__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.attention-banner__emblem {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent) 16%, var(--surface-bg));
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .attention-banner {
        grid-template-columns: 1fr;
    }

    .attention-banner__emblem {
        justify-self: start;
    }
}

.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.feature-card { border: 1px solid var(--surface-border); border-radius: 12px; padding: 12px; }
.feature-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-bg));
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-subtle-text);
}
.feature-icon .bi {
    font-size: 16px;
    line-height: 1;
}
.feature-card h4 { font-size: 14px; margin-bottom: 4px; }
.feature-card p { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.feature-card > a:hover { text-decoration: none; }

.quick-list { display: grid; gap: 8px; }
.quick-item {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--surface-bg) 92%, var(--text-primary) 8%);
}
.mgmt-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--surface-border);
    background: color-mix(in srgb, var(--surface-bg) 84%, var(--accent) 16%);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    text-align: left;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--surface-border);
    padding: 12px 10px;
}
.data-table tbody td {
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--surface-border);
    padding: 11px 10px;
}
.data-table tbody td a:not(.billing-mod-icon-btn) {
    color: inherit;
}

.data-table th.num,
.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table--compact thead th {
    padding: 6px 10px;
    font-size: 10px;
}
.data-table--compact tbody td {
    padding: 6px 10px;
    vertical-align: middle;
}

/* Billing modules — no outer card; toolbar + per-module cards */
.billing-modules-wrap {
    margin-bottom: 16px;
}
.billing-modules-toolbar {
    padding: 0 0 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--surface-border);
    background: transparent;
}
.billing-modules-search {
    margin: 0;
    max-width: 360px;
}
.billing-modules-search input[type="text"] {
    flex: 1;
    min-width: 140px;
}
.billing-modules-empty {
    margin: 0;
    padding: 12px 0;
    font-size: 13px;
}
/* Fixed toasts (e.g. billing modules AJAX feedback) */
.mgmt-toast-host {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: none;
    max-width: min(380px, calc(100vw - 32px));
}
.mgmt-toast {
    pointer-events: auto;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.mgmt-toast.is-visible {
    opacity: 1;
    transform: translateX(0);
}
.mgmt-toast--ok {
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
    border: 1px solid var(--alert-success-border);
}
.mgmt-toast--err {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-border);
}
.billing-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 12px 0 0;
}

@media (max-width: 1100px) {
    .billing-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .billing-card-grid {
        grid-template-columns: 1fr;
    }
}
.billing-card {
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface-bg);
    box-shadow: var(--surface-shadow);
    min-width: 0;
}
.billing-card--muted {
    opacity: 0.82;
}
.billing-card__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.billing-card__desc {
    margin: 0;
    min-width: 0;
    flex: 1;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--text-secondary);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.billing-card__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 4px;
    color: var(--text-primary);
}
.billing-card__meta {
    margin: 0;
    font-size: 11px;
    line-height: 1.35;
}
.billing-card__actions {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    margin-top: 8px;
}
.billing-card__form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}
.billing-mod-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.billing-mod-badge--ok {
    background: color-mix(in srgb, #198754 14%, transparent);
    color: #146c43;
}
.billing-mod-badge--off {
    background: color-mix(in srgb, var(--text-muted) 18%, transparent);
    color: var(--text-secondary);
}
[data-mode="dark"] .billing-mod-badge--ok {
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}
[data-mode="dark"] .billing-mod-badge--off {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}

.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* Inline toolbars: label above control, aligned with row actions */
.form-row > label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-row > label input:not([type="checkbox"]),
.form-row > label select {
    width: 100%;
    min-width: 0;
}

/* Card forms: vertical fields, consistent spacing */
.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 100%;
    width: 100%;
}
.stack-form--narrow {
    max-width: 100%;
}
.stack-form--wide {
    max-width: 100%;
}
/* Muted helper text (pagination, subtitles, empty states) */
.muted {
    color: var(--text-muted);
}

.stack-form > p.muted {
    margin: -8px 0 0;
    font-size: 12px;
    line-height: 1.45;
}

/* Table row icon actions (aligned with billing module cards) */
.data-table-actions {
    position: relative;
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
}

.table > tbody > tr > td.data-table-actions {
    white-space: nowrap;
    vertical-align: middle;
}

.data-table-actions form {
    display: inline-flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    margin: 0;
    line-height: 0;
}

.table-empty {
    margin: 0;
    padding: 4px 0 12px;
    font-size: 14px;
}

.table-empty a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.table-empty a:hover {
    color: var(--accent-subtle-text, var(--accent));
}

.stack-form > label {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.stack-form > label > input:not([type="hidden"]):not([type="checkbox"]),
.stack-form > label > select,
.stack-form > label > textarea {
    width: 100%;
    margin: 0;
}
.stack-form > label > input[type="checkbox"] {
    width: auto;
    height: auto;
    margin: 0;
    flex-shrink: 0;
}
/* Checkbox rows: hidden + checkbox + caption */
.stack-form > label:has(> input[type="hidden"] + input[type="checkbox"]),
.stack-form > label:has(> input[type="checkbox"]:first-child) {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-field--check {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}
.form-field--check .form-label {
    margin: 0;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ── Operations-style forms (form-grid + form-group + uniform-control) ── */
.form-group {
    margin-bottom: 14px;
    min-width: 0;
}
.form-grid > .form-group {
    margin-bottom: 0;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-secondary);
}
.form-group .check-label,
.form-group label.check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    font-weight: 400;
    color: var(--text-primary);
    cursor: pointer;
}
.form-group .check-label input[type="checkbox"],
.form-group label.check-label input[type="checkbox"] {
    width: auto;
    height: auto;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Create tenant → modules (hard prerequisites auto-selected in UI) */
.tenant-modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    max-height: 320px;
    overflow: auto;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 12px;
    background: color-mix(in srgb, var(--surface-bg) 96%, var(--content-bg) 4%);
}
.tenant-module-pick {
    border-radius: 0.375rem;
    padding: 6px 8px;
    margin: -4px -6px;
    transition: background 0.15s ease, border-color 0.15s ease;
    border: 1px solid transparent;
    color: var(--text-primary);
}
.tenant-module-pick span {
    color: inherit;
}
.tenant-module-pick .muted {
    color: var(--text-muted);
}
.tenant-module-pick--explicit {
    border-color: transparent;
}
.tenant-module-pick--auto {
    background: rgba(217, 119, 6, 0.1);
    border-color: rgba(217, 119, 6, 0.35);
}

/* Profile → Email notifications: native checkbox at readable size (avoid Bootstrap form-check shrink) */
.profile-email-notify-card .profile-email-notify-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--accent);
}
.profile-email-notify-card .profile-email-notify-check span {
    line-height: 1.4;
    font-size: 14px;
    color: var(--text-primary);
}
.form-group--span {
    grid-column: 1 / -1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px 20px;
}
.form-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* Default card forms: up to three fields per row (matches Operations profile density) */
.form-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
    .form-grid--3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 560px) {
    .form-grid--2 {
        grid-template-columns: 1fr;
    }
    .form-grid--3 {
        grid-template-columns: 1fr;
    }
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group select,
.form-group textarea,
.stack-form > label > input:not([type="hidden"]):not([type="checkbox"]),
.stack-form > label > select,
.stack-form > label > textarea,
.form-row > label > input:not([type="hidden"]):not([type="checkbox"]),
.form-row > label > select,
.form-field > input:not([type="hidden"]):not([type="checkbox"]),
.form-field > select,
.form-field > textarea,
.uniform-control {
    width: 100%;
    padding: 9px 12px;
    height: auto;
    min-height: 0;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.form-group textarea,
.stack-form > label > textarea,
.form-field > textarea,
textarea.uniform-control {
    resize: vertical;
    min-height: 72px;
    line-height: 1.45;
}
.form-group select,
.stack-form > label > select,
.form-row > label > select,
.form-field > select,
select.uniform-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.stack-form > label > input:not([type="hidden"]):not([type="checkbox"]):focus,
.stack-form > label > select:focus,
.stack-form > label > textarea:focus,
.form-row > label > input:not([type="hidden"]):not([type="checkbox"]):focus,
.form-row > label > select:focus,
.form-field > input:not([type="hidden"]):not([type="checkbox"]):focus,
.form-field > select:focus,
.form-field > textarea:focus,
.uniform-control:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px var(--input-shadow-focus);
}

textarea.uniform-control.code-field,
textarea.stack-form__code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

/* Exclude `.form-switch`: Bootstrap needs fixed width/height on `.form-check-input` for the pill switch */
.form-check:not(.form-switch) label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 0;
}

.form-check:not(.form-switch) input[type="checkbox"] {
    width: auto;
    height: auto;
    accent-color: var(--accent);
}

.bundle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px 16px;
}
.bundle-grid label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.35;
}
.bundle-grid label input[type="checkbox"] {
    width: auto;
    height: auto;
    margin-top: 2px;
    flex-shrink: 0;
}

/* Textareas outside card forms only (tables, etc.) */
textarea:not(.uniform-control):not(.stack-form__code) {
    border-radius: 8px;
    border: 1px solid var(--input-border);
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.45;
    background: var(--input-bg);
    color: var(--text-primary);
    min-height: 72px;
    height: auto;
    resize: vertical;
    font-family: inherit;
}

.stack-form > .form-actions,
.stack-form > button[type="submit"] {
    margin-top: 4px;
    align-self: flex-start;
}

/* Compact defaults for filters/toolbars — low specificity so .form-group / .stack-form / .form-row fields win */
input:not([type]),
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
input[type="tel"],
select {
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    padding: 0 10px;
    font-size: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
}

/* Toolbar / GET filters: direct controls in .form-row (no label wrapper) — match uniform-control tokens */
.form-row > input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
.form-row > select {
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 40px;
    padding: 9px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
    box-sizing: border-box;
}
.form-row > select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
    background-color: var(--input-bg);
}
.form-row > input:focus,
.form-row > select:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px var(--input-shadow-focus);
}
.form-row > input[type="text"],
.form-row > input[type="search"],
.form-row > input[type="email"],
.form-row > input[type="url"],
.form-row > input[type="tel"] {
    flex: 1 1 200px;
    min-width: 160px;
    max-width: 28rem;
}
/* Split from `.btn` so sidebar `button.sidebar-nav-group-toggle` is never targeted by the button line. */
button:not(.topnav-btn):not(.user-btn):not(.mode-btn):not(.theme-swatch):not(.dropdown-item):not(.billing-mod-icon-btn):not(.sidebar-nav-group-toggle):not(.tenant-segment-nav__btn) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 18px;
    border-radius: 8px;
    /* border: 1px solid var(--surface-border); */
    font-size: 14px;
    font-weight: 500;
    /* background: var(--surface-bg); */
    /* color: var(--text-primary); */
    cursor: pointer;
    font-family: inherit;
    height: auto;
    box-sizing: border-box;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 500;
    background: var(--surface-bg);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    height: auto;
    box-sizing: border-box;
}

.btn-close{
    background: transparent var(--bs-btn-close-bg) center/1em auto no-repeat !important;
}

.btn.btn-primary,
button.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.btn-secondary,
.btn-muted,
button.btn-secondary,
button.btn-muted {
    background: color-mix(in srgb, var(--surface-bg) 92%, var(--text-primary) 8%);
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

.btn-danger,
button.btn-danger {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* Compact buttons — after base button rules so min-height/padding win */
button.btn-compact,
.btn.btn-compact {
    min-height: 26px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 500;
    gap: 4px;
    border-radius: 6px;
}

/* Page header actions use btn-compact but need readable tap targets */
.page-header__actions .btn.btn-compact,
.page-header__actions button.btn-compact {
    min-height: 34px;
    padding: 8px 16px;
    font-size: 13px;
    gap: 6px;
    border-radius: 8px;
}

/* Bare filter / toolbar submits — after global button:not(...) so primary styling wins */
html[data-theme][data-mode] .layout .form-row > button[type="submit"]:not([class]),
html[data-theme][data-mode] .layout .form-row > form > button[type="submit"]:not([class]) {
    min-height: 40px;
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-text);
}
html[data-theme][data-mode] .layout .form-row > button[type="submit"]:not([class]):hover,
html[data-theme][data-mode] .layout .form-row > form > button[type="submit"]:not([class]):hover {
    filter: brightness(0.96);
}

/* Billing modules: icon-only row (after base button rules) */
a.billing-mod-icon-btn,
button.billing-mod-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 !important;
    margin: 0;
    box-sizing: border-box;
    aspect-ratio: 1;
    border: none !important;
    border-radius: 8px;
    background: transparent !important;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    flex: 0 0 38px;
    transition: background 0.12s, color 0.12s;
    font-weight: 400;
    gap: 0;
}
a.billing-mod-icon-btn:hover,
button.billing-mod-icon-btn:hover {
    background: var(--sidebar-hover-bg) !important;
    color: var(--text-primary);
    text-decoration: none;
}
button.billing-mod-icon-btn--accent {
    color: var(--accent) !important;
    background: transparent !important;
    border: none !important;
}
button.billing-mod-icon-btn--accent:hover {
    background: var(--accent-subtle) !important;
    color: var(--accent-subtle-text) !important;
}
button.billing-mod-icon-btn--warn {
    color: var(--text-secondary) !important;
    background: transparent !important;
}
button.billing-mod-icon-btn--warn:hover {
    background: color-mix(in srgb, var(--accent) 10%, var(--sidebar-hover-bg)) !important;
    color: var(--accent) !important;
}
button.billing-mod-icon-btn--danger {
    color: #b91c1c !important;
    background: transparent !important;
}
button.billing-mod-icon-btn--danger:hover {
    background: #fee2e2 !important;
    color: #991b1b !important;
}
[data-mode="dark"] button.billing-mod-icon-btn--danger {
    color: #f87171 !important;
}
[data-mode="dark"] button.billing-mod-icon-btn--danger:hover {
    background: rgba(248, 113, 113, 0.12) !important;
    color: #fecaca !important;
}
button.billing-mod-icon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tables & table pagination: compact square icon actions, subtle fill + border */
.data-table a.billing-mod-icon-btn,
.data-table button.billing-mod-icon-btn,
.table-pagination a.billing-mod-icon-btn,
.table-pagination button.billing-mod-icon-btn {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    flex: 0 0 28px !important;
    padding: 0 !important;
    border: 1px solid var(--surface-border) !important;
    border-radius: 6px !important;
    background: color-mix(in srgb, var(--text-muted) 8%, var(--surface-bg)) !important;
    font-size: 15px !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.data-table a.billing-mod-icon-btn:hover,
.data-table button.billing-mod-icon-btn:hover,
.table-pagination a.billing-mod-icon-btn:hover,
.table-pagination button.billing-mod-icon-btn:hover {
    border-color: color-mix(in srgb, var(--text-muted) 32%, var(--surface-border)) !important;
}

.log-json-modal-body {
    margin: 0;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: min(70vh, 520px);
    overflow: auto;
    background: color-mix(in srgb, var(--text-muted) 6%, var(--surface-bg));
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    color: var(--text-primary);
}

.log-json-payload {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
}
.badge-accent { background: var(--accent-subtle); color: var(--accent-subtle-text); }
.badge-secondary { background: #f3f4f6; color: #6b7280; }

.flash-ok,
.alert-success {
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
    border: 1px solid var(--alert-success-border);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.flash-err,
.alert-error {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-border);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.guest-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: clamp(16px, 4vw, 32px);
}

.guest-body--auth {
    background:
        radial-gradient(ellipse 80% 60% at 70% 0%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 55%),
        radial-gradient(ellipse 60% 45% at 10% 90%, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 50%),
        var(--content-bg);
}

.auth-shell {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    min-height: min(520px, calc(100vh - 48px));
    border: 1px solid var(--surface-border);
    background: var(--surface-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow:
        var(--surface-shadow),
        0 24px 48px rgba(15, 23, 42, 0.08),
        0 2px 0 rgba(255, 255, 255, 0.6) inset;
}

.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-right: 1px solid var(--surface-border);
    background:
        linear-gradient(145deg,
            color-mix(in srgb, var(--accent) 22%, #fff5f3) 0%,
            color-mix(in srgb, var(--surface-bg) 96%, #fff) 42%,
            var(--surface-bg) 100%);
}

[data-mode="dark"] .auth-hero {
    background:
        linear-gradient(145deg,
            color-mix(in srgb, var(--accent) 18%, transparent) 0%,
            color-mix(in srgb, var(--surface-bg) 100%, #0f172a) 50%,
            var(--surface-bg) 100%);
}

.auth-hero-inner {
    flex: 1;
    padding: clamp(28px, 5vw, 40px) clamp(28px, 4vw, 36px) 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--accent-subtle) 88%, #fff);
    color: var(--accent-subtle-text);
    border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
    margin-bottom: 20px;
}

.auth-hero-badge i {
    font-size: 13px;
    opacity: 0.9;
}

.auth-hero-title {
    font-size: clamp(1.65rem, 2.8vw, 2rem);
    line-height: 1.15;
    margin: 0 0 12px;
    letter-spacing: -0.03em;
    font-weight: 700;
    color: var(--text-primary);
    text-wrap: balance;
}

.auth-hero-title .brand-name {
    font-size: 1em;
}

.auth-hero-lead {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.55;
    margin: 0 0 28px;
    max-width: 38ch;
}

.auth-feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.auth-feature-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-size: 12px;
}

.auth-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(24px, 4vw, 40px);
    background: var(--surface-bg);
}

.auth-panel-inner {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
}

.auth-panel-brand {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 28px;
}

.auth-panel-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--accent);
    background: var(--accent-subtle);
    border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
    flex-shrink: 0;
    overflow: hidden;
}

.auth-panel-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.auth-panel-header {
    min-width: 0;
}

.auth-panel-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-panel-header p {
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-muted);
    margin: 0;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 22px;
}

.auth-alert i {
    flex-shrink: 0;
    margin-top: 1px;
}

.auth-alert--error {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-border);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    font-size: 15px;
    line-height: 1.35;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--input-bg, #fff) 94%, var(--accent) 3%);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

[data-mode="dark"] .auth-input {
    background: color-mix(in srgb, var(--surface-bg) 92%, #fff 4%);
}

.auth-input::placeholder {
    color: var(--text-muted);
    opacity: 0.75;
}

.auth-input:hover {
    border-color: color-mix(in srgb, var(--input-border) 70%, var(--accent) 30%);
}

.auth-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--input-shadow-focus, rgba(37, 99, 235, 0.2));
}

.auth-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
}

.auth-submit:hover {
    background: var(--accent-hover, var(--accent));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.auth-submit:active {
    transform: translateY(1px);
}

.auth-submit i {
    font-size: 1.35rem;
    line-height: 1;
    margin-right: -4px;
}

@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .feature-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 860px) {
    .layout { flex-direction: column; height: auto; }
    .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--sidebar-border); }
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .feature-grid { grid-template-columns: 1fr; }
    .auth-shell {
        grid-template-columns: 1fr;
        min-height: 0;
    }
    .auth-hero {
        border-right: 0;
        border-bottom: 1px solid var(--surface-border);
    }
    .auth-hero-inner {
        padding: 24px 22px 20px;
    }
    .auth-panel {
        padding: 28px 22px 36px;
    }
}

/* ── Operations-aligned profile & detail layout ── */
.page-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.page-actions .page-header {
    margin-bottom: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    align-items: start;
}

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

.detail-card {
    background: var(--surface-bg);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: none;
}

.detail-card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--divider);
}

.detail-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--divider);
    font-size: 14px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-muted);
    width: 130px;
    flex-shrink: 0;
    font-size: 13px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 450;
    flex: 1;
}

.td-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
}

.form-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 4px 0 0;
    line-height: 1.45;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.appearance-section-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.theme-swatch-caption {
    font-size: 12px;
    color: var(--text-muted);
    width: 40px;
    text-align: center;
}

/* Card forms: multi-column rows fill content width */
.card .stack-form .form-grid--3 {
    width: 100%;
}

/* Table pagination (items per page from profile) */
.table-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 4px 4px;
    margin-top: 4px;
    border-top: 1px solid var(--surface-border);
    font-size: 14px;
}

.table-pagination__meta {
    margin: 0;
}

.table-pagination__nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* —— Platform health (/platform-health) —— */
.ph-page {
    max-width: 1200px;
}
.ph-page-head {
    margin-bottom: 1.25rem;
}
.ph-page-head h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}
.ph-lead {
    color: var(--text-muted);
    font-size: 0.9375rem;
    max-width: 56rem;
    line-height: 1.55;
}
.ph-stat .card-body {
    padding: 1rem 1.1rem;
}
.ph-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.ph-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: 0.25rem;
}
.ph-stat-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}
.ph-chart-wrap {
    position: relative;
    height: 240px;
}
.ph-chart-wrap--sm {
    height: 260px;
}
.ph-pre {
    font-size: 0.7rem;
    line-height: 1.35;
    max-height: 7rem;
    overflow: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--content-bg);
    border-radius: 6px;
    padding: 6px 8px;
}
.ph-target-table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom-width: 1px;
}
.ph-target-table tbody td {
    vertical-align: top;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}
.ph-target-table .ph-target-url-cell {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 992px) {
    .ph-target-table .ph-target-url-cell {
        max-width: 22rem;
    }
}
.ph-target-table tbody tr.ph-target-row--ok {
    box-shadow: inset 3px 0 0 0 var(--bs-success);
}
.ph-target-table tbody tr.ph-target-row--bad {
    box-shadow: inset 3px 0 0 0 var(--bs-danger);
}
.ph-target-table .ph-target-body {
    min-width: 12rem;
    max-width: 28rem;
}

/* Sidebar nav group toggles: beat high-specificity `button:not(.topnav-btn):not(...)` (≈0,7,1) */
aside.sidebar button.sidebar-nav-group-toggle {
    display: flex !important;
    width: 100% !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    min-height: 0 !important;
    padding: 9px 20px !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    color: var(--sidebar-muted) !important;
    cursor: pointer;
    text-align: left;
    line-height: 1.3;
    -webkit-appearance: none;
    appearance: none;
    font-family: inherit;
    box-sizing: border-box;
}
aside.sidebar button.sidebar-nav-group-toggle:hover {
    color: var(--sidebar-text) !important;
    background: var(--sidebar-hover-bg) !important;
}

.required { color: var(--required-mark, #dc2626); }

.form-label.required::after {
    content: " *";
    color: var(--required-mark, #dc2626);
}

/* ─────────────────────────────────────────────────────────────
   Dark mode — Bootstrap bridge + readability (all admin pages)
   Requires data-bs-theme on <html> (set in theme.js + layout head).
   ───────────────────────────────────────────────────────────── */

[data-mode="dark"] {
    color-scheme: dark;
}

[data-mode="dark"] body {
    color: var(--text-primary);
    background: var(--content-bg);
}

/* Bootstrap utilities → theme tokens */
[data-mode="dark"] .text-muted,
[data-mode="dark"] .text-secondary,
[data-mode="dark"] .form-text {
    color: var(--text-muted) !important;
}

[data-mode="dark"] .text-dark,
[data-mode="dark"] .text-body,
[data-mode="dark"] .text-black {
    color: var(--text-primary) !important;
}

[data-mode="dark"] .text-primary {
    color: var(--accent-subtle-text) !important;
}

[data-mode="dark"] h1,
[data-mode="dark"] h2,
[data-mode="dark"] h3,
[data-mode="dark"] h4,
[data-mode="dark"] h5,
[data-mode="dark"] h6,
[data-mode="dark"] .h1,
[data-mode="dark"] .h2,
[data-mode="dark"] .h3,
[data-mode="dark"] .h4,
[data-mode="dark"] .h5,
[data-mode="dark"] .h6 {
    color: var(--text-primary);
}

[data-mode="dark"] .text-muted.h6,
[data-mode="dark"] h3.text-muted,
[data-mode="dark"] .text-uppercase.text-muted {
    color: var(--text-muted) !important;
}

[data-mode="dark"] a:not(.btn):not(.billing-mod-icon-btn):not(.nav-link):not(.topnav-btn):not(.topnav-breadcrumb-module-link):not(.ov-metric-action):not(.fb-ix-action-item):not(.fb-ix-title-link):not(.fb-ix-footer-link) {
    color: var(--link, var(--opero-red-80, var(--accent-subtle-text)));
}

[data-mode="dark"] a:not(.btn):not(.billing-mod-icon-btn):not(.nav-link):not(.topnav-btn):not(.topnav-breadcrumb-module-link):not(.ov-metric-action):not(.fb-ix-action-item):not(.fb-ix-title-link):not(.fb-ix-footer-link):hover {
    color: var(--accent-hover, rgba(193, 53, 43, 0.92));
}

[data-mode="dark"] a.fb-ix-action-item:hover,
[data-mode="dark"] a.fb-ix-title-link:hover,
[data-mode="dark"] a.fb-ix-footer-link:hover {
    text-decoration: none;
}

/* Sidebar nav is not prose — keep neutral text, not global link accent */
[data-mode="dark"] aside.sidebar .sidebar-nav li a,
[data-mode="dark"] aside.sidebar .sidebar-nav li a .sidebar-link-label {
    color: var(--sidebar-text);
    text-decoration: none;
}

[data-mode="dark"] aside.sidebar .sidebar-nav li a:hover,
[data-mode="dark"] aside.sidebar .sidebar-nav li a:hover .sidebar-link-label {
    color: var(--sidebar-brand-text);
    text-decoration: none;
}

[data-mode="dark"] aside.sidebar .sidebar-nav li.active a,
[data-mode="dark"] aside.sidebar .sidebar-nav li.active a .sidebar-link-label {
    color: var(--sidebar-active-text);
    text-decoration: none;
}

[data-mode="dark"] code {
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--text-muted) 12%, var(--surface-bg));
    border-radius: 4px;
    padding: 0 0.2em;
}

[data-mode="dark"] .td-mono {
    color: var(--text-secondary);
}

/* .td-mono on table cells is for tabular/mono text only — not inline code chips */
[data-mode="dark"] .data-table .td-mono,
[data-mode="dark"] .data-table code {
    color: inherit;
    background: transparent;
    border-radius: 0;
    padding: 0;
}

[data-mode="dark"] .form-control,
[data-mode="dark"] .form-select {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-primary);
}

[data-mode="dark"] .form-control:focus,
[data-mode="dark"] .form-select:focus {
    background-color: var(--input-bg);
    color: var(--text-primary);
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px var(--input-shadow-focus);
}

[data-mode="dark"] .form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.85;
}

[data-mode="dark"] .modal-content {
    background: var(--surface-bg);
    color: var(--text-primary);
    border-color: var(--surface-border);
}

[data-mode="dark"] .modal-header,
[data-mode="dark"] .modal-footer {
    border-color: var(--surface-border);
}

[data-mode="dark"] .btn-close {
    filter: invert(1) grayscale(100%);
    opacity: 0.72;
}

[data-mode="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--surface-border);
    --bs-table-striped-bg: color-mix(in srgb, var(--text-muted) 6%, var(--surface-bg));
    --bs-table-hover-bg: color-mix(in srgb, var(--text-muted) 10%, var(--surface-bg));
}

[data-mode="dark"] .badge-secondary,
[data-mode="dark"] .text-bg-secondary {
    background: color-mix(in srgb, var(--text-muted) 24%, var(--surface-bg)) !important;
    color: var(--text-secondary) !important;
}

[data-mode="dark"] .btn-danger,
[data-mode="dark"] button.btn-danger {
    background: var(--danger, #c75555);
    border-color: var(--danger, #c75555);
    color: #fff;
}

[data-mode="dark"] .btn-danger:hover,
[data-mode="dark"] button.btn-danger:hover {
    background: var(--danger-hover, #d97066);
    border-color: var(--danger-hover, #d97066);
}

[data-mode="dark"] .tenant-modules-grid {
    background: color-mix(in srgb, var(--surface-bg) 88%, #000 12%);
    border-color: var(--surface-border);
}

[data-mode="dark"] .tenant-module-pick--auto {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.32);
    color: var(--text-primary);
}

[data-mode="dark"] .flash-err,
[data-mode="dark"] .alert-error {
    color: var(--alert-error-text);
}

[data-mode="dark"] .dropdown-menu {
    background: var(--surface-bg);
    border-color: var(--surface-border);
    color: var(--text-primary);
}

[data-mode="dark"] .dropdown-item {
    color: var(--text-secondary);
}

[data-mode="dark"] .dropdown-item:hover,
[data-mode="dark"] .dropdown-item:focus {
    background: var(--topnav-hover);
    color: var(--text-primary);
}

[data-mode="dark"] .list-group-item {
    background: var(--surface-bg);
    border-color: var(--surface-border);
    color: var(--text-primary);
}

[data-mode="dark"] .border,
[data-mode="dark"] .border-top,
[data-mode="dark"] .border-bottom {
    border-color: var(--surface-border) !important;
}

[data-mode="dark"] .small,
[data-mode="dark"] small {
    color: var(--text-muted);
}

[data-mode="dark"] legend {
    color: var(--text-primary);
}

[data-mode="dark"] .form-check-label {
    color: var(--text-secondary);
}

[data-mode="dark"] .tag {
    color: var(--text-primary);
}

/* Feedback detail — inset panels and description (dark-mode safe tokens) */
.feedback-detail-pre {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 50vh;
    overflow: auto;
    margin: 0;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--content-surface-alt, color-mix(in srgb, var(--text-muted) 8%, var(--surface-bg)));
    border: 1px solid var(--surface-border);
    border-radius: 6px;
}

.feedback-detail-panel {
    background: var(--content-surface-alt, color-mix(in srgb, var(--text-muted) 8%, var(--surface-bg)));
    border: 1px solid var(--surface-border) !important;
}

.feedback-followup-pre {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    padding: 0;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.55;
    color: var(--text-primary);
    background: transparent;
    border: 0;
}

.feedback-detail-page .feedback-context-list strong {
    color: var(--text-primary);
}

.feedback-detail-page .feedback-context-list code {
    color: var(--text-secondary);
}

[data-mode="dark"] .feedback-detail-page pre.feedback-detail-pre,
[data-mode="dark"] .feedback-detail-page pre.feedback-followup-pre {
    color: var(--text-primary);
}

[data-mode="dark"] .feedback-detail-page .feedback-detail-pre,
[data-mode="dark"] .feedback-detail-page .feedback-detail-panel {
    background: var(--content-surface-alt);
    border-color: var(--surface-border);
}

[data-mode="dark"] .feedback-detail-page .img-fluid.border {
    border-color: var(--surface-border) !important;
}

[data-mode="dark"] .feedback-detail-page .btn-outline-primary {
    color: var(--accent-subtle-text, var(--accent));
    border-color: color-mix(in srgb, var(--accent) 45%, var(--surface-border));
}

[data-mode="dark"] .feedback-detail-page .btn-outline-primary:hover {
    background: var(--accent-subtle);
    color: var(--text-primary);
    border-color: var(--accent);
}

/* Feedback — title links and status pills (list + detail, light/dark) */
.fb-fd-page .fb-ix-title-link,
.feedback-detail-page .fb-ix-title-link {
    color: var(--text-primary);
    font-weight: 500;
    text-decoration: none;
}

.fb-fd-page .fb-ix-title-link:hover,
.feedback-detail-page .fb-ix-title-link:hover,
.fb-fd-page .fb-ix-title-link:focus-visible,
.feedback-detail-page .fb-ix-title-link:focus-visible {
    color: var(--text-primary);
    text-decoration: none;
}

[data-mode="dark"] .fb-fd-page .fb-ix-title-link,
[data-mode="dark"] .feedback-detail-page .fb-ix-title-link {
    color: var(--text-primary, #f4f4f5);
}

[data-mode="dark"] .fb-fd-page .fb-ix-title-link:hover,
[data-mode="dark"] .feedback-detail-page .fb-ix-title-link:hover,
[data-mode="dark"] .fb-fd-page .fb-ix-title-link:focus-visible,
[data-mode="dark"] .feedback-detail-page .fb-ix-title-link:focus-visible {
    color: var(--text-primary, #fafafa);
    text-decoration: none;
}

.fb-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    border: 1px solid transparent;
    white-space: nowrap;
}

.fb-status-badge--completed {
    background: color-mix(in srgb, #22c55e 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #22c55e 45%, transparent);
    color: #166534;
}

.fb-status-badge--in_progress {
    background: color-mix(in srgb, #3b82f6 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 45%, transparent);
    color: #1d4ed8;
}

.fb-status-badge--not_started {
    background: color-mix(in srgb, #f59e0b 24%, var(--surface-bg));
    border-color: color-mix(in srgb, #f59e0b 48%, transparent);
    color: #92400e;
}

.fb-status-badge--backlog {
    background: color-mix(in srgb, #64748b 20%, var(--surface-bg));
    border-color: color-mix(in srgb, #64748b 40%, transparent);
    color: #334155;
}

.fb-status-badge--wont_fix {
    background: color-mix(in srgb, #ef4444 20%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 42%, transparent);
    color: #991b1b;
}

.fb-status-badge--duplicate {
    background: color-mix(in srgb, #06b6d4 20%, var(--surface-bg));
    border-color: color-mix(in srgb, #06b6d4 42%, transparent);
    color: #0e7490;
}

.fb-status-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 16%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

[data-mode="dark"] .fb-status-badge--completed {
    background: color-mix(in srgb, #22c55e 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #22c55e 50%, transparent);
    color: #86efac;
}

[data-mode="dark"] .fb-status-badge--in_progress {
    background: color-mix(in srgb, #3b82f6 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 50%, transparent);
    color: #93c5fd;
}

[data-mode="dark"] .fb-status-badge--not_started {
    background: color-mix(in srgb, #f59e0b 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #f59e0b 50%, transparent);
    color: #fcd34d;
}

[data-mode="dark"] .fb-status-badge--backlog {
    background: color-mix(in srgb, #94a3b8 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #94a3b8 40%, transparent);
    color: #cbd5e1;
}

[data-mode="dark"] .fb-status-badge--wont_fix {
    background: color-mix(in srgb, #ef4444 26%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 48%, transparent);
    color: #fca5a5;
}

[data-mode="dark"] .fb-status-badge--duplicate {
    background: color-mix(in srgb, #06b6d4 26%, var(--surface-bg));
    border-color: color-mix(in srgb, #06b6d4 48%, transparent);
    color: #67e8f9;
}

[data-mode="dark"] .fb-status-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 20%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-muted);
}

.tk-status-badge,
.tk-priority-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.35;
    border: 1px solid transparent;
    white-space: nowrap;
}

.tk-status-badge--open {
    background: color-mix(in srgb, #f59e0b 24%, var(--surface-bg));
    border-color: color-mix(in srgb, #f59e0b 48%, transparent);
    color: #92400e;
}

.tk-status-badge--in_progress {
    background: color-mix(in srgb, #3b82f6 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 45%, transparent);
    color: #1d4ed8;
}

.tk-status-badge--blocked {
    background: color-mix(in srgb, #ef4444 20%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 42%, transparent);
    color: #991b1b;
}

.tk-status-badge--done {
    background: color-mix(in srgb, #22c55e 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #22c55e 45%, transparent);
    color: #166534;
}

.tk-status-badge--cancelled {
    background: color-mix(in srgb, #64748b 20%, var(--surface-bg));
    border-color: color-mix(in srgb, #64748b 40%, transparent);
    color: #334155;
}

.tk-status-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 16%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

.tk-priority-badge--urgent {
    background: color-mix(in srgb, #ef4444 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 45%, transparent);
    color: #991b1b;
}

.tk-priority-badge--high {
    background: color-mix(in srgb, #f97316 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #f97316 45%, transparent);
    color: #9a3412;
}

.tk-priority-badge--normal {
    background: color-mix(in srgb, #3b82f6 18%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 40%, transparent);
    color: #1d4ed8;
}

.tk-priority-badge--low {
    background: color-mix(in srgb, #64748b 18%, var(--surface-bg));
    border-color: color-mix(in srgb, #64748b 38%, transparent);
    color: #475569;
}

.tk-priority-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 16%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-secondary);
}

[data-mode="dark"] .tk-status-badge--open {
    background: color-mix(in srgb, #f59e0b 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #f59e0b 50%, transparent);
    color: #fcd34d;
}

[data-mode="dark"] .tk-status-badge--in_progress {
    background: color-mix(in srgb, #3b82f6 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 50%, transparent);
    color: #93c5fd;
}

[data-mode="dark"] .tk-status-badge--blocked {
    background: color-mix(in srgb, #ef4444 26%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 48%, transparent);
    color: #fca5a5;
}

[data-mode="dark"] .tk-status-badge--done {
    background: color-mix(in srgb, #22c55e 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #22c55e 50%, transparent);
    color: #86efac;
}

[data-mode="dark"] .tk-status-badge--cancelled {
    background: color-mix(in srgb, #94a3b8 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #94a3b8 40%, transparent);
    color: #cbd5e1;
}

[data-mode="dark"] .tk-status-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 20%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-muted);
}

[data-mode="dark"] .tk-priority-badge--urgent {
    background: color-mix(in srgb, #ef4444 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #ef4444 50%, transparent);
    color: #fca5a5;
}

[data-mode="dark"] .tk-priority-badge--high {
    background: color-mix(in srgb, #f97316 28%, var(--surface-bg));
    border-color: color-mix(in srgb, #f97316 50%, transparent);
    color: #fdba74;
}

[data-mode="dark"] .tk-priority-badge--normal {
    background: color-mix(in srgb, #3b82f6 26%, var(--surface-bg));
    border-color: color-mix(in srgb, #3b82f6 48%, transparent);
    color: #93c5fd;
}

[data-mode="dark"] .tk-priority-badge--low {
    background: color-mix(in srgb, #94a3b8 22%, var(--surface-bg));
    border-color: color-mix(in srgb, #94a3b8 40%, transparent);
    color: #cbd5e1;
}

[data-mode="dark"] .tk-priority-badge--unknown {
    background: color-mix(in srgb, var(--text-muted) 20%, var(--surface-bg));
    border-color: var(--surface-border);
    color: var(--text-muted);
}

[data-mode="dark"] .task-detail-page .fb-ix-title-link,
[data-mode="dark"] .tk-ix-page .fb-ix-title-link {
    color: var(--text-primary, #f4f4f5);
}

[data-mode="dark"] .task-detail-page .fb-ix-title-link:hover,
[data-mode="dark"] .tk-ix-page .fb-ix-title-link:hover {
    color: var(--text-primary, #fafafa);
    text-decoration: none;
}

/* Tenant dashboard card availability matrix (Desktop + PWA) */
.tenant-card-matrix .tenant-card-matrix__flag-col {
    width: 9rem;
    text-align: center;
}

.tenant-card-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.tenant-card-toggle__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tenant-card-toggle__box {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid color-mix(in srgb, var(--surface-border) 80%, var(--text-muted));
    background: color-mix(in srgb, var(--surface-bg) 90%, var(--text-muted));
    position: relative;
    transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.tenant-card-toggle__box::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0.4);
    opacity: 0;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.tenant-card-toggle:hover .tenant-card-toggle__box {
    border-color: color-mix(in srgb, var(--accent) 48%, var(--surface-border));
}

.tenant-card-toggle__input:checked + .tenant-card-toggle__box {
    background: var(--accent);
    border-color: var(--accent);
}

.tenant-card-toggle__input:checked + .tenant-card-toggle__box::after {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}

.tenant-card-toggle__input:focus-visible + .tenant-card-toggle__box {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
    border-color: var(--accent);
}

.tenant-card-toggle__input:disabled + .tenant-card-toggle__box {
    opacity: 0.55;
    cursor: not-allowed;
}

.tenant-card-toggle__label {
    min-width: 1.7rem;
    text-align: left;
}

[data-mode="dark"] .tenant-card-toggle {
    color: var(--text-muted);
}

[data-mode="dark"] .tenant-card-toggle__box {
    background: color-mix(in srgb, var(--surface-bg) 85%, #000000);
    border-color: color-mix(in srgb, var(--surface-border) 78%, #000000);
}

