:root {
    --primary: #0052CC;
    --primary-hover: #0041a3;
    --bg-main: #F4F5F7;
    --bg-card: #FFFFFF;
    --sidebar-bg: #FFFFFF;
    --border-color: #DFE1E6;
    --text-main: #172B4D;
    --text-muted: #6B778C;
    --success: #36B37E;
    --warning: #FFAB00;
    --danger: #FF5630;
    --sidebar-width: 260px;
    --navbar-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.nav-item:hover, .nav-item.active {
    background-color: #EBECF0;
    color: var(--primary);
}

.nav-item.active {
    background-color: #DEEBFF;
    color: var(--primary);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #FF5630;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-navbar {
    height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    margin-right: 0.5rem;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding-left: 1rem;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.breadcrumb-sep {
    width: 14px;
    height: 14px;
    color: var(--border-color);
}

.breadcrumb .current {
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
}

.top-navbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-wrapper {
    position: relative;
    width: 320px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.search-wrapper input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    background: var(--bg-main);
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}

.search-wrapper input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 82, 204, 0.05);
    outline: none;
}

.navbar-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

.header-tools {
    display: flex;
    gap: 0.25rem;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border: 2px solid white;
    border-radius: 50%;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.header-profile:hover {
    background: var(--bg-main);
}

.profile-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, #00b4d8 100%);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

/* Content Area */
.content-wrapper {
    padding: 2rem;
}

/* Stats Grid */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue { background: #DEEBFF; color: #0052CC; }
.stat-icon.green { background: #E3FCEF; color: #006644; }
.stat-icon.orange { background: #FFFAE6; color: #FF8B00; }

.stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

/* Data Table section */
.table-container {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.table-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
}

.table-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-title p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.table-actions {
    display: flex;
    gap: 0.8rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: filter 0.2s;
    border: 1px solid transparent;
}

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

.btn-secondary {
    background: white;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn:hover {
    filter: brightness(0.9);
}

/* Table Card */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: #F4F5F7;
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table td {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.data-table tr:hover {
    background-color: #F9FAFB;
}

/* Status Badge */
.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #E3FCEF; color: #006644; }
.badge-info { background: #DEEBFF; color: #0052CC; }

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(9, 30, 66, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    padding: 2rem;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
}

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

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-group input {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    font-size: 0.95rem;
}

.form-group input:focus {
    border-color: var(--primary);
}

.form-input[type="file"] {
    background: #F4F5F7;
    padding: 0.5rem;
    cursor: pointer;
}

.form-input[type="file"]::-webkit-file-upload-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    margin-right: 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Custom Switch */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.8rem;
    background: #F4F5F7;
    border-radius: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { display: none; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #B3BAC5;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    background: #172B4D;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.hidden { display: none !important; }

.empty-state {
    padding: 4rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.text-right { text-align: right; }
.btn-delete-link {
    background: none;
    border: none;
    color: var(--danger);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
}

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

/* Branch Manager Header */
.section-header-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.btn-back {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-back:hover {
    background: #EBECF0;
}

/* Form Elements Enhancement */
textarea {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}

textarea:focus {
    border-color: var(--primary);
}

.form-select {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    font-size: 0.95rem;
    background: white;
}

/* Company Table Row Interaction */
.clickable-row {
    cursor: pointer;
}

.btn-menu {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-main);
    align-items: center;
    justify-content: center;
}

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

.sidebar-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 95;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Responsive Styles */
@media screen and (max-width: 992px) {
    .search-box {
        width: 200px;
    }
}

@media screen and (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        height: 100vh;
        transition: left 0.3s ease;
        box-shadow: 10px 0 20px rgba(0,0,0,0.1);
    }

    .sidebar.mobile-active {
        left: 0;
    }

    .btn-menu {
        display: flex;
    }

    .breadcrumb {
        display: none; /* Hide breadcrumb on mobile to save space */
    }

    .content-wrapper {
        padding: 1rem;
    }

    .stats-overview {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .top-navbar {
        padding: 0 1rem;
    }

    .search-box {
        width: 150px;
    }

    .top-navbar-actions {
        gap: 0.8rem;
    }

    .table-header {
        flex-direction: column;
        gap: 1rem;
    }

    .table-actions {
        width: 100%;
        justify-content: flex-start;
    }

    /* Horizontal scroll for table */
    .table-card {
        width: 100%;
        overflow-x: auto;
    }

    .data-table {
        min-width: 700px; /* Ensure table has enough width to scroll */
    }

    .modal {
        padding: 1.5rem;
        margin: 1rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

@media screen and (max-width: 480px) {
    .search-box {
        display: none; /* Hide search box on very small screens or use a toggle */
    }
    
}

/* Searchable Select Component */
.ss-container {
    position: relative;
    width: 100%;
}

.ss-input {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    outline: none;
    font-size: 0.95rem;
    background: white;
    transition: all 0.2s;
}

.ss-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

.ss-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 999;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}

.ss-dropdown.active {
    display: block;
}

.ss-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.1s;
}

.ss-option:hover {
    background: #f4f5f7;
    color: var(--primary);
}

.ss-option.selected {
    background: var(--primary);
    color: white;
}

.ss-no-results {
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Form Layouts */
.order-form-container {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
}

.form-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    /* overflow: hidden; Removed to prevent dropdown clipping */
}

.form-card-header {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
}

.form-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.form-card-body {
    padding: 1.5rem;
}

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

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

.form-input {
    width: 100%;
    padding: 0.7rem;
    border: 1px solid #1a1a1a;
    border-radius: 6px;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
}

.product-add-row {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
}

.flex-grow { flex-grow: 1; }

.order-totals-footer {
    display: flex;
    justify-content: flex-end;
}

.totals-card {
    background: white;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 10px;
    min-width: 350px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.total-row.grand {
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn-block { width: 100%; }

@media screen and (max-width: 992px) {
    .grid-3 { grid-template-columns: 1fr; }
    .product-add-row { flex-direction: column; align-items: stretch; }
    .totals-card { min-width: 100%; }
}

/* Order Matrix Styles */
.order-matrix-container {
    padding: 1.5rem;
    overflow-x: auto;
}

.matrix-table {
    border-collapse: collapse;
    width: auto;
    min-width: 100%;
}

.matrix-table th, .matrix-table td {
    border: 1px solid #1a1a1a; /* Thin black borders */
    padding: 0;
    font-size: 0.85rem;
    position: relative;
}

.matrix-table th {
    background: #f8f9fa;
    padding: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

/* Sticky First Column (Product Name) */
.matrix-table th:first-child, 
.matrix-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    min-width: 200px;
    padding: 0.75rem;
    text-align: left;
    border-right: 2px solid #1a1a1a;
}

.matrix-table th:first-child {
    background: #f8f9fa;
    z-index: 3;
}

.matrix-table td:last-child,
.matrix-table th:last-child {
    background: #fcfcfc;
    font-weight: 700;
    border-left: 2px solid #1a1a1a;
}

.matrix-table tr:hover td {
    background-color: #f0f7ff !important; /* Light blue highlight */
}

.matrix-input {
    width: 100%;
    border: none;
    padding: 0.75rem;
    text-align: center;
    background: transparent;
    outline: none;
    font-size: 0.95rem;
}

.matrix-input:focus {
    background: #fffbe6;
}

/* Chrome, Safari, Edge, Opera */
.matrix-input::-webkit-outer-spin-button,
.matrix-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
.matrix-input[type=number] {
  -moz-appearance: textfield;
}

.matrix-stats-bar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-bottom: 2px solid #0052cc;
    position: sticky;
    top: 0;
    z-index: 10;
}

.m-stat {
    font-size: 0.9rem;
}

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

.m-stat strong {
    font-size: 1.1rem;
    margin-left: 0.5rem;
    color: var(--primary);
}

.matrix-empty-state {
    padding: 6rem;
    text-align: center;
    color: var(--text-muted);
}

.matrix-empty-state i {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

/* ===== SETTINGS PAGE ===== */
.text-muted { color: var(--text-muted); }
small.text-muted { font-size: 0.80rem; display: block; margin-top: 0.35rem; }
.mt-1 { margin-top: 1rem; }
.modal-footer { margin-top: 1.5rem; display: flex; gap: 1rem; justify-content: flex-end; }
.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 0.25rem;
}

/* ===== INVOICE MODAL ===== */
.modal-xl {
    max-width: 860px !important;
    width: 95%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 12px;
    padding: 0 !important;
}

.modal-xl .modal-header {
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 12px 12px 0 0;
}

.invoice-body {
    padding: 2.5rem;
}

/* --- Invoice Document Itself --- */
.invoice-doc {
    font-family: 'Inter', sans-serif;
    color: #1a1a2e;
    font-size: 0.9rem;
    line-height: 1.6;
}

.invoice-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 1.5rem;
    border-bottom: 3px solid var(--primary);
    margin-bottom: 2rem;
}

.invoice-brand .biz-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 0.5rem;
    border-radius: 6px;
}

.invoice-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.invoice-brand p {
    font-size: 0.82rem;
    color: #6B778C;
    margin-top: 0.1rem;
}

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

.invoice-meta h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.invoice-meta .inv-badge {
    display: inline-block;
    background: #DEEBFF;
    color: var(--primary);
    border-radius: 4px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.invoice-meta p { font-size: 0.85rem; color: #6B778C; }
.invoice-meta strong { color: #172B4D; }

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.invoice-party h4 {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid #DEEBFF;
}

.invoice-party p { font-size: 0.88rem; line-height: 1.7; }
.invoice-party strong { display: block; font-size: 1rem; color: #172B4D; }

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

.invoice-table thead tr {
    background: var(--primary);
    color: white;
}

.invoice-table th {
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
}

.invoice-table th.text-right,
.invoice-table td.text-right { text-align: right; }
.invoice-table th.text-center,
.invoice-table td.text-center { text-align: center; }

.invoice-table tbody tr:nth-child(even) { background: #F4F5F7; }
.invoice-table tbody tr:nth-child(odd) { background: #FFFFFF; }

.invoice-table td {
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
    border-bottom: 1px solid #DFE1E6;
}

.invoice-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 2rem;
}

.invoice-totals-box {
    min-width: 300px;
}

.inv-total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.88rem;
    color: #6B778C;
}

.inv-total-row.grand {
    border-top: 2px solid var(--primary);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.invoice-footer {
    border-top: 1px solid #DFE1E6;
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.82rem;
    color: #6B778C;
}

.inv-sig-line {
    border-top: 1px solid #aaa;
    width: 180px;
    margin-bottom: 0.25rem;
}

/* ===== PRINT STYLES ===== */
@media print {
    /* Allow full page height — remove any scroll clipping */
    html, body {
        height: auto !important;
        overflow: visible !important;
    }

    /* Hide EVERYTHING on the page */
    body * {
        visibility: hidden !important;
    }

    /* Unhide the modal containers so they don't clip */
    #invoice-modal-backdrop,
    #invoice-modal-backdrop > *,
    .modal-xl,
    .invoice-body {
        visibility: visible !important;
        max-height: none !important;
        overflow: visible !important;
        position: static !important;
        background: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Then show ONLY the invoice render area and all its children */
    #invoice-render-area,
    #invoice-render-area * {
        visibility: visible !important;
    }

    /* Position invoice at the very top-left of the printed page */
    #invoice-render-area {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure invoice borders/colors print correctly */
    .rss-invoice {
        border: 2px solid #000 !important;
        font-size: 9pt !important;
    }

    .rss-items th,
    .rss-items td,
    .rss-slab th,
    .rss-slab td {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Page margins */
    @page {
        margin: 10mm;
    }
}



/* ═══════════════════════════════════════════════
   RSS RADHIKA STATIONERY INVOICE FORMAT
═══════════════════════════════════════════════ */

.rss-invoice {
    border: 2px solid #000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.65rem;
    color: #000;
    background: #fff;
}

/* Each page is a self-contained invoice block */
.rss-page {
    border: 2px solid #000;
    margin-bottom: 1.5rem;
    background: #fff;
}

/* Force a new printed page before every page except the first */
.rss-page-break {
    page-break-after: always;
    margin-bottom: 0;
}

/* Keep the entire footer block (tax slab + words + declaration) together — never split */
.rss-nobreak {
    page-break-inside: avoid;
    break-inside: avoid;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 8mm;
    }
    .rss-page-break {
        page-break-after: always;
    }
    .rss-nobreak {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

/* ── HEADER ── */
.rss-header {
    border-bottom: 1px solid #000;
    width: 100%;
}

.rss-header-banner {
    width: 100%;
    height: auto;
    display: block;
}

/* ── GSTIN ROW ── */
.rss-gstin-row {
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid #000;
    font-size: 0.65rem;
    background: #fafafa;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── INVOICE META ROW (formerly transport row) ── */
.rss-transport {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #000;
}

.rss-tc {
    padding: 0.35rem 0.75rem;
    font-size: 0.62rem;
    border-right: 1px solid #000;
}

.rss-tc:last-child {
    border-right: none;
}

/* ── BILL TO ── */
.rss-bill-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #000;
}

.rss-bill-left {
    padding: 0.5rem 0.9rem;
    border-right: 1px solid #000;
    font-size: 0.65rem;
    line-height: 1.65;
}

.rss-bill-right {
    padding: 0.5rem 0.9rem;
    font-size: 0.65rem;
    line-height: 1.65;
}

.rss-bill-hd {
    font-weight: 700;
    text-decoration: underline;
    margin-bottom: 0.2rem;
}

/* ── ITEMS TABLE ── */
.rss-items {
    width: 100%;
    border-collapse: collapse;
    border-bottom: 2px solid #000;
}

.rss-items thead tr {
    background: #f0f0f0;
}

.rss-items th {
    border: 1px solid #555;
    padding: 0.3rem 0.35rem;
    text-align: center;
    font-size: 0.60rem;
    font-weight: 700;
    line-height: 1.2;
    vertical-align: middle;
}

.rss-items .rss-desc {
    text-align: left;
    min-width: 150px;
}

.rss-items td {
    border: 1px solid #aaa;
    padding: 0.3rem 0.35rem;
    font-size: 0.62rem;
    vertical-align: middle;
}

.rss-items td.c { text-align: center; }
.rss-items td.r { text-align: right; }

.rss-empty td {
    height: 18px;
    border-left: 1px solid #aaa;
    border-right: 1px solid #aaa;
    border-top: none;
    border-bottom: none;
}

.rss-items-foot {
    background: #f8f8f8;
    border-top: 2px solid #000;
}

.rss-items-foot td {
    border: 1px solid #555;
    font-weight: 700;
    font-size: 0.62rem;
}

/* ── BOTTOM: TAX SLAB + SUMMARY ── */
.rss-bottom {
    display: grid;
    grid-template-columns: 1fr 210px;
    border-bottom: 1px solid #000;
    page-break-inside: avoid;
    break-inside: avoid;
}

.rss-slab-wrap {
    border-right: 1px solid #000;
}

.rss-slab {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.60rem;
}

.rss-slab th,
.rss-slab td {
    border: 1px solid #aaa;
    padding: 0.25rem 0.4rem;
    text-align: right;
}

.rss-slab th:first-child,
.rss-slab td:first-child {
    text-align: left;
    font-weight: 700;
}

.rss-slab thead th {
    background: #f0f0f0;
    font-size: 0.58rem;
}

.rss-slab tfoot td {
    background: #f0f0f0;
    font-weight: 700;
    border-top: 2px solid #000;
}

/* Summary box */
.rss-summary {
    padding: 0.5rem 0.6rem;
    font-size: 0.62rem;
}

.rss-sr {
    display: flex;
    justify-content: space-between;
    padding: 0.18rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.rss-grand {
    border-top: 2px solid #000;
    margin-top: 0.25rem;
    padding-top: 0.35rem;
    font-weight: 700;
    font-size: 0.68rem;
    border-bottom: none;
}

.rss-sr-bold {
    font-weight: 700;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 0.25rem 0;
}

/* ── AMOUNT IN WORDS ── */
.rss-words {
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid #000;
    font-size: 0.65rem;
    background: #fafafa;
    line-height: 1.5;
    page-break-inside: avoid;
    break-inside: avoid;
}

/* ── FOOTER ── */
.rss-footer {
    display: grid;
    grid-template-columns: 1fr 210px;
    min-height: 90px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.rss-declaration {
    padding: 0.65rem 0.9rem;
    border-right: 1px solid #000;
    font-size: 0.58rem;
    color: #333;
    line-height: 1.5;
}

.rss-sig-box {
    padding: 0.65rem 0.9rem;
    font-size: 0.65rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.rss-sig-space {
    flex-grow: 1;
    min-height: 45px;
}
/* Matrix Branch Selector */
.branch-checkbox-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.branch-checkbox-pill:hover {
    background: #e5e7eb;
}

.branch-checkbox-pill input {
    cursor: pointer;
}

.branch-checkbox-pill input:checked + span {
    font-weight: 600;
    color: var(--primary);
}

.branch-checkbox-pill:has(input:checked) {
    background: #eff6ff;
    border-color: #bfdbfe;
}
/* Status Select Colors */
.status-select {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
}

.status-select:focus {
    box-shadow: 0 0 0 2px rgba(0,0,0,0.05);
}

.status-select.status-created {
    background-color: #DEEBFF;
    color: #0052CC;
    border-color: #B3D4FF;
}

.status-select.status-delivered {
    background-color: #FFF0B3;
    color: #825c00;
    border-color: #FFE380;
}

.status-select.status-done {
    background-color: #E3FCEF;
    color: #006644;
    border-color: #ABF5D1;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    margin-top: 2rem;
}

.dashboard-side-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.alert-list, .branch-summary-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    background: #fff5f5;
    border-left: 4px solid #fc8181;
    border-radius: 4px;
}

.alert-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #c53030;
}

.alert-info span {
    font-size: 0.75rem;
    color: #e53e3e;
}

.alert-qty {
    font-weight: 700;
    color: #c53030;
}

.branch-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

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

.branch-name-small {
    font-weight: 600;
    font-size: 0.9rem;
}

.branch-client-small {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.branch-metric {
    font-weight: 600;
    color: var(--primary);
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Chat & Order Component */
.chat-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    height: calc(100vh - 180px);
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-main {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.system-message .avatar { background: #e0e7ff; color: #4338ca; }
.user-message .avatar { background: #fee2e2; color: #b91c1c; }

.msg-content {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.system-message .msg-content {
    background: white;
    border: 1px solid var(--border-color);
    border-top-left-radius: 0;
}

.user-message .msg-content {
    background: var(--primary);
    color: white;
    border-top-right-radius: 0;
}

.chat-input-area {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

.chat-tools {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.tool-btn {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #edf2f7;
    color: var(--primary);
}

.input-wrapper {
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    min-height: 48px;
    max-height: 150px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.input-wrapper textarea:focus {
    border-color: var(--primary);
}

.send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

/* Preview Panel */
.chat-preview-panel {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    height: 100%;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.preview-header h3 {
    font-size: 1rem;
    font-weight: 700;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.preview-empty {
    margin-top: 4rem;
    text-align: center;
    color: var(--text-muted);
}

.preview-empty i {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.preview-item {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #f8fafc;
}

.p-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.p-name { font-weight: 600; font-size: 0.9rem; }
.p-qty { color: var(--primary); font-weight: 700; }
.p-branch { font-size: 0.75rem; color: var(--text-muted); display: block; }
.p-price { font-size: 0.85rem; color: var(--text-main); font-weight: 600; text-align: right; margin-top: 0.3rem; }

.preview-footer {
    padding-top: 1.5rem;
    border-top: 2px dashed var(--border-color);
}

.preview-total-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.preview-total-info strong {
    font-size: 1.25rem;
    color: var(--primary);
}

/* Spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 992px) {
    .chat-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    .chat-preview-panel {
        border-top: 1px solid var(--border-color);
    }
}


/* --- AUTH SCREEN --- */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0052cc 0%, #6b778c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000; /* Over everything */
    padding: 1rem;
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
    position: relative;
    overflow: hidden;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .logo-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border-radius: 12px;
    font-size: 1.5rem;
}

.auth-header h2 {
    font-size: 1.75rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

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

.auth-tab-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab-btn {
    flex: 1;
    padding: 0.8rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.auth-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.auth-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

.auth-submit-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.auth-submit-btn:hover {
    background: var(--primary-hover);
}

.auth-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.history-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-col {
    flex: 1;
    min-width: 180px;
}

.filter-col label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.p-4 { padding: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-2 { margin-top: 2rem; }

/* Scrollers for Dashboard */
.alert-list, .branch-summary-list {
    max-height: 400px;
    overflow-y: auto;
}

/* Custom Scrollbar for sleek look */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #DFE1E6;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #B3BAC5;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }

    .btn-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #sidebar-close-btn {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        background: white;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-body {
        width: 100%;
        min-width: 100%;
    }

    .top-navbar {
        padding: 0 1rem;
    }

    .breadcrumb {
        display: none; /* Hide breadcrumb on mobile to save space */
    }

    .search-wrapper {
        max-width: 150px;
    }

    .stats-row {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 1rem auto;
        padding: 1.5rem;
    }

    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 600px;
    }

    .history-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-col {
        width: 100%;
    }

    /* Adjust Order Matrix for mobile */
    .order-matrix-container {
        overflow-x: auto;
    }

    .order-matrix {
        min-width: 800px;
    }

    .matrix-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .matrix-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .top-navbar-actions .search-wrapper {
        display: none; /* Hide search on very small screens */
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .header-actions .btn {
        width: 100%;
    }
}

.hidden {
    display: none !important;
}
