/* ===== 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.4;
    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;
    padding: 8px;
    padding-top: 4px;
}

.nav-section {
    margin-bottom: 0;
}

.sidebar-nav > .nav-section,
.sidebar-nav > .nav-link.single {
    position: relative;
}

.sidebar-nav > * + * {
    margin-top: 4px;
    padding-top: 4px;
}

.sidebar-nav > * + *::before {
    content: "";
    position: absolute;
    top: 0;
    left: 4px;
    right: 4px;
    height: 1px;
    background: var(--border-color);
    opacity: 0.32;
}

.nav-section-header {
    padding: 12px 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;
    border-radius: 10px;
}

.nav-section-header i {
    color: var(--text-muted);
    margin-right: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

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

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

/* Only show fill when user explicitly opened the section (not auto-open) */
.nav-section-header.open:not([data-auto-open]) {
    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;
    padding-top: 4px;
    padding-bottom: 4px;
}

.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: 12px 16px;
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-left: none;
    border-radius: 10px;
}

.nav-link.single i {
    color: var(--text-muted);
    margin-right: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.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;
}

/* Sub-item links */
.nav-section-content .nav-link {
    padding: 8px 16px 8px 24px;
    font-size: 12px;
    border-radius: 8px;
    border-left: none;
    color: var(--text-secondary);
}

.nav-section-content .nav-link + .nav-link {
    margin-top: 2px;
}

/* 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;
    border-radius: 10px;
}

.nav-link i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
    margin-right: 0;
    line-height: 1;
    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;
    border-radius: 10px;
}

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

.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;
    border-radius: 10px;
}

.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;
}

.nav-section-header,
.nav-link {
    position: relative;
}

.nav-link:hover,
.nav-section-header:hover {
    transform: none;
    box-shadow: inset 0 0 0 1px rgba(46, 122, 191, 0.16);
}

.nav-link.single.active,
.nav-link.active {
    box-shadow: inset 0 0 0 1px rgba(90, 157, 230, 0.18);
}

.nav-link::before,
.nav-section-header::before {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 4px;
    width: 2px;
    border-radius: 2px;
    opacity: 0;
    background: linear-gradient(180deg, var(--primary-color), transparent);
    transition: var(--transition);
}

.nav-link:hover::before,
.nav-section-header:hover::before,
.nav-link.active::before {
    opacity: 0.4;
}

/* ===== 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-content {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    max-width: 1620px;
    padding: 16px;
    padding-top: 0;
    gap: 24px;
}

.page-content.card {
    border-radius: 16px;
}

.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: none;
}

.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);
}

/* Validation bell */
.validation-bell-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.validation-bell-btn {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 16px;
    border: 1px solid var(--warning-color, #f59e0b);
    background: var(--bg-primary);
    color: var(--warning-color, #f59e0b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    transition: var(--transition);
}

.validation-bell-btn:hover {
    background: rgba(245, 158, 11, 0.12);
}

.validation-bell-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
}

.validation-bell-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 420px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 2000;
    overflow: hidden;
}

.validation-bell-header {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.validation-bell-loading,
.validation-bell-empty {
    padding: 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Bell dropdown table */
.vbell-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.vbell-table thead tr th {
    padding: 6px 5px;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.vbell-table thead tr th.vbell-th-order {
    text-align: left;
    padding-left: 12px;
}

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

.vbell-table tbody tr:last-child { border-bottom: none; }
.vbell-table tbody tr:hover { background: var(--bg-hover, rgba(0,0,0,0.02)); }

.vbell-td-order {
    padding: 8px 6px 8px 12px;
    text-align: left;
    max-width: 190px;
}

.vbell-order-top {
    display: flex;
    align-items: center;
    gap: 5px;
}

.vbell-sale {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.vbell-type {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(245,158,11,0.15);
    color: #d97706;
    border: 1px solid rgba(245,158,11,0.35);
}

.vbell-customer {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.vbell-meta {
    display: block;
    font-size: 0.67rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.vbell-td-done,
.vbell-td-todo,
.vbell-td-na,
.vbell-td-saving {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    min-width: 28px;
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
}

.vbell-td-done  { color: #10b981; }
.vbell-td-done:hover  { background: rgba(16,185,129,0.10); }
.vbell-td-todo  { color: #f59e0b; }
.vbell-td-todo:hover  { background: rgba(245,158,11,0.10); }
.vbell-td-na    { color: var(--text-secondary); opacity: 0.45; cursor: default; }
.vbell-td-saving { color: var(--text-secondary); cursor: wait; }

.validation-bell-dismiss {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: var(--transition);
}

.validation-bell-dismiss:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.validation-bell-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

.validation-bell-view-all {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.validation-bell-view-all:hover {
    text-decoration: underline;
}

/* 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: 20px;
    font-weight: 700;
    color: var(--primary-color);
}

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

/* ===== Kebab Menu ===== */
/* Single, site-wide 3-dot contextual menu. Structure:
   <div class="kebab-menu">
     <button class="kebab-trigger" onclick="toggleKebab(this, event)">
       <i class="bi bi-three-dots-vertical"></i>
     </button>
     <div class="kebab-dropdown">
       <a class="kebab-item">…</a>
       <button class="kebab-item danger">…</button>
       <div class="kebab-divider"></div>
       <span class="kebab-label">Section</span>
     </div>
   </div>
   The global toggleKebab()/closeAllKebabs() helpers in base.html handle open/close
   and position the dropdown (position:fixed) so it escapes any clipping container. */
.kebab-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.kebab-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.kebab-trigger:hover,
.kebab-menu.open .kebab-trigger {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.kebab-dropdown {
    display: none;
    position: fixed;
    z-index: 9000;
    min-width: 210px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    /* overflow visible so nested popovers (e.g. edging diagram) can escape */
    overflow: visible;
}

.kebab-menu.open .kebab-dropdown,
.kebab-dropdown.open {
    display: flex;
}

.kebab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    white-space: nowrap;
    transition: background 0.12s;
}

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

.kebab-item i {
    font-size: 1rem;
    color: var(--success-color);
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* Muted (e.g. "add missing data") variant */
.kebab-item.muted i,
.kebab-item-muted i {
    color: var(--text-muted);
}

/* Danger variant */
.kebab-item.danger,
.kebab-item-danger {
    color: var(--danger-color);
}

.kebab-item.danger i,
.kebab-item-danger i {
    color: var(--danger-color);
}

.kebab-item.danger:hover,
.kebab-item-danger:hover {
    background: var(--danger-subtle);
    color: var(--danger-color);
}

.kebab-item.disabled,
.kebab-item-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Divider + section label inside the dropdown */
.kebab-divider,
.kebab-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.kebab-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 4px 0;
}

.kebab-label,
.kebab-dropdown-header {
    display: block;
    padding: 6px 10px 2px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.kebab-item.active {
    color: var(--success-color);
}

.kebab-check-icon {
    margin-left: auto;
    font-size: 0.95rem;
    color: var(--success-color);
    opacity: 0;
    transition: opacity 0.1s;
}

.kebab-item.active .kebab-check-icon {
    opacity: 1;
}

/* Toggle item variant: label row with a checkbox/control on the right */
.kebab-item-toggle {
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.kebab-item-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.kebab-item-toggle i {
    color: inherit;
}

.kebab-item-toggle input[type="checkbox"] {
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--success-color);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 32px;
    padding: 0 16px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.01em;
    box-sizing: border-box;
}

.btn i {
    font-size: 12px;
    line-height: 1;
}

.btn i::before {
    vertical-align: 0;
}

.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: #fff;
}

.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-color: 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-color: 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-color: 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-color: 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-color: 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-color: 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 {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

/* ===== 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;
}

/* ===== Site-wide ± qty stepper ===== */
.qty-stepper-input {
    display: inline-flex;
    align-items: stretch;
    width: 92px;
    min-width: 92px;
    height: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    overflow: hidden;
    vertical-align: middle;
    transition: border-color 0.15s ease;
}

/* Center stepper pills when placed directly inside a table cell */
td > .qty-stepper-input {
    display: flex;
    margin: 0 auto;
}
.qty-step-btn {
    width: 26px;
    border: none;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.qty-stepper-input .qty-step-btn:hover {
    background: var(--bg-hover);
    color: var(--primary-hover);
}
.qty-step-value,
.qty-stepper-input input.quantity-input {
    flex: 1 1 auto;
    min-width: 30px;
    width: auto;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    padding: 0 2px;
    outline: none;
    -moz-appearance: textfield;
    appearance: textfield;
}
.qty-step-value::-webkit-inner-spin-button,
.qty-step-value::-webkit-outer-spin-button,
.qty-stepper-input input.quantity-input::-webkit-inner-spin-button,
.qty-stepper-input input.quantity-input::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
    display: none !important;
}

/* ===== 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;
    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: flex-start;
    justify-content: center;
    padding-top: calc(var(--topbar-height) + 16px);
    padding-bottom: 16px;
    overflow-y: auto;
}

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

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

/* Lock background scrolling while a modal is open */
body:has(.modal.show),
body:has(.modal.active),
body:has(.modal-overlay.active) {
    overflow: hidden;
}

/* When overlay is inside .modal, it's just a backdrop behind the dialog */
.modal > .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.40);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: -1;
}

/* Standalone overlay (used as centering wrapper on other pages) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.40);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

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

/* ===== Native <dialog> element centering ===== */
dialog {
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

.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 used directly inside a flex modal: align to top, no auto margins */
.modal > .modal-content {
    margin-top: 0;
    margin-bottom: 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 16px;
}

.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-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);
}

/* ===== Global Utilities ===== */
.icon-warning {
    color: #f59e0b;
}

.required-star {
    color: var(--danger-color);
}

.modal-body .form-group {
    margin-bottom: var(--sp-4);
}

.modal-body .form-check {
    margin-bottom: var(--sp-2);
}

/* ===== 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;
}

/* ===== Entity Hero Card ===== */
/* Shared customer-info banner used on sale, order, and customer detail pages */

.entity-hero-card {
    border-radius: 40px !important;
}

.entity-hero-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

/* Left: avatar + name/subtitle */
.entity-hero-identity {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    padding-right: 20px;
    min-width: 180px;
}

.entity-hero-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.entity-hero-avatar i {
    font-size: 1.35rem;
    color: #fff;
}

.entity-hero-identity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.entity-hero-name {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.entity-hero-name a {
    color: var(--primary-color);
    text-decoration: none;
}

.entity-hero-name a:hover {
    color: var(--primary-hover);
}

.entity-hero-since {
    font-size: 0.76rem;
    color: var(--text-secondary);
}

/* Middle: info columns (Phone | Email | Address) */
.entity-hero-cols {
    display: flex;
    gap: 0;
    flex: 1;
    flex-wrap: wrap;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.entity-hero-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 20px;
    min-width: 140px;
}

.entity-hero-col + .entity-hero-col {
    border-left: 1px solid var(--border-color);
}

.entity-hero-col-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.entity-hero-col-value {
    font-size: 0.83rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.entity-hero-col-email {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entity-hero-col-action {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    margin-top: 1px;
}

.entity-hero-col-action:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Right status block and action buttons are now separate flex items */
.entity-hero-status-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 0 16px;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
    min-width: 110px;
}

/* Status label and badge on the same row */
.entity-hero-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.entity-hero-updated {
    font-size: 0.74rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.entity-hero-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Save and cancel buttons are hidden until edit mode is toggled via JS */
.entity-hero-actions #btn-save,
.entity-hero-actions #btn-cancel {
    display: none;
}

.entity-hero-links {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Copy-to-clipboard button inside hero card columns */
.entity-hero-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 3px 5px;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
    flex-shrink: 0;
}

.entity-hero-copy-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background-color: rgba(0, 0, 0, 0.04);
}

.entity-hero-copy-btn.copied {
    color: var(--success-color);
    border-color: var(--success-color);
    background-color: rgba(25, 135, 84, 0.1);
}

[data-theme="dark"] .entity-hero-copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .entity-hero-copy-btn.copied {
    background-color: rgba(25, 135, 84, 0.2);
}

.entity-hero-col-address {
    white-space: normal;
}

/* Value + copy button side by side */
.entity-hero-col-value-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Detail Tab Bar ===== */
/* Tabbed navigation for combined sale/order detail page */

.detail-tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
}

.detail-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: -2px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    white-space: nowrap;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}

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

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

.detail-tab .tab-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.detail-tab.active .tab-count {
    background: rgba(var(--primary-rgb, 33, 150, 243), 0.15);
    color: var(--primary-color);
}

.detail-tab-panel {
    display: none;
}

.detail-tab-panel.active {
    display: block;
    padding-top: 16px;
}

.detail-tab-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    color: var(--text-muted);
    gap: var(--sp-2);
}

.detail-tab-empty i {
    font-size: 2rem;
}

/* ===== Sale+Order Combined Page Layout ===== */
/* Persistent two-column layout: tab panels on the left, financial summary on the right */

.sale-page-layout {
    display: flex;
    gap: var(--sp-6);
    align-items: flex-start;
}

.sale-page-main {
    flex: 3;
    min-width: 0;
}

.sale-page-summary-col {
    flex: 1;
    min-width: 240px;
    max-width: 320px;
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
}
