:root {
    --brand-950: #073c32;
    --brand-900: #0b5142;
    --brand-700: #11725b;
    --brand-500: #20a37d;
    --gold: #e5b957;
    --ink: #16221f;
    --muted: #66736f;
    --surface: #f4f7f6;
    --line: #dde7e3;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
}
a { color: var(--brand-700); }
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 264px;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1030;
    padding: 24px 16px;
    color: #fff;
    background: linear-gradient(180deg, var(--brand-950), #092e28);
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { width: 46px; height: 46px; border-radius: 12px; }
.brand strong { display: block; font-family: "Lora", serif; font-size: 22px; }
.brand small { color: #9fc3b9; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.nav-section { margin: 28px 10px 10px; color: #7fa99d; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.side-link {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
    padding: 10px 13px;
    border-radius: 12px;
    color: #d5e8e2;
    text-decoration: none;
    font-weight: 500;
}
.side-link:hover, .side-link.active { color: #fff; background: rgba(255,255,255,.11); }
.side-link.active { box-shadow: inset 3px 0 var(--gold); }
.side-link svg { width: 20px; height: 20px; }
.main { width: calc(100% - 264px); margin-left: 264px; }
.topbar {
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.88);
    backdrop-filter: blur(10px);
}
.content { max-width: 1500px; margin: auto; padding: 30px 32px 48px; }
.eyebrow { margin: 0 0 5px; color: var(--brand-700); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3 { color: var(--brand-950); }
h1 { margin: 0; font-family: "Lora", serif; font-size: clamp(25px, 3vw, 34px); font-weight: 700; }
.page-subtitle { margin: 7px 0 0; color: var(--muted); }
.card {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(9, 62, 50, .05);
}
.stat-card { height: 100%; padding: 20px; background: #fff; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin: 7px 0 2px; color: var(--brand-950); font-family: "Lora", serif; font-size: 26px; font-weight: 700; }
.stat-note { color: #8a9692; font-size: 11px; }
.icon-box {
    width: 42px; height: 42px; display: grid; place-items: center;
    border-radius: 12px; color: var(--brand-700); background: #e6f5f0;
}
.btn { min-height: 44px; border-radius: 11px; font-weight: 600; }
.btn-brand { color: #fff; background: var(--brand-700); border-color: var(--brand-700); }
.btn-brand:hover { color: #fff; background: var(--brand-900); border-color: var(--brand-900); }
.btn-soft { color: var(--brand-900); background: #e5f2ee; border-color: transparent; }
.form-control, .form-select {
    min-height: 46px;
    border-color: #cfdcd7;
    border-radius: 11px;
    font-size: 16px;
}
.form-control:focus, .form-select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(32,163,125,.14); }
.form-label { color: #35423e; font-size: 13px; font-weight: 650; }
.invalid-feedback { font-size: 13px; }
.ts-wrapper {
    min-height: 46px;
}
.ts-wrapper .ts-control {
    min-height: 46px;
    border-color: #cfdcd7;
    border-radius: 11px;
    font-size: 16px;
    padding: 8px 12px;
}
.ts-wrapper.single .ts-control { padding-right: 36px; }
.ts-wrapper.focus .ts-control { border-color: var(--brand-500); box-shadow: 0 0 0 .2rem rgba(32,163,125,.14); }
.ts-wrapper.is-invalid .ts-control { border-color: #dc3545; }
.ts-dropdown { z-index: 1080; border-radius: 11px; }
.table { margin: 0; }
.table th { padding: 14px 16px; border-bottom-color: var(--line); color: #71807b; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 15px 16px; border-bottom-color: #edf2f0; vertical-align: middle; }
.table > :not(caption) > * > * { background: transparent; }
.table-sort { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.table-sort:hover, .table-sort.active { color: var(--brand-700); }
.table-sort .bi { font-size: 14px; }
.badge-status { padding: 7px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.status-active { color: #087051; background: #dff5ed; }
.status-redeemed { color: #4e6077; background: #e9eef5; }
.status-expired { color: #a53b32; background: #fde8e5; }
.transaction-due-soon td { background: #fff8e8 !important; }
.transaction-due-soon td:first-child { box-shadow: inset 4px 0 #e5a629; }
.transaction-due-urgent td { background: #fdeceb !important; }
.transaction-due-urgent td:first-child { box-shadow: inset 4px 0 #d64535; }
.due-soon-label { margin-top: 3px; color: #a26400; font-size: 11px; font-weight: 700; white-space: nowrap; }
.transaction-due-urgent .due-soon-label { color: #b32d1f; }
.cell-nowrap { white-space: nowrap; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--brand-700); font-weight: 700; }
.search-panel { padding: 18px; }
.filter-label { display: block; margin-bottom: 7px; color: #56645f; font-size: 12px; font-weight: 700; }
.btn-filter-dropdown {
    min-height: 46px;
    overflow: hidden;
    border: 1px solid #cfdcd7;
    background: #fff;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.btn-filter-dropdown:hover, .btn-filter-dropdown:focus { border-color: var(--brand-500); background: #fff; }
.status-filter-menu { min-width: 220px; border-color: var(--line); border-radius: 12px; }
.filter-search { width: 350px; max-width: 100%; }
.filter-status-btn { width: 220px; max-width: 100%; }
.js-date-range { min-width: 0; overflow-x: auto; }
.date-range-control {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    width: max-content;
    max-width: 100%;
}
.date-range-control > .dropdown { flex: 0 0 200px; width: 200px; }
.date-range-control > .input-group { flex: 0 0 300px; width: 300px; flex-wrap: nowrap; }
.date-range-preset-btn { width: 100%; }
.date-range-control .input-group-text, .date-range-control .js-date-range-clear { padding: 0 9px; }
.date-range-control .js-date-range-display { flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 13px; }
.date-range-preset-menu { min-width: 200px; max-height: 320px; overflow: auto; border-color: var(--line); border-radius: 12px; }
.date-range-preset-menu .dropdown-item.active { color: var(--brand-700); font-weight: 600; background: #eef8f4; }
.list-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
.list-footer-end { display: flex; align-items: center; flex-wrap: wrap; margin-left: auto; gap: 12px 16px; }
.list-footer .pagination { margin: 0; }
.rows-per-page { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.rows-per-page .form-select { width: 72px; min-height: 36px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.js-list-table, .js-dashboard-loading { position: relative; min-height: 120px; }
.js-list-table.is-loading, .js-dashboard-loading.is-loading { pointer-events: none; }
.js-list-table.is-loading::after, .js-dashboard-loading.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(248, 250, 249, .62);
}
.js-list-table.is-loading::before, .js-dashboard-loading.is-loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid #d7e4df;
    border-top-color: var(--brand-700);
    border-radius: 50%;
    animation: list-spin .7s linear infinite;
}
@keyframes list-spin { to { transform: rotate(360deg); } }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.cccd-preview { width: 100%; aspect-ratio: 1.58; object-fit: cover; border: 1px solid var(--line); border-radius: 14px; background: #edf2f0; }
.js-cccd-empty { place-items: center; }
.mobile-topbar { display: none; }
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at 15% 10%, #1a8068 0, var(--brand-950) 38%, #052b24 100%);
}
.auth-card { width: min(100%, 430px); padding: 32px; border: 1px solid rgba(255,255,255,.17); border-radius: 24px; background: rgba(255,255,255,.97); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.auth-logo { width: 68px; height: 68px; margin-bottom: 22px; border-radius: 18px; }
.pagination { margin: 0; }
.page-link { color: var(--brand-700); }
.active > .page-link { background: var(--brand-700); border-color: var(--brand-700); }
.interest-metric, .interest-highlight {
    height: 100%;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbfa;
}
.interest-highlight { background: #eef8f4; }
.interest-highlight.is-due { background: #fff8e8; }
.interest-highlight .stat-value { font-size: 22px; }
.interest-days {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}
.interest-days .table th { position: sticky; top: 0; background: #fff; z-index: 1; }
.interest-days tr.is-today td { background: #e7f6ef; }
.interest-days tr.is-due-row td { background: #fff6dc; }

@media (max-width: 991.98px) {
    .sidebar { display: none; }
    .main { width: 100%; margin-left: 0; }
    .topbar { display: none; }
    .mobile-topbar {
        height: 66px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        border-bottom: 1px solid var(--line);
        background: #fff;
    }
    .mobile-topbar .brand strong { color: var(--brand-950); font-size: 19px; }
    .mobile-topbar .brand img { width: 40px; height: 40px; border-radius: 11px; }
    .offcanvas { color: #fff; background: var(--brand-950); }
    .content { padding: 22px 16px 88px; }
}

@media (max-width: 575.98px) {
    body { font-size: 14px; }
    .card { border-radius: 15px; }
    .auth-card { padding: 26px 22px; }
    .page-actions { width: 100%; margin-top: 16px; }
    .page-actions .btn { width: 100%; }
    .mobile-cards thead { display: none; }
    .mobile-cards, .mobile-cards tbody, .mobile-cards tr, .mobile-cards td { display: block; width: 100%; }
    .mobile-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
    .mobile-cards td { display: flex; justify-content: space-between; gap: 18px; padding: 6px 0; border: 0; text-align: right; }
    .mobile-cards td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
    .mobile-cards td.primary-cell { display: block; text-align: left; }
    .mobile-cards td.primary-cell::before { display: none; }
    .mobile-cards td.action-cell { justify-content: flex-end; padding-top: 12px; }
    .mobile-cards td.action-cell::before { display: none; }
    .list-footer { align-items: stretch; flex-direction: column; }
    .list-footer-end { justify-content: flex-end; margin-left: 0; width: 100%; }
    .list-footer nav { max-width: 100%; overflow-x: auto; }
    .cell-nowrap { white-space: normal; }
    .filter-search, .filter-status-btn { width: 100%; }
}

.litepicker {
    font-family: "Be Vietnam Pro", system-ui, sans-serif;
    --litepicker-month-header-color: #0b5142;
    --litepicker-button-prev-month-color: #11725b;
    --litepicker-button-next-month-color: #11725b;
    --litepicker-button-apply-color: #fff;
    --litepicker-button-apply-background: #11725b;
    --litepicker-is-in-range-color: #e6f5f0;
    --litepicker-is-start-color: #fff;
    --litepicker-is-start-color-bg: #11725b;
    --litepicker-is-end-color: #fff;
    --litepicker-is-end-color-bg: #11725b;
    --litepicker-is-today-color: #11725b;
    --litepicker-month-weekday-color: #66736f;
}
