/* ===== Font Imports (must be first) ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
/* @import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700&display=swap'); */

/* ===== CSS Variables (Dark mode default) ===== */
:root {
    /* Surfaces — clean neutral black, cards float above page */
    --bg-primary: #181818;
    --bg-secondary: #2c2c30;
    --bg-tertiary: #3a3a3e;
    --bg-nav: #2a2a2e;
    --bg-input: #232326;
    --bg-hover: rgba(255, 255, 255, 0.06);

    /* Text */
    --text-primary: #d8d8da;
    --text-secondary: #a6a6aa;
    --text-muted: #6a6a6e;
    --text-on-color: #ffffff;

    /* Primary */
    --primary-color: #5a9de6;
    --primary-hover: #4889d0;
    --primary-subtle: rgba(90, 157, 230, 0.14);
    --accent-glow: rgba(90, 157, 230, 0.18);

    /* Semantic */
    --success-color: #4cc080;
    --success-hover: #3eae6e;
    --success-subtle: rgba(76, 192, 128, 0.12);

    --warning-color: #efb040;
    --warning-hover: #dda030;
    --warning-subtle: rgba(239, 176, 64, 0.12);

    --danger-color: #e05258;
    --danger-hover: #cc454a;
    --danger-subtle: rgba(224, 82, 88, 0.12);

    --info-color: #56c4e0;
    --info-hover: #42b0cc;
    --info-subtle: rgba(86, 196, 224, 0.12);

    --purple-color: #8b5cf6;
    --purple-hover: #7c4fe0;
    --purple-subtle: rgba(139, 92, 246, 0.12);

    /* Overlay */
    --overlay-bg: rgba(0, 0, 0, 0.60);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 52px;

    /* Borders & Shadows */
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.40);

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 16px;

    /* Transitions */
    --transition: all 0.2s ease;

    /* Spacing (4px grid) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
}


/* ===== Reset & Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; */
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Impersonation Banner ===== */
.impersonation-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: linear-gradient(90deg, #d97706, #b45309);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.impersonation-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
}

.impersonation-stop {
    color: #fff;
    text-decoration: none;
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 600;
    transition: background 0.2s;
    margin-left: 8px;
}

.impersonation-stop:hover {
    background: rgba(255,255,255,0.35);
}

/* When impersonating, shift everything down */
body:has(.impersonation-banner) .sidebar {
    top: 34px;
    height: calc(100vh - 34px);
}

body:has(.impersonation-banner) .top-navbar {
    top: 34px;
}

body:has(.impersonation-banner) .main-content {
    padding-top: calc(var(--topbar-height) + 34px);
}

/* ===== Sidebar Navigation ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--bg-nav);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 56px;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 8px;
}

.sidebar.collapsed .sidebar-logo {
    justify-content: center;
}

.sidebar-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-logo {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    height: 38px;
}

.logo-full {
    height: 38px;
    width: auto;
    display: block;
    transition: opacity 0.2s ease;
}

.logo-icon {
    height: 38px;
    width: auto;
    display: none;
    transition: opacity 0.2s ease;
}

/* Light/dark background logo visibility */
.logo-light-bg {
    display: none !important;
}

body.light-mode .logo-dark-bg {
    display: none !important;
}

body.light-mode .logo-light-bg.logo-full {
    display: block !important;
}

body.light-mode .logo-light-bg.logo-icon {
    display: none !important;
}

.sidebar.collapsed .logo-full {
    display: none !important;
}

.sidebar.collapsed .logo-icon.logo-dark-bg {
    display: block !important;
    margin: 0 auto;
}

.sidebar.collapsed .logo-icon.logo-light-bg {
    display: none !important;
}

body.light-mode .sidebar.collapsed .logo-icon.logo-dark-bg {
    display: none !important;
}

body.light-mode .sidebar.collapsed .logo-icon.logo-light-bg {
    display: block !important;
    margin: 0 auto;
}

.sidebar.collapsed .sidebar-toggle {
    display: none;
}

.sidebar.collapsed .sidebar-header h3 {
    opacity: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: var(--transition);
}

/* Search Bar */
.sidebar-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-search form {
    position: relative;
    display: flex;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 40px 8px 16px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.sidebar-search button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.sidebar.collapsed .sidebar-search {
    display: none;
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-section {
    border-bottom: 1px solid var(--border-color);
}

.nav-section-header {
    padding: 8px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: var(--transition);
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
}

.nav-section-header i {
    color: var(--text-muted);
    margin-right: 2px;
}

.nav-section-header:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-section-header.open {
    color: var(--text-primary);
    border-bottom: none;
    background-color: var(--bg-hover);
}

.section-arrow {
    transition: var(--transition);
    display: inline-block;
    font-size: 0.8rem;
}

.nav-section-header.open .section-arrow {
    transform: rotate(180deg);
}

.user-icon {
    font-size: 1.2rem;
}

.nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-section-content.open {
    max-height: 500px;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-left-color: rgba(74, 144, 217, 0.4);
}

.nav-link:hover i {
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--accent-glow);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-link.active i {
    color: var(--primary-color);
}

.nav-link.single {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-left: none;
}

.nav-link.single i {
    color: var(--text-muted);
    margin-right: 2px;
}

.nav-link.single:hover {
    color: var(--text-primary);
    border-left: none;
}

/* Nav badge counters */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 1;
    background: var(--accent-color, #6366f1);
    color: #fff;
}

.nav-badge.unread {
    background: #ea580c;
}

.sidebar.collapsed .nav-badge {
    display: none;
}

.nav-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-link.disabled:hover {
    padding-left: 40px;
}

.nav-link.single.disabled:hover {
    padding-left: 20px;
}

.not-ready {
    color: var(--danger-color);
    font-size: 0.9rem;
    font-weight: bold;
    margin-left: auto;
}

/* Nav text spacing */
.nav-text {
    margin-left: 8px;
}

.nav-label {
    display: flex;
    align-items: center;
}

/* Hide icons on sub-items (inside section content) */
.nav-section-content .nav-link i {
    display: none;
}

.nav-section-content .nav-link .nav-text {
    margin-left: 0;
}

/* Icons always visible */
.nav-section-header i {
    display: inline-block;
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px 12px 32px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.825rem;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link i {
    display: inline-block;
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
    margin-right: 0;
    transition: var(--transition);
}

/* ===== Collapsed Sidebar ===== */

/* Hide text and arrows in collapsed state */
.sidebar.collapsed .nav-text {
    display: none;
}

.sidebar.collapsed .section-arrow {
    display: none;
}

/* Hide section content in collapsed state */
.sidebar.collapsed .nav-section-content {
    max-height: 0 !important;
}

/* Center icons in collapsed state - same vertical padding as expanded */
.sidebar.collapsed .nav-section-header {
    justify-content: center;
    padding: 12px 0;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px 0;
    border-left: 3px solid transparent;
}

.sidebar.collapsed .nav-link.active {
    border-left-color: var(--primary-color);
}

.sidebar.collapsed .nav-link:hover {
    padding: 12px 0;
}

.sidebar.collapsed .nav-link.single {
    padding: 12px 0;
    justify-content: center;
}

.sidebar.collapsed .nav-section-header i,
.sidebar.collapsed .nav-link i {
    font-size: 1rem;
    margin-right: 0;
}

/* ===== Collapsed Sidebar Hover - Expand to show text ===== */
.sidebar.collapsed:hover {
    width: var(--sidebar-width);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed:hover .sidebar-header {
    justify-content: space-between;
    padding: 12px 20px;
}

.sidebar.collapsed:hover .sidebar-logo {
    justify-content: flex-start;
}

.sidebar.collapsed:hover .logo-full.logo-dark-bg {
    display: block !important;
}

.sidebar.collapsed:hover .logo-icon {
    display: none !important;
}

body.light-mode .sidebar.collapsed:hover .logo-full.logo-dark-bg {
    display: none !important;
}

body.light-mode .sidebar.collapsed:hover .logo-full.logo-light-bg {
    display: block !important;
}

body.light-mode .sidebar.collapsed:hover .logo-icon {
    display: none !important;
}

.sidebar.collapsed:hover .sidebar-toggle {
    display: flex;
}

/* Restore text and arrows on hover */
.sidebar.collapsed:hover .nav-text {
    display: inline;
}

.sidebar.collapsed:hover .section-arrow {
    display: inline-block;
}

/* Restore section content on hover (if section is open) */
.sidebar.collapsed:hover .nav-section-content.open {
    max-height: 500px !important;
}

/* Restore header layout on hover */
.sidebar.collapsed:hover .nav-section-header {
    justify-content: space-between;
    padding: 12px 16px;
}

/* Restore nav-link layout on hover */
.sidebar.collapsed:hover .nav-link {
    justify-content: flex-start;
    padding: 12px 16px 12px 32px;
    border-left: 3px solid transparent;
}

.sidebar.collapsed:hover .nav-link.active {
    border-left-color: var(--primary-color);
}

.sidebar.collapsed:hover .nav-link:hover {
    padding: 12px 16px 12px 32px;
}

.sidebar.collapsed:hover .nav-link.single {
    padding: 12px 16px;
    justify-content: flex-start;
}

/* Restore icon sizes on hover (match expanded state) */
.sidebar.collapsed:hover .nav-section-header i,
.sidebar.collapsed:hover .nav-link i {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    margin-right: 0;
}

/* ===== Top Navbar ===== */
.top-navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background-color: var(--bg-nav);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 999;
    transition: var(--transition);
}

.sidebar.collapsed ~ .top-navbar,
.top-navbar.expanded {
    left: var(--sidebar-collapsed-width);
}

.top-navbar-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.top-navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Top Search */
.top-search {
    position: relative;
    width: 280px;
}

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

.top-search i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.top-search input[type="search"] {
    width: 100%;
    height: 32px;
    padding: 4px 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
}

.top-search input[type="search"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

.top-search input[type="search"]::placeholder {
    color: var(--text-muted);
}

/* Location Selector */
.top-location-select {
    width: auto;
    min-width: 0;
    height: 32px;
    padding: 4px 28px 4px 12px;
    font-size: 0.85rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    flex-shrink: 0;
}

.top-location-select:hover,
.top-location-select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-subtle);
}

/* Theme Toggle */
.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: var(--transition);
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    background: var(--primary-subtle);
}

/* Top User */
.top-user {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 32px;
    padding: 4px 12px;
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    text-decoration: none;
    transition: var(--transition);
}

.top-user:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.top-user i {
    font-size: 1.1rem;
    color: var(--primary-color);
}

/* Top Logout */
.top-logout {
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    text-decoration: none;
    transition: var(--transition);
}

.top-logout:hover {
    color: white;
    background: var(--danger-color);
    border-color: var(--danger-color);
}

.top-login {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 100px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.top-login:hover {
    opacity: 0.9;
}

/* ===== Main Content Area ===== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
    transition: var(--transition);
    padding: 24px;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
    max-width: 1620px;
    margin: 0 auto;
}

/* ===== Cards ===== */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: transparent;
    font-weight: 600;
    font-size: 1rem;
}

.card-body {
    padding: 16px;
    padding-top: 12px;
}

/* ===== Stats Cards ===== */
.stats-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    transition: var(--transition);
}

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

.stats-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stats-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-on-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(90, 157, 230, 0.35);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--text-on-color);
}

.btn-success:hover {
    background-color: var(--success-hover);
    box-shadow: 0 4px 12px rgba(76, 192, 128, 0.35);
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--text-on-color);
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    box-shadow: 0 4px 12px rgba(224, 82, 88, 0.35);
}

.btn-warning {
    background-color: var(--warning-color);
    color: #1a1d24;
}

.btn-warning:hover {
    background-color: var(--warning-hover);
    box-shadow: 0 4px 12px rgba(239, 176, 64, 0.35);
}

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

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

/* Ghost Button (minimal, for icon actions) */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Outline Button Variants */
.btn-outline-primary {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    color: var(--text-on-color);
    box-shadow: 0 4px 12px rgba(90, 157, 230, 0.3);
}

.btn-outline-success {
    background-color: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.btn-outline-success:hover {
    background-color: var(--success-color);
    color: var(--text-on-color);
    box-shadow: 0 4px 12px rgba(76, 192, 128, 0.3);
}

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

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

.btn-outline-danger {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: var(--text-on-color);
    box-shadow: 0 4px 12px rgba(224, 82, 88, 0.3);
}

.btn-outline-warning {
    background-color: transparent;
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.btn-outline-warning:hover {
    background-color: var(--warning-color);
    color: #1a1d24;
    box-shadow: 0 4px 12px rgba(239, 176, 64, 0.3);
}

.btn-cancel {
    padding: 8px 20px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-save {
    padding: 8px 20px;
    background: var(--success-color);
    color: var(--text-on-color);
    border: none;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save:hover {
    background: var(--success-hover);
}

.btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.85rem;
}

/* ===== Attention Pulse ===== */
@keyframes pulse-primary {
    0%, 100% { box-shadow: 0 0 0 0 rgba(90, 157, 230, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(90, 157, 230, 0); }
}

@keyframes pulse-success {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 192, 128, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(76, 192, 128, 0); }
}

@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(224, 82, 88, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(224, 82, 88, 0); }
}

@keyframes pulse-warning {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 176, 64, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(239, 176, 64, 0); }
}

.btn-pulse-primary { animation: pulse-primary 2s ease-in-out infinite; }
.btn-pulse-success { animation: pulse-success 2s ease-in-out infinite; }
.btn-pulse-danger  { animation: pulse-danger 2s ease-in-out infinite; }
.btn-pulse-warning { animation: pulse-warning 2s ease-in-out infinite; }

.btn-pulse-primary:hover,
.btn-pulse-success:hover,
.btn-pulse-danger:hover,
.btn-pulse-warning:hover {
    animation: none;
}

/* ===== Utility Classes ===== */
.hidden,
.d-none {
    display: none !important;
}

/* ===== Forms ===== */
.form-label,
label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 6px 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

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

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* ===== Hide native number spinners ===== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

/* ===== Custom Number Spinner ===== */
.pnx-spinner-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.pnx-spinner-wrap input[type="number"] {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    text-align: end;
}

.pnx-spinner-btns {
    display: flex;
    flex-direction: column;
    height: 30px;
    flex-shrink: 0;
}

.pnx-spinner-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-left: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 8px;
    line-height: 1;
    padding: 0;
    user-select: none;
    transition: background 0.15s, color 0.15s;
}

.pnx-spinner-btn:first-child {
    border-radius: 0 var(--radius-sm) 0 0;
    border-bottom: none;
}

.pnx-spinner-btn:last-child {
    border-radius: 0 0 var(--radius-sm) 0;
}

.pnx-spinner-btn:hover {
    background: var(--primary-color);
    color: var(--text-on-color);
}

/* ===== Tables ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-secondary);
    overflow: hidden;
}

.table thead th {
    background-color: var(--bg-tertiary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: var(--bg-hover);
}

.table tbody td {
    padding: 8px 12px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.table-sm td,
.table-sm th {
    padding: 4px 8px;
}

.td-center {
    text-align: center;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

.badge-success {
    background-color: var(--success-subtle);
    color: var(--success-color);
}

.badge-warning {
    background-color: var(--warning-subtle);
    color: var(--warning-color);
}

.badge-danger {
    background-color: var(--danger-subtle);
    color: var(--danger-color);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border-left: 3px solid;
}

.alert-info {
    background-color: var(--info-subtle);
    border-color: var(--info-color);
    color: var(--text-primary);
}

.alert-warning {
    background-color: var(--warning-subtle);
    border-color: var(--warning-color);
    color: var(--text-primary);
}

.alert-danger {
    background-color: var(--danger-subtle);
    border-color: var(--danger-color);
    color: var(--text-primary);
}

.alert-success {
    background-color: var(--success-subtle);
    border-color: var(--success-color);
    color: var(--text-primary);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
}

.modal.active {
    display: flex !important;
}

/* When overlay is inside .modal, it's just a backdrop behind the dialog */
.modal > .modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: -1;
}

/* Standalone overlay (used as centering wrapper on other pages) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 760px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-dialog .modal-content {
    border: none;
    box-shadow: none;
    margin: 0;
    max-width: none;
    border-radius: 0;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin: 32px auto;
    max-width: 1000px;
    max-height: calc(100vh - 64px);
    display: flex;
    flex-direction: column;
    position: relative;
}

.modal-content-csv-table {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    margin: 32px auto;
    max-width: 1200px;
    position: relative;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== Login Page ===== */
.login-container {
    max-width: 450px;
    margin: 48px auto;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-md);
}

.login-container h3 {
    color: var(--primary-color);
    margin-bottom: 4px;
    text-align: center;
    font-size: 1.8rem;
}

.login-container form p,
.login-container form .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.login-container form p label,
.login-container form .form-group label {
    margin-bottom: 8px;
    font-weight: 500;
}

.login-container form p input,
.login-container form p select,
.login-container form p textarea,
.login-container form .form-group input {
    padding: 12px;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.login-container .btn-primary {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
}

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

.login-container a:hover {
    text-decoration: underline;
}

.login-container p {
    text-align: center;
    color: var(--text-secondary);
}

/* ===== Utility Classes ===== */
.field-div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.boards-po-title {
    font-size: 1.75rem;
    margin: 0;
    padding: 0;
    font-weight: 600;
}

.opacity-25 {
    opacity: 0.25;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

/* ===== Mobile Hamburger Button ===== */
.mobile-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-right: 8px;
    flex-shrink: 0;
}

.mobile-hamburger:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===== Mobile Overlay ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== Mobile Close Button (inside sidebar) ===== */
.mobile-nav-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mobile-nav-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        z-index: 1001;
    }

    /* Show sidebar when mobile-open class is added */
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Hide the desktop sidebar toggle on mobile */
    .sidebar-toggle {
        display: none;
    }

    /* Show the close button inside sidebar on mobile */
    .mobile-nav-close {
        display: flex;
    }

    /* Show the hamburger button */
    .mobile-hamburger {
        display: flex;
    }

    /* Top navbar takes full width on mobile, stays above overlay */
    .top-navbar {
        left: 0 !important;
        z-index: 1002;
    }

    /* Main content takes full width */
    .main-content {
        margin-left: 0 !important;
        padding: 8px;
    }

    /* Ensure expanded classes don't mess with mobile */
    .main-content.expanded {
        margin-left: 0;
    }

    .top-navbar.expanded {
        left: 0;
    }

    /* Hide some top navbar items on small screens */
    .top-search {
        display: none;
    }

    .top-location-select {
        display: none;
    }

    .top-user span {
        display: none;
    }

    .top-user {
        padding: 4px 8px;
    }

    .top-navbar-right {
        gap: 8px;
    }

    .page-title {
        font-size: 0.95rem;
    }

    /* Top navbar tighter padding on mobile */
    .top-navbar {
        padding: 0 8px;
    }

    /* Sidebar starts below the top navbar on mobile */
    .sidebar {
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
    }

    /* Hide sidebar header on mobile (logo/close) since we have the top bar */
    .sidebar-header {
        display: none;
    }

    /* Tighter nav padding on mobile */
    .nav-section-header {
        padding: 8px 12px;
    }

    .nav-link {
        padding: 8px 12px 8px 24px;
    }

    .nav-link.single {
        padding: 8px 12px;
    }

    /* Remove card body extra padding on mobile */
    .card-header {
        padding: 8px;
    }

    .card-body {
        padding: 8px;
    }

    /* Reset content-wrapper margin */
    .content-wrapper {
        margin: 0;
    }

    /* Page header tighter on mobile */
    .page-header {
        margin-bottom: 8px;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stats-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 8px 0 0;
}

.stats-card-wide {
    grid-column: span 2;
}

.stats-content {
    flex: 1;
}

.stats-icon {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-left: 16px;
}

.filter-form {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr auto;
    gap: 16px;
    align-items: end;
}

.form-actions {
    display: flex;
    flex-direction: column;
}

.btn-group-inline {
    display: flex;
    gap: 12px;
}

.tab-nav {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background-color: transparent;
}

.tab-button {
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    white-space: nowrap;
    text-decoration: none;
}

.tab-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: rgba(90, 157, 230, 0.06);
}

.tab-button .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* Pill-style tab variant */
.tab-nav-pills {
    display: flex;
    gap: 4px;
    border-bottom: none;
    background: var(--bg-tertiary);
    border-radius: 20px;
}

.tab-nav-pills .tab-button {
    border-bottom: none;
    margin-bottom: 0;
    border-radius: 16px;
    padding: 8px 16px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.tab-nav-pills .tab-button:hover {
    background-color: var(--bg-hover);
}

.tab-nav-pills .tab-button.active {
    background-color: var(--primary-color);
    color: var(--text-on-color);
    box-shadow: var(--shadow-sm);
}

.tab-content {
    padding: 0;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
    gap: var(--sp-6);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-large {
    text-align: center;
    padding: 80px 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    margin: 20px 0;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p,
.empty-state-large p {
    margin: 12px 0 20px;
    color: var(--text-secondary);
}

.empty-state-large h3 {
    margin: 16px 0 12px;
}

/* ===== Responsive Grid ===== */
@media (max-width: 1200px) {
    .stats-card-wide {
        grid-column: span 1;
    }
}

@media (max-width: 968px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .tab-nav {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1 1 50%;
    }
}

@media (max-width: 568px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-button {
        flex: 1 1 100%;
        font-size: 0.9rem;
        padding: 12px 15px;
    }
}

/* ===== Additional Styles ===== */
.errorlist {
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--danger-color);
}

.errorlist li {
    padding: 4px 0;
    font-size: 0.9rem;
}

/* Table Color Variants */
.table-success {
    background-color: rgba(92, 184, 92, 0.15);
}

.table-warning {
    background-color: rgba(240, 173, 78, 0.15);
}

.table-danger {
    background-color: rgba(217, 83, 79, 0.15);
}

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

.list-group-item {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 15px;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    margin: 8px 4px 4px 4px;
}

#id_all_items_ordered,
#id_job_finished {
    height: 20px;
    width: 20px;
    margin-left: 12px;
}

.category-badge {
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
}

#csv_file {
    margin-bottom: 20px;
}

.job-info-link {
    color: white;
}

/* ===== Global Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 16px rgba(0,0,0,0.35);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-hiding {
    opacity: 0;
    transform: translateX(30px);
}

.toast-success { border-left: 4px solid var(--success-color); }
.toast-error,
.toast-danger  { border-left: 4px solid var(--danger-color); }
.toast-warning { border-left: 4px solid var(--warning-color); }
.toast-info    { border-left: 4px solid var(--primary-color); }

.toast-text {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-nav .bi-speedometer2,
.sidebar-nav .bi-folder,
.sidebar-nav .bi-cash-stack,
.sidebar-nav .bi-cart,
.sidebar-nav .bi-calendar3,
.sidebar-nav .bi-tools,
.sidebar-nav .bi-file-earmark-bar-graph,
.sidebar-nav .bi-shield-lock-fill,
.sidebar-nav .bi-ticket-detailed {
    height: 30px;
}

/* .bi-file-earmark-pdf {
    height: 30px;
} */