/* ═══════════════════════════════════════════════════════════════════════
   AbbadCo ERP — Modern Stylesheet v2
   Theme: Forest Green #0B6623 · Gold #D4AF37 · Dark Navy #0f172a
   ═══════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
    /* Brand */
    --green:          #0B6623;
    --green-hover:    #0d7c2a;
    --green-dark:     #074d1a;
    --green-pale:     #f0fdf4;
    --green-light:    #dcfce7;
    --gold:           #D4AF37;
    --gold-dark:      #b89b1e;
    --cream:          #FFFDD0;
    --cream-dark:     #f0eebc;
    /* Sidebar */
    --sidebar-bg:     #0f172a;
    --sidebar-hover:  rgba(255,255,255,0.06);
    --sidebar-active: rgba(11,102,35,0.25);
    --sidebar-border: rgba(255,255,255,0.07);
    --sidebar-w:      260px;
    --sidebar-mini-w: 64px;
    /* Layout */
    --topbar-h:       60px;
    --content-bg:     #f8fafc;
    /* Cards */
    --card-bg:        #ffffff;
    --card-radius:    12px;
    --card-shadow:    0 1px 3px 0 rgba(0,0,0,.08), 0 1px 2px -1px rgba(0,0,0,.06);
    --card-shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
    /* Text */
    --text:           #0f172a;
    --text-muted:     #64748b;
    --text-xmuted:    #94a3b8;
    /* Border */
    --border:         #e2e8f0;
    --border-light:   #f1f5f9;
    /* Transition */
    --tr:             0.3s cubic-bezier(0.4,0,0.2,1);
}

/* ── Base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--content-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }

/* ═══════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════ */
.erp-wrapper { display: flex; min-height: 100vh; }

/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════ */
.erp-sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex; flex-direction: column;
    z-index: 1050;
    transition: width var(--tr), transform var(--tr);
    overflow: hidden; flex-shrink: 0;
}

/* ── Sidebar Header (Brand + close) ── */
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; height: 64px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    white-space: nowrap; overflow: hidden;
}
.brand-icon-wrap {
    width: 36px; height: 36px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--green), var(--green-hover));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: var(--gold);
}
.brand-text-wrap { overflow: hidden; min-width: 0; }
.brand-name { display: block; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -.2px; line-height: 1.2; }
.brand-tag  { font-size: 10px; font-weight: 500; color: var(--gold); letter-spacing: 1.5px; text-transform: uppercase; }
.sidebar-logo-img { height: 36px; width: auto; max-width: 180px; object-fit: contain; filter: brightness(0) invert(1); }
.sidebar-logo-mini { display: none; height: 30px; width: 30px; object-fit: contain; }

/* Collapsed: swap to favicon */
.sidebar-collapsed .sidebar-logo-full { display: none; }
.sidebar-collapsed .sidebar-logo-mini { display: block; }
.sidebar-close-btn {
    display: none; /* shown only on mobile via @media */
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.45); font-size: 18px;
    width: 32px; height: 32px; border-radius: 8px;
    align-items: center; justify-content: center;
    transition: all .18s; flex-shrink: 0;
}
.sidebar-close-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Nav ── */
.sidebar-nav {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 8px 12px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.08) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

/* Nav Sections */
.nav-section { margin-bottom: 4px; }
.nav-section-label {
    display: block; font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: rgba(255,255,255,.28);
    padding: 16px 10px 6px;
}

/* Nav links */
.sidebar-nav .s-nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 10px;
    color: rgba(255,255,255,.6) !important;
    font-size: 13.5px; font-weight: 450;
    margin-bottom: 2px;
    transition: all .18s ease;
    white-space: nowrap; overflow: hidden;
    position: relative; cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}
.sidebar-nav .s-nav-link .nav-icon-wrap {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 16px;
    background: rgba(255,255,255,.04);
    transition: all .18s;
}
.sidebar-nav .s-nav-link .nav-txt {
    overflow: hidden; text-overflow: ellipsis; flex: 1;
}

/* Hover */
.sidebar-nav .s-nav-link:hover {
    color: rgba(255,255,255,.92) !important;
    background: var(--sidebar-hover);
    border-color: rgba(255,255,255,.06);
}
.sidebar-nav .s-nav-link:hover .nav-icon-wrap {
    background: rgba(255,255,255,.1);
}

/* Active */
.sidebar-nav .s-nav-link.active {
    background: var(--sidebar-active);
    color: #fff !important; font-weight: 550;
    border-color: rgba(11,102,35,.3);
}
.sidebar-nav .s-nav-link.active .nav-icon-wrap {
    background: var(--green);
    color: #fff;
}

/* ── Nav Group (Invoices expandable) ── */
.nav-group-toggle {
    width: 100%; border: none; text-align: left;
    background: none; font: inherit;
}
.nav-arrow {
    margin-left: auto; font-size: 12px;
    flex-shrink: 0; transition: transform .25s;
    color: rgba(255,255,255,.3);
}
.nav-group.open .nav-arrow { transform: rotate(90deg); }

/* Sub-nav */
.nav-sub {
    max-height: 0; overflow: hidden;
    transition: max-height .3s ease;
    padding-left: 22px;
}
.nav-sub.open { max-height: 200px; }

.sidebar-nav .s-nav-link.sub {
    font-size: 13px; padding: 7px 12px; gap: 10px;
}
.nav-dot {
    width: 6px; height: 6px; flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    transition: all .18s;
}
.sidebar-nav .s-nav-link.sub:hover .nav-dot { background: rgba(255,255,255,.5); }
.sidebar-nav .s-nav-link.sub.active .nav-dot {
    background: var(--gold);
    box-shadow: 0 0 6px rgba(212,175,55,.4);
}
.sidebar-nav .s-nav-link.sub.active {
    background: rgba(255,255,255,.06);
    color: #fff !important;
}

/* ── Sidebar Bottom / User ── */
.sidebar-bottom {
    border-top: 1px solid var(--sidebar-border);
    padding: 12px; flex-shrink: 0;
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    white-space: nowrap; overflow: hidden;
    transition: background .18s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.user-avatar {
    width: 34px; height: 34px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--green), var(--gold-dark));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 14px; font-weight: 600;
}
.user-details { flex: 1; overflow: hidden; }
.user-name  { display: block; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.88); overflow: hidden; text-overflow: ellipsis; }
.user-role  { font-size: 11px; color: rgba(255,255,255,.35); }
.user-logout {
    color: rgba(255,255,255,.35); font-size: 16px;
    padding: 6px; border-radius: 8px; flex-shrink: 0;
    transition: all .18s; display: flex; align-items: center;
}
.user-logout:hover { color: #f87171; background: rgba(248,113,113,.1); }

/* ── Mobile Overlay ── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.55); z-index: 1049;
    backdrop-filter: blur(3px);
    transition: opacity .25s;
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════════════════════════════════
   MAIN AREA
   ═══════════════════════════════════════════════════════════════════════ */
.erp-main-area {
    margin-left: var(--sidebar-w); flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    transition: margin-left var(--tr);
}

/* Desktop sidebar hidden state */
.sidebar-hidden .erp-sidebar { transform: translateX(-100%); }
.sidebar-hidden .erp-main-area { margin-left: 0; }

/* Desktop sidebar collapsed (icon-only) state */
.sidebar-collapsed .erp-sidebar  { width: var(--sidebar-mini-w); }
.sidebar-collapsed .erp-main-area { margin-left: var(--sidebar-mini-w); }

.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: 0 0 0 0;
}
.sidebar-collapsed .sidebar-brand { justify-content: center; }
.sidebar-collapsed .sidebar-close-btn { display: none !important; }

.sidebar-collapsed .nav-sub { display: none !important; }

/* Fade labels/text with the slide */
.nav-section-label, .nav-txt, .nav-arrow {
    transition: opacity 0.15s ease, visibility 0.15s ease;
    opacity: 1; visibility: visible;
    white-space: nowrap;
}
.sidebar-collapsed .nav-section-label,
.sidebar-collapsed .nav-txt,
.sidebar-collapsed .nav-arrow {
    opacity: 0; visibility: hidden; pointer-events: none;
}

.sidebar-collapsed .s-nav-link {
    justify-content: center;
    padding: 9px 0;
    gap: 0;
    position: relative;
}
.sidebar-collapsed .s-nav-link .nav-icon-wrap { width: 36px; height: 36px; }

/* Tooltip on collapsed icons */
.sidebar-collapsed .s-nav-link[data-tip]::after {
    content: attr(data-tip);
    position: absolute; left: calc(var(--sidebar-mini-w) + 8px); top: 50%;
    transform: translateY(-50%);
    background: #1e293b; color: #f1f5f9;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    padding: 5px 10px; border-radius: 7px;
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    pointer-events: none; opacity: 0;
    transition: opacity .15s .05s;
    z-index: 2000;
}
.sidebar-collapsed .s-nav-link[data-tip]:hover::after { opacity: 1; }

.sidebar-collapsed .sidebar-user { justify-content: center; padding: 8px 0; }
.sidebar-collapsed .sidebar-bottom { padding: 8px 0; }

/* Avatar link wrapper */
.user-avatar-link { display: contents; cursor: default; pointer-events: none; }
.sidebar-collapsed .user-avatar-link {
    display: flex; justify-content: center; align-items: center;
    width: 100%; pointer-events: auto;
    position: relative;
}
/* Hide invisible siblings so they don't push avatar off-center */
.sidebar-collapsed .sidebar-user .user-details,
.sidebar-collapsed .sidebar-user .user-logout {
    display: none !important;
}
/* Tooltip on collapsed avatar */
.sidebar-collapsed .user-avatar-link::after {
    content: 'Logout';
    position: absolute; left: calc(var(--sidebar-mini-w) + 8px); top: 50%;
    transform: translateY(-50%);
    background: #1e293b; color: #f1f5f9;
    font-size: 12px; font-weight: 500; white-space: nowrap;
    padding: 5px 10px; border-radius: 7px;
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    pointer-events: none; opacity: 0;
    transition: opacity .15s .05s;
    z-index: 2000;
}
.sidebar-collapsed .user-avatar-link:hover::after { opacity: 1; }

/* Topbar */
.erp-topbar {
    height: var(--topbar-h); background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; position: sticky; top: 0; z-index: 900;
    box-shadow: 0 1px 3px rgba(0,0,0,.04); flex-shrink: 0;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.sidebar-toggle {
    background: none; border: none; cursor: pointer;
    width: 36px; height: 36px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; color: var(--text-muted);
    transition: all .18s;
}
.sidebar-toggle:hover { background: var(--border-light); color: var(--text); }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text); }
.topbar-date  {
    font-size: 12px; color: var(--text-muted);
    padding: 4px 10px; background: var(--border-light); border-radius: 6px;
}
.topbar-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--green), var(--gold-dark));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 600;
}
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.topbar-user-name { font-weight: 500; }
.topbar-logout {
    color: var(--text-muted); font-size: 18px;
    padding: 6px 8px; border-radius: 8px; transition: all .18s;
    display: flex; align-items: center;
}
.topbar-logout:hover { color: #ef4444; background: #fef2f2; }

/* Content */
.erp-content {
    flex: 1; padding: 1.5rem 1.75rem;
    width: 100%;
}

/* ═══════════════════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════════════════ */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 {
    font-size: 1.2rem; font-weight: 600; color: var(--text); margin: 0;
    display: flex; align-items: center; gap: 8px;
}
.page-header h1 i { color: var(--green); font-size: 1.05rem; }

/* ═══════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════ */
.erp-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 1.35rem;
    transition: box-shadow .2s;
}

/* KPI Cards */
.kpi-card {
    background: linear-gradient(135deg, var(--green) 0%, #0f7a2a 100%);
    border-radius: var(--card-radius); color: #fff;
    padding: 1.25rem 1.4rem;
    position: relative; overflow: hidden; border: none;
    box-shadow: 0 4px 15px rgba(11,102,35,.3);
    height: 100%; transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(11,102,35,.35); }
.kpi-card.kpi-gold {
    background: linear-gradient(135deg, #b8941a 0%, var(--gold) 100%);
    box-shadow: 0 4px 15px rgba(180,148,30,.35); color: #1a1100;
}
.kpi-card.kpi-gold:hover { box-shadow: 0 8px 25px rgba(180,148,30,.4); }
.kpi-card.kpi-blue {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    box-shadow: 0 4px 15px rgba(59,130,246,.3);
}
.kpi-card.kpi-blue:hover { box-shadow: 0 8px 25px rgba(59,130,246,.35); }
.kpi-card.kpi-cream {
    background: linear-gradient(135deg, #92400e 0%, #d97706 100%);
    box-shadow: 0 4px 15px rgba(217,119,6,.3);
}
.kpi-card.kpi-cream:hover { box-shadow: 0 8px 25px rgba(217,119,6,.35); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; opacity: .75; margin-bottom: 4px; font-weight: 500; }
.kpi-value { font-size: 1.85rem; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.kpi-sub   { font-size: 11.5px; opacity: .65; margin-top: 6px; }
.kpi-icon  { position: absolute; right: 1.1rem; top: 50%; transform: translateY(-50%); font-size: 3rem; opacity: .12; }
.kpi-card.kpi-gold .kpi-label,
.kpi-card.kpi-gold .kpi-value,
.kpi-card.kpi-gold .kpi-sub { color: #1a1100; }

/* Section title */
.section-title {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .9px;
    color: var(--green);
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 1rem;
}
.section-title::before {
    content: ''; display: inline-block;
    width: 3px; height: 14px; background: var(--gold);
    border-radius: 2px; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════════════ */
.erp-table thead { background: var(--green); color: #fff; }
.erp-table thead th {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    padding: .65rem .9rem; border: none; white-space: nowrap;
    background-color: var(--green) !important; color: #fff !important;
}
.erp-table tbody td {
    padding: .6rem .9rem; vertical-align: middle;
    font-size: 13.5px; border-color: var(--border-light); color: var(--text);
}
.erp-table tbody tr:hover { background: #f8fafc; }
.erp-table tbody tr:last-child td { border-bottom: none; }

/* ═══════════════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════════════ */
.erp-form-label {
    font-size: 11.5px; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .4px; margin-bottom: 5px; display: block;
}
.form-control, .form-select {
    border-color: var(--border); font-size: 13.5px;
    border-radius: 8px; transition: border-color .18s, box-shadow .18s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(11,102,35,.12);
}
.form-control.is-invalid { border-color: #ef4444; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }
.input-group-text {
    border-color: var(--border); background: var(--border-light);
    color: var(--text-muted); border-radius: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════ */
.btn-erp-primary {
    background: var(--green); color: #fff !important; border: none;
    border-radius: 8px; font-size: 13.5px; font-weight: 500;
    padding: .45rem 1.1rem;
    transition: background .18s, transform .15s, box-shadow .18s;
}
.btn-erp-primary:hover {
    background: var(--green-hover); transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11,102,35,.3);
}
.btn-erp-gold {
    background: var(--gold); color: #1a1100 !important; border: none;
    border-radius: 8px; font-size: 13.5px; font-weight: 600;
    padding: .45rem 1.1rem;
    transition: background .18s, transform .15s, box-shadow .18s;
}
.btn-erp-gold:hover {
    background: var(--gold-dark); transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(184,155,30,.35);
}
.btn-sm { padding: .3rem .7rem; font-size: 12.5px; border-radius: 7px; }

/* ═══════════════════════════════════════════════════════════════════════
   INVOICE ITEMS TABLE
   ═══════════════════════════════════════════════════════════════════════ */
.invoice-items-table { font-size: 12.5px; }
.invoice-items-table thead { background: var(--green); color: #fff; }
.invoice-items-table thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .35px;
    padding: .55rem .5rem; white-space: nowrap;
    border-color: transparent; font-weight: 600;
    background-color: var(--green) !important; color: rgba(255,255,255,.92) !important;
}
.invoice-items-table tbody td { padding: .3rem .4rem; vertical-align: middle; }
.invoice-items-table .form-control,
.invoice-items-table .form-select {
    font-size: 12.5px; padding: .3rem .5rem; border-radius: 6px;
}
.invoice-items-table .computed-field {
    background: var(--green-pale) !important;
    border-color: #86efac !important;
    color: var(--green-dark); font-weight: 600;
}
.add-row-btn {
    border: 2px dashed var(--border); color: var(--text-muted);
    background: transparent; border-radius: 8px; cursor: pointer;
    font-size: 12.5px; padding: .35rem 1.1rem; transition: all .18s;
    display: inline-flex; align-items: center; gap: 5px;
}
.add-row-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-pale); }

.invoice-totals-bar {
    background: var(--green-pale); border: 1px solid #bbf7d0;
    border-radius: 10px; padding: .9rem 1.2rem;
    margin-top: .75rem; display: flex; gap: 2rem; flex-wrap: wrap;
}
.invoice-totals-bar .total-item .label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); display: block; margin-bottom: 2px;
}
.invoice-totals-bar .total-item .value { font-size: 1.05rem; font-weight: 700; color: var(--green); }
.invoice-totals-bar .total-item .value.gold { color: var(--gold-dark); }

/* ═══════════════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════════════ */
.badge-pending { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; font-size: 11.5px; padding: 3px 10px; border-radius: 20px; font-weight: 500; display: inline-block; }
.badge-paid    { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; font-size: 11.5px; padding: 3px 10px; border-radius: 20px; font-weight: 500; display: inline-block; }
.badge-partial { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; font-size: 11.5px; padding: 3px 10px; border-radius: 20px; font-weight: 500; display: inline-block; }

/* Invoice View Detail Fields */
.inv-detail-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); margin-bottom: 3px; font-weight: 500; }
.inv-detail-value { font-size: 14px; color: var(--text); font-weight: 500; }

/* Payment grid in view */
.inv-pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1.25rem; }
.inv-pay-item { padding: .65rem .85rem; background: var(--bg); border-radius: 8px; border: 1px solid var(--border); }

/* Payment history rows */
.inv-pay-history-item { display: flex; justify-content: space-between; align-items: flex-start;
    padding: .6rem 0; border-bottom: 1px solid var(--border-light); }
.inv-pay-history-item:last-child { border-bottom: none; padding-bottom: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════════════════ */
.modal-content  { border-radius: var(--card-radius); border: none; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header   { padding: 1rem 1.25rem; }
.modal-body     { padding: 1.25rem; }
.modal-footer   { padding: .75rem 1.25rem; }
.modal-header[style*="background:var(--green)"] { border-radius: calc(var(--card-radius) - 1px) calc(var(--card-radius) - 1px) 0 0; }

/* ═══════════════════════════════════════════════════════════════════════
   NAV TABS  (Reports page)
   ═══════════════════════════════════════════════════════════════════════ */
.nav-tabs { border-bottom: 2px solid var(--border); gap: 3px; }
.nav-tabs .nav-link {
    border: none !important; color: var(--text-muted) !important;
    padding: .55rem 1.1rem; font-size: 13.5px; font-weight: 500;
    border-radius: 8px 8px 0 0; transition: all .18s; margin-bottom: -2px;
}
.nav-tabs .nav-link:hover { color: var(--green) !important; background: var(--green-pale); }
.nav-tabs .nav-link.active {
    color: var(--green) !important; background: var(--card-bg);
    border-bottom: 2px solid var(--green) !important; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════════════ */
.login-wrapper {
    min-height: 100vh; display: flex;
    align-items: center; justify-content: center;
    background: var(--sidebar-bg); position: relative; overflow: hidden;
}
.login-wrapper::before {
    content: ''; position: absolute;
    width: 600px; height: 600px; border-radius: 50%;
    background: var(--green); opacity: .07;
    top: -200px; right: -150px;
}
.login-wrapper::after {
    content: ''; position: absolute;
    width: 400px; height: 400px; border-radius: 50%;
    background: var(--gold); opacity: .07;
    bottom: -150px; left: -100px;
}
.login-card {
    background: #fff; border-radius: 20px;
    box-shadow: 0 25px 65px rgba(0,0,0,.45);
    padding: 2.75rem 2.5rem;
    width: 100%; max-width: 430px;
    position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-img { height: 90px; width: auto; max-width: 240px; object-fit: contain; margin-bottom: .75rem; }
.login-logo-icon {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, var(--green), var(--green-hover));
    border-radius: 16px; margin: 0 auto 1rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; color: var(--gold);
    box-shadow: 0 8px 20px rgba(11,102,35,.35);
}
.login-logo .logo-title { font-size: 1.75rem; font-weight: 700; color: var(--text); letter-spacing: -.5px; }
.login-logo .logo-title span { color: var(--green); }
.login-logo .logo-sub { font-size: 12px; color: var(--text-muted); letter-spacing: 1.2px; text-transform: uppercase; margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════════════
   INVOICE GRID — Summary Bar
   ═══════════════════════════════════════════════════════════════════════ */
.inv-summary-bar {
    display: flex; gap: 1rem; flex-wrap: wrap;
}
.inv-sum-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: .7rem 1.2rem;
    display: flex; flex-direction: column; gap: 3px;
    flex: 1; min-width: 160px;
}
.inv-sum-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .6px; color: var(--text-muted);
}
.inv-sum-value {
    font-size: 1.15rem; font-weight: 700; color: var(--text);
    letter-spacing: -.3px;
}

/* invoice no hover underline */
.inv-no-link:hover { text-decoration: underline !important; }

/* ═══════════════════════════════════════════════════════════════════════
   INVOICE GRID — card no inner padding
   ═══════════════════════════════════════════════════════════════════════ */
.erp-card.p-0 { padding: 0 !important; }
.erp-card.p-0 .table-responsive { border-radius: var(--card-radius) var(--card-radius) 0 0; overflow-x: auto; }

/* ═══════════════════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════════════════ */
.text-green   { color: var(--green) !important; }
.text-gold    { color: var(--gold-dark) !important; }
.text-xmuted  { color: var(--text-xmuted) !important; }
.bg-cream     { background: var(--cream) !important; }
.fw-medium    { font-weight: 500 !important; }
.fw-semibold  { font-weight: 600 !important; }
.border-green { border-color: var(--green) !important; }
.toast-container { z-index: 9999; }
.alert        { border-radius: 8px; font-size: 13.5px; }
.page-item.active .page-link { background: var(--green) !important; border-color: var(--green) !important; }
.btn-xs { padding: .22rem .55rem; font-size: 12px; border-radius: 6px; line-height: 1.4; }
.btn-outline-danger { color: #ef4444; border-color: #fca5a5; }
.btn-outline-danger:hover { background: #fef2f2; color: #dc2626; border-color: #ef4444; }

/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tablet ≤ 991px ───────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* Sidebar */
    .erp-sidebar { transform: translateX(-100%); box-shadow: none; }
    .erp-sidebar.mobile-open { transform: translateX(0); box-shadow: 8px 0 30px rgba(0,0,0,.3); }
    .sidebar-close-btn { display: flex; }
    .erp-main-area { margin-left: 0 !important; }
    .erp-topbar { padding: 0 1rem; }
    .erp-content { padding: 1rem; }

    /* Typography */
    .page-header { gap: .5rem; }
    .page-header h1 { font-size: 1.05rem; }
    .kpi-value { font-size: 1.5rem; }
    .kpi-card { padding: 1.1rem 1.2rem; }
    .kpi-icon { font-size: 2.25rem; }

    /* Invoice form items table */
    .invoice-totals-bar { gap: 1rem; padding: .7rem .9rem; }
    .invoice-items-table { min-width: 600px; }

    /* Login */
    .login-card { margin: 1rem; padding: 2rem 1.5rem; }

    /* ── Invoices list table: hide Vendor(4), DC No(5), Profit(8) ── */
    #invoicesTable th:nth-child(4), #invoicesTable td:nth-child(4),
    #invoicesTable th:nth-child(5), #invoicesTable td:nth-child(5),
    #invoicesTable th:nth-child(8), #invoicesTable td:nth-child(8) { display: none; }
    #invoicesTable { font-size: 12.5px; }

    /* ── Vendors / Customers: hide Added On col ── */
    #vendorsTable th:nth-child(3),   #vendorsTable td:nth-child(3),
    #customersTable th:nth-child(3), #customersTable td:nth-child(3) { display: none; }
    #vendorsTable td:last-child, #customersTable td:last-child { white-space: nowrap; }

    /* ── Receivables / Payables: hide Location(2), Date(3) ── */
    #recPendingTable  th:nth-child(2), #recPendingTable  td:nth-child(2),
    #recPendingTable  th:nth-child(3), #recPendingTable  td:nth-child(3),
    #recReceivedTable th:nth-child(2), #recReceivedTable td:nth-child(2),
    #recReceivedTable th:nth-child(3), #recReceivedTable td:nth-child(3),
    #payPendingTable  th:nth-child(2), #payPendingTable  td:nth-child(2),
    #payPendingTable  th:nth-child(3), #payPendingTable  td:nth-child(3),
    #payPaidTable     th:nth-child(2), #payPaidTable     td:nth-child(2),
    #payPaidTable     th:nth-child(3), #payPaidTable     td:nth-child(3) { display: none; }
    #recPendingTable, #recReceivedTable,
    #payPendingTable, #payPaidTable { font-size: 12.5px; }

    /* ── Prevent long Invoice No / Customer / Vendor from wrapping ── */
    /* No wrapping on any cell — table-responsive handles horizontal scroll */
    #recPendingTable  td, #recPendingTable  th,
    #recReceivedTable td, #recReceivedTable th,
    #payPendingTable  td, #payPendingTable  th,
    #payPaidTable     td, #payPaidTable     th { white-space: nowrap; }

    /* Cap Invoice No and Customer/Vendor columns with ellipsis */
    #recPendingTable  td:nth-child(1), #recReceivedTable td:nth-child(1),
    #payPendingTable  td:nth-child(1), #payPaidTable     td:nth-child(1) {
        max-width: 130px; overflow: hidden; text-overflow: ellipsis;
    }
    #recPendingTable  td:nth-child(4), #recReceivedTable td:nth-child(4),
    #payPendingTable  td:nth-child(4), #payPaidTable     td:nth-child(4) {
        max-width: 140px; overflow: hidden; text-overflow: ellipsis;
    }
    /* Same for invoices list */
    #invoicesTable td, #invoicesTable th { white-space: nowrap; }
    #invoicesTable td:nth-child(1) { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
    #invoicesTable td:nth-child(3) { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
}

/* ── Phone ≤ 575px ────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
    .erp-content { padding: .6rem; }

    /* Page header: title + action on same row, wrap if no space */
    .page-header { flex-wrap: wrap; row-gap: .5rem; }
    .page-header h1 { font-size: .95rem; }

    /* KPI cards: always 2 per row on phones */
    .kpi-card { padding: .85rem 1rem; }
    .kpi-value { font-size: 1.2rem; }
    .kpi-sub   { font-size: 10.5px; }
    .kpi-icon  { font-size: 1.8rem; right: .7rem; }

    /* erp-card padding */
    .erp-card { padding: .85rem; }

    /* Invoice totals bar: 2-column grid on phones */
    .invoice-totals-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: .6rem .75rem;
        padding: .75rem;
    }
    .invoice-totals-bar .total-item { display: flex; flex-direction: column; }
    .invoice-totals-bar .total-item .label { margin-bottom: 2px; }

    /* Summary bar (invoices list): 2-column grid */
    .inv-summary-bar { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
    .inv-sum-item { min-width: 0; }
    .inv-sum-value { font-size: .95rem; }

    /* Modal */
    .modal-dialog { margin: .4rem; }

    /* Login */
    .login-card { padding: 1.75rem 1.25rem; }

    /* Nav tabs: scrollable, no text wrap */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 1px; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { font-size: 11.5px; padding: .4rem .65rem; white-space: nowrap; }

    /* Reports page-header filter row: vertical stack */
    .reports-filter-row { flex-direction: column; align-items: stretch !important; gap: .5rem !important; }
    .reports-filter-row label { display: none; }
    .reports-filter-row select { width: 100% !important; }

    /* Invoice view KPI strip: small font, tighter padding */
    .invoice-view-kpi .kpi-card { padding: .7rem .8rem; }
    .invoice-view-kpi .kpi-value { font-size: 1rem; }
    .invoice-view-kpi .kpi-sub   { font-size: 10px; }

    /* Table cells: tighter padding on phones */
    .erp-table tbody td { padding: .45rem .6rem; font-size: 12.5px; }
    .erp-table thead th { padding: .5rem .6rem; font-size: 10px; }

    /* Receivables/Payables pending: also hide Due Date(5), Ageing(8) */
    #recPendingTable th:nth-child(5), #recPendingTable td:nth-child(5),
    #recPendingTable th:nth-child(8), #recPendingTable td:nth-child(8),
    #payPendingTable th:nth-child(5), #payPendingTable td:nth-child(5),
    #payPendingTable th:nth-child(8), #payPendingTable td:nth-child(8) { display: none; }
    /* Receivables/Payables received/paid: also hide Due Date(5), Ageing(7) */
    #recReceivedTable th:nth-child(5), #recReceivedTable td:nth-child(5),
    #recReceivedTable th:nth-child(7), #recReceivedTable td:nth-child(7),
    #payPaidTable th:nth-child(5), #payPaidTable td:nth-child(5),
    #payPaidTable th:nth-child(7), #payPaidTable td:nth-child(7) { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════ */
@media print {
    .erp-sidebar, .erp-topbar, .no-print { display: none !important; }
    .erp-main-area { margin-left: 0 !important; }
    .erp-content { padding: 0 !important; }
    body, .erp-card { background: #fff !important; }
    .erp-card { border: none !important; box-shadow: none !important; padding: 0 !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   SEARCHABLE PRODUCT DROPDOWN
   ═══════════════════════════════════════════════════════════════════════ */
.product-search-wrap {
    position: relative;
}
.product-search-input {
    width: 100%;
}
.product-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,.12);
    max-height: 200px;
    overflow-y: auto;
}
.product-search-dropdown:empty {
    display: none;
}
.product-dd-item {
    padding: 7px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-dd-item:hover {
    background: var(--green-pale);
    color: var(--green);
}
.product-dd-empty {
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
