/* =============================================================================
   INMS Design System
   Single source of truth for colors, surfaces, type, and Bootstrap bridging.
   Brand color (--primary*) is overridden at runtime from Settings → Appearance.
   ============================================================================= */

:root {
    /* Brand */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-subtle: rgba(99, 102, 241, 0.12);
    --primary-rgb: 99, 102, 241;
    --on-primary: #ffffff;
    --glow-primary: rgba(99, 102, 241, 0.35);
    --glow-primary-soft: rgba(99, 102, 241, 0.22);

    /* Semantic */
    --success: #10b981;
    --success-rgb: 16, 185, 129;
    --success-subtle: rgba(16, 185, 129, 0.12);
    --success-fg: #047857;
    --on-success: #ffffff;

    --danger: #ef4444;
    --danger-rgb: 239, 68, 68;
    --danger-subtle: rgba(239, 68, 68, 0.12);
    --danger-fg: #b91c1c;
    --on-danger: #ffffff;

    --warning: #f59e0b;
    --warning-rgb: 245, 158, 11;
    --warning-subtle: rgba(245, 158, 11, 0.14);
    --warning-fg: #b45309;
    --on-warning: #ffffff;

    --info: #3b82f6;
    --info-rgb: 59, 130, 246;
    --info-subtle: rgba(59, 130, 246, 0.12);
    --info-fg: #1d4ed8;
    --on-info: #ffffff;

    --accent: #7c3aed;
    --accent-subtle: rgba(124, 58, 237, 0.14);
    --accent-fg: #5b21b6;

    /* Surfaces */
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --bg-muted: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Chrome */
    --sidebar-bg: #0f172a;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: rgba(255, 255, 255, 0.65);
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(99, 102, 241, 0.18);
    --sidebar-active-border: var(--primary);
    --sidebar-width: 225px;
    --sidebar-collapsed: 64px;
    --topbar-height: 52px;

    /* Shape / depth */
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-sm:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md:
        0 2px 4px rgba(15, 23, 42, 0.04),
        0 8px 24px rgba(15, 23, 42, 0.09);
    --shadow-lg:
        0 4px 8px rgba(15, 23, 42, 0.05),
        0 20px 56px rgba(15, 23, 42, 0.16);
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 110%);
    --focus-ring: 0 0 0 3px var(--primary-subtle);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --color-scheme: light;

    /* Bootstrap 5.3 bridge — utilities/components follow our tokens */
    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-success: var(--success);
    --bs-success-rgb: var(--success-rgb);
    --bs-danger: var(--danger);
    --bs-danger-rgb: var(--danger-rgb);
    --bs-warning: var(--warning);
    --bs-warning-rgb: var(--warning-rgb);
    --bs-info: var(--info);
    --bs-info-rgb: var(--info-rgb);
    --bs-body-bg: var(--surface-2);
    --bs-body-color: var(--text-primary);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-bg: var(--surface-3);
    --bs-secondary-bg: var(--surface-3);
    --bs-border-color: var(--border);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-emphasis-color: var(--text-primary);
    --bs-heading-color: var(--text-primary);
    --bs-border-radius: var(--radius-sm);
    --bs-border-radius-sm: var(--radius-xs);
    --bs-border-radius-lg: var(--radius);
    --bs-focus-ring-color: var(--primary-subtle);
}

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #a5b4fc;
    --primary-light: #6366f1;
    --primary-subtle: rgba(129, 140, 248, 0.16);
    --primary-rgb: 129, 140, 248;
    --on-primary: #0f172a;
    --glow-primary: rgba(129, 140, 248, 0.4);
    --glow-primary-soft: rgba(129, 140, 248, 0.25);

    --success: #34d399;
    --success-rgb: 52, 211, 153;
    --success-subtle: rgba(52, 211, 153, 0.14);
    --success-fg: #6ee7b7;
    --on-success: #064e3b;

    --danger: #f87171;
    --danger-rgb: 248, 113, 113;
    --danger-subtle: rgba(248, 113, 113, 0.14);
    --danger-fg: #fca5a5;
    --on-danger: #7f1d1d;

    --warning: #fbbf24;
    --warning-rgb: 251, 191, 36;
    --warning-subtle: rgba(251, 191, 36, 0.14);
    --warning-fg: #fcd34d;
    --on-warning: #78350f;

    --info: #60a5fa;
    --info-rgb: 96, 165, 250;
    --info-subtle: rgba(96, 165, 250, 0.14);
    --info-fg: #93c5fd;
    --on-info: #1e3a8a;

    --accent: #a78bfa;
    --accent-subtle: rgba(167, 139, 250, 0.16);
    --accent-fg: #c4b5fd;

    --surface: #0f172a;
    --surface-2: #020617;
    --surface-3: #1e293b;
    --bg-muted: #1e293b;
    --border: #334155;
    --border-light: #1e293b;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --sidebar-bg: #020617;
    --sidebar-border: rgba(148, 163, 184, 0.12);
    --sidebar-text: rgba(226, 232, 240, 0.72);
    --sidebar-text-hover: #f8fafc;
    --sidebar-active-bg: rgba(129, 140, 248, 0.18);
    --sidebar-active-border: var(--primary);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-sm:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md:
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 10px 28px rgba(0, 0, 0, 0.5);
    --shadow-lg:
        0 4px 8px rgba(0, 0, 0, 0.35),
        0 24px 64px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px var(--primary-subtle);
    --color-scheme: dark;

    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-success: var(--success);
    --bs-success-rgb: var(--success-rgb);
    --bs-danger: var(--danger);
    --bs-danger-rgb: var(--danger-rgb);
    --bs-warning: var(--warning);
    --bs-warning-rgb: var(--warning-rgb);
    --bs-info: var(--info);
    --bs-info-rgb: var(--info-rgb);
    --bs-body-bg: var(--surface-2);
    --bs-body-color: var(--text-primary);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-bg: var(--surface-3);
    --bs-secondary-bg: var(--surface-3);
    --bs-border-color: var(--border);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-emphasis-color: var(--text-primary);
    --bs-heading-color: var(--text-primary);
}

html {
    color-scheme: var(--color-scheme);
}

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

body {
    font-family: 'Tajawal', system-ui, sans-serif;
    background:
        radial-gradient(1000px 500px at 85% -10%, var(--primary-subtle), transparent 60%),
        var(--surface-2);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 0.8125rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Compact heading scale aligned with the denser body */
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 0.9375rem; }
h6, .h6 { font-size: 0.8438rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover { color: var(--primary-dark); }

::selection {
    background: var(--primary-subtle);
    color: var(--primary-dark);
}

/* Premium slim scrollbars for content areas */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-muted) 45%, transparent);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-muted) 70%, transparent);
    background-clip: content-box;
    border: 3px solid transparent;
}

.stat-card .stat-value,
.mlist-amount {
    font-variant-numeric: tabular-nums;
}

/* ── Layout ── */
#wrapper {
    display: flex;
    min-height: 100vh;
}

#content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin var(--transition), width var(--transition);
}

.main-content {
    padding: 1rem 1.25rem 1.5rem;
    flex: 1;
}

/* Tighter grid gutters for a denser, practical layout */
.main-content .row.g-3 { --bs-gutter-x: 0.75rem; --bs-gutter-y: 0.75rem; }
.main-content .row.g-4 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
.main-content .mb-4 { margin-bottom: 1rem !important; }
.main-content .mb-3 { margin-bottom: 0.75rem !important; }

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-width);
    background:
        radial-gradient(400px 240px at 100% 0%, var(--glow-primary-soft), transparent 70%),
        var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
    transition: transform var(--transition), width var(--transition);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--sidebar-border);
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar-brand {
    padding: 0.875rem 1rem 0.75rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #fff !important;
    text-decoration: none !important;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 30px;
    height: 30px;
    background: var(--gradient-primary);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--glow-primary);
}

.sidebar-brand-text {
    line-height: 1.3;
    overflow: hidden;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.62rem;
    font-weight: 400;
    color: var(--sidebar-text);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0.625rem 0.75rem;
}

.nav-section-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.35);
    padding: 0.6rem 0.625rem 0.25rem;
    margin-top: 0.2rem;
}

#sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.42rem 0.7rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
    font-weight: 500;
    font-size: 0.78rem;
    margin-bottom: 1px;
    border-right: 3px solid transparent;
}

#sidebar .nav-link:hover {
    color: var(--sidebar-text-hover);
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(-2px);
}

#sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, var(--sidebar-active-bg), transparent 130%);
    border-right-color: var(--sidebar-active-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

#sidebar .nav-link i {
    font-size: 0.9rem;
    width: 1.1rem;
    text-align: center;
    opacity: 0.85;
    flex-shrink: 0;
}

#sidebar .nav-link.active i { opacity: 1; }

.sidebar-footer {
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--sidebar-border);
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    transition: opacity var(--transition);
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ── Topbar ── */
.topbar {
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    height: var(--topbar-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: var(--shadow-xs);
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.topbar-end {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Theme + notifications */
.notify-bell {
    position: relative;
}

.notify-badge {
    position: absolute;
    top: 2px;
    left: 2px;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--surface);
}

.notify-menu {
    width: min(360px, calc(100vw - 1.5rem));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    margin-top: 0.5rem !important;
    box-shadow: var(--shadow-lg);
}

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
}

.dropdown-item {
    color: var(--text-primary);
    border-radius: var(--radius-xs);
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--primary-subtle);
    color: var(--primary-dark);
}

.notify-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.notify-menu-list {
    max-height: 360px;
    overflow-y: auto;
}

.notify-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.notify-item:last-child { border-bottom: none; }

.notify-item:hover {
    background: var(--surface-2);
    color: inherit;
}

.notify-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--surface-3);
    color: var(--text-secondary);
}

.notify-item.tone-danger .notify-item-icon {
    background: var(--danger-subtle);
    color: var(--danger);
}
.notify-item.tone-warning .notify-item-icon {
    background: var(--warning-subtle);
    color: var(--warning);
}
.notify-item.tone-primary .notify-item-icon {
    background: var(--primary-subtle);
    color: var(--primary);
}
.notify-item.tone-success .notify-item-icon {
    background: var(--success-subtle);
    color: var(--success);
}

.notify-item-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.notify-item-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.notify-item-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.notify-menu-footer {
    display: block;
    text-align: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--surface-2);
    text-decoration: none;
}

.notify-menu-footer:hover {
    color: var(--primary-dark);
    background: var(--primary-subtle);
}

.notify-empty {
    padding: 1.75rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.notify-empty i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-3);
    --bs-table-hover-bg: var(--surface-3);
    --bs-table-hover-color: var(--text-primary);
}

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

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--surface-3);
    color: var(--text-primary);
}

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

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

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

[data-theme="dark"] .page-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-secondary);
}

[data-theme="dark"] .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-white {
    background-color: var(--surface-3) !important;
}

.bg-light {
    background-color: var(--bg-muted) !important;
}

.bg-white {
    background-color: var(--surface) !important;
}

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

.badge.text-dark {
    color: inherit !important;
}

[data-theme="dark"] .btn-outline-primary,
[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-danger,
[data-theme="dark"] .btn-outline-success,
[data-theme="dark"] .btn-outline-warning {
    background: var(--surface);
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .badge.bg-secondary {
    background: var(--surface-3) !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .alert {
    border-color: var(--border);
}

/* ── Settings page tabs ── */
.settings-tabs {
    border-bottom: 1px solid var(--border);
}

.settings-tabs .nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.settings-tabs .nav-link:hover {
    color: var(--primary);
    border-color: var(--border) var(--border) transparent;
}

.settings-tabs .nav-link.active {
    background: var(--surface);
    border-color: var(--border) var(--border) var(--surface);
    color: var(--primary);
    font-weight: 600;
}

.settings-tab-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.settings-tab-content > .tab-pane { padding: 1rem 1.125rem; }
.settings-tab-content > .tab-pane:not(.active) { display: none !important; }

/* Appearance settings */
.appearance-preview {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 140px;
    background: var(--surface-2);
}

.appearance-preview-sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 0.85rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.appearance-preview-brand {
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.appearance-preview-nav {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-xs);
}

.appearance-preview-nav.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
    border-right: 3px solid var(--sidebar-active-border);
}

.appearance-preview-main {
    padding: 1rem;
    display: flex;
    align-items: center;
}

.appearance-preview-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-xs);
    width: 100%;
}

.appearance-preview-stat {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.theme-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.theme-preset {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 2px solid var(--border);
    background: var(--swatch);
    padding: 0;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.theme-preset:hover {
    transform: scale(1.08);
    box-shadow: var(--focus-ring);
}

.form-control-color {
    width: 3.25rem;
    height: 2.5rem;
    padding: 0.2rem;
}

@media (max-width: 767.98px) {
    .appearance-preview {
        grid-template-columns: 1fr;
    }
    .appearance-preview-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
}

/* ── Global Search ── */
.topbar-search {
    flex: 1;
    max-width: 480px;
    margin: 0 1rem;
    position: relative;
}

.global-search-form {
    position: relative;
    display: flex;
    align-items: center;
}

.global-search-icon {
    position: absolute;
    right: 0.875rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    z-index: 1;
}

.global-search-input {
    width: 100%;
    padding: 0.35rem 2.25rem 0.35rem 4rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 0.8125rem;
    transition: all var(--transition);
}

.global-search-input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--primary-light);
    box-shadow: var(--focus-ring);
}

.global-search-kbd {
    position: absolute;
    left: 0.75rem;
    font-size: 0.68rem;
    padding: 0.15rem 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: inherit;
}

.global-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    max-height: 380px;
    overflow-y: auto;
}

.global-search-dropdown .search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.global-search-dropdown .search-result-item:hover,
.global-search-dropdown .search-result-item.active {
    background: var(--surface-2);
}

.global-search-dropdown .search-result-item:last-child {
    border-bottom: none;
}

.search-result-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-xs);
    background: var(--primary-subtle);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.global-search-dropdown .search-result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-dropdown .search-result-title {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-dropdown .search-dropdown-footer {
    padding: 0.625rem 1rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8125rem;
}

.global-search-dropdown .search-dropdown-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.global-search-dropdown .search-dropdown-loading {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.page-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    transition: all var(--transition);
}

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

/* Legacy page headers (backward compat) */
.main-content > .d-flex.justify-content-between.align-items-center.mb-3,
.main-content > .d-flex.justify-content-between.align-items-center.mb-4 {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem !important;
    flex-wrap: wrap;
}

.main-content > .d-flex.justify-content-between h4,
.main-content > h4.mb-3,
.main-content > h4.mb-4 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.main-content > .card.mb-3:has(form[method="get"]) {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
}

.main-content > .card.mb-3:has(form[method="get"]) .card-body {
    padding: 1rem 1.25rem;
}

/* ── Page Header ── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    flex-wrap: wrap;
}

.page-header h4,
.page-header .page-heading {
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}

.page-header .page-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0.15rem 0 0;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ── Cards ── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    overflow: hidden;
    transition: box-shadow var(--transition-slow), border-color var(--transition-slow);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.8438rem;
    padding: 0.625rem 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header i {
    color: var(--primary);
    font-size: 1rem;
}

.card-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    padding: 0.625rem 1rem;
}

.card-body {
    padding: 0.875rem 1rem;
}

/* ── Stat Cards ── */
.stat-card-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.stat-card-link:hover,
.stat-card-link:focus {
    color: inherit;
    text-decoration: none;
}

.stat-card-link:focus-visible .stat-card {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    background: var(--surface);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    opacity: 0;
    transition: opacity var(--transition);
}

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

.stat-card:hover::before { opacity: 1; }

.stat-card .card-body { padding: 0.75rem 0.875rem; }

.stat-card .stat-text {
    min-width: 0;
    line-height: 1.25;
}

.stat-card .stat-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), var(--shadow-xs);
    transition: transform var(--transition);
}

.stat-card:hover .stat-icon {
    transform: scale(1.06);
}

.stat-card .stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
    margin-top: 0.125rem;
}

.stat-card .stat-sublabel {
    display: inline-block;
    color: var(--success);
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.2rem;
    white-space: nowrap;
    text-decoration: none;
    z-index: 2;
}

a.stat-sublabel:hover {
    text-decoration: underline;
    color: var(--success);
}

.stat-card .stat-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.375rem;
}

.stat-card.stat-primary::before { background: var(--primary); opacity: 1; }
.stat-card.stat-success::before { background: var(--success); opacity: 1; }
.stat-card.stat-danger::before { background: var(--danger); opacity: 1; }
.stat-card.stat-warning::before { background: var(--warning); opacity: 1; }

/* ── Filter Bar ── */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-xs);
}

.filter-bar .form-control,
.filter-bar .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.8125rem;
    padding: 0.35rem 0.7rem;
    background: var(--surface-2);
}

.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

/* ── Tables ── */
.table-responsive {
    border-radius: 0;
}

.table {
    margin-bottom: 0;
    font-size: 0.8125rem;
}

.table th {
    background: var(--surface-2);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    padding: 0.5rem 0.875rem;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.5rem 0.875rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: var(--surface-2);
}

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

.table a {
    font-weight: 500;
    color: var(--text-primary);
}

.table a:hover { color: var(--primary); }

.table .empty-row td {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    opacity: 0.35;
    display: block;
    margin-bottom: 0.75rem;
}

/* ── Badges — soft-tint premium style ── */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    padding: 0.38em 0.7em;
    border-radius: 999px;
    letter-spacing: 0.02em;
}

.badge.bg-primary {
    background: var(--primary-subtle) !important;
    color: var(--primary-dark) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 25%, transparent);
}
.badge.bg-success {
    background: var(--success-subtle) !important;
    color: var(--success-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 30%, transparent);
}
.badge.bg-danger {
    background: var(--danger-subtle) !important;
    color: var(--danger-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent);
}
.badge.bg-warning {
    background: var(--warning-subtle) !important;
    color: var(--warning-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning) 35%, transparent);
}
.badge.bg-info {
    background: var(--info-subtle) !important;
    color: var(--info-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--info) 30%, transparent);
}
.badge.bg-secondary {
    background: var(--surface-3) !important;
    color: var(--text-secondary) !important;
    box-shadow: inset 0 0 0 1px var(--border);
}

.badge-status-active {
    background: var(--success-subtle) !important;
    color: var(--success-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 30%, transparent);
}
.badge-status-expired {
    background: var(--danger-subtle) !important;
    color: var(--danger-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent);
}
.badge-status-suspended {
    background: var(--warning-subtle) !important;
    color: var(--warning-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warning) 35%, transparent);
}
.badge-status-debtor {
    background: var(--accent-subtle) !important;
    color: var(--accent-fg) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* ── Buttons ── */
.btn {
    font-weight: 600;
    font-size: 0.8125rem;
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.8rem;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-xs);
}

.btn-primary {
    background: var(--gradient-primary);
    border: 1px solid transparent;
    color: var(--on-primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 1px 2px var(--glow-primary-soft);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 110%);
    color: var(--on-primary);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.12),
        0 6px 16px var(--glow-primary);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px var(--glow-primary-soft);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: var(--on-success);
    box-shadow: 0 1px 2px var(--success-subtle);
}

.btn-success:hover,
.btn-success:focus {
    filter: brightness(0.95);
    background: var(--success);
    border-color: var(--success);
    color: var(--on-success);
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-danger);
    box-shadow: 0 1px 2px var(--danger-subtle);
}

.btn-danger:hover,
.btn-danger:focus {
    filter: brightness(0.95);
    background: var(--danger);
    border-color: var(--danger);
    color: var(--on-danger);
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: var(--on-warning);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-primary:hover {
    background: var(--primary-subtle);
    border-color: var(--primary-light);
    color: var(--primary-dark);
}

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

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

.btn-outline-danger {
    color: var(--danger);
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-danger:hover {
    background: var(--danger-subtle);
    border-color: var(--danger);
    color: var(--danger-fg);
}

.btn-outline-success {
    color: var(--success);
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-success:hover {
    background: var(--success-subtle);
    border-color: var(--success);
    color: var(--success-fg);
}

.btn-outline-warning {
    color: var(--warning-fg);
    border-color: var(--border);
    background: var(--surface);
}

.btn-outline-warning:hover {
    background: var(--warning-subtle);
    border-color: var(--warning);
    color: var(--warning-fg);
}

.btn-action-group {
    display: flex;
    gap: 0.25rem;
}

/* ── Forms ── */
.form-label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.form-control,
.form-select,
textarea.form-control {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 0.4rem 0.7rem;
    font-size: 0.8125rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--surface);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.form-text {
    font-size: 0.7rem;
}

textarea.form-control {
    min-height: 4.5rem;
}

/* Size inputs by purpose on desktop — no full-row fields for short values */
@media (min-width: 768px) {
    input.form-control[type="date"],
    input.form-control[type="time"] { max-width: 11rem; }
    input.form-control[type="number"] { max-width: 10rem; }
    input.form-control[type="color"],
    .form-control-color { max-width: 3.5rem; }
}

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

.form-control::placeholder {
    color: var(--text-muted);
}

.form-check-input {
    border-color: var(--border);
    background-color: var(--surface);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-card .card-body { padding: 1rem 1.125rem; }

.input-group-text {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-secondary);
}

/* ── List Groups (Dashboard widgets) ── */
.list-group-item {
    border-color: var(--border-light);
    padding: 0.55rem 0.875rem;
    font-size: 0.8125rem;
    transition: background var(--transition);
}

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

.widget-list .list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.widget-list .item-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Pagination ── */
.pagination { gap: 0.25rem; }

.page-link {
    border-radius: var(--radius-xs) !important;
    border-color: var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    margin: 0 2px;
}

.page-link:hover {
    background: var(--primary-subtle);
    border-color: var(--primary-light);
    color: var(--primary);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 2px 6px var(--glow-primary);
}

/* ── Modals ── */
.modal-content {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    background: var(--surface);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.125rem;
    background: var(--surface-2);
}

.modal-title {
    font-weight: 700;
    font-size: 1rem;
}

.modal-body { padding: 1.125rem; }

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 1.5rem;
    background: var(--surface-2);
}

.modal-danger-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--danger-subtle);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

/* ── Alerts / Toasts ── */
.alert-container {
    position: fixed;
    top: calc(var(--topbar-height) + 0.75rem);
    left: 1.25rem;
    z-index: 9999;
    min-width: 320px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-container .alert {
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.875rem 1rem;
    border-right: 4px solid;
    animation: slideIn 0.3s ease;
}

.alert-success {
    border-right-color: var(--success) !important;
    background: var(--success-subtle) !important;
    color: var(--success-fg) !important;
}
.alert-danger,
.alert-error {
    border-right-color: var(--danger) !important;
    background: var(--danger-subtle) !important;
    color: var(--danger-fg) !important;
}
.alert-warning {
    border-right-color: var(--warning) !important;
    background: var(--warning-subtle) !important;
    color: var(--warning-fg) !important;
}
.alert-info {
    border-right-color: var(--info) !important;
    background: var(--info-subtle) !important;
    color: var(--info-fg) !important;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--sidebar-bg);
}

.login-visual {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.login-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, var(--glow-primary) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, var(--glow-primary-soft) 0%, transparent 50%);
}

.login-visual-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.login-visual h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.login-visual p {
    color: rgba(255, 255, 255, 0.65);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 0;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
    margin-bottom: 0.875rem;
}

.login-features li i {
    width: 28px;
    height: 28px;
    background: var(--glow-primary-soft);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
    font-size: 0.85rem;
    flex-shrink: 0;
}

.login-form-panel {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
}

.login-card {
    width: 100%;
    max-width: 380px;
    border: none;
    box-shadow: none;
    background: transparent;
}

.login-logo {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 24px var(--glow-primary);
}

.login-card h4 {
    font-weight: 700;
    font-size: 1.375rem;
    text-align: center;
    margin-bottom: 0.25rem;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.login-card .form-control {
    padding: 0.6875rem 1rem;
    background: var(--surface-2);
}

.login-card .form-control:focus { background: var(--surface); }

.login-card .btn-primary {
    padding: 0.6875rem;
    font-size: 0.9375rem;
    margin-top: 0.5rem;
}

.input-icon-wrap {
    position: relative;
}

.input-icon-wrap i {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.input-icon-wrap .form-control {
    padding-right: 2.5rem;
}

/* ── Dashboard Sections ── */
.dashboard-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    padding-right: 0.25rem;
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.quick-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: all var(--transition);
    text-decoration: none;
}

.quick-action-btn:hover {
    background: var(--primary-subtle);
    border-color: var(--primary-light);
    color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.quick-action-btn i { color: var(--primary); }

/* ── Subscriber ops hub ── */
.subscriber-hub-summary {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.subscriber-hub-summary .hub-meta {
    align-items: center;
}
.subscriber-hub-summary .hub-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.subscriber-hub-summary .hub-chip i {
    font-size: 0.9rem;
}
.subscriber-hub-summary .hub-actions .btn {
    white-space: nowrap;
}

/* ── Bulk Actions Bar ── */
.bulk-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--primary-subtle);
    border: 1px solid color-mix(in srgb, var(--primary) 28%, transparent);
    border-radius: var(--radius-sm);
}

.bulk-actions-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bulk-actions-count {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.875rem;
}

.bulk-actions-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.table .form-check-input {
    cursor: pointer;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
}

/* ── Print ── */
@media print {
    #sidebar, .topbar, .no-print, .sidebar-backdrop { display: none !important; }
    #content { margin: 0; width: 100%; }
    .main-content { padding: 0; }
}

/* ── Responsive ── */
@media (max-width: 992px) {
    .login-visual { display: none; }
    .login-form-panel {
        max-width: 100%;
        box-shadow: none;
    }
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(100%);
        box-shadow: var(--shadow-lg);
    }

    #sidebar.show { transform: translateX(0); }

    #content {
        margin-right: 0;
        width: 100%;
    }

    .topbar {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--topbar-height);
        gap: 0.5rem;
    }

    .topbar-search {
        order: 3;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .global-search-kbd { display: none !important; }

    .page-title {
        font-size: 0.9375rem;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .main-content { padding: 0.75rem 0.75rem 1rem; }

    .user-name { display: none; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-actions { justify-content: flex-start; }

    .alert-container {
        left: 0.75rem;
        right: 0.75rem;
        min-width: auto;
        max-width: none;
    }

    /* Keep touch targets comfortable despite the compact scale */
    .btn { min-height: 38px; }
    .btn-sm { min-height: 32px; }
    .btn-icon { width: 38px; height: 38px; }
    .form-control,
    .form-select { min-height: 40px; font-size: 16px; }
    .table td { padding: 0.6rem 0.75rem; }
}

/* ── Shared mobile list system (mlist) ── */
.mlist-page { padding-bottom: 5.5rem; }

.mlist-filter {
    margin-bottom: 1rem;
    padding: 0.875rem;
}

.mlist-filter-primary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mlist-search {
    position: relative;
}

.mlist-search > i {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.mlist-search .form-control {
    padding-right: 2.5rem;
    min-height: 44px;
    border-radius: var(--radius-sm);
}

.mlist-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.mlist-chips::-webkit-scrollbar { display: none; }

.mlist-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}

.mlist-chip:hover {
    color: var(--primary-dark);
    border-color: var(--primary-light);
    background: var(--primary-subtle);
}

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

.mlist-chip.is-active:hover {
    color: var(--on-primary);
    background: var(--primary-dark);
}

.mlist-feed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.mlist-item {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1rem 0.875rem;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.mlist-item:active {
    transform: scale(0.995);
}

.mlist-item::before {
    content: '';
    position: absolute;
    inset-block: 0;
    right: 0;
    width: 4px;
    background: var(--primary);
}

.mlist-item.is-danger::before { background: var(--danger); }
.mlist-item.is-warning::before { background: var(--warning); }
.mlist-item.is-success::before { background: var(--success); }
.mlist-item.is-info::before { background: var(--info); }
.mlist-item.is-muted::before { background: var(--text-muted); }
.mlist-item.is-done { opacity: 0.78; }
.mlist-item.is-done::before { background: var(--success); }

.mlist-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}

.mlist-item-top-start {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.mlist-check {
    flex-shrink: 0;
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
}

.mlist-kicker {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
}

.mlist-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--text-primary);
}

.mlist-title a {
    color: inherit;
}

.mlist-title a:hover {
    color: var(--primary);
}

.mlist-desc {
    margin: 0.3rem 0 0;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    line-height: 1.45;
}

.mlist-status {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-secondary);
}

.mlist-status.is-success { background: var(--success-subtle); color: var(--success-fg); }
.mlist-status.is-danger { background: var(--danger-subtle); color: var(--danger-fg); }
.mlist-status.is-warning { background: var(--warning-subtle); color: var(--warning-fg); }
.mlist-status.is-primary { background: var(--primary-subtle); color: var(--primary-dark); }

.mlist-chip[aria-expanded="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.mlist-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.75rem;
}

.mlist-detail {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    min-width: 0;
}

.mlist-detail i {
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.mlist-detail span,
.mlist-detail a {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mlist-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mlist-amount.is-danger { color: var(--danger); }
.mlist-amount.is-success { color: var(--success); }

.mlist-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.875rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
}

.mlist-actions .btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
}

.mlist-empty {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.25rem;
    color: var(--text-secondary);
}

.mlist-empty i {
    font-size: 2rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.75rem;
}

.mlist-empty p { margin: 0 0 1rem; font-weight: 500; }

.mlist-pagination { margin-top: 1.25rem; }

.mlist-fab {
    position: fixed;
    left: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1040;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--on-primary) !important;
    font-size: 1.5rem;
    box-shadow: 0 8px 24px var(--glow-primary);
}

.mlist-fab:hover {
    background: var(--primary-dark);
    color: var(--on-primary) !important;
}

@media (min-width: 768px) {
    .mlist-page { padding-bottom: 0; }

    .mlist-filter-primary {
        flex-direction: row;
        align-items: center;
    }

    .mlist-search {
        flex: 1;
        min-width: 220px;
    }
}
