:root {
    --navy-900: #0f172a;
    --navy-800: #111827;
    --navy-700: #1f2937;
    --teal-500: #14b8a6;
    --teal-400: #2dd4bf;
    --blue-500: #3b82f6;
    --sidebar-bg: #f8fafc;
    --sidebar-accent: #e6fffb;
    --primary: var(--teal-500);
    --danger: #dc3545;
    --success: #198754;
    --warning: #ffc107;
    --text: #1f2937;
    --muted: #64748b;
    --card-border: #e2e8f0;
    --body-bg: #f3f7fb;
    --nav-bg: var(--navy-900);
    --nav-border: rgba(148, 163, 184, 0.15);
    --footer-bg: var(--navy-800);
    --footer-border: rgba(148, 163, 184, 0.12);
}

body {
    font-family: "Segoe UI", sans-serif;
    background: var(--body-bg);
    color: var(--text);
}

.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef4ff 0%, #f7f9fc 100%);
}

.login-card {
    width: min(420px, 90vw);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
    padding: 2rem;
}

.app-shell {
    min-height: 100vh;
    background: #f5f7fb;
}

.topbar {
    height: 72px;
    background: linear-gradient(135deg, var(--nav-bg) 0%, #111827 100%);
    border-bottom: 1px solid var(--nav-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

.topbar .fw-bold {
    color: #e2fdf9 !important;
    letter-spacing: 0.04em;
    font-size: 0.98rem;
}

.topbar-inner {
    gap: 0.75rem;
}

.topbar-brand {
    min-width: 0;
}

.topbar-brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(48vw, 420px);
    font-size: clamp(0.9rem, 1.5vw, 1.6rem);
    line-height: 1.2;
}

.topbar-user-menu {
    flex-shrink: 0;
}

.topbar-user-button {
    max-width: min(48vw, 220px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.5rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.topbar-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu-toggle {
    display: none !important;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    padding: 0;
    margin-top: 4px;
    margin-bottom: 4px;
    background: rgba(20, 184, 166, 0.18);
    border-color: rgba(20, 184, 166, 0.5);
    color: #fff;
}

.mobile-menu-toggle:hover,
.mobile-menu-toggle:focus,
.mobile-menu-toggle:active {
    background: rgba(20, 184, 166, 0.28);
    border-color: rgba(20, 184, 166, 0.7);
    color: #fff;
}

.topbar .dropdown-toggle {
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(148, 163, 184, 0.08);
    color: #f8fafc !important;
}

.topbar .dropdown-menu-dark {
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.28);
}

.topbar .dropdown-menu-dark .dropdown-item:hover,
.topbar .dropdown-menu-dark .dropdown-item:focus {
    background: rgba(20, 184, 166, 0.14);
    color: #e2fdf9 !important;
}

.sidebar {
    width: 260px;
    height: auto;
    max-height: none;
    overflow: visible;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--card-border);
    padding: 1rem 0.75rem;
    position: sticky;
    top: 72px;
    flex-shrink: 0;
}

.sidebar .brand-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--primary);
}

.sidebar-header {
    padding: 0.75rem 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 0.5rem;
}

.sidebar .nav-link {
    color: var(--text);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 500;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: var(--sidebar-accent);
    color: var(--primary);
}

.nav-group {
    margin-top: 0.25rem;
}

.nav-group-toggle {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    font-weight: 600;
    text-align: left;
}

.nav-group-toggle:hover,
.nav-group-toggle:focus {
    background: var(--sidebar-accent);
    color: var(--primary);
    outline: none;
}

.nav-group-toggle span {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-submenu {
    margin: 0.25rem 0 0.5rem 0.9rem;
    padding-left: 0.4rem;
    border-left: 1px solid var(--card-border);
}

.sub-nav-link {
    margin-top: 0.2rem;
    padding-left: 0.9rem;
    font-size: 0.95rem;
}

.nav-section {
    margin: 1rem 0.75rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.main-content {
    flex: 1;
    padding: 1.5rem;
}

.form-label {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
    text-align: left;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.modal-header {
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    color: #fff;
}

.modal-header .modal-title,
.modal-header .btn-close {
    color: #fff;
}

.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.page-header {
    margin-bottom: 1.25rem;
}

.card {
    border: 1px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.02);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
}

.stat-card {
    min-height: 126px;
    position: relative;
    overflow: hidden;
}

.stat-card .icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    background: linear-gradient(135deg, var(--teal-500), var(--blue-500));
}

.app-footer {
    background: linear-gradient(180deg, var(--footer-bg) 0%, #0b1220 100%);
    color: #e2e8f0;
    border-top: 1px solid var(--footer-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.app-footer a {
    color: #e2fdf9 !important;
    transition: color 0.2s ease;
}

.app-footer a:hover,
.app-footer a:focus {
    color: var(--teal-400) !important;
}

.app-footer hr {
    border-color: rgba(148, 163, 184, 0.15);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-posted {
    background: rgba(25, 135, 84, 0.12);
    color: var(--success);
}

.status-void {
    background: rgba(220, 53, 69, 0.12);
    color: var(--danger);
}

.status-low {
    background: rgba(255, 193, 7, 0.12);
    color: #9a6a00;
}

.status-out {
    background: rgba(220, 53, 69, 0.12);
    color: var(--danger);
}

.table-responsive {
    max-width: 100%;
}

.mobile-card-list {
    display: none;
}

.mobile-card-item {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.02);
}

.mobile-card-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid #eef2f7;
}

.mobile-card-line:last-child {
    border-bottom: none;
}

.mobile-card-label {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mobile-card-value {
    text-align: right;
    word-break: break-word;
}

.filter-form {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
}

.form-control, .form-select {
    border-radius: 10px;
}

.btn {
    border-radius: 10px;
}

.action-btns .btn {
    margin-right: 0.35rem;
    margin-bottom: 0.25rem;
}

.summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.summary-box {
    flex: 1 1 180px;
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
}

@media (max-width: 767.98px) {
    .mobile-menu-toggle {
        display: inline-flex !important;
        min-width: 48px;
        min-height: 48px;
        margin-top: 0;
        margin-bottom: 0;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 1040;
        height: auto;
        min-height: 72px;
        padding: 0.7rem 0.9rem;
    }

    .topbar-inner {
        gap: 0.5rem;
    }

    .topbar-brand-text {
        max-width: 38vw;
        font-size: 0.95rem;
    }

    .topbar-user-button {
        max-width: 42vw;
        padding: 0.45rem 0.65rem;
        font-size: 0.8rem;
    }

    .app-shell > .d-flex {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .offcanvas {
        top: 72px;
        height: calc(100vh - 72px);
    }

    .offcanvas .sidebar {
        display: block;
        width: 100%;
        min-height: auto;
        background: #f8fafc;
        border-right: none;
        padding: 0;
        box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
    }

    .offcanvas .sidebar .sidebar-header {
        padding: 1rem 1rem 0.9rem;
        background: linear-gradient(135deg, var(--navy-900) 0%, #111827 100%);
        color: #fff;
        border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    }

    .offcanvas .sidebar .sidebar-header small {
        color: rgba(255, 255, 255, 0.75);
    }

    .offcanvas .sidebar .brand-title {
        font-size: 1.2rem;
        color: #e2fdf9;
    }

    .offcanvas .sidebar nav {
        display: block;
        padding: 0.75rem 0.75rem 1rem;
    }

    .offcanvas .sidebar .nav-link,
    .offcanvas .sidebar .nav-group-toggle {
        min-height: 48px;
        padding: 0.8rem 0.85rem;
        font-size: 1rem;
        border-radius: 10px;
    }

    .offcanvas .sidebar .nav-link i,
    .offcanvas .sidebar .nav-group-toggle i {
        font-size: 1.05rem;
    }

    .offcanvas .sidebar .nav-submenu {
        margin: 0.4rem 0 0.5rem 0.7rem;
        padding-left: 0.5rem;
    }

    .offcanvas .sidebar .sub-nav-link {
        padding-left: 0.8rem;
        font-size: 0.96rem;
    }

    .offcanvas .sidebar .nav-link.text-danger {
        margin-top: 0.75rem;
    }

    .main-content {
        padding: 1rem;
    }

    .main-content .table-responsive > table.table[data-mobile-card="true"]:not(.report-table) {
        display: none !important;
    }

    .main-content .table-responsive > table.table[data-mobile-card="false"] {
        display: table !important;
    }

    .main-content .utilities-page .table-responsive > table.table:not(.report-table) {
        display: table !important;
    }

    .main-content .table-responsive:has(.report-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .main-content .report-table {
        min-width: 640px;
        width: 100%;
    }

    .main-content .mobile-card-list {
        display: block;
    }
}

@media (min-width: 768px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

@media print {
    .topbar, .sidebar, .btn, .offcanvas, .dropdown, .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .main-content {
        padding: 0;
    }
}
