/* ============================================================
   DareOS — Caribbean Equality Project Design System
   Brand: 🏳️‍🌈 LGBT Pride Rainbow
   ============================================================ */

/* --- Design Tokens --- */
:root {
    color-scheme: light dark;
    /* Dare To Change Brand Colors */
    --dtc-gold: #C49A6C;
    --dtc-gold-dark: #8B6914;
    --dtc-black: #1A1513;
    --dtc-brown: #3A302A;
    --dtc-light: #F4EFE6;

    --primary: #8B6914;
    --primary-hover: #C49A6C;
    --primary-bg: rgba(139, 105, 20, 0.15);
    --green: #1dd1a1;
    --green-bg: rgba(29, 209, 161, 0.15);
    --red: #ff6b6b;
    --red-bg: rgba(255, 107, 107, 0.15);
    --orange: #ff9f43;
    --orange-bg: rgba(255, 159, 67, 0.15);
    --purple: #8B6914;
    --purple-bg: rgba(139, 105, 20, 0.15);
    --teal: #1dd1a1;
    --blue: #54a0ff;

    /* 🌟 DTC Gradients */
    --rainbow: linear-gradient(135deg, #C49A6C 0%, #8B6914 50%, #C49A6C 100%);
    --pride-gradient: linear-gradient(135deg, #1A1513 0%, #3A302A 100%);
    --pride-gradient-135: linear-gradient(135deg, #1A1513 0%, #3A302A 100%);
    --pride-gradient-soft: linear-gradient(135deg, rgba(26, 21, 19, 0.8), rgba(58, 48, 42, 0.9));
    --pride-gradient-vertical: linear-gradient(180deg, #C49A6C 0%, #8B6914 100%);

    --bg: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #fbfcfd;
    --surface: rgba(255, 255, 255, 0.92);
    --text: #1d1d1f;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border: rgba(0, 0, 0, 0.06);
    --border-focus: rgba(117, 7, 135, 0.35);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 24px 48px -12px rgba(0, 0, 0, 0.12);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --radius-pill: 980px;

    --sidebar-w: 260px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Glass Utility --- */
.glass,
.glass-card {
    background: rgba(255, 255, 255, 0.55) !important;
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.35) !important;
}

:root[data-theme="dark"] .glass,
:root[data-theme="dark"] .glass-card {
    background: rgba(28, 28, 30, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

@media (prefers-color-scheme: dark) {

    :root:not([data-theme="light"]) .glass,
    :root:not([data-theme="light"]) .glass-card {
        background: rgba(28, 28, 30, 0.55) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
    }
}

/* --- Dark Mode --- */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #0a0a0a;
    --surface: rgba(28, 28, 30, 0.92);
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --text-tertiary: #636366;
    --border: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(171, 140, 228, 0.5);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

    /* Enhance background colors in dark mode to prevent muddiness */
    --primary-bg: rgba(139, 105, 20, 0.25);
    --green-bg: rgba(29, 209, 161, 0.25);
    --red-bg: rgba(255, 107, 107, 0.25);
    --orange-bg: rgba(255, 159, 67, 0.25);
    --purple-bg: rgba(139, 105, 20, 0.25);

    /* Make soft gradient more visible on dark backgrounds */
    --pride-gradient-soft: linear-gradient(135deg, rgba(200, 160, 100, 0.2), rgba(139, 105, 20, 0.25));
}

:root[data-theme="dark"] .sidebar {
    background: rgba(10, 10, 10, 0.6);
    border-right: none;
    box-shadow: 1px 0 10px rgba(0, 0, 0, 0.15);
}

:root[data-theme="dark"] .form-control {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: #f5f5f7;
}

:root[data-theme="dark"] .form-control:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

:root[data-theme="dark"] .form-control::placeholder {
    color: #98989d;
    opacity: 0.8;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #000000;
        --bg-secondary: #1c1c1e;
        --bg-tertiary: #0a0a0a;
        --surface: rgba(28, 28, 30, 0.92);
        --text: #f5f5f7;
        --text-secondary: #98989d;
        --text-tertiary: #636366;
        --border: rgba(255, 255, 255, 0.12);
        --border-focus: rgba(171, 140, 228, 0.5);
        
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);

        --primary-bg: rgba(139, 105, 20, 0.25);
        --green-bg: rgba(29, 209, 161, 0.25);
        --red-bg: rgba(255, 107, 107, 0.25);
        --orange-bg: rgba(255, 159, 67, 0.25);
        --purple-bg: rgba(139, 105, 20, 0.25);

        --pride-gradient-soft: linear-gradient(135deg, rgba(200, 160, 100, 0.2), rgba(139, 105, 20, 0.25));
    }

    :root:not([data-theme="light"]) .sidebar {
        background: rgba(10, 10, 10, 0.6);
        border-right: none;
        box-shadow: 1px 0 10px rgba(0, 0, 0, 0.15);
    }

    :root:not([data-theme="light"]) .form-control {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.15);
        color: #f5f5f7;
    }

    :root:not([data-theme="light"]) .form-control:focus {
        background: rgba(255, 255, 255, 0.08);
        border-color: var(--primary);
    }

    :root:not([data-theme="light"]) .form-control::placeholder {
        color: #98989d;
        opacity: 0.8;
    }
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--pride-gradient-vertical);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #1A1513, #3A302A, #C49A6C, #8B6914);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-secondary);
    background-image:
        radial-gradient(ellipse at 15% 15%, rgba(228, 3, 3, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 25%, rgba(255, 140, 0, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 85%, rgba(0, 128, 38, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 20% 80%, rgba(0, 77, 255, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(117, 7, 135, 0.04) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.47059;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 15px;
}

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

a:hover {
    text-decoration: underline;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.17rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.text-muted {
    color: var(--text-secondary);
}

/* --- Layout: Dashboard --- */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: none;
    box-shadow: 1px 0 8px rgba(0, 0, 0, 0.03);
    padding: 2rem 1rem;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 50;
    overflow-y: auto;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    padding: 0 0.75rem;
    margin-bottom: 2rem;
    display: none;
}

.sidebar-logo span {
    color: var(--primary);
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-section {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 1.5rem 0.75rem 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    opacity: 0.6;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--bg-secondary);
    color: var(--text);
    text-decoration: none;
}

.nav-link:hover svg {
    opacity: 1;
}

.nav-link.active {
    background: var(--pride-gradient-soft);
    color: var(--primary);
    font-weight: 600;
    position: relative;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--pride-gradient-vertical);
}

.nav-link.active svg {
    opacity: 1;
    color: var(--primary);
}

.nav-bottom {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 0;
    width: calc(100% - var(--sidebar-w));
    max-width: calc(100% - var(--sidebar-w));
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition), width var(--transition), max-width var(--transition);
}

.main-content-inner {
    padding: 2rem 2.5rem;
    flex: 1;
}

/* --- Collapsed Sidebar --- */
html.sidebar-collapsed {
    --sidebar-w: 84px;
}

html.sidebar-collapsed .sidebar-profile>div:nth-child(2),
html.sidebar-collapsed .nav-section,
html.sidebar-collapsed .nav-link-text {
    display: none;
}

html.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0;
    width: 44px;
    height: 44px;
    margin: 0 auto 2px auto;
}

html.sidebar-collapsed .nav-link svg {
    margin: 0;
}

html.sidebar-collapsed .sidebar-logo {
    flex-direction: column;
    justify-content: center !important;
    gap: 0.75rem;
    padding: 0;
    margin-bottom: 1rem;
}

html.sidebar-collapsed .sidebar-logo .logo-text {
    font-size: 1rem;
    text-align: center;
    display: flex !important;
    justify-content: center;
    width: 100%;
}

html.sidebar-collapsed .sidebar-logo img {
    max-width: 100% !important;
    height: auto !important;
    max-height: 34px;
}

html.sidebar-collapsed .sidebar-profile {
    padding: 0.25rem 0 1rem 0 !important;
    justify-content: center;
}

html.sidebar-collapsed .sidebar-powered-footer {
    padding: 1.5rem 0 !important;
}

html.sidebar-collapsed .powered-text {
    font-size: 0.55rem !important;
    letter-spacing: 0 !important;
}

html.sidebar-collapsed .sidebar-logo-bottom {
    font-size: 0.85rem !important;
}

/* --- Collapsed Sidebar Tooltips (JS-powered, appended to body) --- */
.sidebar-tooltip {
    position: fixed;
    background: var(--bg, #1c1c1e);
    color: var(--text, #f5f5f7);
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    letter-spacing: 0.01em;
    transform: translateX(-4px);
}
.sidebar-tooltip.visible {
    opacity: 1;
    transform: translateX(0);
}

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

.page-header h1 {
    margin-bottom: 0.25rem;
}

/* --- Cards (Glass) --- */
.card {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

:root[data-theme="dark"] .card {
    background: rgba(28, 28, 30, 0.5);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .card {
        background: rgba(28, 28, 30, 0.5);
        border-color: rgba(255, 255, 255, 0.08);
        box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    }
}

.card-body {
    padding: 1.5rem;
}

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

.stat-card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px) saturate(160%);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: all var(--transition);
    box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--rainbow);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

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

:root[data-theme="dark"] .stat-card {
    background: rgba(28, 28, 30, 0.45);
    border-color: rgba(255, 255, 255, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .stat-card {
        background: rgba(28, 28, 30, 0.45);
        border-color: rgba(255, 255, 255, 0.08);
    }
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.stat-value.blue {
    color: var(--primary);
}

.stat-value.green {
    color: var(--green);
}

.stat-value.orange {
    color: var(--orange);
}

.stat-value.purple {
    color: var(--purple);
}

/* --- Tables --- */
.table-wrap {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px) saturate(150%);
    -webkit-backdrop-filter: blur(10px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: var(--shadow-xs);
}

:root[data-theme="dark"] .table-wrap {
    background: rgba(28, 28, 30, 0.45);
    border-color: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .table-wrap {
        background: rgba(28, 28, 30, 0.45);
        border-color: rgba(255, 255, 255, 0.06);
    }
}

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

th {
    text-align: left;
    padding: 0.85rem 1rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

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

tr:hover td {
    background: var(--bg-secondary);
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-blue {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-green {
    background: var(--green-bg);
    color: #0a7c42;
}

.badge-red {
    background: var(--red-bg);
    color: var(--red);
}

.badge-orange {
    background: var(--orange-bg);
    color: #b45309;
}

.badge-purple {
    background: var(--purple-bg);
    color: var(--purple);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--pride-gradient-soft);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: var(--text);
    font-weight: 700;
    position: relative;
    z-index: 1;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, rgba(139, 105, 20, 0.4), rgba(196, 154, 108, 0.4));
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger-soft {
    background: var(--red-bg);
    color: var(--red);
}

.btn-danger-soft:hover {
    background: rgba(255, 59, 48, 0.15);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

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

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text);
    transition: all var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* --- Remove Number Input Spinners (Global) --- */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Custom File Input Styling */
input[type="file"].form-control {
    padding: 0.35rem 0.65rem;
    color: var(--text-primary);
    line-height: 1.5;
}

input[type="file"].form-control::file-selector-button {
    padding: 0.4rem 0.85rem;
    margin-right: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

input[type="file"].form-control::file-selector-button:hover {
    background: var(--border);
    color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
    color-scheme: light;
}
:root[data-theme="dark"] select.form-control {
    color-scheme: dark !important;
    background-color: #1c1c1e !important;
    color: #f5f5f7 !important;
}




.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.invalid-feedback {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 0.3rem;
    display: block;
}

.alert-success {
    padding: 0.85rem 1rem;
    background: var(--green-bg);
    color: #0a7c42;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9rem;
}

/* --- Auth Layout --- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 2rem;
    position: relative;
}

.auth-card {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.auth-card::before {
    content: "";
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: -4px;
    right: -4px;
    background: linear-gradient(45deg, #ff6b6b, #ff9f43, #feca57, #1dd1a1, #54a0ff, #ab8ce4);
    filter: blur(16px);
    z-index: -1;
    border-radius: calc(var(--radius-lg) + 2px);
    opacity: 0.5;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 0.35rem;
}

.auth-card .text-muted {
    text-align: center;
    margin-bottom: 2rem;
    display: block;
}

.auth-card .form-group:last-of-type {
    margin-bottom: 1.5rem;
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link a {
    font-weight: 600;
}

/* --- Notification Bell --- */
.notif-panel {
    position: relative;
}

.notif-bell {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all var(--transition);
}

.notif-bell:hover {
    background: rgba(255, 255, 255, 0.6);
}

.notif-bell svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.notif-count {
    position: absolute;
    top: -3px;
    right: -3px;
    background: var(--red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

.notif-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 50px;
    width: 360px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255, 255, 255, 0.5);
    z-index: 200;
    overflow: hidden;
    animation: slideDown 0.15s ease-out;
}

:root[data-theme="dark"] .notif-dropdown {
    background: rgba(20, 20, 22, 0.75);
    border-color: rgba(255, 255, 255, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .notif-dropdown {
        background: rgba(20, 20, 22, 0.75);
        border-color: rgba(255, 255, 255, 0.08);
    }
}

.notif-panel.open .notif-dropdown {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notif-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
}

.notif-body {
    max-height: 380px;
    overflow-y: auto;
}

.notif-item {
    display: block;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background var(--transition);
}

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

.notif-item:hover {
    background: var(--bg-secondary);
    text-decoration: none;
}

.notif-item.unread {
    background: var(--primary-bg);
    border-left: 3px solid var(--primary);
}

.notif-item .n-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.15rem;
}

.notif-item .n-msg {
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.4;
}

.notif-item .n-time {
    color: var(--text-tertiary);
    font-size: 0.72rem;
    margin-top: 0.35rem;
}

.notif-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* --- Searchable Dropdown --- */
.search-dropdown {
    position: relative;
}

.search-dropdown .dd-list {
    display: none;
    position: absolute;
    z-index: 100;
    width: 100%;
    max-height: 240px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}

.search-dropdown .dd-list.open {
    display: block;
}

.dd-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border);
}

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

.dd-item:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

/* --- Toast --- */
.toast-wrap {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
}

.toast {
    padding: 0.85rem 1.25rem;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.25s ease-out;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Utility --- */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* --- Form Grid --- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* --- Badge Purple --- */
.badge-purple {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
}

/* --- Button Variants --- */
.btn-danger {
    background: var(--red);
    color: #fff;
    border: none;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* --- Red Background (overdue rows) --- */
:root {
    --red-bg: rgba(239, 68, 68, 0.06);
}


/* --- Global Tabs --- */
.tab-container,
.service-tabs {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
    overflow-x: auto;
}

.tab,
.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
}

.tab:hover,
.tab-btn:hover {
    color: var(--text);
    background: var(--bg-secondary);
}

.tab.active,
.tab-btn.active {
    color: var(--primary);
    border-bottom: 3px solid transparent;
    border-image: var(--rainbow) 1;
    background: var(--primary-bg);
}

.tab-pane,
.tab-content {
    display: none;
}

.tab-pane.active,
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Dark-mode global-topbar --- */
:root[data-theme="dark"] .global-topbar {
    background: rgba(10, 10, 10, 0.5) !important;
    border-bottom: none !important;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .global-topbar {
        background: rgba(10, 10, 10, 0.5) !important;
        border-bottom: none !important;
        box-shadow: 0 1px 8px rgba(0, 0, 0, 0.12) !important;
    }
}

/* --- Mobile Responsive --- */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-logo {
        display: flex !important;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

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

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 49;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .sidebar.mobile-open~.mobile-overlay {
        opacity: 1;
        pointer-events: all;
    }

    html.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    html.sidebar-collapsed .main-content {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    /* Grid layout fixes for mobile */
    .grid-2,
    .form-grid {
        grid-template-columns: 1fr;
    }

    div[style*="display:grid;"],
    div[style*="display: grid;"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Global topbar adjustments */
    .global-topbar {
        padding: 0.65rem 1rem !important;
    }

    .global-topbar form {
        display: none !important;
        /* Hide global search on small mobile to save space */
    }

    /* Cards and Padding */
    .glass-card {
        padding: 1.25rem !important;
    }

    .kpi-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 1rem !important;
    }

    /* Make all tables scrollable horizontally */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Header adjustments */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header .actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Buttons */
    .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .btn-sm {
        width: auto;
    }
}