/* =========================================================
   WACS design system — Waste Analysis & Characterization Study
   Sits on top of the Modernize theme (styles.min.css) and
   Bootstrap 5. Forest-green environmental palette, calm
   neutrals, consistent spacing.
========================================================= */

:root {
    /* Brand */
    --app-brand: #15803d;
    --app-brand-600: #166534;
    --app-brand-dark: #14532d;
    --app-brand-50: #ecf8f0;
    --app-brand-100: #d5efdf;
    --app-accent: #84cc16;

    /* Sidebar */
    --app-side-bg: #0e3b2b;
    --app-side-bg-2: #0a2c20;
    --app-side-text: #b9d3c6;
    --app-side-muted: #6f9a85;
    --app-side-hover: rgba(255, 255, 255, 0.06);

    /* Neutrals */
    --app-bg: #f3f6f4;
    --app-surface: #ffffff;
    --app-border: #e3e9e5;
    --app-border-soft: #eef2ef;
    --app-text: #1f2d27;
    --app-muted: #5f6f68;
    --app-subtle: #f7faf8;

    /* Data colors (match wacs-charts.js) */
    --app-c1: #15803d;
    --app-c2: #0ea5e9;
    --app-c3: #f59e0b;
    --app-c4: #8b5cf6;
    --app-c5: #ef4444;

    --app-radius: 12px;
    --app-radius-sm: 8px;
    --app-shadow: 0 1px 2px rgba(16, 40, 30, 0.04), 0 2px 8px rgba(16, 40, 30, 0.04);
    --app-shadow-lg: 0 10px 30px rgba(16, 40, 30, 0.10);

    /* Re-point Bootstrap's primary at the brand green */
    --bs-primary: #15803d;
    --bs-primary-rgb: 21, 128, 61;
    --bs-link-color: #15803d;
    --bs-link-color-rgb: 21, 128, 61;
    --bs-link-hover-color: #14532d;
    --bs-link-hover-color-rgb: 20, 83, 45;
    --bs-primary-bg-subtle: #ecf8f0;
    --bs-primary-text-emphasis: #14532d;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: #1f2d27;
}

body {
    font-family: var(--bs-body-font-family);
    color: var(--app-text);
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
}

body,
.page-wrapper,
.body-wrapper {
    background-color: var(--app-bg);
}

.body-wrapper > .container-fluid {
    max-width: 1400px;
    padding-bottom: 40px;
}

::selection { background: var(--app-brand-100); }

.text-primary { color: var(--app-brand) !important; }
.bg-primary { background-color: var(--app-brand) !important; }
.border-primary { border-color: var(--app-brand) !important; }
.bg-primary-subtle { background-color: var(--app-brand-50) !important; }
.min-w-0 { min-width: 0; }
.tabular { font-variant-numeric: tabular-nums; }

/* =========================================================
   Sidebar
========================================================= */
.left-sidebar {
    background: linear-gradient(180deg, var(--app-side-bg) 0%, var(--app-side-bg-2) 100%);
    border-right: 0;
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.05);
}

.left-sidebar .sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.brand-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.brand-logo {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-height: 0;     /* theme's own .brand-logo sets 70px + padding */
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(132, 204, 22, 0.25);
}

.brand-logo img { width: 36px !important; height: 36px !important; max-width: none; object-fit: contain; margin: 0 !important; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { color: #fff; font-size: 20px; font-weight: 800; letter-spacing: 1.5px; }
.brand-text small { color: var(--app-side-muted); font-size: 11px; font-weight: 500; white-space: nowrap; }

.btn-sidebar-close {
    color: var(--app-side-text);
    padding: 4px 8px;
    border: 0;
}
.btn-sidebar-close:hover { color: #fff; background: var(--app-side-hover); }

.left-sidebar .scroll-sidebar {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    padding: 4px 14px 16px;
}

.left-sidebar .nav-small-cap {
    margin-top: 20px;
    padding: 3px 12px;
    color: var(--app-side-muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.sidebar-nav ul .sidebar-item .sidebar-link {
    color: var(--app-side-text);
    border-radius: 10px;
    padding: 9px 12px;
    gap: 12px;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-nav ul .sidebar-item .sidebar-link .ti { font-size: 20px; }

.sidebar-nav ul .sidebar-item .sidebar-link:hover {
    background-color: var(--app-side-hover);
    color: #fff;
}

.sidebar-link.active,
.sidebar-nav ul .sidebar-item > .sidebar-link.active,
.sidebar-nav ul .sidebar-item.selected > .sidebar-link,
.sidebar-nav ul .sidebar-item.selected > .sidebar-link.active,
.sidebar-nav ul .sidebar-item.selected > .sidebar-link.active:hover {
    background-color: transparent;
    background-image: linear-gradient(90deg, rgba(132, 204, 22, 0.22), rgba(132, 204, 22, 0.06));
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--app-accent);
}

.sidebar-link.active .ti { color: var(--app-accent); }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 14px 14px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
}

.sidebar-user .avatar-initials {
    background: var(--app-accent);
    color: var(--app-side-bg-2);
    width: 36px;
    height: 36px;
}

.sidebar-user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-user-text strong { color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text small { color: var(--app-side-muted); font-size: 11.5px; }

.sidebar-logout {
    color: var(--app-side-text);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.sidebar-logout:hover { background: rgba(239, 68, 68, 0.18); color: #fecaca; }

/* =========================================================
   Top bar
========================================================= */
.app-header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--app-border);
    box-shadow: none;
}

.app-header .navbar { min-height: 68px; }

.topbar-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--app-border);
    color: var(--app-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    padding: 0;
}
.topbar-icon-btn:hover { background: var(--app-subtle); }

.system-title { line-height: 1.2; min-width: 0; }

.system-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--app-brand-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.system-crumb {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--app-muted);
    margin-top: 2px;
}
.system-crumb .ti { font-size: 13px; }
.system-crumb .ti-leaf { color: var(--app-brand); }
.system-crumb .current { color: var(--app-text); font-weight: 600; }

.topbar-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--app-subtle);
    border: 1px solid var(--app-border);
    font-size: 12.5px;
    color: var(--app-muted);
    white-space: nowrap;
}
.topbar-date .ti { color: var(--app-brand); font-size: 15px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--app-muted);
    border: 1px solid transparent;
}
.topbar-user:hover,
.topbar-user[aria-expanded="true"] { background: var(--app-subtle); border-color: var(--app-border); }
.topbar-user-text { flex-direction: column; line-height: 1.15; }
.topbar-user-text strong { color: var(--app-text); font-size: 13px; }
.topbar-user-text small { font-size: 11.5px; color: var(--app-muted); }

.topbar-menu {
    min-width: 240px;
    padding: 8px;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-lg);
    margin-top: 8px !important;
}
.topbar-menu-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--app-border-soft);
}
.topbar-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}
.topbar-menu .dropdown-item .ti { font-size: 18px; color: var(--app-muted); }
.topbar-menu .dropdown-item.text-danger .ti { color: inherit; }
.topbar-menu .dropdown-item:hover { background: var(--app-brand-50); color: var(--app-brand-dark); }
.topbar-menu .dropdown-item.text-danger:hover { background: #fef2f2; color: #b91c1c; }

/* =========================================================
   Page heading
========================================================= */
.page-heading { margin-bottom: 1.5rem; }

.page-heading h4,
.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--app-text);
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.page-heading .page-subtitle,
.page-subtitle {
    color: var(--app-muted);
    font-size: 0.875rem;
}

.breadcrumb { font-size: 0.8125rem; margin-bottom: 0.5rem; }
.breadcrumb a { color: var(--app-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--app-brand); }

/* =========================================================
   Cards
========================================================= */
.card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    background: var(--app-surface);
}

.card > .card-header {
    background: var(--app-surface);
    color: var(--app-text);
    border-bottom: 1px solid var(--app-border-soft);
    padding: 14px 20px;
    font-weight: 600;
    border-top-left-radius: var(--app-radius);
    border-top-right-radius: var(--app-radius);
}

.card > .card-header .ti { color: var(--app-brand); }

.card-title {
    color: var(--app-text);
    font-size: 1rem;
    font-weight: 600 !important;
}

.card-subtitle-sm {
    font-size: 0.8125rem;
    color: var(--app-muted);
}

/* Legacy KPI cards (border-start border-4) → soft accent cards */
.card.border-start.border-4 {
    border-left-width: 1px !important;
    border-color: var(--app-border) !important;
    position: relative;
    overflow: hidden;
}
.card.border-start.border-4::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}
.card.border-start.border-4.border-success::before { background: var(--app-c1); }
.card.border-start.border-4.border-primary::before { background: var(--app-c2); }
.card.border-start.border-4.border-info::before    { background: var(--app-c4); }
.card.border-start.border-4.border-warning::before { background: var(--app-c3); }
/* The theme gives every card a 30px bottom margin; inside a grid row
   with h-100 that margin stretches the card past its content. */
.row > [class*="col"] > .card.h-100 { margin-bottom: 0; }
.card.border-start.border-4 h6 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =========================================================
   KPI cards (dashboard)
========================================================= */
.kpi-card {
    height: 100%;
    margin-bottom: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.kpi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-muted);
}

.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 0.875rem; font-weight: 600; color: var(--app-muted); letter-spacing: 0; margin-left: 2px; }

.kpi-foot { font-size: 0.8125rem; color: var(--app-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tone-green  .kpi-icon { background: #e7f6ec; color: var(--app-c1); }
.tone-blue   .kpi-icon { background: #e6f5fd; color: #0284c7; }
.tone-amber  .kpi-icon { background: #fef3e2; color: #d97706; }
.tone-violet .kpi-icon { background: #f1ecfe; color: #7c3aed; }

.trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.trend-up   { background: #fef2f2; color: #b91c1c; }   /* more waste = bad */
.trend-down { background: #ecf8f0; color: #166534; }

.meter {
    height: 8px;
    border-radius: 999px;
    background: var(--app-border-soft);
    overflow: hidden;
}
.meter > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--app-brand), var(--app-accent));
}
.meter.meter-sm { height: 6px; }

/* =========================================================
   Dashboard hero
========================================================= */
.dash-hero {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    padding: 24px 28px;
    margin-bottom: 1.5rem;
    color: #fff;
    background:
        radial-gradient(600px 200px at 100% 0%, rgba(132, 204, 22, 0.35), transparent 60%),
        linear-gradient(120deg, #14532d 0%, #15803d 55%, #1e9a52 100%);
    box-shadow: 0 8px 24px rgba(20, 83, 45, 0.18);
}

.dash-hero .hero-leaf {
    position: absolute;
    right: -20px;
    bottom: -40px;
    font-size: 200px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.07);
    pointer-events: none;
}

.dash-hero h4 { color: #fff; font-weight: 700; font-size: 1.45rem; margin-bottom: 4px; letter-spacing: -0.01em; }
.dash-hero p { color: rgba(255, 255, 255, 0.82); margin-bottom: 0; font-size: 0.9rem; }
.dash-hero .hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #d9f99d;
    margin-bottom: 8px;
}

.dash-hero .hero-actions { position: relative; z-index: 1; }

.dash-hero .form-select {
    background-color: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
    min-width: 120px;
    font-weight: 600;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
.dash-hero .form-select option { color: var(--app-text); }
.dash-hero .form-select:focus { box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25); border-color: #fff; }

.btn-hero {
    background: #fff;
    color: var(--app-brand-dark);
    font-weight: 600;
    border: 0;
}
.btn-hero:hover { background: #f0fdf4; color: var(--app-brand-dark); }

.btn-hero-ghost {
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: transparent;
}
.btn-hero-ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.5); }

.hero-field-label { font-size: 0.72rem; color: rgba(255, 255, 255, 0.75); text-transform: uppercase; letter-spacing: 0.08em; }

/* Ranked list (top cooperators) */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { padding: 10px 0; border-bottom: 1px solid var(--app-border-soft); }
.rank-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-badge {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--app-border-soft);
    color: var(--app-muted);
    flex-shrink: 0;
}
.rank-list li:nth-child(1) .rank-badge { background: #fef3c7; color: #b45309; }
.rank-list li:nth-child(2) .rank-badge { background: #e5e7eb; color: #374151; }
.rank-list li:nth-child(3) .rank-badge { background: #fde7d6; color: #9a3412; }

/* Activity list (recent entries) */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--app-border-soft);
}
.activity-list li:last-child { border-bottom: 0; }
.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--app-brand-50);
    color: var(--app-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.activity-title { font-weight: 600; font-size: 0.875rem; color: var(--app-text); }
.activity-meta { font-size: 0.75rem; color: var(--app-muted); }

/* Quick actions */
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--app-radius);
    border: 1px solid var(--app-border);
    background: var(--app-surface);
    text-decoration: none;
    color: var(--app-text);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    height: 100%;
}
.quick-action:hover {
    border-color: var(--app-brand-100);
    box-shadow: var(--app-shadow-lg);
    transform: translateY(-1px);
    color: var(--app-text);
}
.quick-action .kpi-icon { width: 40px; height: 40px; font-size: 19px; }
.quick-action strong { display: block; font-size: 0.875rem; }
.quick-action small { color: var(--app-muted); font-size: 0.75rem; }

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--app-muted);
}
.empty-state .ti {
    font-size: 40px;
    color: #b7c8bf;
    display: block;
    margin-bottom: 8px;
}

.chip-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--app-muted); }
.chip-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* =========================================================
   Tables
========================================================= */
.table { --bs-table-color: var(--app-text); }

.table > thead.table-light > tr > th,
.table > thead > tr.table-light > th,
.table-modern > thead > tr > th {
    background-color: var(--app-subtle);
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--app-border);
    white-space: nowrap;
}

.table > tfoot > tr.table-light > td { background-color: var(--app-subtle); }
.table > :not(caption) > * > * { border-bottom-color: var(--app-border-soft); }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f3faf5; }

/* =========================================================
   Buttons, forms, badges, alerts
========================================================= */
.btn { border-radius: var(--app-radius-sm); font-weight: 500; }

.btn-primary {
    --bs-btn-bg: var(--app-brand);
    --bs-btn-border-color: var(--app-brand);
    --bs-btn-hover-bg: var(--app-brand-600);
    --bs-btn-hover-border-color: var(--app-brand-600);
    --bs-btn-active-bg: var(--app-brand-dark);
    --bs-btn-active-border-color: var(--app-brand-dark);
    --bs-btn-disabled-bg: var(--app-brand);
    --bs-btn-disabled-border-color: var(--app-brand);
    --bs-btn-focus-shadow-rgb: 21, 128, 61;
    box-shadow: 0 1px 2px rgba(20, 83, 45, 0.15);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-brand);
    --bs-btn-border-color: var(--app-brand-100);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--app-brand);
    --bs-btn-hover-border-color: var(--app-brand);
    --bs-btn-active-bg: var(--app-brand-600);
    --bs-btn-active-border-color: var(--app-brand-600);
    --bs-btn-focus-shadow-rgb: 21, 128, 61;
}

/* Theme's "secondary" is light blue; keep secondary actions neutral */
.btn-outline-secondary {
    --bs-btn-color: #3f4f48;
    --bs-btn-border-color: #d8e1dc;
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-hover-bg: var(--app-subtle);
    --bs-btn-hover-border-color: #c4d0c9;
    --bs-btn-active-color: var(--app-text);
    --bs-btn-active-bg: var(--app-border-soft);
    --bs-btn-active-border-color: #c4d0c9;
}

.btn-light-brand {
    background: var(--app-brand-50);
    color: var(--app-brand-dark);
    border: 1px solid transparent;
}
.btn-light-brand:hover { background: var(--app-brand-100); color: var(--app-brand-dark); }

.form-control,
.form-select {
    border-radius: var(--app-radius-sm);
    border-color: #d8e1dc;
}

.form-control:focus,
.form-select:focus {
    border-color: #6fbf8c;
    box-shadow: 0 0 0 0.2rem rgba(21, 128, 61, 0.15);
}

.form-check-input:checked { background-color: var(--app-brand); border-color: var(--app-brand); }
.form-check-input:focus { box-shadow: 0 0 0 0.2rem rgba(21, 128, 61, 0.15); border-color: #6fbf8c; }

.form-label { font-weight: 600; color: var(--app-text); font-size: 0.875rem; }
.form-hint { font-size: 0.8125rem; color: var(--app-muted); margin-top: 4px; }

.page-link { color: var(--app-brand); border-color: var(--app-border); }
.page-link:hover { color: var(--app-brand-dark); background: var(--app-brand-50); }
.active > .page-link,
.page-link.active { background-color: var(--app-brand); border-color: var(--app-brand); }

.nav-pills .nav-link.active { background-color: var(--app-brand); }
.nav-tabs .nav-link.active { color: var(--app-brand-dark); border-bottom-color: var(--app-brand); }

.progress { background-color: var(--app-border-soft); border-radius: 999px; }
.progress-bar { border-radius: 999px; }

.alert { border-radius: var(--app-radius); border-width: 1px; }
.badge { font-weight: 600; }

.modal-content { border: 0; border-radius: 16px; box-shadow: var(--app-shadow-lg); }
.modal-header { border-bottom-color: var(--app-border-soft); }
.modal-footer { border-top-color: var(--app-border-soft); }

/* =========================================================
   Accordion (encoding forms, record view)
========================================================= */
.accordion-item { border-color: var(--app-border) !important; }

.accordion-button { background: #fff; color: var(--app-text); padding: 14px 20px; }

.accordion-button:not(.collapsed) {
    background: var(--app-brand-50);
    color: var(--app-brand-dark);
    box-shadow: inset 0 -1px 0 var(--app-border);
}

.accordion-button:focus { box-shadow: none; }

/* =========================================================
   Small stat tiles
========================================================= */
.stat-tile {
    padding: 14px 18px;
    border-radius: var(--app-radius);
    background: #fff;
    border: 1px solid var(--app-border);
    height: 100%;
}

.stat-tile .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
    margin-bottom: 4px;
}

.stat-tile .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* =========================================================
   Meta chips (record details)
========================================================= */
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eff4f1;
    color: var(--app-muted);
    font-size: 0.8125rem;
}

/* =========================================================
   Avatars
========================================================= */
.avatar-initials {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.8125rem;
    background: var(--app-brand-50);
    color: var(--app-brand);
}

.avatar-initials.avatar-lg { width: 72px; height: 72px; font-size: 1.5rem; }

/* =========================================================
   Form sections
========================================================= */
.form-section-title {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-section + .form-section {
    border-top: 1px solid var(--app-border);
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

/* =========================================================
   Two-step progress (Generate -> Encode)
========================================================= */
.stepper { display: flex; gap: 8px; flex-wrap: wrap; }

.stepper .step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--app-muted);
}

.stepper .step .step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8125rem;
    background: #eef1f5;
    color: var(--app-muted);
}

.stepper .step.active { color: var(--app-text); font-weight: 600; }
.stepper .step.active .step-num { background: var(--app-brand); color: #fff; }
.stepper .step.done .step-num { background: var(--app-brand-100); color: var(--app-brand); }
.stepper .step-sep { width: 32px; height: 1px; background: var(--app-border); align-self: center; }

/* =========================================================
   Encoding sheet (add / update waste)
========================================================= */
.entry-toolbar .cat-jump { border: 1px solid var(--app-border); font-weight: 500; }

.entry-sheet {
    max-height: calc(100vh - 330px);
    min-height: 320px;
    overflow: auto;
}

.entry-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--app-subtle);
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--app-border);
    padding-top: 10px;
    padding-bottom: 10px;
}

.entry-table .cat-row > th {
    background: var(--app-brand-50);
    color: var(--app-brand-dark);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-top: 2px solid var(--app-brand-100);
    padding-top: 8px;
    padding-bottom: 8px;
    scroll-margin-top: 44px;
}

.entry-table .sub-row td { border-color: var(--app-border-soft); }
.entry-table .sub-row:hover td { background: #fafcfb; }
.entry-table .sub-row.has-value .sub-name { color: var(--app-text); font-weight: 600; }
.entry-table .sub-name { color: var(--app-muted); }
.entry-table .weight-input { min-width: 90px; }

.weight-input.is-filled { background-color: #f2faf6; border-color: #bfe3cf; }
.weight-input.is-changed { background-color: #fff8e6; border-color: #ffd27a; }
.weight-input.is-removed { background-color: #fff1ee; border-color: #f7b7a8; }
.weight-input.is-removed::placeholder { color: #d9534f; }

.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.weight-input[type=number] { -moz-appearance: textfield; }

kbd {
    background: #eef1f5;
    color: var(--app-text);
    border: 1px solid var(--app-border);
    font-size: 0.75rem;
    padding: 1px 5px;
}

/* =========================================================
   Categories page
========================================================= */
.category-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--app-brand-50);
    color: var(--app-brand);
    font-size: 1.2rem;
}

.card > .card-header .category-icon .ti { color: var(--app-brand); }

.subcat-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
    max-height: 420px;
    overflow-y: auto;
}

.subcat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--app-border-soft);
}

.subcat-item:last-child { border-bottom: 0; }
.subcat-item:hover { background: #f8fbf9; }

.subcat-name { flex-grow: 1; color: var(--app-text); font-size: 0.9rem; }
.subcat-usage { font-size: 0.75rem; color: var(--app-muted); white-space: nowrap; }

.subcat-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.subcat-item:hover .subcat-actions,
.subcat-actions:focus-within { opacity: 1; }

@media (hover: none) {
    .subcat-actions { opacity: 1; }
}

/* =========================================================
   Record history (view-generated)
========================================================= */
.history-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #eff4f1;
    color: var(--app-muted);
}

.record-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--app-brand-50);
    color: var(--app-brand);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.breakdown-table > thead > tr > th {
    background: var(--app-subtle);
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--app-border-soft);
    border-bottom: 1px solid var(--app-border);
    padding: 10px 16px;
    white-space: nowrap;
}

.breakdown-table td,
.breakdown-table th { padding-left: 16px; padding-right: 16px; }
.breakdown-table > :not(caption) > * > :first-child { padding-left: 24px; }
.breakdown-table > :not(caption) > * > :last-child { padding-right: 24px; }

.breakdown-table .cat-row > th {
    background: #fbfdfc;
    color: var(--app-text);
    font-size: 0.875rem;
    font-weight: 700;
    padding-top: 12px;
    padding-bottom: 12px;
    border-top: 1px solid var(--app-border);
}
.breakdown-table tbody:first-of-type .cat-row > th { border-top: 0; }

.cat-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 8px;
    vertical-align: 0;
}

.cat-share {
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--app-border-soft);
    color: var(--app-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.breakdown-table .sub-row td { font-size: 0.875rem; padding-top: 8px; padding-bottom: 8px; }
.breakdown-table .sub-row .sub-name { padding-left: 42px !important; color: var(--app-text); }
.breakdown-table .sub-row.empty-note td,
.breakdown-table .sub-row.is-empty td[colspan] { padding-left: 42px !important; }
.breakdown-table .text-muted-2 { color: #b5c2bb; }

/* Items with no weight are hidden unless "Show items with no weight" is on */
.breakdown-table .sub-row.is-empty { display: none; }
.breakdown-table.show-empty .sub-row.is-empty { display: table-row; }
.breakdown-table.show-empty .sub-row.empty-note { display: none; }
.breakdown-table .sub-row.is-empty .sub-name { color: var(--app-muted); }

.breakdown-table > tfoot > tr > th {
    background: var(--app-brand-50);
    color: var(--app-brand-dark);
    border-top: 2px solid var(--app-brand-100);
    border-bottom: 0;
    padding-top: 14px;
    padding-bottom: 14px;
    font-size: 0.875rem;
}
.breakdown-table .grand-total { font-size: 1.05rem; white-space: nowrap; }

.composition-bar {
    display: flex;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--app-border-soft);
    gap: 2px;
}
.composition-bar > span { display: block; height: 100%; }

.mini-stat {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--app-subtle);
    border: 1px solid var(--app-border-soft);
}
.mini-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--app-text); line-height: 1.2; }
.mini-stat-label { font-size: 0.75rem; color: var(--app-muted); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: var(--app-border-soft);
}
.timeline li { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--app-brand-50);
    color: var(--app-brand);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--app-brand-100);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    position: relative;
}
.timeline li.is-muted .timeline-icon { background: var(--app-border-soft); color: var(--app-muted); box-shadow: 0 0 0 1px var(--app-border); }
.timeline-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--app-muted); }
.timeline-meta { font-size: 0.8125rem; color: var(--app-muted); }

/* =========================================================
   Audit trail
========================================================= */
.audit-table .audit-reason {
    min-width: 200px;
    max-width: 320px;
    color: var(--app-text);
}

.audit-table .badge {
    font-size: 0.6875rem;
    padding: 0.3em 0.6em;
    border-radius: 6px;
}

.audit-callout {
    padding: 14px 16px;
    border-radius: var(--app-radius);
    background: #fff8eb;
    border: 1px solid #fde4b0;
}

td.has-audit { cursor: help; }
td.has-audit:hover { background: #f3faf5; color: var(--app-text) !important; }

/* =========================================================
   Responsive
========================================================= */
@media (max-width: 1199.98px) {
    .left-sidebar { box-shadow: var(--app-shadow-lg); }
}

@media (max-width: 575.98px) {
    .app-header { padding: 0 12px; }
    .system-name { font-size: 13px; }
    .body-wrapper > .container-fluid { padding-left: 14px; padding-right: 14px; }
    .dash-hero { padding: 20px; }
    .kpi-value { font-size: 1.55rem; }
    .kpi-card { padding: 16px; }
    .kpi-card .kpi-icon { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
}

@media print {
    .left-sidebar, .app-header, #pageLoader, .d-print-none { display: none !important; }
    .body-wrapper { margin-left: 0 !important; }
    .card { box-shadow: none !important; break-inside: avoid; }
    .table-responsive { overflow: visible !important; }
}
