/* =========================================
   1. CORE VARIABLES & RESET
   ========================================= */
:root {
    --primary:       #1a73e8;
    --primary-hover: #1557b0;
    --bg-body:       #ffffff;
    --bg-surface:    #f8f9fa;
    --border:        #dadce0;
    --text-main:     #202124;
    --text-muted:    #5f6368;
    --success:       #137333;
    --success-bg:    #e6f4ea;
    --danger:        #d93025;
    --danger-bg:     #fce8e6;
    --warning:       #ea8600;
    --warning-bg:    #fef7e0;
    --info:          #1967d2;
    --info-bg:       #e8f0fe;
    --shadow:        0 1px 3px rgba(60,64,67,0.3);
    --radius:        8px;
    --font-sans:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { text-decoration: none; color: var(--primary); transition: 0.2s; }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { font-weight: 500; letter-spacing: -0.5px; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* =========================================
   2. BUTTONS & UTILITIES
   ========================================= */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.95rem;
    border: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); color: white; }

.btn-outline { background-color: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background-color: #f1f3f4; }

.btn-danger { background-color: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background-color: #b31b11; color: white; }

.btn-sm { padding: 5px 12px; font-size: 0.85rem; }
.btn-large { padding: 12px 30px; font-size: 1rem; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}
.btn-icon:hover { background-color: var(--bg-surface); color: var(--primary); }
.btn-icon.text-danger:hover { background-color: var(--danger-bg); color: var(--danger); }
.btn-icon.text-success { color: var(--success); }
.btn-icon.text-success:hover { background-color: var(--success-bg); color: var(--success); }

/* Utility classes */
.hidden          { display: none !important; }
.text-muted      { color: var(--text-muted); }
.text-danger     { color: var(--danger); }
.text-danger:hover { color: #a50e0e; }
.text-success    { color: var(--success); }
.text-right      { text-align: right; }
.text-center     { text-align: center; }
.text-sm         { font-size: 0.8rem; }
.text-hint       { font-size: 0.8rem; margin-top: 5px; }
.text-hint-top   { font-size: 0.85rem; margin-top: 5px; }
.fw-medium       { font-weight: 500; }
.fw-semibold     { font-weight: 600; }
.section-disabled { opacity: 0.5; pointer-events: none; }

/* Alerts — app pages */
.alert-box { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-size: 0.95rem; border: 1px solid transparent; }
.alert-danger  { background-color: #fdecea; color: var(--danger); border-color: #fad2cf; }
.alert-success { background-color: var(--success-bg); color: var(--success); border-color: #ceead6; }
.alert-margin  { margin: 20px; }
.alert-form    { margin: 20px; }

/* =========================================
   3. PUBLIC HEADER & NAVIGATION
   ========================================= */
header:not(.app-header) {
    border-bottom: 1px solid var(--border);
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
}
header:not(.app-header) nav {
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span { color: var(--primary); }
.nav-links { display: flex; gap: 20px; align-items: center; }

@media (max-width: 768px) {
    .nav-links a:not(.btn) { display: none; }
}

/* =========================================
   4. AUTH PAGES
   ========================================= */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    background-color: var(--bg-surface);
    padding: 20px;
}
.auth-card {
    background: white;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.auth-header { text-align: center; margin-bottom: 30px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 0.9rem; color: var(--text-muted); }

/* Auth alert messages */
.alert-success-auth {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #ceead6;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.5;
}
.alert-error {
    background: #fdecea;
    color: #d93025;
    border: 1px solid #fad2cf;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    text-align: center;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .auth-card { padding: 28px 20px; border-radius: 12px; }
    .auth-container { align-items: flex-start; padding-top: 30px; }
}

/* =========================================
   5. FORMS
   ========================================= */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 500; }

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    transition: border 0.2s;
    background: white;
    color: var(--text-main);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,115,232,0.2); }
.form-control:disabled,
.form-control[readonly] { background-color: #f1f3f4; color: var(--text-muted); cursor: not-allowed; opacity: 1; }

.form-label-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.form-label-wrapper label { margin-bottom: 0; }
.small-link { font-size: 0.85rem; text-decoration: none; color: var(--primary); }
.small-link:hover { text-decoration: underline; }

.input-group { display: flex; width: 100%; }
.input-group-text {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-right: 0;
    padding: 0 12px;
    display: flex;
    align-items: center;
    border-radius: 4px 0 0 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}
.input-group .form-control { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-readonly { background: #f0f0f0; cursor: not-allowed; }

.form-inline { display: inline; margin: 0; padding: 0; }
.form-actions { margin-top: 30px; text-align: right; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* Form grid helpers */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-4      { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-3      { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; }
.span-2      { grid-column: span 2; }

@media (max-width: 992px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  {
    .form-grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: span 1; }
}

/* Form card widths */
.form-card-wide { max-width: 800px; margin: 0 auto; }
.form-card-md   { max-width: 800px; margin: 0 auto; }
.form-card-sm   { max-width: 600px; margin: 0 auto; }
.form-card-lg   { max-width: 900px; margin: 0 auto; }

/* =========================================
   6. APP LAYOUT — HEADER
   ========================================= */
.app-body { background-color: #fdfdfd; }

.app-header {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 10px;
}

.header-left  { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.user-email { font-size: 0.9rem; font-weight: 500; color: var(--text-main); }

.log-user   { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text-main); }
.log-avatar {
    width: 32px; height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .app-header { padding: 0 12px; }
    .header-right { gap: 6px; }
}

/* =========================================
   7. APP LAYOUT — SIDEBAR
   ========================================= */
.app-layout {
    display: flex;
    min-height: calc(100vh - 64px);
}

.app-sidebar {
    width: 240px;
    background-color: white;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease, width 0.3s ease;
}
.sidebar-content { padding: 12px 0; }

.nav-section  { margin-bottom: 25px; }
.nav-label    { padding: 0 20px; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 0.5px; white-space: nowrap; }
.nav-group    { margin-bottom: 2px; }

.nav-link-parent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    border-radius: 6px;
    margin: 0 8px;
    text-decoration: none;
    font-size: 0.92rem;
}
.nav-link-parent:hover { background-color: #f1f3f4; color: var(--primary); }

.nav-label-wrapper { display: flex; align-items: center; gap: 10px; }

.nav-arrow {
    width: 14px; height: 14px;
    color: var(--text-muted);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Active / open states */
.nav-group.open .nav-arrow                              { transform: rotate(180deg); }
.nav-group.active-parent .nav-link-parent               { background-color: var(--info-bg); color: var(--primary); }
.nav-group.active-parent .nav-arrow,
.nav-group.active-parent .nav-label-wrapper svg         { color: var(--primary); }

/* Sub menu */
.nav-sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    margin-left: 28px;
    padding-left: 14px;
    border-left: 1px solid var(--border);
}
.nav-group.open .nav-sub-menu { max-height: 600px; }

.nav-sub-link {
    display: block;
    padding: 7px 10px;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 4px;
    margin-top: 1px;
    position: relative;
    transition: 0.15s;
}
.nav-sub-link:hover  { color: var(--primary); background-color: var(--bg-surface); }
.nav-sub-link.active { color: var(--primary); font-weight: 500; }
.nav-sub-link::before {
    content: '';
    position: absolute;
    left: -15px; top: 50%;
    width: 8px; height: 1px;
    background-color: var(--border);
}

/* Sidebar desktop collapse */
@media (min-width: 769px) {
    .app-sidebar.active { width: 64px; }
    .app-sidebar.active .nav-label-wrapper span,
    .app-sidebar.active .nav-arrow,
    .app-sidebar.active .nav-sub-menu,
    .app-sidebar.active .nav-label { display: none !important; }
    .app-sidebar.active .nav-link-parent { justify-content: center; padding: 12px; margin: 0 4px; }
    .app-sidebar.active .nav-label-wrapper { gap: 0; }
}

/* Sidebar mobile — full-width overlay */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        left: 0; top: 64px; bottom: 0;
        z-index: 200;
        width: 260px;
        transform: translateX(-100%);
        box-shadow: 4px 0 16px rgba(0,0,0,0.12);
    }
    .app-sidebar.active { transform: translateX(0); }
    .nav-sub-menu { border-left: none; padding-left: 8px; margin-left: 8px; }
    .nav-sub-link::before { display: none; }

    /* Dim overlay behind sidebar on mobile */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 64px 0 0 0;
        background: rgba(0,0,0,0.3);
        z-index: 199;
    }
    .sidebar-overlay.active { display: block; }
}

/* =========================================
   8. APP CONTENT AREA
   ========================================= */
.app-content { flex: 1; padding: 28px 24px; overflow-x: hidden; min-width: 0; }

@media (max-width: 768px) { .app-content { padding: 16px 14px; } }
@media (max-width: 480px) { .app-content { padding: 12px 10px; } }

/* =========================================
   9. PAGE HEADER
   ========================================= */
.page-header,
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 12px;
    flex-wrap: wrap;
}
.page-title   { font-size: 1.4rem; font-weight: 600; color: var(--text-main); }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 3px; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 600px) {
    .page-header,
    .dashboard-header { flex-direction: column; align-items: stretch; }
    .header-actions   { justify-content: flex-start; }
    .page-title       { font-size: 1.2rem; }
}

/* =========================================
   10. CARDS
   ========================================= */
.content-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title  { font-size: 1rem; font-weight: 600; color: var(--text-main); margin: 0; }
.card-body   { padding: 20px; }

@media (max-width: 600px) {
    .card-header { padding: 12px 16px; }
    .card-body   { padding: 14px; }
}

/* =========================================
   11. TABLES
   ========================================= */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
    background-color: var(--bg-surface);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background-color: #fafafa; }

/* Column helpers */
.col-desc       { width: 45%; }
.col-qty        { width: 12%; text-align: center; }
.col-price      { width: 14%; text-align: right; }
.col-total      { width: 14%; text-align: right; }
.col-action     { width: 10%; text-align: center; }
.col-contact    { width: 35%; }
.col-address    { width: 30%; }
.col-added      { width: 15%; }
.col-action-crm { width: 15%; text-align: right; }
.col-sku        { width: 15%; }
.col-product    { width: 40%; }
.col-stock      { width: 15%; text-align: center; }
.col-actions    { width: 100px; text-align: right; }

.cell-center  { text-align: center !important; }
.cell-right   { text-align: right !important; }
.row-total    { padding-top: 18px !important; font-weight: 600; }

/* =========================================
   12. BADGES & STATUS
   ========================================= */
.badge {
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: inline-block;
    white-space: nowrap;
}
.badge-success { background-color: var(--success-bg); color: var(--success); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge-danger  { background-color: var(--danger-bg);  color: var(--danger); }
.badge-info    { background-color: var(--info-bg);    color: var(--info); }
.badge-neutral { background-color: #f1f3f4;           color: var(--text-muted); }

/* =========================================
   13. STAT CARDS (DASHBOARD)
   ========================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: white;
    padding: 18px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.stat-icon  { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.revenue-icon  { background: var(--info-bg);    color: var(--info); }
.customer-icon { background: var(--success-bg); color: var(--success); }
.invoice-icon  { background: var(--warning-bg); color: var(--warning); }
.product-icon  { background: var(--danger-bg);  color: var(--danger); }
.stat-info h3  { font-size: 1.4rem; margin-bottom: 2px; font-weight: 600; }
.stat-info p   { font-size: 0.82rem; color: var(--text-muted); }

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card  { padding: 14px; gap: 10px; }
    .stat-icon  { width: 36px; height: 36px; }
    .stat-info h3 { font-size: 1.1rem; }
}

/* =========================================
   14. FILTER TOOLBAR
   ========================================= */
.filter-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.filter-group     { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-group-end { flex-grow: 1; justify-content: flex-end; }
.filter-select    { padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; background: white; font-size: 0.9rem; min-width: 110px; }
.search-input     { max-width: 240px; }

@media (max-width: 768px) {
    .filter-toolbar   { flex-direction: column; align-items: stretch; }
    .filter-group     { flex-direction: row; flex-wrap: wrap; }
    .filter-select,
    .search-input     { width: 100%; max-width: 100%; }
}

/* =========================================
   15. PAGINATION
   ========================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-main);
    background: white;
    border: 1px solid var(--border);
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}
.page-btn:hover:not(.disabled):not(.active):not(.page-ellipsis) {
    background: var(--info-bg);
    color: var(--primary);
    border-color: var(--primary);
}
.page-btn.active   { background: var(--primary); color: white; border-color: var(--primary); cursor: default; }
.page-btn.disabled { color: var(--text-muted); cursor: not-allowed; opacity: 0.6; }
.page-btn.page-ellipsis { border: none; background: transparent; cursor: default; min-width: 20px; }

/* Legacy page-link alias */
.page-link { padding: 8px 12px; border: 1px solid var(--border); background: white; color: var(--text-main); text-decoration: none; border-radius: 4px; font-size: 0.9rem; transition: 0.2s; }
.page-link:hover  { background-color: var(--bg-surface); border-color: var(--text-muted); }
.page-link.active { background-color: var(--primary); color: white; border-color: var(--primary); }

.page-info { color: var(--text-muted); font-size: 0.8rem; margin-left: 6px; }

/* =========================================
   16. AUTOCOMPLETE / SEARCH DROPDOWN
   ========================================= */
.search-wrapper { position: relative; }

.search-results {
    position: absolute;
    top: 100%; left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
    z-index: 9999;
    display: none;
}
.search-results.show { display: block; }

.search-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background 0.15s;
}
.search-item:last-child  { border-bottom: none; }
.search-item:hover       { background-color: var(--bg-surface); color: var(--primary); }
.search-item strong      { display: block; font-weight: 600; }
.search-item span        { font-size: 0.8rem; color: var(--text-muted); }

/* =========================================
   17. ACTION BUTTONS GROUP
   ========================================= */
.action-buttons, .action-group {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}
.action-group { justify-content: center; }

@media (max-width: 600px) {
    .action-buttons { gap: 4px; }
}

/* =========================================
   18. INVOICE / QUOTATION MODULE
   ========================================= */
.invoice-form-container { max-width: 1000px; margin: 0 auto; }
.invoice-grid      { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.invoice-card-padded { padding: 22px; margin-bottom: 24px; }
.invoice-table-wrapper { padding: 0; }
.invoice-table-head  { background-color: var(--bg-surface); }
.invoice-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.grand-total-text { font-size: 1.2rem; font-weight: 600; }

/* Invoice line items — mobile card view */
@media (max-width: 768px) {
    #itemsTable,
    #itemsTable tbody,
    #itemsTable tr,
    #itemsTable td { display: block; width: 100% !important; }
    #itemsTable thead { display: none; }
    #itemsTable tr {
        margin-bottom: 14px;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 10px;
        background: white;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    #itemsTable td {
        border: none;
        padding: 6px 0;
        text-align: left !important;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    #itemsTable td:nth-of-type(1)::before { content: "Item";        font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
    #itemsTable td:nth-of-type(2)::before { content: "Description"; font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
    #itemsTable td:nth-of-type(3)::before { content: "Quantity";    font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
    #itemsTable td:nth-of-type(4)::before { content: "Price";       font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
    #itemsTable td:nth-of-type(5)::before { content: "Total";       font-weight: 600; font-size: 0.8rem; color: var(--text-muted); }
    #itemsTable input.form-control { text-align: left !important; background-color: var(--bg-surface); }
    #grandTotalDisplay { font-size: 1.4rem !important; }

    .invoice-footer { flex-direction: column; align-items: flex-start; }
}

/* =========================================
   19. LANDSCAPE FORM LAYOUT
   ========================================= */
.form-card-landscape {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.form-section { padding: 22px 24px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }
.form-section.bg-footer {
    background-color: var(--bg-surface);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.form-section-head  { margin-bottom: 18px; }
.form-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-section-title svg { color: var(--text-muted); }
.form-section-danger { border-left: 4px solid #ef4444; background-color: #fef2f2; }
.form-section-head-padded { padding: 15px 20px 0 20px; }
.form-section-padded { padding: 0 20px 20px 20px; }
.text-danger-title { color: #b91c1c; }
.btn-save-profile { min-width: 140px; }

@media (max-width: 600px) {
    .form-section { padding: 16px; }
    .form-section.bg-footer { justify-content: stretch; }
    .form-section.bg-footer .btn { width: 100%; text-align: center; }
}

/* =========================================
   20. CRM / CUSTOMERS MODULE
   ========================================= */
.crm-search-card  { padding: 14px; margin-bottom: 16px; }
.crm-search-form  { display: flex; gap: 10px; flex-wrap: wrap; }
.crm-search-input { flex: 1; min-width: 180px; }
.customer-name    { font-weight: 600; color: var(--text-main); }
.customer-meta    { font-size: 0.82rem; color: var(--text-muted); }
.address-cell     { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 600px) {
    .crm-search-form  { flex-direction: column; }
    .crm-search-input { width: 100%; }
    .btn-clear        { text-align: center; display: block; width: 100%; }
    .address-cell     { display: none; }
}

/* =========================================
   21. INVENTORY MODULE
   ========================================= */
.stock-low   { color: var(--danger); font-weight: 600; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* =========================================
   22. HRM MODULE
   ========================================= */
.hrm-wrapper { max-width: 1100px; margin: 0 auto; }

.hrm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}
.hrm-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.hrm-section-box {
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
}

@media (max-width: 600px) { .hrm-form-grid { grid-template-columns: 1fr; } }

/* =========================================
   23. USER / PERMISSIONS MODULE
   ========================================= */
.perm-section-title { font-size: 1rem; margin-bottom: 14px; font-weight: 600; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.perm-category-card { background: var(--bg-surface); padding: 14px; border-radius: var(--radius); }
.perm-category-title { text-transform: uppercase; font-size: 0.72rem; color: var(--text-muted); display: block; margin-bottom: 10px; font-weight: 600; }
.perm-item  { margin-bottom: 8px; }
.perm-label { display: flex; align-items: center; gap: 8px; font-weight: normal; font-size: 0.9rem; cursor: pointer; }

@media (max-width: 600px) { .perm-grid { grid-template-columns: 1fr; } }

/* =========================================
   24. COMPANY SETTINGS
   ========================================= */
.logo-upload-container {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 18px;
    background: var(--bg-surface);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
    margin-bottom: 20px;
}
.logo-preview {
    width: 90px; height: 90px;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.logo-preview img   { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-placeholder   { color: var(--text-muted); font-size: 0.8rem; text-align: center; }
.upload-info        { font-size: 0.82rem; color: var(--text-muted); margin-top: 5px; }

@media (max-width: 600px) {
    .logo-upload-container { flex-direction: column; align-items: flex-start; }
}

/* =========================================
   25. TAB SWITCHER
   ========================================= */
.tab-segmented {
    display: inline-flex;
    background: #f1f3f4;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 22px;
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
}
.tab-segment-item {
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    background: none;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    cursor: pointer;
}
.tab-segment-item:hover  { color: var(--text-main); background: rgba(0,0,0,0.04); }
.tab-segment-item.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; }

@media (max-width: 600px) {
    .tab-segmented    { display: flex; width: 100%; }
    .tab-segment-item { flex: 1; justify-content: center; padding: 9px 6px; font-size: 0.8rem; }
}

/* =========================================
   26. SETTINGS MODULE
   ========================================= */
.settings-toggle-box   { background: var(--bg-surface); padding: 14px; border-radius: 6px; border: 1px solid var(--border); }
.settings-toggle-row   { display: flex; justify-content: space-between; align-items: center; }
.settings-toggle-label { margin: 0; cursor: pointer; font-weight: 500; color: var(--text-main); }
.settings-toggle-input { transform: scale(1.2); cursor: pointer; }
.settings-desc         { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; }

/* =========================================
   27. FORM MISC UTILITIES
   ========================================= */
.info-box-green {
    background: var(--success-bg);
    padding: 10px 14px;
    border-radius: 6px;
    color: var(--success);
    font-size: 0.9rem;
    width: 100%;
}
.flex-bottom { display: flex; align-items: flex-end; padding-bottom: 10px; }
.text-method { margin-top: 4px; font-size: 0.85rem; }

/* =========================================
   28. FINANCIAL REPORTS
   ========================================= */
.report-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.report-title          { text-align: center; margin-bottom: 28px; }
.report-section-header { border-bottom: 2px solid var(--primary); padding-bottom: 10px; margin-bottom: 14px; font-size: 1.05rem; font-weight: 600; color: var(--primary); }
.report-section-header.liability { border-color: var(--danger); color: var(--danger); }
.report-sub-header     { font-size: 0.92rem; font-weight: 600; margin-bottom: 8px; margin-top: 18px; color: var(--text-main); }
.report-table          { width: 100%; border-collapse: collapse; }
.report-total-row      { font-weight: 700; background-color: var(--bg-surface); }
.report-total-row td   { padding: 10px 5px; }
.report-double-line    { border-top: 1px solid var(--border); border-bottom: 3px double; }

@media (max-width: 768px) {
    .report-container { padding: 16px; }
}
@media print {
    .report-container { border: none; width: 100%; max-width: none; padding: 0; }
    .btn { display: none !important; }
}

/* =========================================
   29. REPORTS CENTER
   ========================================= */
.report-card        { padding: 0; overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.report-card-header { background: var(--bg-surface); border-bottom: 1px solid var(--border); padding: 14px 18px; font-weight: 700; text-transform: uppercase; font-size: 0.82rem; letter-spacing: 0.5px; }
.report-list        { padding: 8px; flex-grow: 1; }
.report-list-item   { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 8px; text-decoration: none; transition: background-color 0.2s; margin-bottom: 4px; }
.report-list-item:hover { background-color: #f1f3f4; }
.report-icon-box    { width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.report-item-title  { font-weight: 600; color: var(--text-main); font-size: 0.92rem; margin-bottom: 2px; }
.report-item-desc   { font-size: 0.78rem; color: var(--text-muted); }

/* =========================================
   30. SELECT2 OVERRIDES
   ========================================= */
.select2-container .select2-selection--single {
    height: 42px !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
    padding: 6px;
    display: flex;
    align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__arrow    { top: 8px !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--text-main) !important; padding-left: 0; }

/* =========================================
   31. FOOTER
   ========================================= */
footer {
    background-color: white;
    border-top: 1px solid var(--border);
    padding: 30px 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* =========================================
   32. MOBILE — GLOBAL RESPONSIVE FIXES
   ========================================= */
@media (max-width: 768px) {

    /* Tables — hide less important columns */
    .hide-mobile { display: none !important; }

    /* Table cells — reduce padding on mobile */
    .table th, .table td { padding: 8px 10px; font-size: 0.85rem; }

    /* Cards */
    .content-card { border-radius: 6px; }

    /* Buttons — make touch-friendly */
    .btn { padding: 10px 18px; }
    .btn-sm { padding: 7px 12px; font-size: 0.82rem; }

    /* Filter toolbar full stretch */
    .filter-toolbar .btn { width: 100%; text-align: center; }
}

@media (max-width: 480px) {

    /* Stack card headers on very small screens */
    .card-header { flex-direction: column; align-items: flex-start; }

    /* Full-width buttons in footer sections */
    .form-section.bg-footer { flex-direction: column; }
    .form-section.bg-footer .btn { width: 100%; text-align: center; }

    /* Reduce font sizes slightly */
    .table th { font-size: 0.72rem; }
    .table td { font-size: 0.82rem; }
    .badge    { font-size: 0.65rem; padding: 2px 7px; }

    /* Make page header stacked */
    h1.page-title { font-size: 1.1rem; }
}