/**
 * Purchase Management App - Styles
 * Extracted from inline styles for maintainability
 */

/* ============================================
   BASE STYLES
   ============================================ */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 0;
    margin: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   HEADER (Sticky, Two-Row Layout)
   ============================================ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
}

/* Row 1: Title + Settings */
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.header-top h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

/* Settings dropdown */
.settings-area { position: relative; }

.settings-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}
.settings-btn:hover { background: rgba(255,255,255,0.25); }

.settings-btn .avatar {
    width: 26px; height: 26px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.settings-btn .uname { font-weight: 600; }
.settings-btn .urole { font-size: 10px; opacity: 0.7; text-transform: uppercase; }
.settings-btn .caret { font-size: 10px; opacity: 0.7; margin-left: 2px; }

.settings-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 180px;
    overflow: hidden;
    z-index: 200;
}
.settings-dropdown.open { display: block; }

/* Shared dropdown item styles */
.dd-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    border: none; background: none; width: 100%; text-align: left;
    font-family: inherit;
}
.dd-item:hover { background: #f3f4f6; }
.dd-divider { height: 1px; background: #e5e7eb; }
.dd-item.danger { color: #dc2626; }
.dd-item .ico { font-size: 16px; width: 22px; text-align: center; }

/* Row 2: Nav buttons */
.header-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 7px 14px;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.25); }
.nav-btn.active {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
    font-weight: 600;
}

/* Create button with dropdown */
.create-area { position: relative; }

.create-btn {
    padding: 7px 16px;
    background: white;
    color: #667eea;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    display: flex; align-items: center; gap: 4px;
}
.create-btn:hover { background: #f0f0ff; }

.create-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    min-width: 200px;
    overflow: hidden;
    z-index: 200;
}
.create-dropdown.open { display: block; }

/* Hamburger (hidden on desktop) */
.hamburger-btn {
    display: none;
    padding: 6px 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

/* Mobile bottom nav (hidden on desktop) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    z-index: 100;
    padding: 4px 0;
}
.mobile-bottom-nav .mnav-items {
    display: flex;
    justify-content: center;
}
.mobile-bottom-nav .mnav-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 6px 4px;
    font-size: 10px;
    color: #6b7280;
    cursor: pointer;
    border: none; background: none;
    font-family: inherit;
    min-width: 56px;
}
.mobile-bottom-nav .mnav-item .mnav-icon { font-size: 18px; margin-bottom: 2px; }

/* Mobile create dropdown (opens upward from bottom bar) */
.mobile-create-dropdown {
    top: auto;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
}

/* Mobile nav overlay */
.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99;
}
.mobile-nav-overlay.open { display: block; }

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn-primary {
    background: white;
    color: #667eea;
}

.btn-primary:hover {
    background: #f8f9fa;
}

.btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

/* Confirm modal should appear on top of other modals */
#confirmModal {
    z-index: 2000;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 700px;
    margin: 40px auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9fafb;
    border-radius: 0 0 12px 12px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6b7280;
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
    color: #374151;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Remove scroll arrows from number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* ============================================
   ORDER CARDS
   ============================================ */

.order-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.order-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.order-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
}

.empty-state {
    background: white;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px dashed #d1d5db;
}

/* ============================================
   STATUS BADGES
   ============================================ */

.status-badge {
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: inline-block;
    margin-right: 6px;
}

.status-draft { background: #f3f4f6; color: #374151; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-sent { background: #dbeafe; color: #1e40af; }
.status-approved { background: #dcfce7; color: #166534; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-received { background: #e0e7ff; color: #3730a3; }

/* ============================================
   ITEM ROWS
   ============================================ */

.item-row {
    display: grid;
    grid-template-columns: 3fr 1fr 1fr 1.5fr 1fr 1.5fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}

.item-row input,
.item-row select {
    padding: 6px;
}

.item-total {
    padding: 6px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-align: right;
    line-height: 1.5;
}

.delete-item-btn {
    padding: 6px 10px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.delete-item-btn:hover {
    background: #b91c1c;
}

/* ============================================
   AUTOCOMPLETE
   ============================================ */

.autocomplete-suggestions {
    position: absolute;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.autocomplete-suggestion {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
}

.autocomplete-suggestion:hover {
    background: #f3f4f6;
}

.autocomplete-container {
    position: relative;
}

/* ============================================
   RECEIPT BADGES & HISTORY
   ============================================ */

.receipt-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.receipt-pending { background: #fef3c7; color: #92400e; }
.receipt-partial { background: #dbeafe; color: #1e40af; }
.receipt-complete { background: #dcfce7; color: #166534; }
.receipt-short-closed { background: #f3e8ff; color: #7c3aed; }

.receipt-item {
    background: #f9fafb;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.receipt-history {
    margin-top: 15px;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
}

.receipt-history-item {
    padding: 8px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================
   MODIFICATION HISTORY (AUDIT TRAIL)
   ============================================ */

.modification-history {
    margin-top: 10px;
    padding: 10px;
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: 4px;
    font-size: 12px;
}

.modification-entry {
    margin-bottom: 6px;
    padding: 6px;
    background: white;
    border-radius: 3px;
}

.change-old {
    color: #dc2626;
    text-decoration: line-through;
}

.change-new {
    color: #16a34a;
    font-weight: 500;
}

/* ============================================
   INVOICE BADGES
   ============================================ */

.invoice-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.invoice-none { background: #fef3c7; color: #92400e; }
.invoice-draft { background: #e5e7eb; color: #374151; }
.invoice-pending { background: #fef3c7; color: #92400e; }
.invoice-approved { background: #dcfce7; color: #166534; }
.invoice-rejected { background: #fee2e2; color: #991b1b; }

.discrepancy-alert {
    background: #fef2f2;
    border-left: 3px solid #dc2626;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================
   PAYMENT BADGES & HISTORY
   ============================================ */

.payment-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

.payment-unpaid { background: #fee2e2; color: #991b1b; }
.payment-partial { background: #fef3c7; color: #92400e; }
.payment-paid { background: #dcfce7; color: #166534; }

.payment-history {
    margin-top: 15px;
    padding: 15px;
    background: #f0fdf4;
    border-radius: 8px;
}

.payment-history-item {
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid #16a34a;
}

/* ============================================
   LOGIN & AUTHENTICATION
   ============================================ */

#login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    padding: 20px;
    overflow-y: auto;
}

#login-container.hidden { display: none; }

.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-logo { font-size: 48px; margin-bottom: 20px; }
.login-title { font-size: 24px; color: #1f2937; margin-bottom: 10px; }
.login-subtitle { color: #6b7280; margin-bottom: 30px; }

/* Demo Banner */
.demo-banner {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 20px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}
.demo-banner-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
}
.demo-credentials {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.demo-cred-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1.4;
    transition: background 0.2s;
    text-align: center;
}
.demo-cred-btn:hover {
    background: rgba(255,255,255,0.35);
}

/* Login Form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}
.login-input {
    padding: 12px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.login-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.login-btn {
    padding: 12px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.login-btn:hover {
    background: #1d4ed8;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
}

.login-pending {
    background: #fef3c7;
    color: #92400e;
    padding: 12px;
    border-radius: 8px;
    margin-top: 20px;
}

#app-container.hidden { display: none; }

/* User menu styles moved to settings dropdown in HEADER section above */

/* ============================================
   USER MANAGEMENT
   ============================================ */

.user-management-modal .modal-content { max-width: 800px; }

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th, .users-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.users-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.users-table tr:hover { background: #f9fafb; }

.role-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.role-admin { background: #fef2f2; color: #dc2626; }
.role-data_entry { background: #eff6ff; color: #2563eb; }
.role-verifier { background: #f0fdf4; color: #16a34a; }
.role-pending { background: #fefce8; color: #ca8a04; }

.status-active { background: #dcfce7; color: #16a34a; }
.status-inactive { background: #fee2e2; color: #dc2626; }

.role-select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 4px;
}

.action-btn.activate { background: #dcfce7; color: #16a34a; }
.action-btn.deactivate { background: #fee2e2; color: #dc2626; }

/* Category badges for autocomplete management */
.category-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.category-description { background: #dbeafe; color: #1d4ed8; }
.category-unit { background: #f3e8ff; color: #7c3aed; }
.category-vendor { background: #dcfce7; color: #16a34a; }
.category-project { background: #fef3c7; color: #b45309; }

.no-users {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-overlay.hidden { display: none; }

.loading-box {
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ============================================
   FILTER BAR
   ============================================ */

.filter-bar {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.filter-bar h3 {
    margin: 0 0 15px 0;
}

.filter-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    margin-bottom: 0;
}

.filter-group select {
    min-width: 150px;
    cursor: pointer;
    width: auto;
}

.filter-reset-btn {
    padding: 8px 16px;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    white-space: nowrap;
}

.filter-reset-btn:hover {
    background: #4b5563;
}

.filter-date-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
}

.filter-date-row > label {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0;
    white-space: nowrap;
}

.filter-export-btns {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.export-btn {
    padding: 8px 14px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    white-space: nowrap;
}

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

/* ============================================
   SECTION HEADERS (view title bars)
   ============================================ */

.section-header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.section-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.section-header-top h2 {
    margin: 0;
}

.section-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.section-header-actions button {
    font-family: inherit;
}

/* ============================================
   VENDOR TABLE / CARDS
   ============================================ */

.vendor-table-wrap {
    display: block;
}

.vendor-cards {
    display: none;
}

.vendor-card {
    background: white;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

.vendor-card-name {
    font-weight: 600;
    font-size: 15px;
    color: #1e293b;
    margin-bottom: 4px;
}

.vendor-card-contact {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 10px;
}

.vendor-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.vendor-card-stat {
    text-align: center;
    padding: 6px 4px;
    background: #f8fafc;
    border-radius: 6px;
}

.vendor-card-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #9ca3af;
    font-weight: 600;
    margin-bottom: 2px;
}

.vendor-card-stat-value {
    font-size: 14px;
    font-weight: 700;
}

.vendor-card-action {
    display: block;
    width: 100%;
    padding: 8px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    text-align: center;
}

.vendor-card-action:hover {
    background: #1d4ed8;
}

/* ============================================
   REPORT TABLE WRAPPER
   ============================================ */

.report-table-wrap {
    overflow: visible;
}

.report-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.report-table-wrap thead {
    position: sticky;
    top: 0;
    background: #f9fafb;
}

.report-table-wrap th {
    padding: 10px;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

.report-table-wrap td {
    padding: 10px;
}

.report-table-wrap tr {
    border-bottom: 1px solid #e5e7eb;
}

/* ============================================
   VENDOR LEDGER - MOBILE RESPONSIVE
   ============================================ */

/* Desktop defaults */
.mobile-ledger { display: none; }
.ledger-table { display: block; }
.mobile-toolbar { display: none; }
.desktop-toolbar { display: block; }

/* ===== MOBILE TOOLBAR ===== */
.m-toolbar {
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 10px;
    overflow: hidden;
}
.m-toolbar-head {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
}
.m-toolbar-back {
    background: none;
    border: none;
    color: #2563eb;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    flex-shrink: 0;
}
.m-toolbar-vendor { flex: 1; min-width: 0; }
.m-toolbar-vendor .m-vname {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-toolbar-vendor .m-vpath {
    font-size: 11px;
    color: #94a3b8;
}
.m-toolbar-vendor .m-vpath a {
    color: #2563eb;
    text-decoration: none;
}
.m-toolbar-csv {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    font-family: inherit;
}

/* Summary strip */
.m-toolbar-summary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border-top: 1px solid #f1f5f9;
}
.m-toolbar-summary .m-sum {
    padding: 8px 0;
    text-align: center;
    border-right: 1px solid #f1f5f9;
}
.m-toolbar-summary .m-sum:last-child { border-right: none; }
.m-toolbar-summary .m-sum-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
    margin-bottom: 2px;
}
.m-toolbar-summary .m-sum-value { font-size: 14px; font-weight: 700; }
.m-sum-value.debit { color: #e53e3e; }
.m-sum-value.credit { color: #38a169; }
.m-sum-value.balance { color: #d69e2e; }

/* Collapsible date filter */
.m-toolbar-filter { border-top: 1px solid #f1f5f9; }
.m-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 7px;
    background: #fafbfc;
    border: none;
    cursor: pointer;
    font-size: 11px;
    color: #6b7280;
    font-family: inherit;
    font-weight: 500;
}
.m-filter-toggle .m-filter-arrow {
    font-size: 8px;
    transition: transform 0.2s;
}
.m-filter-body { display: none; padding: 8px 12px 10px; }
.m-filter-body.open { display: block; }
.m-filter-body .m-filter-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.m-filter-body input[type="date"] {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    min-width: 0;
}
.m-filter-body .m-filter-sep {
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}
.m-filter-body .m-filter-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.m-filter-body .m-filter-actions button {
    flex: 1;
    padding: 6px;
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
}
.m-filter-apply { background: #2563eb; color: white; border: none; }
.m-filter-clear { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* ===== MOBILE LEDGER CARDS ===== */
.m-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-bottom: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.15s;
    border-left: 4px solid #e5e7eb;
}
.m-card:active { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.m-card.type-invoice { border-left-color: #e53e3e; }
.m-card.type-payment { border-left-color: #38a169; }
.m-card.type-advance { border-left-color: #805ad5; }
.m-card.type-pending { border-left-color: #d69e2e; background: #fffdf5; }
.m-card.type-draft { border-left-color: #6b7280; background: #fafafa; }
.m-card.type-rejected { border-left-color: #c53030; background: #fff8f8; }

.m-card-head {
    display: flex;
    align-items: center;
    padding: 10px 12px 0 12px;
    gap: 8px;
}
.m-card-head .m-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}
.m-badge-invoice { background: #fff5f5; color: #e53e3e; border: 1px solid #feb2b2; }
.m-badge-payment { background: #f0fff4; color: #38a169; border: 1px solid #9ae6b4; }
.m-badge-advance { background: #f5f3ff; color: #805ad5; border: 1px solid #ddd6fe; }
.m-badge-pending { background: #fffff0; color: #b7791f; border: 1px solid #fbd38d; }
.m-badge-draft { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }
.m-badge-rejected { background: #fff5f5; color: #c53030; border: 1px solid #feb2b2; }

.m-card-head .m-ref {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-card-head .m-chevron {
    width: 20px; height: 20px;
    border-radius: 4px;
    background: #f2f3f7;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px;
    color: #9ca3af;
    flex-shrink: 0;
    transition: all 0.15s;
}
.m-card.open .m-chevron { background: #667eea; color: white; }

.m-card-sub {
    padding: 2px 12px 0 12px;
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    gap: 6px;
    align-items: center;
}
.m-card-sub .m-po { color: #6b7280; }

.m-card-amounts {
    display: flex;
    padding: 8px 12px 10px 12px;
    gap: 8px;
    align-items: flex-end;
}
.m-card-amounts .m-amt { flex: 1; }
.m-card-amounts .m-amt-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #9ca3af;
    font-weight: 500;
    margin-bottom: 1px;
}
.m-card-amounts .m-amt-value { font-size: 16px; font-weight: 700; }
.m-amt-value.debit { color: #e53e3e; }
.m-amt-value.credit { color: #38a169; }
.m-amt-value.faded { opacity: 0.4; }

.m-card-amounts .m-bal { text-align: right; flex-shrink: 0; }
.m-card-amounts .m-bal-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #9ca3af;
    font-weight: 500;
    margin-bottom: 1px;
}
.m-card-amounts .m-bal-value { font-size: 14px; font-weight: 600; color: #d69e2e; }
.m-bal-value.dash { color: #d1d5db; }

/* Card expanded detail */
.m-card-detail {
    display: none;
    padding: 0 12px 10px 12px;
    border-top: 1px solid #f1f5f9;
}
.m-card.open .m-card-detail { display: block; }
.m-card-detail-inner {
    margin-top: 8px;
    padding: 10px;
    background: #fafbfc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    color: #6b7280;
}

/* Mobile total bar */
.m-total-bar {
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    border-top: 2px solid #667eea;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}
.m-total-item { text-align: center; flex: 1; }
.m-total-item .m-total-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #9ca3af;
    font-weight: 600;
    margin-bottom: 2px;
}
.m-total-item .m-total-value { font-size: 14px; font-weight: 700; }
.m-total-item .m-total-value.debit { color: #e53e3e; }
.m-total-item .m-total-value.credit { color: #38a169; }
.m-total-item .m-total-value.balance { color: #d69e2e; }

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 768px) {
    /* Header mobile */
    .header { padding: 10px 16px; }
    .header-top { margin-bottom: 0; }
    .header-top h1 { font-size: 16px; }
    .hamburger-btn { display: block; }
    .mobile-bottom-nav { display: block; }
    .settings-btn .uname, .settings-btn .urole { display: none; }
    .settings-btn .caret { display: none; }
    .settings-btn { padding: 4px; border: none; background: none; }
    .container { padding-bottom: 70px; }

    /* Mobile nav: slide-down menu panel */
    .header-nav { display: none; }
    .header-nav.mobile-open {
        display: block;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: white;
        box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        z-index: 150;
        padding: 6px 0;
        animation: mnavSlide 0.15s ease-out;
    }
    @keyframes mnavSlide {
        from { opacity: 0; transform: translateY(-6px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .header-nav.mobile-open .nav-btn {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 12px 20px;
        background: none;
        border: none;
        border-radius: 0;
        color: #374151;
        font-size: 14px;
        font-weight: 500;
        text-align: left;
        gap: 4px;
    }
    .header-nav.mobile-open .nav-btn:hover { background: #f3f4f6; }
    .header-nav.mobile-open .nav-btn.active {
        background: #f0f0ff;
        color: #667eea;
        font-weight: 600;
        border-left: 3px solid #667eea;
        padding-left: 17px;
    }
    .header-nav.mobile-open .create-area {
        border-top: 1px solid #e5e7eb;
        margin-top: 2px;
        padding-top: 2px;
    }
    .header-nav.mobile-open .create-btn {
        display: flex;
        align-items: center;
        width: 100%;
        padding: 12px 20px;
        background: none;
        border: none;
        border-radius: 0;
        color: #667eea;
        font-size: 14px;
        font-weight: 600;
        justify-content: flex-start;
        gap: 4px;
    }
    .header-nav.mobile-open .create-btn:hover { background: #f0f0ff; }
    .header-nav.mobile-open .create-dropdown {
        position: static;
        box-shadow: none;
        border-radius: 0;
        border-top: 1px solid #f3f4f6;
    }
    .header-nav.mobile-open .create-dropdown .dd-item {
        padding-left: 44px;
        font-size: 13px;
    }

    /* ===== FILTER BARS: stack vertically ===== */
    .filter-bar {
        padding: 15px;
    }
    .filter-bar h3 {
        margin: 0 0 10px 0;
        font-size: 15px;
    }
    .filter-row {
        flex-direction: column;
        gap: 10px;
    }
    .filter-group {
        width: 100%;
    }
    .filter-group label {
        min-width: 55px;
        font-size: 13px;
    }
    .filter-group select {
        flex: 1;
        min-width: 0;
        width: auto;
    }
    .filter-reset-btn {
        width: 100%;
        text-align: center;
    }
    .filter-date-row {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }
    .filter-export-btns {
        margin-left: 0;
        width: 100%;
    }
    .filter-export-btns .export-btn,
    .filter-export-btns button {
        flex: 1;
        text-align: center;
        font-size: 12px;
        padding: 8px 6px;
    }

    /* ===== SECTION HEADERS: stack on mobile ===== */
    .section-header {
        padding: 15px;
    }
    .section-header-top {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .section-header-top h2 {
        font-size: 18px;
    }
    .section-header-actions {
        width: 100%;
    }
    .section-header-actions button {
        flex: 1;
        text-align: center;
        font-size: 13px;
        padding: 10px 8px;
    }

    /* ===== ORDER/INVOICE/PAYMENT CARDS: compact layout ===== */
    .order-card {
        padding: 14px;
        margin-bottom: 10px;
    }
    .order-header {
        flex-direction: column;
        gap: 10px;
    }
    /* Smaller badges on mobile */
    .status-badge,
    .receipt-badge,
    .invoice-badge,
    .payment-badge {
        padding: 3px 8px;
        font-size: 10px;
        margin-right: 2px;
    }

    /* ===== VENDORS: table -> cards ===== */
    .vendor-table-wrap {
        display: none !important;
    }
    .vendor-cards {
        display: block !important;
    }

    /* ===== REPORT TABLES: horizontal scroll ===== */
    .report-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    .report-table-wrap table {
        min-width: 500px;
    }

    /* ===== MODALS: full width on mobile ===== */
    .modal {
        padding: 10px;
    }
    .modal-content {
        margin: 10px auto;
        max-width: 100%;
    }
    .modal-header, .modal-body, .modal-footer {
        padding: 15px;
    }
    .form-row {
        grid-template-columns: 1fr;
    }

    /* ===== ITEM ROWS: stack on mobile ===== */
    .item-row {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 10px;
        background: #f9fafb;
        border-radius: 6px;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
    }

    /* ===== STATS GRID in reports ===== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* ===== ORDER/INVOICE DETAILS: prevent overflow ===== */
    .order-card p {
        word-break: break-word;
    }

    /* Vendor ledger mobile */
    .ledger-table { display: none; }
    .mobile-ledger { display: block; }
    .mobile-toolbar { display: block; }
    .desktop-toolbar { display: none; }
}
