/* Rodl Brand Colors */
:root {
    --roedl-green: #3ABE7C;
    --hunter-green: #1C3828;
    --poison-green: #CAFD26;
    --light-matcha: #ECF4E9;
    --white: #FFFFFF;
    --border-subtle: #CDEAC0;
    --text-primary: #1C3828;
    --text-secondary: #4A6B5A;
    --shadow-card: 0 2px 12px rgba(28, 56, 40, 0.07);
    --radius: 10px;
    --sidebar-width: 220px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', Tahoma, sans-serif; background: var(--light-matcha); color: var(--text-primary); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); min-height: 100vh; background: var(--roedl-green); display: flex; flex-direction: column; padding: 24px 0; position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; }
.sidebar-logo { padding: 0 24px 28px 24px; }
.sidebar-logo-text { color: var(--white); font-size: 22px; font-weight: 700; letter-spacing: 3px; }
.sidebar-logo-img { width: 120px; height: auto; object-fit: contain;}

/* Nav */
.nav-menu { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 8px; font-size: 15px; color: var(--hunter-green); text-decoration: none; transition: background 0.2s, color 0.2s; }
.nav-item:hover { background: var(--poison-green); color: var(--hunter-green); }
.nav-item.active { background: var(--hunter-green); color: var(--light-matcha); font-weight: 700; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

/* Main Content */
.main-content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; display: flex; flex-direction: column; background: var(--light-matcha); }

/* Page Header */
.page-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 32px 12px 32px; border-bottom: 2px solid var(--roedl-green); min-height: 72px; }
.page-header h1 { font-size: 24px; font-weight: 600; color: var(--hunter-green); }

/* Page Body */
.page-body { flex: 1; padding: 24px 48px; }

/* KPI Cards */
.kpi-row { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 32px; }
.kpi-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-card); border: 1px solid var(--border-subtle); padding: 20px 28px; min-width: 180px; display: flex; align-items: center; gap: 16px; }
.kpi-icon { border-radius: 50%; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--roedl-green); color: var(--white); }
.kpi-icon.accent { background: var(--poison-green); color: var(--hunter-green); }
.kpi-icon.dark { background: var(--hunter-green); color: var(--light-matcha); }
.kpi-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-bottom: 2px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--hunter-green); }

/* Status */
.status-section { margin-top: 8px; max-width: 480px; }
.status-section h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.status-bar { height: 8px; border-radius: 4px; background: var(--border-subtle); overflow: hidden; margin-bottom: 8px; }
.status-bar-fill { height: 100%; background: var(--roedl-green); border-radius: 4px; transition: width 0.4s; }
.status-labels { display: flex; justify-content: space-between; font-size: 14px; }
.status-active { color: var(--roedl-green); font-weight: 600; }
.status-inactive { color: var(--hunter-green); }

.data-table-container {
    background: var(--white); 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-card); 
    border: 1px solid var(--border-subtle); 
    overflow: auto; 
}

/* Header styling */
.data-table thead th {
    background: var(--roedl-green);
    color: var(--hunter-green);
    padding: 12px 20px;
    text-align: left;
    font-weight: 600;
}

/* Body rows */
.data-table tbody tr {
    background: var(--white);
    border-radius: 6px;
}

.data-table tbody tr:hover { 
    background: rgba(58, 190, 124, 0.06); 
}

/* ✅ Fixed comment + spacing */
.data-table td {
    padding: 12px 20px;
    vertical-align: middle;
}

/* ✅ Core table behavior */
.data-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

/* ✅ Column widths */
.data-table th:nth-child(1),
.data-table td:nth-child(1) {
    width: 45%;
    word-break: break-word;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    width: 15%;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    width: 15%;
    font-weight: 600; /* makes amount stand out */
}

.data-table th:nth-child(4),
.data-table td:nth-child(4) {
    width: 25%;
}

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-active { background: rgba(58, 190, 124, 0.15); color: #2a9d5c; }
.badge-inactive { background: rgba(28, 56, 40, 0.1); color: var(--hunter-green); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: background 0.2s; text-decoration: none; }
.btn-primary { background: var(--roedl-green); color: var(--hunter-green); }
.btn-primary:hover { background: var(--poison-green); }
.btn-accent { background: var(--poison-green); color: var(--hunter-green); }
.btn-secondary { background: var(--white); color: var(--hunter-green); border: 1px solid var(--border-subtle); }
.btn-secondary:hover { background: var(--light-matcha); }
.btn-danger { background: #e74c3c; color: white; }
.btn-icon { padding: 6px 10px; background: transparent; border: none; cursor: pointer; color: var(--hunter-green); font-size: 16px; border-radius: 6px; }
.btn-icon:hover { background: var(--light-matcha); }

/* Forms */
.form-container { max-width: 1200px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-card); border: 1px solid var(--border-subtle); padding: 32px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 14px; border: 1px solid var(--border-subtle); border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--text-primary); background: var(--white); transition: border-color 0.2s; }
.form-control:focus { outline: none; border-color: var(--roedl-green); box-shadow: 0 0 0 3px rgba(58, 190, 124, 0.15); }
select.form-control { appearance: auto; }

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Filter Bar */
.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control { max-width: 240px; }

/* Card List */
.card-list { max-width: 500px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-card); border: 1px solid var(--border-subtle); padding: 24px; }
.card-list h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card-list-item { padding: 10px 0; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; }
.card-list-item:last-child { border-bottom: none; }

/* Breakdown Bars */
.breakdown-bar { display: flex; align-items: center; margin-bottom: 12px; }
.breakdown-label { width: 160px; font-size: 14px; }
.breakdown-track { flex: 1; height: 24px; background: var(--border-subtle); border-radius: 6px; overflow: hidden; margin: 0 12px; }
.breakdown-fill { height: 100%; border-radius: 6px; transition: width 0.4s; }
.breakdown-fill.green { background: var(--roedl-green); }
.breakdown-fill.accent { background: var(--poison-green); }
.breakdown-value { font-size: 14px; font-weight: 600; min-width: 80px; text-align: right; }

/* Utilities */
.section-divider { border: none; border-top: 1px solid var(--border-subtle); margin: 32px 0; }
.text-muted { color: var(--text-secondary); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-row { display: flex; gap: 24px; }
.no-data { padding: 40px; text-align: center; color: var(--text-secondary); }


.metric-card.risk {
    border-left: 4px solid #e74c3c;
}

.metric-card.safe {
    border-left: 4px solid #2ecc71;
}

.urgent {
    color: #e74c3c;
    font-weight: 600;
}

.urgent-row {
    background-color: rgba(231, 76, 60, 0.1);
}

.kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.kpi-card.warning {
    border-left: 4px solid #e67e22;
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background-color: rgba(0, 0, 0, 0.05);
}
.link-like {
    color: #1f6f4a;
    font-weight: 500;
}

.link-like:hover {
    text-decoration: underline;
    cursor: pointer;
}

.invoice-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    border-spacing: 0 10px;
    margin-top: 10px;
}

.invoice-table th {
    text-align: left;
    font-weight: 600;
    padding: 10px 16px;
}

.invoice-table td {
    padding: 14px 16px;
    vertical-align: middle;
}
.invoice-table tbody tr {
    background: var(--white);
    border-radius: 6px;
}

.invoice-table tbody tr:hover {
    background: rgba(58, 190, 124, 0.05);
}


/* Column sizing */
.invoice-table th:nth-child(1),
.invoice-table td:nth-child(1) {
    width: 45%;
    word-break: break-word;
}

.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2) {
    width: 15%;
}

.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3) {
    width: 15%;
    font-weight: 600;
}

.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) {
    width: 25%;
}
.invoice-link {
    color: var(--roedl-green);
    font-weight: 600;
    text-decoration: none;
}

.invoice-link:hover {
    text-decoration: underline;
    color: var(--hunter-green);
}

.critical {
    color: #c0392b;
    font-weight: 700;
}

.missing {
    color: #e74c3c;
}

.covered {
    color: #2ecc71;
}

/* ── Add Vendor Modal ─────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: var(--white);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    width: 100%;
    max-width: 420px;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #e0e0e0;
}

.critical-row {
    background-color: #ffe6e6;
}

.kpi-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-item {
    background: #ffffff;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    min-width: 160px;
}

.kpi-item .kpi-label {
    font-size: 12px;
    color: #777;
}

.kpi-item .kpi-value {
    font-size: 22px;
    font-weight: 600;
}

.kpi-item.danger {
    border-left-color: #e74c3c;
}

.kpi-item.critical {
    border-left-color: #c0392b;
}

.kpi-item.success {
    border-left-color: #2ecc71;
}
.content-grid {
    display: grid;
    background: white;
    padding: 20px;
    border-radius: 8px;
}

.chart-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
}

.kpi-row {
    display: flex;
    gap: 20px;
}


.nav-link {
    color: inherit !important;
    text-decoration: none !important;
}

.nav-link:hover {
    text-decoration: none !important;
}

/* ===== Top bar + notification bell ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    padding: 10px 24px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
}
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-label { font-size: 0.85rem; color: #666; }
.topbar-select { min-width: 220px; padding: 4px 8px; }

.topbar-bell { position: relative; }
.bell-button {
    position: relative;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}
.bell-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #E53935;
    color: #fff;
    border-radius: 10px;
    font-size: 0.7rem;
    padding: 0 6px;
    min-width: 18px;
    text-align: center;
}
.bell-dropdown {
    position: absolute;
    right: 0;
    top: 36px;
    width: 360px;
    max-height: 460px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 1000;
}
.bell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}
.bell-refresh {
    background: none; border: none; color: #1976D2; cursor: pointer; font-size: 0.8rem;
}
.bell-empty { padding: 18px 14px; color: #888; font-size: 0.9rem; }
.bell-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #f2f2f2;
}
.bell-item.unread { background: #f5f9ff; }
.bell-item-main { flex: 1; cursor: pointer; }
.bell-item-title { font-weight: 600; font-size: 0.9rem; }
.bell-item-msg { font-size: 0.85rem; color: #444; margin: 2px 0; }
.bell-item-meta { font-size: 0.75rem; color: #999; }
.bell-ack {
    background: none; border: 1px solid #ccc; border-radius: 4px;
    cursor: pointer; color: #43A047; padding: 0 6px; height: 24px;
}
.status-pill { display: inline-block; }

/* Sortable table headers */
.data-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.data-table th.sortable:hover { text-decoration: underline; }

/* Inline checkbox + label */
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; }

/* Signed-in role chip in the top bar */
.role-chip {
    background: #1C3828; color: #fff; border-radius: 12px;
    padding: 2px 10px; font-size: 0.75rem; margin: 0 6px;
}
.breakdown-link {
    color: inherit;
    text-decoration: none;
}
.breakdown-link:hover {
    text-decoration: underline;
}

/* =============================================
   MOBILE RESPONSIVE  (≤ 768px)
   ============================================= */
@media (max-width: 768px) {

    /* --- Hamburger button: fixed top-left so it's always reachable --- */
    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 8px;
        left: 8px;
        width: 40px;
        height: 40px;
        background: var(--white);
        border: 1px solid var(--border-subtle);
        box-shadow: 0 1px 4px rgba(0,0,0,0.12);
        font-size: 20px;
        cursor: pointer;
        color: var(--hunter-green);
        border-radius: 8px;
        z-index: 50;
        flex-shrink: 0;
    }
    .hamburger-btn:hover { background: var(--light-matcha); }

    /* Give topbar enough left padding so content doesn't sit under the hamburger */
    .topbar { padding-left: 56px; }

    /* --- Sidebar overlay backdrop --- */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 99;
    }
    .sidebar-overlay.visible { display: block; }

    /* --- Sidebar: hidden off-screen, slides in when open --- */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 200;
    }
    .app-layout.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Close (×) button inside sidebar — shown only on mobile */
    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 0 16px 12px 16px;
    }
    .sidebar-close-btn button {
        background: none;
        border: none;
        font-size: 22px;
        cursor: pointer;
        color: var(--hunter-green);
        border-radius: 6px;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .sidebar-close-btn button:hover { background: rgba(0,0,0,0.1); }

    /* --- Main content: full width, no sidebar offset --- */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* --- TopBar: compact on mobile --- */
    .topbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px 8px 56px; /* left pad keeps content clear of fixed hamburger */
        justify-content: space-between;
    }
    .topbar-user { flex-wrap: wrap; gap: 4px; font-size: 0.8rem; }
    .topbar-label { display: none; } /* hide "Signed in as" label to save space */

    /* Bell dropdown: constrain to viewport */
    .bell-dropdown {
        width: calc(100vw - 24px);
        right: -8px;
    }

    /* --- Page body: reduce padding --- */
    .page-body { padding: 16px; }
    .page-header { padding: 16px 16px 10px 16px; }
    .page-header h1 { font-size: 18px; }

    /* --- KPI row: wrap, full width cards --- */
    .kpi-row { gap: 12px; }
    .kpi-card { min-width: 0; flex: 1 1 calc(50% - 6px); }
    .kpi-summary { flex-wrap: wrap; }
    .kpi-item { flex: 1 1 calc(50% - 10px); min-width: 0; }

    /* --- Tables: horizontal scroll --- */
    .data-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 520px; }
    .invoice-table { min-width: 520px; }

    /* Reset fixed column widths on mobile — let columns size naturally */
    .data-table th:nth-child(n),
    .data-table td:nth-child(n),
    .invoice-table th:nth-child(n),
    .invoice-table td:nth-child(n) { width: auto; }

    /* --- Forms: single column --- */
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .form-container { padding: 16px; }
    .form-actions { flex-wrap: wrap; justify-content: stretch; }
    .form-actions .btn { flex: 1; justify-content: center; }

    /* --- Filter bar: stack --- */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .form-control { max-width: 100%; }

    /* --- Breakdown bars: shrink label --- */
    .breakdown-label { width: 100px; font-size: 12px; }
    .breakdown-value { min-width: 60px; font-size: 12px; }

    /* --- Gap row: stack --- */
    .gap-row { flex-direction: column; }

    /* --- Card list: full width --- */
    .card-list { max-width: 100%; }
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
    .hamburger-btn { display: none; }
    .sidebar-overlay { display: none !important; }
    .sidebar-close-btn { display: none; }
    .sidebar { transform: none !important; transition: none; }
}