:root {
    --sidebar-width: 238px;
    --sidebar-collapsed-width: 72px;
    --ink: #17202a;
    --muted: #6b7280;
    --line: #e5e7eb;
    --surface: #ffffff;
    --soft: #f4f7f6;
    --accent: #0f766e;
    --accent-dark: #115e59;
}

body {
    background: var(--soft);
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: #101820;
    color: #e5eef4;
    flex: 0 0 var(--sidebar-width);
    padding: 18px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .18s ease, flex-basis .18s ease;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
    flex-basis: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .brand-subtitle,
body.sidebar-collapsed .nav-group-title,
body.sidebar-collapsed .sidebar-nav .nav-link span {
    display: none;
}

.brand-block {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 0 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: relative;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.brand-name {
    font-weight: 800;
    font-size: 14px;
}

.brand-subtitle {
    color: #95a3af;
    font-size: 12px;
}

.sidebar-toggle {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .08);
    color: #e5eef4;
}

body.sidebar-collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.nav-group {
    margin-top: 14px;
}

.nav-group-title {
    color: #8da0ae;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 0 10px 8px;
}

.sidebar-nav .nav-link {
    color: #d9e2e8;
    border-radius: 8px;
    padding: 7px 9px;
    margin: 2px 0;
    font-size: 13px;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background: rgba(15, 118, 110, 0.22);
    color: #fff;
}

.app-main {
    min-width: 0;
    flex: 1;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    min-height: 62px;
    padding: 12px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}

.content-card,
.summary-card,
.filter-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(16, 24, 32, 0.035);
}

.content-card {
    padding: 18px;
}

.summary-card {
    padding: 13px 14px;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
}

.summary-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.summary-value {
    font-size: 20px;
    font-weight: 800;
    margin-top: 3px;
}

.filter-panel {
    padding: 12px;
}

.filter-panel .form-label,
.filter-card .form-label {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .035em;
}

.filter-panel .form-control,
.filter-panel .form-select,
.filter-card .form-control,
.filter-card .form-select {
    min-height: 34px;
    padding: 5px 9px;
    font-size: 13px;
}

.filter-panel .row {
    --bs-gutter-y: .65rem;
}

.filter-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 6px 18px rgba(16, 24, 32, 0.035);
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #ecfdf5;
    color: #047857;
    padding: 4px 9px;
    font-size: 12px;
}

.report-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.table > :not(caption) > * > * {
    padding: .55rem .65rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 14px;
    box-shadow: 0 6px 18px rgba(16, 24, 32, 0.035);
}

.metric-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.metric-value {
    font-size: 20px;
    font-weight: 800;
    margin-top: 3px;
}

.metric-subtext {
    color: var(--muted);
    font-size: 12px;
}

.report-page {
    display: block;
}

.compact-filter-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 22px rgba(16, 24, 32, 0.04);
}

.compact-filter-card .form-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.filter-primary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 10px;
}

.more-filters summary {
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.active-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.active-filter-chip {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    color: #047857;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
}

.report-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

.metric-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 10px;
}

.metric-card-compact {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
}

.metric-card-compact .summary-label {
    font-size: 10px;
}

.metric-card-compact .summary-value {
    font-size: 17px;
}

.report-table {
    font-size: 12px;
    white-space: nowrap;
}

.report-table thead th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 11px;
    position: sticky;
    text-transform: uppercase;
    top: 0;
    z-index: 1;
}

.report-table td,
.report-table th {
    padding: .42rem .52rem !important;
    vertical-align: middle;
}

.status-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
}

.diff-positive {
    color: #047857;
}

.diff-negative {
    color: #b91c1c;
}

.empty-state {
    color: var(--muted);
    padding: 28px;
    text-align: center;
}

.badge-soft {
    background: #ecfdf5;
    color: #047857;
}

.table-empty,
.loading-row {
    color: var(--muted);
    text-align: center;
    padding: 24px !important;
}

.modal-content {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.list-group-item.active {
    background: var(--accent);
    border-color: var(--accent);
}

@media print {
    .app-sidebar,
    .topbar,
    .filter-panel,
    .btn,
    .modal,
    .toast-container {
        display: none !important;
    }

    .app-shell,
    .app-main {
        display: block;
        width: 100%;
    }

    body::before {
        content: "Kushal Timber Management | Printed " attr(data-print-date);
        display: block;
        margin-bottom: 12px;
        font-weight: 700;
    }

    .content-card,
    .summary-card {
        box-shadow: none;
        border-color: #ccc;
    }
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f6f8fb, #e8eef3);
}

.login-card {
    width: min(430px, 92vw);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 24px 60px rgba(16, 24, 32, 0.10);
}

@media (max-width: 992px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }

    .filter-primary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
