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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f9fafb;
    color: #111827;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    width: auto;
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    background: #2563eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 13px;
    letter-spacing: .5px;
}
.logo h1 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}
.header-sub {
    font-size: 14px;
    color: #6b7280;
}

/* Grouped top navigation (shared across pages via lib/nav.php + nav.js) */
.nav { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.nav-btn { font-size:12px; padding:7px 12px; border:1px solid #e5e7eb; background:#fff; border-radius:8px; cursor:pointer; color:#374151; text-decoration:none; display:inline-flex; align-items:center; gap:6px; white-space:nowrap; font-family:inherit; line-height:1; }
.nav-btn:hover { background:#f9fafb; border-color:#d1d5db; }
.nav-btn .caret { font-size:9px; color:#9ca3af; }
.nav-group { position:relative; }
.nav-group.open .nav-btn { background:#eff6ff; border-color:#bfdbfe; color:#1d4ed8; }
.nav-menu { position:absolute; right:0; top:calc(100% + 6px); background:#fff; border:1px solid #e5e7eb; border-radius:10px; box-shadow:0 10px 28px rgba(0,0,0,.13); min-width:190px; padding:6px; z-index:5000; display:none; }
.nav-group.open .nav-menu { display:block; }
.nav-menu a, .nav-menu button { display:flex; align-items:center; justify-content:space-between; gap:10px; width:100%; text-align:left; padding:9px 10px; font-size:13px; color:#374151; text-decoration:none; border:none; background:none; border-radius:7px; cursor:pointer; font-family:inherit; }
.nav-menu a:hover, .nav-menu button:hover { background:#f3f4f6; }
.nav-menu .nav-logout { margin-top:4px; padding-top:10px; border-top:1px solid #e5e7eb; color:#b91c1c; }
.nav-menu .nav-logout:hover { background:#fef2f2; }
.nav-menu .nav-logout svg { color:#b91c1c; }
.nav-plus { width:34px; height:34px; padding:0; display:inline-flex; align-items:center; justify-content:center; background:#2563eb; color:#fff; border:none; border-radius:9px; font-size:22px; font-weight:600; text-decoration:none; cursor:pointer; line-height:0; }
.nav-plus:hover { background:#1d4ed8; }
.nav-home { width:34px; height:34px; padding:0; display:inline-flex; align-items:center; justify-content:center; background:#fff; color:#374151; border:1px solid #e5e7eb; border-radius:9px; text-decoration:none; cursor:pointer; line-height:0; }
.nav-home:hover { background:#f9fafb; border-color:#d1d5db; color:#2563eb; }
.nav-badge { padding:1px 7px; border-radius:9px; background:#dc2626; color:#fff; font-size:11px; font-weight:600; line-height:1.5; }
.header-right { display:flex; align-items:center; gap:10px; }
.nav-toggle { display:none; }

/* Mobile: collapse the grouped nav behind a hamburger; groups become accordions. */
@media (max-width: 860px) {
    .header { position:relative; }
    .logo-icon + h1 { display:none; }        /* just the LGL mark on mobile — not page titles */
    .header-inner { gap:8px; }
    .nav-toggle {
        display:inline-flex; align-items:center; justify-content:center;
        width:38px; height:38px; padding:0; border:1px solid #e5e7eb; border-radius:9px;
        background:#fff; color:#374151; font-size:18px; cursor:pointer; line-height:0;
    }
    .nav {
        display:none; position:absolute; left:0; right:0; top:100%;
        flex-direction:column; align-items:stretch; gap:5px; flex-wrap:nowrap;
        background:#fff; border-top:1px solid #e5e7eb; border-bottom:1px solid #e5e7eb;
        box-shadow:0 12px 26px rgba(0,0,0,.14); padding:10px 16px 16px; z-index:4000;
        max-height:80vh; overflow-y:auto;
    }
    .nav.open { display:flex; }
    .nav-group { width:100%; }
    .nav .nav-btn { width:100%; justify-content:space-between; }   /* panel buttons only — not the inline Vendors/Items */
    .nav-menu {
        position:static; display:none; box-shadow:none; border:none;
        padding:2px 0 6px 14px; min-width:0; border-radius:0;
    }
    .nav-group.open .nav-menu { display:block; }
}

/* Compact nav: hamburger-only at ALL widths (for the "← Back" detail pages that
   already carry page-specific action buttons). The whole menu lives in the panel. */
.nav-compact { position:relative; }
.nav-compact .nav-toggle {
    display:inline-flex; align-items:center; justify-content:center;
    width:38px; height:38px; padding:0; border:1px solid #e5e7eb; border-radius:9px;
    background:#fff; color:#374151; font-size:18px; cursor:pointer; line-height:0;
}
.nav-compact .nav {
    display:none; position:absolute; right:0; left:auto; top:calc(100% + 8px);
    flex-direction:column; align-items:stretch; gap:4px; flex-wrap:nowrap;
    background:#fff; border:1px solid #e5e7eb; border-radius:10px;
    box-shadow:0 12px 26px rgba(0,0,0,.14); padding:8px; min-width:220px;
    z-index:5000; max-height:80vh; overflow-y:auto;
}
.nav-compact .nav.open { display:flex; }
.nav-compact .nav .nav-group { width:100%; }
.nav-compact .nav .nav-btn { width:100%; justify-content:space-between; }
.nav-compact .nav .nav-menu {
    position:static; display:none; box-shadow:none; border:none;
    padding:2px 0 6px 14px; min-width:0; border-radius:0;
}
.nav-compact .nav .nav-group.open .nav-menu { display:block; }

/* Main */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
@media (max-width: 640px) {
    .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
}
.stat-card {
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.stat-clickable {
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.stat-active {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}
.stat-card p.label { font-size: 11px; color: #6b7280; }
.stat-card p.value { font-size: 18px; font-weight: 700; color: #111827; line-height: 1.15; }
.stat-card .stat-sub { font-size: 10px; color: #9ca3af; margin-top: 1px; }
.stat-card.yellow { background: #fefce8; border-color: #fde68a; }
.stat-card.yellow .label { color: #a16207; }
.stat-card.yellow .value { color: #92400e; }
.stat-card.orange { background: #fff7ed; border-color: #fdba74; }
.stat-card.orange .label { color: #c2410c; }
.stat-card.orange .value { color: #ea580c; }
.stat-card.orange .stat-sub { color: #c2410c; }
.stat-card.red { background: #fef2f2; border-color: #fecaca; }
.stat-card.red .label { color: #b91c1c; }
.stat-card.red .value { color: #991b1b; }

/* Filter buttons */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.filter-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4b5563;
    transition: all 0.15s;
}
.filter-btn:hover { background: #f9fafb; }
.filter-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* Table */
.table-wrapper {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    overflow: hidden;
}
.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}
.table-wrapper thead tr {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.table-wrapper th {
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 24px;
}
.table-wrapper th.right { text-align: right; }
.table-wrapper th.center { text-align: center; }
.table-wrapper td {
    padding: 16px 24px;
    font-size: 14px;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
}
.table-wrapper tr.clickable { cursor: pointer; transition: background 0.15s; }
.table-wrapper tr.clickable:hover { background: #f9fafb; }
.table-wrapper tr.pending-row {
    background: #fefce8;
    border-left: 4px solid #facc15;
}
.td-right { text-align: right; font-family: monospace; }
.td-center { text-align: center; }

/* Source badge */
.source-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #f3f4f6;
    color: #374151;
}

/* Status badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid;
}
.badge-PENDING { background: #fef9c3; color: #92400e; border-color: #fde68a; }
.badge-ACCEPTED { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-REJECTED { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* Duplicate warning */
.duplicate-row { background: #fff7ed !important; border-left: 4px solid #f97316 !important; }
.badge-dupe {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    background: #f97316;
    color: #fff;
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

/* Action buttons */
.action-btn {
    padding: 6px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    background: transparent;
    transition: background 0.15s;
}
.action-btn.accept { color: #16a34a; }
.action-btn.accept:hover { background: #f0fdf4; }
.action-btn.reject { color: #dc2626; }
.action-btn.reject:hover { background: #fef2f2; }

/* Empty state */
.empty-state {
    padding: 48px;
    text-align: center;
}
.empty-state .icon { font-size: 40px; margin-bottom: 16px; }
.empty-state .title { font-size: 18px; font-weight: 500; color: #4b5563; }
.empty-state .sub { color: #9ca3af; margin-top: 8px; }

/* Loading */
.loading { padding: 48px; text-align: center; color: #6b7280; }

/* ===================== INVOICE DETAIL PAGE ===================== */

.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline {
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
}
.btn-outline:hover { background: #f9fafb; }
.btn-green { background: #16a34a; color: #fff; }
.btn-green:hover { background: #15803d; }
.btn-red { background: #dc2626; color: #fff; }
.btn-red:hover { background: #b91c1c; }
.btn-blue { background: #2563eb; color: #fff; }
.btn-blue:hover { background: #1d4ed8; }

.back-link {
    color: #6b7280;
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.15s;
}
.back-link:hover { color: #374151; }

/* Two column layout */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}
@media (min-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr 1fr; }
}
.detail-grid.pending-ring {
    border: 2px solid #facc15;
    border-radius: 12px;
    padding: 4px;
}

.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    padding: 24px;
}
.card h2 {
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 16px;
}

/* Document preview */
.doc-preview img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.doc-preview iframe {
    width: 100%;
    height: 600px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}
.doc-preview-clickable {
    position: relative;
    cursor: pointer;
}
.doc-preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
    color: #fff;
    text-align: center;
    padding: 20px 8px 10px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0 0 8px 8px;
    opacity: 0;
    transition: opacity 0.2s;
}
.doc-preview-clickable:hover .doc-preview-overlay { opacity: 1; }
.doc-placeholder {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border-radius: 8px;
    color: #9ca3af;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

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

/* Line items */
.line-items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.line-items-header label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}
.add-item-btn {
    font-size: 14px;
    color: #2563eb;
    background: none;
    border: none;
    cursor: pointer;
}
.add-item-btn:hover { color: #1d4ed8; }

.line-item-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}
.line-item-row .code { width: 84px; }
.line-item-row .desc { flex: 1; }
.line-item-row .qty { width: 64px; }
.line-item-row .price { width: 96px; }
.line-item-row .amt { width: 96px; }
.line-item-row input {
    width: 100%;
    padding: 4px 8px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    outline: none;
}
.line-item-row input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
.remove-item-btn {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
}
.remove-item-btn:hover { color: #b91c1c; }

.no-items {
    text-align: center;
    color: #9ca3af;
    padding: 16px;
    font-size: 14px;
}

.save-btn {
    width: 100%;
    padding: 10px;
    margin-top: 16px;
}

/* PAID status */
.badge-PAID { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.stat-card.blue { background: #eff6ff; border-color: #93c5fd; }
.stat-card.blue .label { color: #1d4ed8; }
.stat-card.blue .value { color: #1e40af; }

/* Thumbnail preview in table */
.thumb-cell { width: 60px; padding: 8px 12px !important; }
.thumb-img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.thumb-img:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #3b82f6;
}
.thumb-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #9ca3af;
}
.thumb-pdf {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #dc2626;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.thumb-pdf:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #dc2626;
}

/* Lightbox overlay */
.lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.lightbox img {
    max-width: 92vw;
    max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    cursor: default;
}
.lightbox-close {
    position: absolute;
    top: 16px;
    right: 24px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    background: none;
    border: none;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.lightbox-close:hover { opacity: 1; }
/* Lightbox gallery: top info bar + prev/next navigation */
.lightbox-info {
    position: absolute; top: 0; left: 0; right: 0;
    padding: 16px 64px; text-align: center; color: #fff; z-index: 10;
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0));
    pointer-events: none;
}
.lightbox-info .lb-vendor { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-info .lb-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.lb-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 46px; height: 46px; border-radius: 50%; border: none;
    background: rgba(0,0,0,0.5); color: #fff; font-size: 26px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 10;
}
.lb-nav:hover { background: rgba(0,0,0,0.78); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
@media (max-width: 640px) { .lb-nav { width: 38px; height: 38px; font-size: 22px; } .lightbox-info { padding: 12px 52px; } }

/* Vendor link */
.vendor-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}
.vendor-link:hover { text-decoration: underline; }

/* Vendor page */
.vendor-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.vendor-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
}
.vendor-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.vendor-stat {
    font-size: 14px;
    color: #6b7280;
}
.vendor-stat strong {
    color: #111827;
    font-size: 18px;
    display: block;
}

/* Vendor cards grid */
.vendor-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 16px;
}
@media (min-width: 640px) { .vendor-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .vendor-grid { grid-template-columns: repeat(3, 1fr); } }

.vendor-card {
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
}
.vendor-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #3b82f6;
}
.vendor-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.vendor-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #2563eb;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    flex-shrink: 0;
}
.vendor-card-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}
.vendor-card-sub {
    font-size: 13px;
    color: #6b7280;
}
.vendor-card-amounts {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.vendor-card-label {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.vendor-card-value {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    font-family: monospace;
}
.vendor-card-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Paid button */
.btn-paid { background: #2563eb; color: #fff; }
.btn-paid:hover { background: #1d4ed8; }
.action-btn.paid { color: #2563eb; }
.action-btn.paid:hover { background: #eff6ff; }

/* Selected row */
.selected-row { background: #eff6ff !important; }

/* Selection bar (floating bottom) */
.selection-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e293b;
    color: #fff;
    padding: 12px 24px;
    z-index: 900;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}
.selection-bar-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

/* Responsive overflow */
.overflow-x { overflow-x: auto; }

/* Hide on small screens */
@media (max-width: 640px) {
    .hide-mobile { display: none; }
    /* Hide only the brand wordmark (the h1 next to the LGL mark) — NOT page titles,
       which live in an <h1> beside a back-link on the "← Back" pages. */
    .logo-icon + h1 { display: none; }
    /* Keep the header on one line (logo left, actions right); let clusters wrap only if they must. */
    .header-inner { padding: 12px 16px; flex-wrap: wrap; align-items: center; gap: 10px; }
    .header-inner > div { flex-wrap: wrap; }
    .header-inner input[type="text"] { width: 100% !important; min-width: 0; box-sizing: border-box; }
    .main { padding: 16px; }
    .table-wrapper th, .table-wrapper td { padding: 10px 12px; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .thumb-cell { display: none; }
}

/* Card tables on mobile.
   A ten-column invoice table can't be read on a phone: it either overflows the
   viewport or gets clipped by .table-wrapper. nav.js tags every wide table
   .mstack and copies each column header into its cells as data-label; here the
   rows stop behaving like rows — each becomes a card with its title on top and
   one labelled line per column, so nothing has to be scrolled to sideways.
   Put .no-stack on a table to keep it a table. */
@media (max-width: 640px) {
    table.mstack { display: block; font-size: 13px; }
    table.mstack thead { display: none; }
    table.mstack tbody, table.mstack tr, table.mstack td { display: block; width: auto; }
    table.mstack tbody tr, table.mstack tfoot tr { padding: 12px 14px; border-bottom: 1px solid #e5e7eb; }
    table.mstack tbody tr:last-child, table.mstack tfoot tr:last-child { border-bottom: none; }
    table.mstack td { padding: 0; border: none; text-align: left; max-width: none; }

    /* One column per line: header on the left, value on the right. */
    table.mstack td[data-label] {
        display: flex; justify-content: space-between; align-items: baseline;
        gap: 12px; padding: 3px 0; border-top: 1px solid #f3f4f6;
    }
    table.mstack td[data-label]::before {
        content: attr(data-label); flex: none; color: #6b7280; font-size: 12px;
    }

    /* The first named column heads the card, so it carries no label. */
    table.mstack td.mstack-title { font-weight: 600; margin-bottom: 6px; }
    /* A cell spanning columns belongs to no header: empty states, footer totals. */
    table.mstack td.mstack-span { display: block; padding: 2px 0; }
    /* Checkboxes and icons (blank header) ride along the top of the card. */
    table.mstack td.mstack-bare { display: inline-block; margin-right: 8px; vertical-align: middle; }
    /* Editable cells: label above, control full width for thumbs. */
    table.mstack td.mstack-field { display: block; border-top: 1px solid #f3f4f6; padding-top: 6px; }
    table.mstack td.mstack-field::before { display: block; margin-bottom: 4px; }
    table.mstack td.mstack-field input,
    table.mstack td.mstack-field select,
    table.mstack td.mstack-field textarea { width: 100% !important; box-sizing: border-box; }
    /* Actions become a button row across the foot of the card. */
    table.mstack td.mstack-actions {
        display: flex; flex-wrap: wrap; gap: 6px;
        padding-top: 10px; white-space: normal !important;
    }
    table.mstack td.mstack-actions > * { flex: 1 1 auto; }

    /* Nothing to show, nothing to reserve space for. */
    table.mstack td:empty { display: none; }
    /* These stay hidden — the block display above would otherwise revive them. */
    table.mstack td.thumb-cell, table.mstack th.thumb-cell,
    table.mstack td.hide-mobile { display: none; }
}

/* VAT periods page + late entry additions */
.stat-card.pink {
    background: #fdf2f8;
    border-color: #fbcfe8;
    color: #9d174d;
}
.stat-card.pink .label { color: #9d174d; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-late { background: #fed7aa; color: #9a3412; margin-left: 6px; }
.badge-future { background: #dbeafe; color: #1e40af; margin-left: 6px; }

.banner { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.banner-yellow { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: white; border-radius: 8px; padding: 24px; max-width: 480px; width: 90%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.btn-small { padding: 4px 10px; font-size: 12px; }

/* Wallet entry status badges */
.badge-pending    { background:#fef3c7;color:#92400e;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:500 }
.badge-approved   { background:#d1fae5;color:#065f46;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:500 }
.badge-rejected   { background:#fee2e2;color:#991b1b;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:500 }
.badge-reimbursed { background:#e0e7ff;color:#3730a3;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:500 }
.badge-generated { background:#ede9fe; color:#6d28d9; }

/* Toast notifications */
#toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 5000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 18px; border-radius: 9px; color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(0,0,0,.18); opacity: 0; transform: translateY(12px); transition: opacity .25s ease, transform .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ok { background: #16a34a; }
.toast-err { background: #dc2626; }
