/* ═══════════════════════════════════════════════════════════════════════════
   Web Push Platform — Components
   ---------------------------------------------------------------------------
   Every value here comes from a token in theme.css. No literal colour, no
   literal spacing, and no theme-specific rule: dark mode is handled entirely by
   the token remap, so each component is written exactly once.
   Order: base → layout → navigation → page chrome → data display → forms →
          feedback → utilities → responsive.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Base ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-base);
    background: var(--page-bg);
    background-image: var(--page-bg-grad);
    color: var(--text);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html[lang="en"] {
    --font-base: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
}

a { color: var(--link); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--link-hover); }

code, pre, .font-mono { font-family: var(--font-mono); }

/* One visible focus style for everything reachable by keyboard. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: var(--radius-full); }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1 1 auto;
    min-width: 0;            /* lets long tables scroll instead of pushing */
    display: flex;
    flex-direction: column;
}

.content-area {
    padding: var(--space-6);
    flex: 1 1 auto;
    width: 100%;
    max-width: 1600px;
    margin-inline: auto;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--sidebar-border);
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--sidebar-active-bg);
    color: var(--text-inverse);
    font-size: var(--text-lg);
    box-shadow: var(--shadow-md);
}

.sidebar-brand-text {
    color: var(--sidebar-text-strong);
    font-weight: var(--weight-bold);
    font-size: var(--text-md);
    line-height: var(--leading-tight);
}

.sidebar-brand-sub {
    color: var(--sidebar-text);
    font-size: var(--text-2xs);
}

.sidebar-group-label {
    padding: var(--space-4) var(--space-4) var(--space-1);
    font-size: var(--text-2xs);
    font-weight: var(--weight-bold);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .38);
}

.sidebar-group-label:first-of-type { padding-top: var(--space-1); }

.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 2px var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar .nav-link .bi {
    font-size: var(--text-lg);
    color: var(--sidebar-icon-color);
    transition: color var(--transition-fast);
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--sidebar-text-strong);
}

.sidebar .nav-link:hover .bi { color: var(--sidebar-text-strong); }

.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--text-inverse);
    box-shadow: var(--shadow-md);
}

.sidebar .nav-link.active .bi { color: var(--text-inverse); }

.sidebar-user {
    border-top: 1px solid var(--sidebar-border);
    padding: var(--space-3);
}

.sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2);
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--sidebar-text);
    text-align: start;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-user-btn:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-strong); }

.sidebar-avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--sidebar-active-bg);
    color: var(--text-inverse);
    font-weight: var(--weight-bold);
}

.sidebar-user-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--sidebar-text-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role { font-size: var(--text-2xs); color: var(--sidebar-text); }

/* ─── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.topbar-breadcrumb {
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.topbar-breadcrumb .current { color: var(--text); font-weight: var(--weight-semibold); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-lg);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.icon-btn:hover { background: var(--surface-2); color: var(--primary); border-color: var(--border); }
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-size: var(--text-lg);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle-btn:hover { background: var(--surface-2); color: var(--primary); }

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.lang-switch:hover { background: var(--surface-2); color: var(--primary); }

.lang-switch-mobile {
    height: 32px;
    padding: 0 var(--space-2);
    border-color: rgba(255, 255, 255, .2);
    color: var(--text-inverse);
}

.lang-switch-mobile:hover { background: rgba(255, 255, 255, .12); color: var(--text-inverse); }

.mobile-topbar {
    display: none;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--sidebar-bg);
    color: var(--text-inverse);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, .12);
    color: var(--text-inverse);
    font-size: var(--text-lg);
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .55);
    z-index: var(--z-backdrop);
}

/* ─── Page header ───────────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: var(--weight-bold);
    color: var(--text-heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.page-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

.section-divider {
    height: 1px;
    background: var(--border);
    border: 0;
    margin: var(--space-6) 0;
}

/* ─── Stat cards ────────────────────────────────────────────────────────── */
.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

/* A plain stat box: any markup may live inside (detail pages use it freely). */
.stat-card {
    position: relative;
    overflow: hidden;
    display: block;
    padding: var(--space-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.stat-card::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    background: var(--stat-gradient, linear-gradient(90deg, var(--brand-500), var(--brand-400)));
    opacity: .85;
}

.stat-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}

.stat-card-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card-value {
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    color: var(--text-heading);
    line-height: var(--leading-tight);
    margin-top: var(--space-1);
}

.stat-card-meta { font-size: var(--text-xs); color: var(--text-subtle); margin-top: 2px; }
.stat-card-suffix { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-muted); margin-inline-start: 2px; }
/* The KPI layout rendered by partials/stat_cards.php: text first, icon at the end. */
.stat-card--kpi {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}
.stat-card-main { min-width: 0; flex: 1 1 auto; }
.stat-card-value { overflow-wrap: break-word; }
a.stat-card { text-decoration: none; color: inherit; }
a.stat-card:hover .stat-card-value { color: var(--primary); }

.stat-card-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: var(--text-xl);
    background: var(--tint-primary);
    color: var(--on-primary);
}

.stat-card-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    padding: 1px var(--space-2);
    border-radius: var(--radius-full);
}

.trend-up   { background: var(--tint-success); color: var(--on-success); }
.trend-down { background: var(--tint-danger);  color: var(--on-danger); }
.trend-flat { background: var(--tint-neutral); color: var(--on-neutral); }

.stat-primary   { --stat-gradient: linear-gradient(90deg, var(--brand-500), var(--brand-400)); }
.stat-primary   .stat-card-icon { background: var(--tint-primary); color: var(--on-primary); }
.stat-success   { --stat-gradient: linear-gradient(90deg, var(--success-500), var(--success-400)); }
.stat-success   .stat-card-icon { background: var(--tint-success); color: var(--on-success); }
.stat-warning   { --stat-gradient: linear-gradient(90deg, var(--warning-500), var(--warning-400)); }
.stat-warning   .stat-card-icon { background: var(--tint-warning); color: var(--on-warning); }
.stat-danger    { --stat-gradient: linear-gradient(90deg, var(--danger-500), var(--danger-400)); }
.stat-danger    .stat-card-icon { background: var(--tint-danger); color: var(--on-danger); }
.stat-info      { --stat-gradient: linear-gradient(90deg, var(--info-500), var(--info-400)); }
.stat-info      .stat-card-icon { background: var(--tint-info); color: var(--on-info); }
.stat-accent    { --stat-gradient: linear-gradient(90deg, var(--accent-500), var(--accent-400)); }
.stat-accent    .stat-card-icon { background: rgba(var(--accent-rgb), .14); color: var(--accent-600); }
.stat-secondary { --stat-gradient: linear-gradient(90deg, var(--gray-500), var(--gray-400)); }
.stat-secondary .stat-card-icon { background: var(--tint-neutral); color: var(--on-neutral); }

/* Sparkline drawn with plain divs — no chart library on list pages. */
.sparkline-bar {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 34px;
    margin-top: var(--space-2);
}

.sparkline-bar span {
    flex: 1 1 auto;
    min-width: 2px;
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    background: var(--tint-primary);
}

.sparkline-bar span:last-child { background: var(--primary); }

/* ─── Bar chart (no chart library: plain boxes driven by tokens) ─────────── */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    font-size: var(--text-xs);
    font-weight: var(--weight-normal);
    color: var(--text-muted);
}

.chart-legend-item { display: inline-flex; align-items: center; gap: var(--space-1); }

.chart-swatch { width: 10px; height: 10px; border-radius: var(--radius-xs); display: inline-block; }
.chart-swatch-primary { background: var(--brand-500); }
.chart-swatch-success { background: var(--success-500); }
.chart-swatch-accent  { background: var(--accent-500); }

.chart-bars {
    display: flex;
    align-items: stretch;
    gap: var(--space-1);
    height: 170px;
}

.chart-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }

.chart-col-bars {
    flex: 1 1 auto;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.chart-bar {
    width: 26%;
    max-width: 12px;
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    transition: opacity var(--transition-fast);
}

.chart-col:hover .chart-bar { opacity: .75; }
.chart-bar-primary { background: var(--brand-500); }
.chart-bar-success { background: var(--success-500); }
.chart-bar-accent  { background: var(--accent-500); }

.chart-col-label {
    border-top: 1px solid var(--border);
    padding-top: var(--space-1);
    text-align: center;
    font-size: var(--text-2xs);
    color: var(--text-subtle);
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .chart-bars { height: 130px; }
    .chart-col-label { font-size: 9px; }
}
/* ─── Cards ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    color: var(--text);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-heading);
    border-radius: var(--card-radius) var(--card-radius) 0 0;
}

.card-header .bi { color: var(--primary); }
.card-body { padding: var(--space-5); }
.card-footer { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: transparent; }

.list-group-item {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
    padding: var(--space-3) var(--space-5);
}

.list-group-item:hover { background: var(--surface-2); }

/* ─── Tables ────────────────────────────────────────────────────────────── */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    margin: 0;
    color: var(--text);
    font-size: var(--text-sm);
}

.table thead th {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: .03em;
    padding: var(--space-3) var(--space-4);
    white-space: nowrap;
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background var(--transition-fast); }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table a { color: var(--text); font-weight: var(--weight-medium); }
.table a:hover { color: var(--link); }

[dir="ltr"] .table thead th,
[dir="ltr"] .table td { text-align: left; }
[dir="rtl"] .table thead th,
[dir="rtl"] .table td { text-align: right; }

/* A table never widens the page: it scrolls inside its own card. */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ─── Badges & status ───────────────────────────────────────────────────── */
.badge {
    font-size: var(--text-2xs);
    font-weight: var(--weight-semibold);
    padding: 4px var(--space-2);
    border-radius: var(--radius-full);
    letter-spacing: .01em;
}

.text-bg-success   { background-color: var(--tint-success) !important; color: var(--on-success) !important; }
.text-bg-danger    { background-color: var(--tint-danger)  !important; color: var(--on-danger)  !important; }
.text-bg-warning   { background-color: var(--tint-warning) !important; color: var(--on-warning) !important; }
.text-bg-info      { background-color: var(--tint-info)    !important; color: var(--on-info)    !important; }
.text-bg-primary   { background-color: var(--tint-primary) !important; color: var(--on-primary) !important; }
.text-bg-secondary { background-color: var(--tint-neutral) !important; color: var(--on-neutral) !important; }
.text-bg-light     { background-color: var(--surface-2)    !important; color: var(--text-muted) !important; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    margin-inline-end: var(--space-1);
    vertical-align: middle;
}

.status-dot-success { background: var(--success-500); box-shadow: 0 0 0 2px var(--tint-success); }
.status-dot-warning { background: var(--warning-500); }
.status-dot-danger  { background: var(--danger-500); }
.status-dot-info    { background: var(--info-500); }
.status-dot-gray    { background: var(--gray-400); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: var(--text-xs);
}

/* ─── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    --bs-btn-focus-box-shadow: var(--focus-ring);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    line-height: var(--leading-tight);
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus-ring); outline: none; }
.btn:disabled,
.btn.disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-sm { font-size: var(--text-xs); padding: 5px var(--space-3); }
.btn-lg { font-size: var(--text-md); padding: var(--space-3) var(--space-5); }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover,
.btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-contrast); }

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

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

.btn-outline-primary { border-color: var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary); color: var(--primary-contrast); }
.btn-outline-danger { border-color: var(--danger-500); color: var(--danger-600); background: transparent; }
.btn-outline-danger:hover { background: var(--danger-600); border-color: var(--danger-600); color: var(--text-inverse); }
.btn-outline-success { border-color: var(--success-500); color: var(--success-600); background: transparent; }
.btn-outline-success:hover { background: var(--success-600); border-color: var(--success-600); color: var(--text-inverse); }
.btn-outline-warning { border-color: var(--warning-500); color: var(--warning-700); background: transparent; }
.btn-outline-warning:hover { background: var(--warning-500); border-color: var(--warning-500); color: var(--gray-900); }
.btn-link { color: var(--link); text-decoration: none; }

/* Submitting state: the label stays put, a spinner replaces the icon slot. */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-inline-start-color: transparent;
    border-radius: var(--radius-full);
    color: var(--primary-contrast);
    animation: spin .6s linear infinite;
}

.btn-outline-secondary.is-loading::after,
.btn-outline-primary.is-loading::after,
.btn-link.is-loading::after { color: var(--primary); }

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

/* ─── Forms ─────────────────────────────────────────────────────────────── */
.form-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--text);
    margin-bottom: var(--space-1);
}

.form-label .required,
.required-mark { color: var(--danger-500); margin-inline-start: 2px; }

.form-control,
.form-select {
    background-color: var(--surface-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.form-control::placeholder { color: var(--text-subtle); }
.form-control:hover:not(:disabled):not(:focus),
.form-select:hover:not(:disabled):not(:focus) { border-color: var(--text-subtle); }

.form-control:focus,
.form-select:focus {
    background-color: var(--surface-input);
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    color: var(--text);
    outline: none;
}

.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
    background-color: var(--surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
}

.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--danger-500); }
.form-control.is-invalid:focus,
.form-select.is-invalid:focus { box-shadow: var(--focus-ring-danger); }

.form-control-sm,
.form-select-sm { font-size: var(--text-xs); padding: 5px var(--space-2); border-radius: var(--radius-sm); }

.form-text,
.form-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }

.invalid-feedback,
.field-error {
    display: block;
    font-size: var(--text-xs);
    color: var(--danger-600);
    margin-top: var(--space-1);
}

.form-check-input { border-color: var(--border-strong); background-color: var(--surface-input); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--primary); }
.form-check-label { font-size: var(--text-sm); color: var(--text); }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.input-with-icon { position: relative; }
.input-with-icon .bi {
    position: absolute;
    inset-inline-start: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}
.input-with-icon input { padding-inline-start: var(--space-8); }

/* A grouped block of fields inside a long form. */
.form-section { margin-bottom: var(--space-6); }
.form-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-md);
    font-weight: var(--weight-semibold);
    color: var(--text-heading);
    margin-bottom: var(--space-1);
}
.form-section-hint { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: var(--space-3); }

/* ─── Section headings inside long forms ─────────────────────────────────── */
.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
}

.section-icon-primary { background: var(--tint-primary); color: var(--on-primary); }
.section-icon-accent  { background: rgba(var(--accent-rgb), .14); color: var(--accent-600); }
.section-icon-success { background: var(--tint-success); color: var(--on-success); }
.section-icon-danger  { background: var(--tint-danger); color: var(--on-danger); }

.section-heading {
    margin: 0;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-heading);
}

/* ─── Multi-step wizard ─────────────────────────────────────────────────── */
.steps {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    padding: var(--space-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1 1 160px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: start;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.step:hover { background: var(--surface-2); color: var(--text); }

.step-index {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
}

.step.is-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--on-primary);
}

.step.is-active .step-index { background: var(--primary); color: var(--primary-contrast); }
.step.is-done .step-index { background: var(--tint-success); color: var(--on-success); }
/* A utility class must never beat the hidden attribute (e.g. d-flex + hidden). */
[hidden] { display: none !important; }

/* ─── Composer ──────────────────────────────────────────────────────────── */
.wizard-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.picker-box {
    max-height: 210px;
    overflow-y: auto;
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.preview-sticky { position: sticky; top: var(--space-6); }
.preview-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; }
.preview-badge { width: 14px; height: 14px; }
.time-input { max-width: 160px; }

.review-grid {
    display: grid;
    grid-template-columns: minmax(120px, 30%) 1fr;
    gap: var(--space-2) var(--space-4);
    margin: 0;
    font-size: var(--text-sm);
}

.review-grid dt { color: var(--text-muted); font-weight: var(--weight-medium); }
.review-grid dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

@media (max-width: 767.98px) {
    .review-grid { grid-template-columns: 1fr; gap: 2px var(--space-2); }
    .review-grid dd { margin-bottom: var(--space-2); }
    .preview-sticky { position: static; }
}

/* ─── Filter bar ────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--space-4);
}

.filter-bar label { font-size: var(--text-xs); color: var(--text-muted); margin: 0; }

.filter-field { flex: 1 1 170px; min-width: 0; }
.filter-field--wide { flex: 2 1 240px; }
.filter-actions { display: flex; gap: var(--space-2); margin-inline-start: auto; }

.filter-count {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    background: var(--tint-primary);
    color: var(--on-primary);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
}

/* ─── Bulk action bar ───────────────────────────────────────────────────── */
.bulk-bar {
    position: sticky;
    bottom: var(--space-3);
    z-index: var(--z-bulkbar);
    margin-top: var(--space-3);
}

.bulk-bar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
}

.bulk-count { font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; }
.bulk-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.bulk-check { cursor: pointer; }
.col-check { width: 36px; }
.site-cell { max-width: 160px; }
tr.bulk-selected > td { background: var(--primary-soft); }
.col.bulk-selected > .card,
.card.bulk-selected { outline: 2px solid var(--primary); }

/* ─── Feedback ──────────────────────────────────────────────────────────── */
.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
}

.alert-success { background: var(--tint-success); border-color: rgba(var(--success-rgb), .3); color: var(--on-success); }
.alert-danger  { background: var(--tint-danger);  border-color: rgba(var(--danger-rgb), .3);  color: var(--on-danger); }
.alert-warning { background: var(--tint-warning); border-color: rgba(var(--warning-rgb), .3); color: var(--on-warning); }
.alert-info    { background: var(--tint-info);    border-color: rgba(var(--info-rgb), .3);    color: var(--on-info); }
.alert-light   { background: var(--surface-2);    border-color: var(--border);                color: var(--text-muted); }
.alert .bi { vertical-align: -.1em; }

.empty-state {
    text-align: center;
    padding: var(--space-10) var(--space-5);
    color: var(--text-muted);
}

.empty-state .bi {
    display: block;
    font-size: var(--text-3xl);
    color: var(--text-subtle);
    margin-bottom: var(--space-3);
}

.empty-state p { font-size: var(--text-sm); margin: 0 0 var(--space-3); }

.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
    background-size: 400% 100%;
    animation: skeleton 1.4s ease infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Shown while a filtered list reloads over AJAX. */
.is-refreshing { opacity: .55; transition: opacity var(--transition-fast); pointer-events: none; }

.progress {
    background: var(--surface-3);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
}

.progress-bar { background: var(--primary); border-radius: var(--radius-full); }

/* ─── Overlays ──────────────────────────────────────────────────────────── */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-xl);
    color: var(--text);
}

.modal-header,
.modal-footer { border-color: var(--border); }
.modal-title { font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-heading); }

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-1);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--text-sm);
    padding: var(--space-2) var(--space-3);
}

.dropdown-item:hover { background: var(--surface-2); color: var(--text-heading); }
.dropdown-item .bi { width: 16px; text-align: center; color: var(--text-muted); }
.dropdown-divider { border-color: var(--border); margin: var(--space-1) 0; }
.dropdown-menu-dark { background: var(--gray-800); border-color: var(--gray-700); }
.dropdown-menu-dark .dropdown-item { color: var(--gray-300); }
.dropdown-menu-dark .dropdown-item:hover { background: var(--gray-700); color: var(--text-inverse); }
.dropdown-menu-dark .dropdown-divider { border-color: var(--gray-700); }
.dropdown-menu-dark .dropdown-item-text { color: var(--gray-400); padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

.tooltip-inner {
    background: var(--gray-900);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    padding: var(--space-1) var(--space-2);
}

/* ─── Tabs & pagination ─────────────────────────────────────────────────── */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: var(--space-1);
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.nav-tabs .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    padding: var(--space-2) var(--space-4);
    white-space: nowrap;
}

.nav-tabs .nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.pagination { --bs-pagination-bg: var(--surface); }

.pagination .page-link {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--text-sm);
    padding: var(--space-1) var(--space-3);
    margin: 0 2px;
    border-radius: var(--radius-sm);
}

.pagination .page-link:hover { background: var(--surface-2); color: var(--text); }
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-contrast);
}

.pagination .page-item.disabled .page-link { background: var(--surface-2); color: var(--text-subtle); }

/* ─── Code snippets (install code, cron lines, API examples) ───────────────── */
.snippet {
    margin: 0;
    padding: var(--space-3);
    padding-inline-end: var(--space-10);   /* room for the copy button */
    background: var(--gray-900);
    color: #e2e8f0;
    border-radius: var(--radius-md);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
    white-space: pre-wrap;                 /* long paths wrap instead of scrolling */
    word-break: break-all;
    text-align: left;
    direction: ltr;
}

.snippet-wrap { position: relative; }

.snippet-wrap .copy-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);                 /* snippets are LTR, so the button sits right in both languages */
    padding: 2px var(--space-2);
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .2);
    color: #e2e8f0;
}

.snippet-wrap .copy-btn:hover { background: rgba(255, 255, 255, .22); color: #fff; }

.worker-card .card-body { padding: var(--space-5); }

/* ─── Plan cards ───────────────────────────────────────────────────────────── */
.plan-limits {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: var(--space-2) 0 var(--space-3);
}

.plan-limit {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.plan-limit dt { font-size: var(--text-2xs); font-weight: var(--weight-medium); color: var(--text-muted); }
.plan-limit dd { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); color: var(--text-heading); }

@media (max-width: 400px) {
    .plan-limits { grid-template-columns: 1fr; }
}

/* ─── Notification preview ──────────────────────────────────────────────── */
.notification-preview {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.notification-preview img.preview-image {
    width: 100%;
    max-height: 160px;
    object-fit: cover;
}

/* ─── Auth pages ────────────────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand-950) 0%, var(--brand-800) 50%, var(--accent-700) 100%);
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: var(--shadow-xl);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    color: var(--text-inverse);
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    margin-inline: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: var(--sidebar-active-bg);
    color: var(--text-inverse);
    font-size: var(--text-2xl);
    box-shadow: var(--shadow-lg);
}

.auth-card .form-control {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .2);
    color: var(--text-inverse);
}

.auth-card .form-control:focus {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .45);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .12);
    color: var(--text-inverse);
}

.auth-card .form-control::placeholder { color: rgba(255, 255, 255, .45); }
.auth-card .form-label { color: rgba(255, 255, 255, .8); }
.auth-card h1,
.auth-card h2 { color: var(--text-inverse); }
.auth-card .text-muted { color: rgba(255, 255, 255, .55) !important; }

.auth-body { background: var(--brand-950); }
.auth-orb { position: absolute; border-radius: 50%; pointer-events: none; }
.auth-orb-1 { width: 300px; height: 300px; top: 10%; inset-inline-start: 5%;
              background: radial-gradient(circle, rgba(var(--brand-rgb), .25) 0%, transparent 70%); }
.auth-orb-2 { width: 200px; height: 200px; bottom: 15%; inset-inline-end: 10%;
              background: radial-gradient(circle, rgba(var(--accent-rgb), .2) 0%, transparent 70%); }
.auth-title { color: var(--text-inverse); font-size: var(--text-xl); font-weight: var(--weight-black); letter-spacing: -.02em; margin: 0; }
.auth-subtitle { color: rgba(255, 255, 255, .5); font-size: var(--text-sm); margin: var(--space-1) 0 0; }
.auth-intro { color: rgba(255, 255, 255, .6); font-size: var(--text-sm); }
.auth-tool { color: rgba(255, 255, 255, .75) !important; }
.auth-tool:hover { color: var(--text-inverse) !important; background: rgba(255, 255, 255, .1); }
.auth-lang { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-2);
             border-radius: var(--radius-sm); font-size: var(--text-sm); }
.auth-addon { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .16); color: rgba(255, 255, 255, .55); }
.btn-auth { font-weight: var(--weight-bold); border-radius: var(--radius-md); }
.auth-link { color: rgba(255, 255, 255, .7); font-size: var(--text-sm); }
.auth-link:hover { color: var(--text-inverse); }
.auth-link-sm { font-size: var(--text-xs); }

.legend-delay { color: var(--warning-600); }
.legend-condition { color: var(--teal-600); }
.icon-tile-lg { width: 48px; height: 48px; font-size: var(--text-2xl); }

.install-shell {
    max-width: 880px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-4) var(--space-16);
}

/* ─── Utilities ─────────────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
.fw-semibold { font-weight: var(--weight-semibold); }
.avatar-sq {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--on-primary);
    font-weight: var(--weight-bold);
}

.avatar-lg { width: 52px; height: 52px; font-size: var(--text-xl); border-radius: var(--radius-lg); }
.surface-inset { background: var(--surface-3); border-radius: var(--radius-md); }
.text-break-any { overflow-wrap: anywhere; word-break: break-word; }
.min-w-0 { min-width: 0; }
.text-subtle { color: var(--text-subtle) !important; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.hide-empty:empty { display: none; }

.fade-in-up { animation: fadeInUp .4s ease both; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

.stat-card-grid .stat-card:nth-child(1) { animation-delay: .04s; }
.stat-card-grid .stat-card:nth-child(2) { animation-delay: .08s; }
.stat-card-grid .stat-card:nth-child(3) { animation-delay: .12s; }
.stat-card-grid .stat-card:nth-child(4) { animation-delay: .16s; }
.stat-card-grid .stat-card:nth-child(5) { animation-delay: .20s; }
.stat-card-grid .stat-card:nth-child(6) { animation-delay: .24s; }
.stat-card-grid .stat-card:nth-child(7) { animation-delay: .28s; }

/* Layout helpers that replaced inline styles in the views. */
.page-title .bi,
.card-header > .bi:first-child { color: var(--primary); }
.text-preline { white-space: pre-line; }
.text-2xs { font-size: var(--text-2xs) !important; }
.text-md { font-size: var(--text-md) !important; }
.text-lg { font-size: var(--text-lg) !important; }
.cursor-pointer { cursor: pointer; }
.row-transition { transition: background var(--transition-base); }
.col-num-sm { width: 40px; text-align: end; }
.col-num-lg { width: 120px; text-align: end; }
.col-fifth { flex: 0 0 20%; max-width: 20%; }
.w-70  { width: 70px; }
.w-90  { width: 90px; }
.w-140 { width: 140px; }
.w-170 { width: 170px; }
.w-200 { width: 200px; }
.minw-140 { min-width: 140px; }
.minw-150 { min-width: 150px; }
.minw-160 { min-width: 160px; }
.minw-180 { min-width: 180px; }
.minw-200 { min-width: 200px; }
.minw-220 { min-width: 220px; }
.minw-240 { min-width: 240px; }
.maxw-150 { max-width: 150px; }
.maxw-160 { max-width: 160px; }
.maxw-190 { max-width: 190px; }
.maxw-220 { max-width: 220px; }
.maxw-260 { max-width: 260px; }
.maxw-320 { max-width: 320px; }
.maxw-620 { max-width: 620px; }
.maxw-800 { max-width: 800px; }
.scroll-340 { max-height: 340px; overflow: auto; }
.scroll-520 { max-height: 520px; overflow: auto; }
.progress-thin { height: 6px; }
.progress-md   { height: 8px; }
.progress-lg   { height: 10px; }
.sticky-offset { top: var(--space-6); }
.surface-2 { background: var(--surface-2) !important; }
.tint-warning { background: var(--tint-warning) !important; }
.tint-danger  { background: var(--tint-danger) !important; }
.tint-info    { background: var(--tint-info) !important; }
.embed-frame { border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.error-icon { font-size: 4rem; color: var(--primary); }
.brand-icon-sm { width: 32px; height: 32px; font-size: var(--text-md); }

.icon-tile {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--tint-primary);
    color: var(--on-primary);
    font-size: var(--text-xl);
}
.icon-tile-sm { width: 36px; height: 36px; font-size: var(--text-lg); }
.icon-tile-success { background: var(--tint-success); color: var(--on-success); }
.icon-tile-warning { background: var(--tint-warning); color: var(--on-warning); }
.icon-tile.is-muted { background: var(--surface-3); color: var(--text-muted); }

.avatar-tile {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--tint-primary);
    color: var(--on-primary);
}
.avatar-tile-sm { width: 36px; height: 36px; }

.avatar-hero {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
    color: var(--text-inverse);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
}

@media (max-width: 767.98px) {
    .col-fifth { flex: 0 0 50%; max-width: 50%; }
    .w-200, .w-170, .minw-240, .minw-220, .minw-200 { width: 100%; min-width: 0; }
}

/* Bootstrap's ms-auto must follow the writing direction, not the left edge. */
[dir="rtl"] .ms-auto { margin-inline-start: auto !important; margin-left: unset !important; }
[dir="ltr"] .ms-auto { margin-left: auto !important; margin-inline-start: unset !important; }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    :root { --sidebar-width: 230px; }
    .content-area { padding: var(--space-4); }
    .stat-card-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-3); }
    .stat-card { padding: var(--space-4); }
    .stat-card-value { font-size: var(--text-xl); }
}

@media (max-width: 767.98px) {
    .lang-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.lang-switch:hover { background: var(--surface-2); color: var(--primary); }

.lang-switch-mobile {
    height: 32px;
    padding: 0 var(--space-2);
    border-color: rgba(255, 255, 255, .2);
    color: var(--text-inverse);
}

.lang-switch-mobile:hover { background: rgba(255, 255, 255, .12); color: var(--text-inverse); }

.mobile-topbar { display: flex; }
    .sidebar-toggle { display: flex; }
    .topbar { display: none; }

    /* Off-canvas drawer instead of a squeezed two-column layout. */
    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        transform: translateX(-105%);
        transition: transform var(--transition-slow);
        box-shadow: var(--shadow-xl);
        z-index: var(--z-drawer);
    }

    [dir="rtl"] .sidebar { transform: translateX(105%); }
    body.sidebar-open .sidebar,
    [dir="rtl"] body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open { overflow: hidden; }

    .content-area { padding: var(--space-3); }
    .page-header { margin-bottom: var(--space-4); }
    /* Two compact KPI cards per row on phones instead of one tall column. */
    .stat-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
    .stat-card--kpi { padding: var(--space-3); gap: var(--space-2); }
    .stat-card--kpi .stat-card-icon { width: 34px; height: 34px; font-size: var(--text-md); }
    .stat-card--kpi .stat-card-value { font-size: var(--text-lg); }
    .stat-card-label { font-size: var(--text-2xs); letter-spacing: 0; }
    .stat-card--kpi .sparkline-bar { height: 22px; }
    .page-title { font-size: var(--text-xl); }
    .card-body,
    .card-header { padding: var(--space-4); }
    .filter-bar { padding: var(--space-3); }
    .filter-field { flex: 1 1 100%; }
    .filter-actions { margin-inline-start: 0; width: 100%; }
    .filter-actions .btn { flex: 1 1 auto; }
    .bulk-actions .btn { flex: 1 1 auto; }
    .steps { gap: var(--space-1); }
    .step { flex: 1 1 100%; }
    .table thead th,
    .table td { padding: var(--space-2) var(--space-3); }
}

@media (min-width: 768px) {
    .sidebar-backdrop { display: none !important; }
}

@media print {
    .sidebar,
    .topbar,
    .mobile-topbar,
    .bulk-bar,
    .filter-bar,
    .btn { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; }
}
