/* ========== ROOT & GENERAL STYLES ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-light: #64748b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
}

/* ========== APP LAYOUT ========== */
#app {
    display: flex;
    height: 100vh;
    background-color: var(--bg-color);
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 280px;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.logo {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.brand-logo {
    display: block;
    width: 150px;
    height: 90px;
    object-fit: contain;
    margin: 0 auto 12px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.logo p {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    overflow-y: auto;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-group-title {
    margin: 4px 12px;
    color: var(--text-light);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.nav-item {
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: left;
}

.nav-item:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
}

.hidden {
    display: none !important;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.logout-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: #fee2e2;
    color: var(--danger-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background-color: #fecaca;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.header-left h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 32px;
}

.datetime {
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 500;
    color: var(--text-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* ========== PAGES CONTAINER ========== */
.pages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== DASHBOARD ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.dashboard-summary-section {
    margin-bottom: 28px;
}

.dashboard-summary-section > h3 {
    margin-bottom: 14px;
    font-size: 18px;
    font-weight: 700;
}

.inventory-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.revenue-summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.rental-summary-grid {
    grid-template-columns: minmax(250px, 1fr);
    max-width: 520px;
}

.stat-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.stat-icon {
    font-size: 32px;
}

.stat-content h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-light);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-detail {
    margin-top: 4px;
    color: var(--text-light);
    font-size: 13px;
}

.dashboard-content {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.dashboard-section {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.dashboard-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ========== CONTENT HEADER ========== */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-header h3 {
    font-size: 24px;
    font-weight: 700;
}

.content-header-actions {
    display: flex;
    gap: 12px;
}

.content-header-actions .search-input {
    min-width: 200px;
}

.clickable-rental-row {
    cursor: pointer;
}

.table-link {
    border: 0;
    padding: 0;
    background: none;
    color: var(--primary-color);
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.rental-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0 16px;
}

/* ========== FORMS ========== */
.form-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 900px;
    margin: 0 auto;
}

.form-container h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-row.full-width {
    grid-template-columns: 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.rental-marketing-input {
    display: flex;
    gap: 8px;
}

.rental-marketing-input input {
    flex: 1;
    min-width: 0;
}

.rental-marketing-input button {
    flex: 0 0 auto;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-light);
    font-size: 12px;
    line-height: 1.4;
}

.form-hint-error {
    color: var(--danger-color);
}

.guarantee-documents-section {
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-color);
}

.guarantee-documents-section h4 {
    margin-bottom: 6px;
}

.guarantee-documents-section .form-row {
    margin-top: 14px;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #15803d;
}

/* ========== TABLES ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin: 12px 0 20px;
}

.table-container .table {
    min-width: 640px;
}

.table thead {
    background-color: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
}

.table th {
    padding: 16px;
    text-align: left;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-color);
}

.table-sort-button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: inherit;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.table-sort-button:hover,
.table-sort-button:focus-visible {
    color: var(--primary-color);
}

.table-sort-button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
    border-radius: 2px;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions .btn {
    padding: 8px 12px;
    font-size: 12px;
}

.btn-delete-action {
    white-space: nowrap;
}

.inventory-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
}

.rental-sales-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.rental-sales-table-wrap .table {
    min-width: 1500px;
}

.clickable-vehicle-row {
    cursor: pointer;
}

.clickable-vehicle-row:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.vehicle-detail-modal-content {
    max-width: 760px;
}

.vehicle-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 16px;
}

.vehicle-detail-actions {
    justify-content: flex-end;
}

.customer-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
}

.customer-table-wrap .table {
    min-width: 800px;
}

.customer-table-wrap .table th:first-child,
.customer-table-wrap .table td:first-child {
    width: 260px;
    min-width: 260px;
    white-space: nowrap;
}

.clickable-customer-row {
    cursor: pointer;
}

.clickable-customer-row:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

.customer-detail-modal-content {
    max-width: 700px;
}

.customer-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0 16px;
}

.customer-document-history {
    margin-top: 16px;
}

.customer-detail-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
}

.customer-detail-actions > .table-actions {
    margin-right: auto;
}

.inventory-table {
    width: 100%;
    table-layout: fixed;
}

.inventory-table th,
.inventory-table td {
    padding: 12px 8px;
    overflow-wrap: normal;
}

.inventory-table th:nth-child(1) { width: 8%; }
.inventory-table th:nth-child(2) { width: 9%; }
.inventory-table th:nth-child(3) { width: 11%; }
.inventory-table th:nth-child(4) { width: 7%; }
.inventory-table th:nth-child(5) { width: 9%; }
.inventory-table th:nth-child(6) { width: 10%; }
.inventory-table th:nth-child(7) { width: 5%; }
.inventory-table th:nth-child(8) { width: 10%; }
.inventory-table th:nth-child(9) { width: 8%; }
.inventory-table th:nth-child(10) { width: 8%; }
.inventory-table th:nth-child(11) { width: 8%; }
.inventory-table th:nth-child(12) { width: 7%; }

.inventory-table th:last-child {
    text-align: center;
}

.inventory-table .inventory-actions-cell {
    padding: 10px 6px;
}

.inventory-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.inventory-action-btn {
    width: 100%;
    min-height: 34px;
    padding: 7px 6px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.25;
    white-space: normal;
}

.inventory-action-edit {
    background-color: var(--primary-color);
    color: #fff;
}

.inventory-action-edit:hover {
    background-color: var(--primary-hover);
}

.inventory-action-maintenance {
    background-color: #fef3c7;
    color: #92400e;
}

.inventory-action-maintenance:hover {
    background-color: #fde68a;
}

.inventory-action-available {
    background-color: #dcfce7;
    color: #166534;
}

.inventory-action-available:hover {
    background-color: #bbf7d0;
}

.inventory-action-deactivate {
    background-color: #e2e8f0;
    color: #475569;
}

.inventory-action-deactivate:hover {
    background-color: #cbd5e1;
}

.inventory-action-delete {
    background-color: var(--danger-color);
    color: #fff;
}

.inventory-action-delete:hover {
    background-color: #b91c1c;
}

.inventory-action-disabled,
.inventory-action-disabled:hover {
    background-color: #e2e8f0;
    color: #475569;
    cursor: not-allowed;
}

.table tbody tr:hover {
    background-color: var(--bg-color);
}

.text-center {
    text-align: center;
    color: var(--text-light);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background-color: #dcfce7;
    color: var(--success-color);
}

.status-pending {
    background-color: #fef3c7;
    color: #d97706;
}

.status-completed {
    background-color: #dbeafe;
    color: var(--primary-color);
}

.status-maintenance {
    background-color: #fecaca;
    color: var(--danger-color);
}

.status-inactive {
    background-color: #e2e8f0;
    color: #475569;
}

/* ========== MODALS ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.payment-history {
    margin: 16px 0;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.payment-history h4 {
    margin-bottom: 8px;
}

.payment-history ul {
    max-height: 140px;
    overflow-y: auto;
    padding-left: 20px;
}

.payment-history li {
    margin: 6px 0;
    font-size: 13px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: var(--text-color);
}

/* ========== INFO BOX ========== */
.info-box {
    background-color: var(--bg-color);
    border-left: 4px solid var(--primary-color);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.info-box p {
    margin-bottom: 8px;
    font-size: 14px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

/* ========== SEARCH & FILTER ========== */
.search-input,
.filter-select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
}

.search-input {
    margin-bottom: 24px;
    width: 100%;
    max-width: 300px;
}

.filter-section {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.filter-section input,
.filter-section select {
    flex: 1;
}

/* ========== REPORTS ========== */
.reports-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.report-filters {
    background-color: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 32px;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.report-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.report-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    opacity: 0.9;
}

.report-value {
    font-size: 28px;
    font-weight: 700;
}

.report-section {
    background-color: var(--bg-color);
    padding: 24px;
    border-radius: 8px;
    margin-top: 24px;
}

.report-section h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
}

.report-period {
    color: var(--text-light);
    margin-bottom: 20px;
}

.report-total-row {
    border-top: 2px solid var(--border-color);
    font-weight: 700;
}

.rental-sales-report-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.rental-sales-report-heading h4 {
    margin-bottom: 0;
}

.rental-sales-screen-total {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.rental-sales-screen-total table {
    width: min(100%, 420px);
    border-collapse: collapse;
}

.rental-sales-screen-total td {
    padding: 8px 12px;
}

.rental-sales-screen-total td:last-child {
    text-align: right;
    white-space: nowrap;
}

.accounting-report-print-layout {
    display: none;
}

.report-summary {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 16px;
}

.report-balance-status {
    margin-top: 16px;
    font-weight: 600;
}

.report-balance-status.balanced {
    color: var(--success-color);
}

.report-balance-status.unbalanced {
    color: var(--danger-color);
}

/* ========== SETTINGS ========== */
.settings-container {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 600px;
}

.settings-section {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section h4 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.button-group .btn {
    width: 100%;
}

.balance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.finance-forms-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin-bottom: 24px;
    padding: 24px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.finance-forms-grid .settings-section {
    margin: 0;
    padding: 0 20px 0 0;
    border: 0;
}

.finance-forms-grid .settings-section + .settings-section {
    padding: 0 0 0 20px;
    border-left: 1px solid var(--border-color);
}

.finance-forms-grid .settings-section h4 {
    margin-bottom: 12px;
}

.finance-forms-grid .form-row {
    gap: 12px;
}

/* ========== RESPONSIVE DESIGN ========== */
.ledger-totals-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.ledger-account-balances {
    margin-top: 24px;
}

.ledger-account-balances .content-header {
    align-items: baseline;
}

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .pages-container {
        padding: 20px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    #app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 42vh;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        overflow: hidden;
    }

    .logo {
        padding: 8px 16px;
        border-bottom: none;
        display: flex;
        align-items: center;
        text-align: left;
        flex-shrink: 0;
    }

    .brand-logo {
        width: 42px;
        height: 38px;
        margin: 0 6px 0 0;
    }

    .logo h1 {
        font-size: 18px;
    }

    .nav-menu {
        flex-direction: column;
        gap: 10px;
        padding: 8px 12px;
        flex: initial;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .nav-group {
        gap: 2px;
    }

    .nav-group-title {
        margin: 4px 8px;
    }

    .nav-item {
        flex-shrink: 0;
    }

    .sidebar-footer {
        padding: 8px 12px;
        border-top: none;
    }

    .logout-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .top-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 16px 20px;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .finance-forms-grid {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .finance-forms-grid .settings-section,
    .finance-forms-grid .settings-section + .settings-section {
        padding: 0;
        border: 0;
    }

    .finance-forms-grid .settings-section + .settings-section {
        padding-top: 20px;
        border-top: 1px solid var(--border-color);
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .pages-container {
        padding: 16px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .settings-container,
    .form-container {
        padding: 20px;
        max-width: 100%;
    }

    .content-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .content-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .content-header-actions .search-input {
        width: 100%;
    }

    .reports-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .inventory-table {
        min-width: 1250px;
        table-layout: auto;
    }

    .inventory-table th,
    .inventory-table td {
        padding: 12px;
    }

    .inventory-table .inventory-actions-cell {
        min-width: 170px;
        padding: 12px;
    }

    .inventory-actions {
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 16px;
    }

    .logo p {
        display: none;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 12px;
    }

    .ledger-totals-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-card {
        flex-direction: column;
        gap: 8px;
    }

    .stat-icon {
        font-size: 24px;
    }

    .stat-value {
        font-size: 20px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .balance-summary-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .header-left h2 {
        font-size: 20px;
    }

    .reports-grid {
        grid-template-columns: 1fr;
    }

    .table {
        font-size: 12px;
    }
}

.rental-sales-print-layout {
    display: none;
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ========== LOGIN ========== */
.auth-overlay { position: fixed; inset: 0; z-index: 10000; background: #1f2937; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(0,0,0,.4); text-align: center; }
.auth-card .form { text-align: left; }
.auth-card .btn { width: 100%; margin-top: 8px; }
.auth-error { color: #b91c1c; font-size: 14px; }
.auth-master-key { font-family: monospace; font-size: 20px; font-weight: bold; letter-spacing: 1px; background: #f3f4f6; border: 2px dashed #6b7280; border-radius: 8px; padding: 14px; margin: 16px 0; user-select: all; word-break: break-all; }
.auth-user-info { font-size: 13px; padding: 6px 10px; opacity: .9; }
.nav-item.hidden, .nav-group.hidden { display: none !important; }
.role-page-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.role-page-options label { display: flex; align-items: center; gap: 6px; }

/* Compact, consistent POS density */
body { font-size: 14px; line-height: 1.45; }
.sidebar { width: 248px; flex: 0 0 248px; }
.logo { padding: 16px 16px 14px; }
.brand-logo { width: 120px; height: 68px; margin-bottom: 8px; }
.logo h1 { font-size: 19px; }
.nav-menu { gap: 10px; padding: 12px; }
.nav-item { padding: 9px 12px; font-size: 13px; border-radius: 7px; }
.sidebar-footer { padding: 12px; }
.logout-btn { padding: 9px 12px; }
.top-header { padding: 14px 24px; }
.header-left h2 { font-size: 23px; }
.header-right { gap: 20px; }
.avatar { width: 34px; height: 34px; }
.pages-container { padding: 24px; }
.dashboard-grid { gap: 14px; margin-bottom: 14px; }
.dashboard-summary-section { margin-bottom: 22px; }
.stat-card, .dashboard-section { padding: 18px; border-radius: 10px; }
.stat-card { gap: 12px; }
.stat-icon { font-size: 27px; }
.stat-value { font-size: 24px; }
.dashboard-content { gap: 24px; }
.dashboard-section h3 { margin-bottom: 14px; }
.content-header { margin-bottom: 18px; }
.content-header h3 { font-size: 21px; }
.form-container { padding: 24px; }
.form-container h3 { font-size: 20px; margin-bottom: 18px; }
.form, .form-row { gap: 14px; }
.form-group { gap: 6px; }
.form-group label { font-size: 13px; }
.form-group input, .form-group select, .form-group textarea { padding: 9px 12px; font-size: 13px; }
.form-group textarea { min-height: 68px; }
.btn { padding: 9px 16px; font-size: 13px; gap: 6px; border-radius: 7px; }
.table th, .table td { padding: 10px 12px; font-size: 13px; }
.table-actions { gap: 6px; }
.table-actions .btn { padding: 6px 10px; font-size: 11px; }
.modal-content { padding: 24px; }
.settings-container { padding: 24px; }
.settings-section { padding: 18px; margin-bottom: 14px; }
.auth-card { padding: 24px; }

@media (max-width: 1024px) {
    .sidebar { width: 220px; flex-basis: 220px; }
    .pages-container { padding: 20px; }
}

@media (max-width: 768px) {
    .sidebar { width: 100%; flex-basis: auto; }
    .top-header { padding: 12px 16px; }
    .pages-container { padding: 16px; }
    .form-container, .settings-container { padding: 16px; }
}

/* Portrait phones: compact menu grouped into short, scrollable grids. */
@media (max-width: 768px) and (orientation: portrait) {
    #app { height: 100vh; height: 100dvh; min-height: 0; }
    .sidebar {
        max-height: 34dvh;
        flex: 0 0 auto;
        overflow: visible;
        box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
    }
    .logo {
        min-height: 48px;
        padding: 5px 12px;
    }
    .brand-logo { width: 34px; height: 34px; }
    .logo h1 { font-size: 15px; }
    .nav-menu {
        display: block;
        flex: 0 0 auto;
        max-height: 22dvh;
        padding: 4px 8px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }
    .nav-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        margin-bottom: 6px;
    }
    .nav-group-title {
        grid-column: 1 / -1;
        margin: 3px 6px 1px;
        font-size: 9px;
    }
    .nav-item {
        min-width: 0;
        min-height: 34px;
        padding: 6px 8px;
        border: 1px solid var(--border-color);
        font-size: 11px;
        line-height: 1.2;
        text-align: left;
        white-space: normal;
        touch-action: manipulation;
    }
    .nav-item.active { border-color: var(--primary-color); }
    .sidebar-footer {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        padding: 3px 10px 6px;
        border-top: 0;
    }
    .auth-user-info { margin-right: auto; padding: 4px 2px; }
    .logout-btn { width: auto; min-height: 36px; padding: 7px 12px; }
    .main-content { min-height: 0; }
    .top-header {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
    }
    .header-left h2 { font-size: 18px; }
    .header-right { width: auto; gap: 8px; }
    .datetime { display: none; }
    .user-profile { gap: 6px; }
    .user-name { font-size: 12px; }
    .avatar { width: 30px; height: 30px; }
    .pages-container { min-height: 0; padding: 12px; }
    .dashboard-grid,
    .reports-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-card,
    .dashboard-section { padding: 13px; }
    .stat-card { flex-direction: row; gap: 9px; }
    .stat-value { font-size: 19px; overflow-wrap: anywhere; }
    .form-container,
    .settings-container { padding: 12px; }
    .form-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .form-actions { flex-direction: row; flex-wrap: wrap; }
    .form-actions .btn { flex: 1 1 150px; width: auto; }
    .btn { width: auto; min-height: 40px; touch-action: manipulation; }
    .content-header { gap: 8px; }
    .content-header-actions { flex-direction: row; flex-wrap: wrap; }
    .content-header-actions .btn { width: auto; flex: 1 1 140px; }
    .table-container { margin: 8px 0 14px; overscroll-behavior-x: contain; }
    .table-container .table { min-width: 600px; }
    .table th, .table td { padding: 8px 9px; font-size: 12px; }
    .table-actions { flex-direction: row; }
    .table-actions .btn { width: auto; }
    .modal { padding: 10px; }
    .modal-content { width: 100%; max-width: 100%; max-height: 92dvh; overflow-y: auto; padding: 16px; }
    .role-page-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Landscape phones and small tablets: keep navigation at the side, tighten vertical space. */
@media (max-height: 600px) and (orientation: landscape) {
    #app { height: 100vh; height: 100dvh; min-height: 0; }
    .sidebar { width: 190px; flex-basis: 190px; }
    .logo { padding: 8px 10px; }
    .brand-logo { width: 70px; height: 42px; margin-bottom: 4px; }
    .logo h1 { font-size: 15px; }
    .nav-menu { gap: 5px; padding: 7px; }
    .nav-item { padding: 7px 8px; font-size: 11px; }
    .nav-group-title { margin: 3px 7px; font-size: 9px; }
    .sidebar-footer { padding: 7px; }
    .top-header { padding: 8px 16px; }
    .header-left h2 { font-size: 18px; }
    .pages-container { padding: 12px; }
    .dashboard-content { gap: 12px; }
    .dashboard-summary-section { margin-bottom: 12px; }
    .form-container { padding: 16px; }
    .form, .form-row { gap: 10px; }
    .modal-content { max-height: 90dvh; overflow-y: auto; }
}

@media (max-width: 380px) and (orientation: portrait) {
    .dashboard-grid,
    .reports-grid { grid-template-columns: 1fr; }
    .header-left h2 { font-size: 16px; }
    .user-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .role-page-options { grid-template-columns: 1fr; }
}

/* Collapsible menu (mobile portrait) */
.nav-toggle { display: none; }
@media (max-width: 768px) and (orientation: portrait) {
    .sidebar .logo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
    .nav-toggle { display: inline-block; margin-left: auto; padding: 6px 10px; font-size: 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
    .sidebar.nav-collapsed .nav-menu,
    .sidebar.nav-collapsed .sidebar-footer { display: none !important; }
    .sidebar.nav-collapsed { max-height: none; }
}

.period-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 12px; }
.period-status { padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: 13px; }
.period-open { background: #ecfdf5; color: #047857; }
.period-closed { background: #fef2f2; color: #b91c1c; }

.period-picker { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.period-picker input { padding: 3px 6px; font-size: 13px; width: 135px; }
@media (max-width: 768px) and (orientation: portrait) { .period-picker input { width: 118px; } .header-right .datetime { display: none; } }
