/* ============================================================
   SosNext — Site Stylesheet
   Sections:
     1. CSS Custom Properties (tokens)
     2. Reset & Base
     3. Layout Shell (topbar, sidebar, content)
     4. Topbar
     5. Sidebar
     6. User Menu
     7. Notifications
     8. Page Content Utilities
     9. Cards & Info Boxes
    10. List Controls & Tables
    11. Dialogs & Modals
    12. Forms
    13. Buttons
    14. Badges & Status
    15. Dark Mode
    16. Responsive
   ============================================================ */


/* ============================================================
   1. CSS Custom Properties
   ============================================================ */

:root {
    /* Primary hue — change --primary-h to retheme the entire UI (0=red, 142=green, 221=blue, 270=purple) */
    --primary-h: 347;
    --primary-s: 63%;
    --primary-l: 34%;
    /* Brand */
    --brand-primary: hsl(var(--primary-h) var(--primary-s) var(--primary-l));
    --brand-primary-hover: hsl(var(--primary-h) 74% 48%);
    --brand-primary-light: hsl(var(--primary-h) 100% 97%);
    /* Surface */
    --surface-bg: #f8fafc;
    --surface-card: #ffffff;
    --surface-card-header: rgb(242, 245, 246);
    --surface-raised: #ffffff;
    --surface-sunken: #f1f5f9;
    --surface-overlay: rgba(255, 255, 255, 0.85);
    /* Topbar */
    --topbar-bg: #ffffff;
    --topbar-height: 56px;
    --topbar-border: #e2e8f0;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    /* Sidebar */
    --sidebar-bg: hsl(var(--primary-h) 28% 17%);
    --sidebar-width: 240px;
    --sidebar-collapsed-w: 0px;
    --sidebar-text: hsl(var(--primary-h) 27% 84%);
    --sidebar-text-active: #ffffff;
    --sidebar-accent: var(--brand-primary);
    --sidebar-hover: rgba(255, 255, 255, 0.07);
    --sidebar-active: hsl(var(--primary-h) var(--primary-s) var(--primary-l) / 0.25);
    --sidebar-section: hsl(var(--primary-h) 16% 47%);
    --sidebar-border: rgba(255, 255, 255, 0.06);
    /* Text */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --text-link: var(--brand-primary);
    /* Border */
    --border-default: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-radius-sm: 4px;
    --border-radius: 6px;
    --border-radius-lg: 8px;
    --border-radius-xl: 12px;
    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    /* Status colours */
    --color-info: var(--brand-primary);
    --color-info-bg: hsl(var(--primary-h) var(--primary-s) var(--primary-l) / 0.12);
    --color-info-border: hsl(var(--primary-h) var(--primary-s) var(--primary-l) / 0.3);
    --color-success: #16a34a;
    --color-success-bg: rgba(22, 163, 74, 0.12);
    --color-success-border: rgba(22, 163, 74, 0.3);
    --color-warning: #d97706;
    --color-warning-bg: rgba(217, 119, 6, 0.12);
    --color-warning-border: rgba(217, 119, 6, 0.3);
    --color-danger: #dc2626;
    --color-danger-bg: rgba(220, 38, 38, 0.12);
    --color-danger-border: rgba(220, 38, 38, 0.3);
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    /* Z-index layers */
    --z-sidebar: 100;
    --z-topbar: 200;
    --z-overlay: 300;
    --z-dropdown: 400;
    --z-modal: 500;
    --z-notification: 600;
}


/* ============================================================
   2. Reset & Base
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    position: relative;
    min-height: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--surface-bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

    a:hover {
        color: var(--brand-primary-hover);
        text-decoration: underline;
    }

img, svg {
    max-width: 100%;
    display: block;
}

code, pre, kbd, samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

pre {
    background: var(--surface-sunken);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius);
    padding: var(--space-4);
    overflow-x: auto;
}

hr {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: var(--space-6) 0;
}

/* Focus visible — keyboard nav */
:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* Remove default outline for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}


/* ============================================================
   3. Layout Shell
   ============================================================ */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-body {
    display: flex;
    flex: 1;
    padding-top: var(--topbar-height);
}

.app-content {
    flex: 1;
    min-width: 0;
    padding: var(--space-6) var(--space-8);
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
}

/* When sidebar is collapsed */
.sidebar-collapsed .app-content {
    margin-left: 0;
}

.app-content-inner {
    max-width: 1280px;
    margin: 0 auto;
}

.app-content-inner.app-content-inner-wide {
    max-width: 2560px;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-sidebar) - 1);
    opacity: 0;
    transition: opacity var(--transition-slow);
}

    .sidebar-overlay.visible {
        opacity: 1;
    }


/* ============================================================
   4. Topbar
   ============================================================ */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: var(--topbar-shadow);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    z-index: var(--z-topbar);
}

/* Hamburger */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

    .hamburger-btn:hover {
        background: var(--surface-sunken);
        color: var(--text-primary);
    }

    .hamburger-btn svg {
        width: 20px;
        height: 20px;
        display: block;
    }

/* Logo */
.topbar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    flex-shrink: 0;
}

    .topbar-logo:hover {
        text-decoration: none;
    }

.logo-mark {
    width: 32px;
    height: 32px;
    background: var(--brand-primary);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.logo-text {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Topbar spacer */
.topbar-spacer {
    flex: 1;
}

/* Topbar right cluster */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}


/* ============================================================
   5. Sidebar
   ============================================================ */

.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-slow), width var(--transition-slow);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

    .sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.1);
        border-radius: 2px;
    }

/* Collapsed state — slides off screen */
.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-header {
    /* Zero-height container — exists only to hold the absolutely-positioned pin button. */
    height: 0;
    overflow: visible;
    position: relative;
    flex-shrink: 0;
}

.sidebar-pin-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-3);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--sidebar-section);
    transition: color var(--transition-fast), background var(--transition-fast);
}

    .sidebar-pin-btn:hover {
        color: var(--sidebar-text-active);
        background: var(--sidebar-hover);
    }

    .sidebar-pin-btn.pinned {
        color: var(--sidebar-accent);
    }

    .sidebar-pin-btn svg {
        width: 15px;
        height: 15px;
        transition: transform var(--transition-base), fill var(--transition-base);
    }

    .sidebar-pin-btn.pinned svg {
        transform: rotate(-90deg);
        fill: currentColor;
    }

.sidebar-nav {
    flex: 1;
    padding: var(--space-4) 0;
}

/* Section heading */
.sidebar-section-label {
    display: block;
    padding: var(--space-4) var(--space-5) var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-section);
}

/* Nav item */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    color: var(--sidebar-text);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-left: 3px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
    min-height: 40px;
}

    .sidebar-item:hover {
        background: var(--sidebar-hover);
        color: var(--sidebar-text-active);
        text-decoration: none;
    }

    .sidebar-item.active {
        background: var(--sidebar-active);
        color: var(--sidebar-text-active);
        border-left-color: var(--sidebar-accent);
    }

    .sidebar-item svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
        opacity: 0.7;
    }

    .sidebar-item.active svg,
    .sidebar-item:hover svg {
        opacity: 1;
    }

/* Sidebar divider */
.sidebar-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: var(--space-3) var(--space-5);
}

/* Sidebar footer */
.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer-text {
    font-size: var(--font-size-xs);
    color: var(--sidebar-section);
}


/* ============================================================
   6. User Menu
   ============================================================ */

.user-menu-wrapper {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-xl);
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

    .user-btn:hover {
        background: var(--surface-sunken);
        border-color: var(--border-strong);
    }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

    .user-avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.user-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-chevron {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    transition: transform var(--transition-base);
    flex-shrink: 0;
}

.user-btn[aria-expanded="true"] .user-chevron {
    transform: rotate(180deg);
}

/* Dropdown panel */
.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 220px;
    background: var(--surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    z-index: var(--z-dropdown);
    display: none;
    animation: dropdown-in var(--transition-base) ease both;
}

    .user-dropdown.open {
        display: block;
    }

@keyframes dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-header {
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
    border-bottom: 1px solid var(--border-default);
}

.dropdown-header-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.dropdown-header-email {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

    .dropdown-item:hover {
        background: var(--surface-sunken);
        text-decoration: none;
        color: var(--text-primary);
    }

    .dropdown-item.danger {
        color: var(--color-danger);
    }

        .dropdown-item.danger:hover {
            background: var(--color-danger-bg);
        }

    .dropdown-item svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        color: var(--text-muted);
    }

    .dropdown-item.danger svg {
        color: var(--color-danger);
    }

.dropdown-divider {
    height: 1px;
    background: var(--border-default);
    margin: var(--space-2) 0;
}

/* Theme toggle inline row */
.dropdown-item-toggle {
    justify-content: space-between;
}

/* Zoom controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
}

    .zoom-controls span {
        font-size: var(--font-size-xs);
        color: var(--text-muted);
        flex: 1;
        display: flex;
        align-items: center;
        gap: var(--space-2);
        white-space: nowrap;
    }

/* Language select inside dropdown */
.language-select {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
    padding: 2px var(--space-2);
    cursor: pointer;
    font-family: inherit;
}

    .language-select:focus {
        outline: 2px solid var(--color-primary);
        outline-offset: 1px;
    }

.zoom-controls span svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-sm);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

    .zoom-btn:hover {
        background: var(--surface-sunken);
        border-color: var(--border-strong);
    }

/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
        position: absolute;
    }

.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition-base);
}

    .toggle-track::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 16px;
        height: 16px;
        background: #fff;
        border-radius: 50%;
        transition: transform var(--transition-base);
        box-shadow: var(--shadow-sm);
    }

.toggle-switch input:checked + .toggle-track {
    background: var(--brand-primary);
}

    .toggle-switch input:checked + .toggle-track::after {
        transform: translateX(16px);
    }


/* ============================================================
   7. Notifications
   ============================================================ */

.notification-host {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding-top: var(--space-3);
    pointer-events: none;
    width: 100%;
    max-width: 560px;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

.notification {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--border-radius-lg);
    border: 1px solid transparent;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-lg);
    width: 100%;
    pointer-events: all;
    animation: notif-slide-in 300ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
    transition: opacity var(--transition-slow), transform var(--transition-slow);
}

    .notification.dismissing {
        opacity: 0;
        transform: translateY(-12px) scale(0.96);
    }

@keyframes notif-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Colour variants */
.notification-info {
    background: rgba(239, 246, 255, 0.92);
    border-color: var(--color-info-border);
    color: #1e3a8a;
}

.notification-success {
    background: rgba(240, 253, 244, 0.92);
    border-color: var(--color-success-border);
    color: #14532d;
}

.notification-warning {
    background: rgba(255, 251, 235, 0.92);
    border-color: var(--color-warning-border);
    color: #78350f;
}

.notification-danger {
    background: rgba(254, 242, 242, 0.92);
    border-color: var(--color-danger-border);
    color: #7f1d1d;
}

.notification-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.notification-info .notification-icon {
    color: var(--color-info);
}

.notification-success .notification-icon {
    color: var(--color-success);
}

.notification-warning .notification-icon {
    color: var(--color-warning);
}

.notification-danger .notification-icon {
    color: var(--color-danger);
}

.notification-body {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    line-height: 1.4;
}

.notification-message {
    font-size: var(--font-size-sm);
    margin-top: 2px;
    opacity: 0.85;
    line-height: 1.5;
}

.notification-close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    flex-shrink: 0;
    padding: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}

    .notification-close:hover {
        opacity: 1;
        background: rgba(0, 0, 0, 0.08);
    }

    .notification-close svg {
        width: 14px;
        height: 14px;
        display: block;
    }

/* Progress bar (auto-dismiss timer) */
.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    animation: notif-progress 15s linear forwards;
    opacity: 0.4;
}

.notification {
    position: relative;
    overflow: hidden;
}

.notification-info .notification-progress {
    background: var(--color-info);
}

.notification-success .notification-progress {
    background: var(--color-success);
}

.notification-warning .notification-progress {
    background: var(--color-warning);
}

.notification-danger .notification-progress {
    background: var(--color-danger);
}

@keyframes notif-progress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}


/* ============================================================
   8. Page Content Utilities
   ============================================================ */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    list-style: none;
    margin: 0 0 var(--space-4);
    padding: 0;
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-muted);
}

    .breadcrumb-item a:hover {
        color: var(--text-link);
    }

.breadcrumb-sep {
    color: var(--border-strong);
}

.breadcrumb-item:last-child {
    color: var(--text-primary);
    font-weight: 500;
}


/* ============================================================
   9. Cards & Info Boxes
   ============================================================ */

.card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    background: var(--surface-card-header);
    border-bottom: 1px solid var(--border-default);
    gap: var(--space-3);
}

.card-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-subtitle {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-default);
    background: var(--surface-sunken);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* ── Adjacent card merging ────────────────────────────────
   Directly adjacent .card siblings flatten their touching
   corners and collapse the shared border, appearing as one
   continuous card. Add .card-separated to the lower card to
   restore the gap and individual card appearance.            */

.card + .card {
    margin-top: -1px; /* collapse shared border */
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    box-shadow: none;
}

.card:has(+ .card) {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: none;
}

/* Opt-out — add .card-separated to the lower card */
.card + .card.card-separated {
    margin-top: var(--space-6);
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.card:has(+ .card.card-separated) {
    border-bottom-left-radius: var(--border-radius-lg);
    border-bottom-right-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

/* ── Card header actions & help button ────────────────────
   .card-header-actions groups right-hand header controls
   (help icon, collapse toggle, etc.) so space-between keeps
   them flush-right as a unit.                              */

.card-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
}

.card-help-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1.5px solid var(--border-default);
    background: transparent;
    border-radius: 50%;
    cursor: help;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

    .card-help-btn:hover,
    .card-help-btn:focus-visible {
        color: var(--brand-primary);
        border-color: var(--brand-primary);
        outline: none;
    }

/* ── Tooltip ──────────────────────────────────────────────
   Shared element appended to <body> by JS so it is never
   clipped by ancestor overflow:hidden. Shown for any
   element carrying a data-tooltip attribute.              */

.help-tooltip {
    position: absolute;
    z-index: var(--z-dropdown);
    max-width: 260px;
    padding: var(--space-2) var(--space-3);
    background: #1e293b;
    color: #f1f5f9;
    font-size: var(--font-size-xs);
    line-height: 1.5;
    border-radius: var(--border-radius);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    white-space: normal;
    word-break: break-word;
}

    .help-tooltip.visible {
        opacity: 1;
    }

/* ── Collapsible card ─────────────────────────────────────
   Opt in with data-collapsible on the .card element.
   JS injects the button and the .card-collapse-body wrapper. */

.card-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
    transition: color var(--transition-fast), background var(--transition-fast);
}

    .card-collapse-btn:hover {
        color: var(--text-primary);
        background: var(--surface-sunken);
    }

    .card-collapse-btn svg {
        width: 16px;
        height: 16px;
        transition: transform var(--transition-base);
    }

/* Arrow rotates to point right when the card is collapsed */
.card.collapsed .card-collapse-btn svg {
    transform: rotate(-90deg);
}

/* Remove the header's bottom border when there is nothing below it */
.card.collapsed .card-header {
    border-bottom-color: transparent;
    transition: border-color var(--transition-slow);
}

/* CSS grid-row trick — animates open/close without knowing content height */
.card-collapse-body {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows var(--transition-slow);
}

.card.collapsed .card-collapse-body {
    grid-template-rows: 0fr;
}

/* Inner wrapper — min-height:0 allows the grid row to collapse to zero */
.card-collapse-inner {
    min-height: 0;
    overflow: hidden;
}

/* Processing indicator — spinning wheel shown after the element's content.
   Works on any element, including replaced elements like <input> and <textarea>.
   Usage: add the "processing" class directly to the element. */
@keyframes processing-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── All elements that support ::after ── */
.processing {
    position: relative;
}

    .processing::after {
        content: '';
        position: absolute;
        top: 50%;
        right: var(--space-3);
        width: 16px;
        height: 16px;
        margin-top: -8px;
        border: 2px solid var(--border-default);
        border-top-color: var(--brand-primary);
        border-radius: 50%;
        animation: processing-spin 0.7s linear infinite;
        pointer-events: none;
    }

/* ── Replaced / void elements (<input>, <textarea>, <select>) ── */
/* ::after is ignored on these, so a self-animating SVG spinner is
   painted as a background-image at the trailing edge instead.     */
:is(input, textarea, select).processing {
    padding-left: 2.25rem;
    background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='9' fill='none' stroke='%23e2e8f0' stroke-width='2.5'/><path d='M12 3a9 9 0 0 1 9 9' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round'><animateTransform attributeName='transform' type='rotate' from='0 12 12' to='360 12 12' dur='0.7s' repeatCount='indefinite'/></path></svg>");
    background-size: 16px 16px;
    background-repeat: no-repeat;
    background-position: 0.625rem center;
}

/* Skeleton / loading shimmer */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient( 90deg, var(--surface-sunken) 25%, var(--border-default) 50%, var(--surface-sunken) 75% );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--border-radius-sm);
}

/* Info box variants (callout-style) */
.info-box {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--border-radius);
    border-left: 4px solid;
    font-size: var(--font-size-sm);
}

.info-box-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.info-box-content {
    flex: 1;
    min-width: 0;
}

.info-box-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.info-box.info {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: #1e3a8a;
}

.info-box.success {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: #14532d;
}

.info-box.warning {
    background: var(--color-warning-bg);
    border-color: var(--color-warning);
    color: #78350f;
}

.info-box.danger {
    background: var(--color-danger-bg);
    border-color: var(--color-danger);
    color: #7f1d1d;
}

/* Stat / metric card */
.stat-card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}

.stat-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-top: var(--space-1);
    letter-spacing: -0.03em;
}

.stat-delta {
    font-size: var(--font-size-xs);
    margin-top: var(--space-2);
    font-weight: 500;
}

    .stat-delta.positive {
        color: var(--color-success);
    }

    .stat-delta.negative {
        color: var(--color-danger);
    }

/* ── Stat sticky bar ──────────────────────────────────────
   Appears below the topbar when the stat-card row scrolls
   out of view. Slides out from under the topbar.          */

.stat-sticky-bar {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform var(--transition-base), opacity var(--transition-base), left var(--transition-slow), top var(--transition-slow);
    pointer-events: none;
}

.sidebar-collapsed .stat-sticky-bar {
    left: 0;
}

.stat-sticky-bar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.has-page-header-bar .stat-sticky-bar {
    top: calc(var(--topbar-height) * 2);
}

.stat-sticky-inner {
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

.stat-sticky-item {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    white-space: nowrap;
}

.stat-sticky-value {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat-sticky-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

@media (max-width: 1024px) {
    .stat-sticky-bar {
        left: 0;
    }
}

/* ── Page-header sticky bar ───────────────────────────────────
   Appears below the topbar when .page-header scrolls off the
   top of the page. Shows title (left) + action buttons (right). */

.page-header-sticky-bar {
    position: fixed;
    top: var(--topbar-height);
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
    z-index: 91;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    transform: translateY(-100%);
    opacity: 0;
    transition: transform var(--transition-base), opacity var(--transition-base), left var(--transition-slow);
    pointer-events: none;
}

.sidebar-collapsed .page-header-sticky-bar {
    left: 0;
}

.page-header-sticky-bar.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.page-header-sticky-title {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-header-sticky-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    .page-header-sticky-bar {
        left: 0;
    }
}


/* ============================================================
   10. List Controls & Tables
   ============================================================ */

/* List toolbar */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.list-toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 1;
    min-width: 0;
}

.list-toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Search input */
.search-input-wrapper {
    position: relative;
    flex: 1;
}

    .search-input-wrapper svg {
        position: absolute;
        left: var(--space-3);
        top: 50%;
        transform: translateY(-50%);
        width: 16px;
        height: 16px;
        color: var(--text-muted);
        pointer-events: none;
    }

.search-input {
    width: 100%;
    padding: var(--space-2) var(--space-3) var(--space-2) calc(var(--space-3) + 20px + var(--space-2));
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    background: var(--surface-card);
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

    .search-input:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    }

    .search-input::placeholder {
        color: var(--text-muted);
    }

/* Filter row */
.filter-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-sunken);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2) 2px var(--space-3);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    border-radius: 100px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.filter-chip-remove {
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-primary);
    border-radius: 50%;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

    .filter-chip-remove:hover {
        opacity: 1;
    }

/* Search filter container — provides position:relative for the absolute panel */
.search-filter-container {
    position: relative;
}

/* Filter toggle button — injected by JS into .search-input-wrapper */
.filter-toggle-btn {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

    .filter-toggle-btn:hover {
        color: var(--text-primary);
        background: var(--surface-sunken);
        border-color: var(--border-strong);
    }

    .filter-toggle-btn.active,
    .filter-toggle-btn.has-filters {
        color: var(--brand-primary);
        background: var(--brand-primary-light);
        border-color: var(--brand-primary);
    }

    .filter-toggle-btn svg {
        display: block;
        width: 14px;
        height: 14px;
        pointer-events: none;
        margin-left:-5px;
    }

/* Widen the search input right padding when a filter button is present */
.search-input-wrapper.has-filter-panel .search-input {
    padding-right: calc(var(--space-2) + 28px + var(--space-2));
}

/* Filter panel — absolutely positioned below the search row */
.filter-panel {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-1));
    left: 0;
    right: 0;
    z-index: var(--z-dropdown);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-2) 0;
    max-height: 420px;
    overflow-y: auto;
}

    .filter-panel.open {
        display: flex;
        flex-wrap: wrap;
    }

/* Filter groups (accordion sections) */
.filter-group {
    flex: 1 1 160px;
    border-right: 1px solid var(--border-default);
    border-bottom: none;
    min-width: 0;
}

    .filter-group:last-child {
        border-right: none;
    }

.filter-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    user-select: none;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

    .filter-group-header:hover {
        color: var(--text-primary);
    }

    .filter-group-header svg {
        width: 12px;
        height: 12px;
        flex-shrink: 0;
        transition: transform var(--transition-fast);
    }

    .filter-group.collapsed .filter-group-header svg {
        transform: rotate(-90deg);
    }

.filter-group-body {
    padding: var(--space-1) var(--space-4) var(--space-3);
    max-height: 204px; /* ~7 items */
    overflow-y: auto;
}

    .filter-group.collapsed .filter-group-body {
        display: none;
    }

/* When groups wrap to a new row, restore horizontal separators */
@media (max-width: 480px) {
    .filter-group {
        flex-basis: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-default);
    }

    .filter-group:last-child {
        border-bottom: none;
    }
}

.filter-group-loading {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
    padding: var(--space-1) 0;
}

/* Individual checkbox row */
.filter-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

    .filter-option input[type="checkbox"] {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        accent-color: var(--brand-primary);
        cursor: pointer;
    }

    .filter-option span {
        line-height: 1.4;
    }

/* Table */
.data-table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

    .data-table thead {
        background: var(--surface-sunken);
    }

    .data-table th {
        padding: var(--space-3) var(--space-4);
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: var(--font-size-xs);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        white-space: nowrap;
        border-bottom: 1px solid var(--border-default);
        user-select: none;
    }

        .data-table th.sortable {
            cursor: pointer;
        }

            .data-table th.sortable:hover {
                color: var(--text-primary);
            }

.sort-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 4px;
    opacity: 0.4;
}

.data-table th.sorted-asc .sort-icon,
.data-table th.sorted-desc .sort-icon {
    opacity: 1;
    color: var(--brand-primary);
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-default);
    background: var(--surface-card);
    transition: background var(--transition-fast);
}

    .data-table tbody tr:last-child {
        border-bottom: none;
    }

    .data-table tbody tr:hover {
        background: var(--surface-sunken);
    }

    .data-table tbody tr.selected {
        background: var(--brand-primary-light);
    }

.data-table td {
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    vertical-align: middle;
}

    .data-table td.text-muted {
        color: var(--text-muted);
    }

/* Row actions */
.row-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.data-table tbody tr:hover .row-actions {
    opacity: 1;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-default);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.pagination-info {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.page-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-sm);
    background: var(--surface-card);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

    .page-btn:hover:not(:disabled) {
        background: var(--surface-sunken);
        border-color: var(--border-strong);
    }

    .page-btn.active {
        background: var(--brand-primary);
        border-color: var(--brand-primary);
        color: #fff;
    }

    .page-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

.page-ellipsis {
    padding: 0 var(--space-1);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    line-height: 32px;
    user-select: none;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-8);
    text-align: center;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    opacity: 0.3;
    margin-bottom: var(--space-4);
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-message {
    font-size: var(--font-size-sm);
    max-width: 320px;
}

/* Error state */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-12) var(--space-8);
    text-align: center;
}

.error-state-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-danger-bg);
    border: 1px solid var(--color-danger-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    flex-shrink: 0;
}

.error-state-icon {
    width: 26px;
    height: 26px;
    color: var(--color-danger);
}

.error-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.error-state-message {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    max-width: 320px;
}

.error-details {
    margin-top: var(--space-6);
    width: 100%;
    max-width: 640px;
    text-align: left;
    border: 1px solid var(--color-danger-border);
    border-radius: var(--border-radius);
    background: var(--color-danger-bg);
    font-size: var(--font-size-sm);
    overflow: hidden;
}

.error-details-summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-danger);
    list-style: none;
    user-select: none;
}

    .error-details-summary::-webkit-details-marker {
        display: none;
    }

    .error-details-summary svg {
        width: 14px;
        height: 14px;
        flex-shrink: 0;
        transition: transform var(--transition-fast);
    }

details.error-details[open] .error-details-summary svg {
    transform: rotate(90deg);
}

.error-details-body {
    padding: var(--space-4);
    border-top: 1px solid var(--color-danger-border);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.error-details-type {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

.error-details-message {
    color: var(--text-secondary);
}

.error-details-stack {
    margin: 0;
    padding: var(--space-3);
    background: var(--surface-sunken);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-sm);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre;
    line-height: 1.6;
}

.error-details-inner-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-top: var(--space-2);
}


/* ============================================================
   11. Dialogs & Modals
   ============================================================ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: calc(var(--z-modal) - 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    animation: backdrop-in var(--transition-base) ease both;
}

@keyframes backdrop-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-backdrop.closing {
    animation: backdrop-out var(--transition-base) ease both;
}

@keyframes backdrop-out {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.modal {
    background: var(--surface-raised);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - var(--space-8));
    display: flex;
    flex-direction: column;
    animation: modal-in var(--transition-slow) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-backdrop.closing .modal {
    animation: modal-out var(--transition-base) ease both;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.93) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modal-out {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.96);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-default);
    gap: var(--space-4);
    flex-shrink: 0;
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
    padding: 0;
}

    .modal-close:hover {
        background: var(--surface-sunken);
        color: var(--text-primary);
    }

    .modal-close svg {
        width: 18px;
        height: 18px;
    }

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-default);
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* Modal size variants */
.modal.modal-sm {
    max-width: 360px;
}

.modal.modal-lg {
    max-width: 720px;
}

.modal.modal-xl {
    max-width: 960px;
}


/* ============================================================
   12. Forms
   ============================================================ */

.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

    .form-label.required::after {
        content: ' *';
        color: var(--color-danger);
    }

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--color-danger);
    margin-top: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.form-control {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    line-height: 1.5;
}

    .form-control:focus {
        outline: none;
        border-color: var(--brand-primary);
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    }

    .form-control.error {
        border-color: var(--color-danger);
    }

        .form-control.error:focus {
            box-shadow: 0 0 0 3px var(--color-danger-bg);
        }

    .form-control::placeholder {
        color: var(--text-muted);
    }

    .form-control:disabled {
        background: var(--surface-sunken);
        color: var(--text-muted);
        cursor: not-allowed;
    }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: calc(var(--space-3) + 16px + var(--space-2));
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Checkbox & radio */
.form-check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    cursor: pointer;
}

.form-check-input {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--border-radius-sm);
    background: var(--surface-card);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--brand-primary);
}

.form-check-label {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    cursor: pointer;
}

/* Form row */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
}


/* ============================================================
   13. Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: var(--font-sans);
    border-radius: var(--border-radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
    line-height: 1.5;
    user-select: none;
}

    .btn svg {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

/* Primary */
.btn-primary {
    background: var(--brand-primary);
    color: #fff;
    border-color: var(--brand-primary);
}

    .btn-primary:hover {
        background: var(--brand-primary-hover);
        border-color: var(--brand-primary-hover);
        color: #fff;
        text-decoration: none;
    }

    .btn-primary.disabled {
        background: hsl(var(--primary-h) 62% 74%);
        border-color: hsl(var(--primary-h) 62% 74%);
        color: rgba(255, 255, 255, 0.7);
        cursor: not-allowed;
        pointer-events: none;
    }

/* Secondary */
.btn-secondary {
    background: var(--surface-card);
    color: var(--text-primary);
    border-color: var(--border-default);
}

    .btn-secondary.disabled {
        background: var(--surface-card);
        border-color: var(--border-default);
        color: var(--text-muted);
        cursor: not-allowed;
        pointer-events: none;
    }

    .btn-secondary:hover {
        background: var(--brand-primary-light);
        border-color: var(--brand-primary);
        color: var(--brand-primary);
        text-decoration: none;
    }

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

    .btn-ghost:hover {
        background: var(--surface-sunken);
        color: var(--text-primary);
        text-decoration: none;
    }

/* Danger */
.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

    .btn-danger:hover {
        background: #b91c1c;
        border-color: #b91c1c;
        color: #fff;
        text-decoration: none;
    }

/* Danger outline */
.btn-danger-outline {
    background: transparent;
    color: var(--color-danger);
    border-color: var(--color-danger);
}

    .btn-danger-outline:hover {
        background: var(--color-danger-bg);
        text-decoration: none;
    }

/* Size variants */
.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
}

    .btn-sm svg {
        width: 14px;
        height: 14px;
    }

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
}

/* Icon-only button */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--border-radius-sm);
}

    .btn-icon.btn-sm {
        width: 28px;
        height: 28px;
    }


/* ============================================================
   14. Badges & Status
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--space-2);
    border-radius: 100px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.badge-info {
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-neutral {
    background: var(--surface-sunken);
    color: var(--text-secondary);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.badge-info .badge-dot {
    background: #2563eb;
}

.badge-success .badge-dot {
    background: var(--color-success);
}

.badge-warning .badge-dot {
    background: var(--color-warning);
}

.badge-danger .badge-dot {
    background: var(--color-danger);
}

.badge-neutral .badge-dot {
    background: var(--text-muted);
}

/* ── Card status ──────────────────────────────────────────
   A full-width status banner for use inside a .card,
   typically as the first or last child. The card's own
   overflow:hidden clips the corners flush with the card.
   Colour variants match badge semantics.                   */

.card-status {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-left: 3px solid transparent;
}

.card-status-info {
    background: rgba(37, 99, 235, 0.12);
    color: #2563eb;
    border-left-color: #2563eb;
}

.card-status-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-left-color: var(--color-success);
}

.card-status-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
    border-left-color: var(--color-warning);
}

.card-status-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-left-color: var(--color-danger);
}

.card-status-neutral {
    background: var(--surface-sunken);
    color: var(--text-secondary);
    border-left-color: var(--border-strong);
}

/* ── File attachment ──────────────────────────────────────
   Displays a downloadable file with icon, name link, and
   upload timestamp. Use data-ext on .file-attachment-icon
   to colour-code by file type.                             */

.file-attachment {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

    .file-attachment:hover {
        border-color: var(--border-strong);
        background: var(--surface-sunken);
    }

    .file-attachment + .file-attachment {
        margin-top: var(--space-2);
    }

/* Icon */
.file-attachment-icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    color: var(--ext-color, var(--text-muted));
}

    .file-attachment-icon svg {
        width: 28px;
        height: 28px;
    }

    /* Extension label — rendered over the bottom of the icon */
    .file-attachment-icon[data-ext]::after {
        content: attr(data-ext);
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        background: var(--ext-color, var(--text-muted));
        color: #fff;
        font-size: 7px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        padding: 1px 3px;
        border-radius: 2px;
        line-height: 1.4;
        white-space: nowrap;
    }

    /* File-type colour tokens */
    .file-attachment-icon[data-ext="pdf"] {
        --ext-color: #dc2626;
    }

    .file-attachment-icon[data-ext="doc"],
    .file-attachment-icon[data-ext="docx"] {
        --ext-color: #2563eb;
    }

    .file-attachment-icon[data-ext="xls"],
    .file-attachment-icon[data-ext="xlsx"],
    .file-attachment-icon[data-ext="csv"] {
        --ext-color: #16a34a;
    }

    .file-attachment-icon[data-ext="ppt"],
    .file-attachment-icon[data-ext="pptx"] {
        --ext-color: #ea580c;
    }

    .file-attachment-icon[data-ext="jpg"],
    .file-attachment-icon[data-ext="jpeg"],
    .file-attachment-icon[data-ext="png"],
    .file-attachment-icon[data-ext="gif"],
    .file-attachment-icon[data-ext="webp"] {
        --ext-color: #7c3aed;
    }

    .file-attachment-icon[data-ext="zip"],
    .file-attachment-icon[data-ext="rar"],
    .file-attachment-icon[data-ext="7z"] {
        --ext-color: #d97706;
    }

/* Body — name + meta */
.file-attachment-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.file-attachment-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-link);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

    .file-attachment-name:hover {
        text-decoration: underline;
    }

.file-attachment-meta {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Download button */
.file-attachment-dl {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    transition: color var(--transition-fast), background var(--transition-fast);
    text-decoration: none;
}

    .file-attachment-dl:hover {
        color: var(--brand-primary);
        background: var(--brand-primary-light);
    }

    .file-attachment-dl svg {
        width: 16px;
        height: 16px;
    }


/* ============================================================
   15. Dark Mode
   ============================================================ */

[data-theme="dark"] {
    --surface-bg: #0f172a;
    --surface-card: #1e293b;
    --surface-card-header: #1e293b;
    --surface-raised: #1e293b;
    --surface-sunken: #0f172a;
    --surface-overlay: rgba(30, 41, 59, 0.9);
    --topbar-bg: #1e293b;
    --topbar-border: #334155;
    --topbar-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --sidebar-bg: hsl(var(--primary-h) 47% 11%);
    --sidebar-border: rgba(255, 255, 255, 0.05);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-default: #334155;
    --border-strong: #475569;
    --brand-primary-light: hsl(var(--primary-h) var(--primary-s) var(--primary-l) / 0.15);
    --color-info-bg: hsl(var(--primary-h) var(--primary-s) var(--primary-l) / 0.15);
    --color-success-bg: rgba(22, 163, 74, 0.15);
    --color-warning-bg: rgba(217, 119, 6, 0.15);
    --color-danger-bg: rgba(220, 38, 38, 0.15);
}

    [data-theme="dark"] .notification-info {
        background: hsl(var(--primary-h) 64% 33% / 0.85);
        color: hsl(var(--primary-h) 96% 87%);
    }

    [data-theme="dark"] .notification-success {
        background: rgba(20, 83, 45, 0.85);
        color: #bbf7d0;
    }

    [data-theme="dark"] .notification-warning {
        background: rgba(120, 53, 15, 0.85);
        color: #fde68a;
    }

    [data-theme="dark"] .notification-danger {
        background: rgba(127, 29, 29, 0.85);
        color: #fecaca;
    }

    [data-theme="dark"] .info-box.info {
        color: hsl(var(--primary-h) 96% 87%);
    }

    [data-theme="dark"] .badge-info {
        background: rgba(37, 99, 235, 0.15);
        color: #93b4e6;
    }

        [data-theme="dark"] .badge-info .badge-dot {
            background: #93b4e6;
        }

    [data-theme="dark"] .card-status-info {
        background: rgba(37, 99, 235, 0.15);
        color: #93b4e6;
        border-left-color: #93b4e6;
    }

    [data-theme="dark"] .info-box.success {
        color: #bbf7d0;
    }

    [data-theme="dark"] .info-box.warning {
        color: #fde68a;
    }

    [data-theme="dark"] .info-box.danger {
        color: #fecaca;
    }

    /* Button disabled class — dark mode */
    [data-theme="dark"] .btn-primary.disabled {
        background: hsl(var(--primary-h) 58% 27%);
        border-color: hsl(var(--primary-h) 58% 27%);
        color: rgba(255, 255, 255, 0.3);
    }

    [data-theme="dark"] .btn-secondary.disabled {
        background: var(--surface-card);
        border-color: var(--border-default);
        color: var(--text-muted);
    }

/* Dark mode transition */
body {
    transition: background-color var(--transition-slow), color var(--transition-slow);
}


/* ============================================================
   15b. Detail / view-edit page layout
   ============================================================ */

.list-layout {

}

/* Two-column grid: narrow static column left, wide editable column right */
.detail-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: var(--space-6);
    align-items: start;

}

/* ── Card sections ──────────────────────────────────────── */
.card-section {
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-default);
    container-type: inline-size;
}

    .card-section:last-child {
        border-bottom: none;
    }

.card-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

/* ── Read-only field (label + value) ────────────────────── */
.detail-field {
    margin-bottom: var(--space-3);
}

    .detail-field:last-child {
        margin-bottom: 0;
    }

.detail-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-value {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* ── Horizontal label-value row ─────────────────────────────
   Use inside .card-section for read-only data presented as
   a two-column label / value pair. Collapses to stacked when
   the containing section is too narrow to be comfortable.    */

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: baseline;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-default);
}

    .field-row:first-of-type {
        padding-top: 0;
    }

    .field-row:last-of-type {
        padding-bottom: 0;
        border-bottom: none;
    }

.field-row-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-muted);
}

.field-row-value {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* Collapse to stacked layout when the card-section is narrow */
@container (max-width: 380px) {
    .field-row {
        grid-template-columns: 1fr;
        gap: var(--space-1);
        padding: var(--space-3) 0;
    }

    .field-row-label {
        font-size: var(--font-size-xs);
    }
}

/* ── Profile avatar (initials circle) ───────────────────── */
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    font-size: var(--font-size-lg);
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-3);
    flex-shrink: 0;
}

.profile-name {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}


/* ============================================================
   16. Responsive
   ============================================================ */

/* Tablet: ≤ 1024px — sidebar collapses by default */
@media (max-width: 1024px) {
    .app-content {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    /* Re-apply collapsed logic only for desktop */
    .sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    .sidebar-collapsed .app-content {
        margin-left: 0;
    }
}

/* Narrow: ≤ 900px — collapse detail layout to single column */
@media (max-width: 900px) {
    .list-layout {
        margin-left: 20px;
        margin-right: 20px;
    }

    .detail-layout {
        grid-template-columns: 1fr;
        margin-left: 20px;
        margin-right: 20px;
    }
}

/* Mobile: ≤ 640px */
@media (max-width: 640px) {
    .app-content {
        padding: var(--space-4);
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
    }

    .user-name {
        display: none;
    }

    .list-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .list-toolbar-left,
    .list-toolbar-right {
        flex-wrap: wrap;
    }

    .search-input-wrapper {
        max-width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: calc(100vh - var(--space-4));
        border-radius: var(--border-radius-lg);
    }

    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    .pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .topbar-logo .logo-text {
        display: none;
    }
}


/* ============================================================
   17. Auth Pages (login, register, forgot password, etc.)
   ============================================================ */

.auth-body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface-bg);
    padding: var(--space-6) var(--space-4);
}

    /* Subtle dot-grid background pattern */
    .auth-body::before {
        content: '';
        position: fixed;
        inset: 0;
        background-image: radial-gradient(var(--border-default) 1px, transparent 1px);
        background-size: 24px 24px;
        pointer-events: none;
        z-index: 0;
    }

.auth-shell {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.auth-card {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-8) var(--space-8);
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.auth-heading {
    margin-bottom: var(--space-6);
}

.auth-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 var(--space-1);
}

.auth-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
}

.auth-forgot {
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--text-link);
    white-space: nowrap;
}

    .auth-forgot:hover {
        color: var(--brand-primary-hover);
    }

/* Password field with show/hide toggle */
.auth-password-wrapper {
    position: relative;
}

    .auth-password-wrapper .form-control {
        padding-right: 2.75rem;
    }

.auth-password-toggle {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border-radius: var(--border-radius-sm);
    transition: color var(--transition-fast);
    /* Sit above the margin-top applied to the input */
    margin-top: 0.25rem;
}

    .auth-password-toggle:hover {
        color: var(--text-primary);
    }

    .auth-password-toggle svg {
        width: 16px;
        height: 16px;
        display: block;
    }

.auth-footer {
    position: relative;
    z-index: 1;
    margin-top: var(--space-6);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    text-align: center;
}

/* Responsive */
@media (max-width: 480px) {
    .auth-card {
        padding: var(--space-6) var(--space-5);
        border-radius: var(--border-radius-lg);
    }
}
