@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Manrope:wght@600;700;800&family=Noto+Sans+Khmer:wght@400;500;600;700&display=swap');

/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Manrope', 'DM Sans', system-ui, sans-serif;

    --bg: #f3f6f2;
    --surface: #ffffff;
    --surface-2: #f8faf8;
    --surface-3: #eef4ea;

    --ink: #16211c;
    --ink-2: #3f5148;
    --muted: #7c8b83;
    --line: #e4ebe6;
    --line-strong: #d3e0d7;

    --brand: #1f3d2f;
    --brand-2: #2f5a43;
    --accent: #c9ec63;
    --accent-2: #8fd06a;
    --accent-ink: #1b3023;

    --green: #2f8f5b;
    --green-bg: #e9f7ef;
    --green-line: #d3ecdd;
    --amber: #a9781b;
    --amber-bg: #fff5df;
    --amber-line: #f2e2b8;
    --red: #b94d44;
    --red-bg: #fff0ee;
    --red-line: #f3d6d2;
    --blue: #2f6f9f;
    --blue-bg: #eaf3fb;
    --blue-line: #d3e6f5;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;

    --shadow-xs: 0 1px 2px rgba(22, 33, 28, .05);
    --shadow-sm: 0 2px 6px rgba(22, 33, 28, .05), 0 1px 2px rgba(22, 33, 28, .04);
    --shadow: 0 12px 34px rgba(22, 33, 28, .08);
    --shadow-lg: 0 30px 80px rgba(14, 32, 22, .22);

    --sidebar-width: 272px;
    --sidebar-bg-top: #0f231c;
    --sidebar-bg-bottom: #17332a;
    --sidebar-border: rgba(255, 255, 255, .07);
    --sidebar-text: #a9c0b4;
    --sidebar-text-strong: #eef7f0;
    --sidebar-muted: #708a7c;
    --sidebar-accent: #d4f26a;
    --sidebar-accent-soft: rgba(212, 242, 106, .12);
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1100px 520px at 100% -8%, #eaf3e5 0%, rgba(234, 243, 229, 0) 60%),
        var(--bg);
    color: var(--ink);
    font: 15px/1.55 var(--font-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3, h4 {
    margin: 0;
    font-family: var(--font-display);
    letter-spacing: -.03em;
    color: var(--ink);
}
h1 { font-size: clamp(24px, 2.4vw, 32px); font-weight: 800; line-height: 1.12; }
h2 { font-size: 18px; font-weight: 700; line-height: 1.25; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 7px 0 0; color: var(--muted); line-height: 1.6; }
small { font-size: 12px; }

:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 10px 10px;
    font-weight: 700;
    transition: top .2s ease;
}
.skip-link:focus { top: 0; }

/* ==========================================================================
   App shell
   ========================================================================== */
.app { min-height: 100vh; display: flex; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 22px 16px 18px;
    color: var(--sidebar-text);
    background: linear-gradient(180deg, var(--sidebar-bg-top) 0%, var(--sidebar-bg-bottom) 100%);
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 4px;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 4px;
    border-radius: 12px;
}

.brand-logo { display: block; height: auto; color: inherit; }
.sidebar .brand-logo { width: 196px; max-width: 100%; color: #f1f7f2; }

.sidebar-close {
    display: none;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--sidebar-border);
    border-radius: 10px;
    background: rgba(255, 255, 255, .04);
    color: var(--sidebar-text-strong);
}
.sidebar-close svg { width: 18px; height: 18px; }

.side-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 4px 8px;
    margin-top: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 242, 106, .28) transparent;
}
.side-scroll::-webkit-scrollbar { width: 6px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(212, 242, 106, .25); border-radius: 999px; }
.side-scroll::-webkit-scrollbar-track { background: transparent; }

.sidebar nav { display: block; margin: 0; }

.nav-group { display: grid; gap: 2px; margin-bottom: 6px; }

.sidebar .side-label {
    margin: 18px 10px 7px;
    color: var(--sidebar-muted);
    font: 700 9.5px var(--font-body);
    letter-spacing: .16em;
    text-transform: uppercase;
}
.nav-group:first-child .side-label { margin-top: 10px; }

.sidebar .nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 11px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.2;
    transition: background-color .16s ease, color .16s ease;
}
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .055); color: var(--sidebar-text-strong); }
.sidebar .nav-link.is-active { background: var(--sidebar-accent-soft); color: var(--sidebar-accent); }
.sidebar .nav-link.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-accent);
}

.nav-icon { width: 19px; height: 19px; flex-shrink: 0; opacity: .78; transition: opacity .16s ease; }
.sidebar .nav-link:hover .nav-icon,
.sidebar .nav-link.is-active .nav-icon { opacity: 1; }

.sidebar .nav-text {
    min-width: 0;
    font-size: inherit;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 14px 4px 0;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .045);
}
.user-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #e6ff8f, #8fd06a);
    color: #173021;
    font: 800 15px var(--font-display);
}
.user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.user-name {
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.user-role {
    color: var(--sidebar-muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    margin-top: 6px;
    padding: 9px 11px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: #b7d78e;
    font-weight: 700;
    font-size: 12.5px;
    transition: background-color .16s ease, color .16s ease;
}
.logout-btn svg { width: 17px; height: 17px; opacity: .85; }
.logout-btn:hover { background: rgba(255, 255, 255, .055); color: #fff; }

.sidebar a:focus-visible,
.sidebar button:focus-visible { outline: 2px solid var(--sidebar-accent); outline-offset: 2px; }

/* Main column */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 40px;
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-heading { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.topbar-title {
    font: 800 15px var(--font-display);
    letter-spacing: -.01em;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar-crumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: .09em;
    text-transform: uppercase;
    font-weight: 700;
}
.topbar-crumbs b { color: var(--line-strong); }
.topbar-current { color: var(--brand-2); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-date { color: var(--muted); font-size: 12px; font-weight: 600; }

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
}
.lang-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 5px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.lang-switch a:hover { color: var(--ink); }
.lang-switch a.is-active { background: var(--brand); color: #fff; }
html[lang="km"] body { font-family: 'Noto Sans Khmer', 'DM Sans', system-ui, sans-serif; }
html[lang="km"] h1,
html[lang="km"] h2,
html[lang="km"] h3,
html[lang="km"] .topbar-title,
html[lang="km"] .trend-total,
html[lang="km"] .donut-center strong { font-family: 'Noto Sans Khmer', 'Manrope', sans-serif; letter-spacing: 0; }
html[lang="km"] .eyebrow,
html[lang="km"] .side-label,
html[lang="km"] .mini-label { letter-spacing: .04em; }

.user-chip {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e4f3d5, #cfe8c0);
    color: #3f6a4b;
    font-weight: 800;
    font-size: 13px;
    border: 1px solid #d8e9cb;
}

.mobile-toggle {
    display: none;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--brand-2);
}
.mobile-toggle svg { width: 20px; height: 20px; }
.mobile-toggle:hover { background: var(--surface-2); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(7, 20, 15, .55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .2s ease;
}

.content {
    width: 100%;
    max-width: 1460px;
    margin: 0 auto;
    padding: 38px 40px 64px;
    flex: 1;
}

footer {
    padding: 0 40px 26px;
    color: #9fada4;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
footer span { opacity: .6; }

/* ==========================================================================
   Page headers
   ========================================================================== */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
    flex-wrap: wrap;
}
.page-head > div:first-child { min-width: 0; }
.panel .page-head { margin-bottom: 14px; }

.eyebrow {
    margin-bottom: 9px;
    color: var(--brand-2);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.page-actions,
.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-note { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* ==========================================================================
   Buttons & links
   ========================================================================== */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 12px 17px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: 13.5px;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(31, 61, 47, .16);
    transition: background-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.button:hover { background: var(--brand-2); transform: translateY(-1px); box-shadow: 0 12px 24px rgba(31, 61, 47, .2); }
.button:active { transform: translateY(0); }
.button.full { width: 100%; justify-content: space-between; }
.button.small { padding: 9px 13px; font-size: 12.5px; }
.button.danger { background: var(--red); box-shadow: 0 8px 18px rgba(185, 77, 68, .18); }
.button.danger:hover { background: #a63f37; }

.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink-2);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.1;
    white-space: nowrap;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
.secondary:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--brand-2);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: color .16s ease;
}
.text-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.text-link.muted { color: var(--muted); }
.text-link.danger { color: var(--red); }
.text-link:disabled { opacity: .45; cursor: not-allowed; }

/* ==========================================================================
   Panels & cards
   ========================================================================== */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.panel + .panel { margin-top: 20px; }
.stack { margin-top: 22px; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 24px;
    flex-wrap: wrap;
}
.panel-head p { font-size: 13px; }

.form-panel,
.list-panel { padding: 24px; }

.panel-body { padding: 0 24px 24px; }

.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Summary card */
.summary {
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 420px;
    margin-bottom: 22px;
    padding: 20px 22px;
    border: 1px solid var(--green-line);
    border-radius: var(--radius);
    background: linear-gradient(135deg, #eef6e9, #f8fbf5);
}
.summary-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 13px;
    background: #dbeacb;
    color: #4c754f;
    font-size: 22px;
}
.summary small,
.summary span,
.summary strong { display: block; }
.summary small { color: #6f8a72; font-size: 9.5px; font-weight: 800; letter-spacing: .12em; }
.summary strong { margin: 4px 0; font: 800 26px var(--font-display); }
.summary span { color: #7d9382; font-size: 12px; }

/* Stat cards */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.stat-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-card small { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.stat-card strong { font: 800 27px/1 var(--font-display); color: var(--ink); }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card.warn strong { color: var(--amber); }
.stat-card.danger strong { color: var(--red); }

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    opacity: 0;
    transition: opacity .18s ease;
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.metric:hover::before { opacity: 1; }
.metric small { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.metric strong { font: 800 30px/1 var(--font-display); color: var(--ink); }
.metric span { color: var(--brand-2); font-size: 12px; font-weight: 700; }
.metric-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin-bottom: 2px;
    border-radius: 11px;
    background: var(--surface-3);
    color: var(--brand-2);
}
.metric-icon svg { width: 19px; height: 19px; }

.clock-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.person-head { margin-bottom: 18px; }
.person-head h2 { margin: 0; }
.person-head small { display: block; margin-top: 3px; color: var(--muted); }
.summary-wide { margin: 0 0 20px; max-width: none; }
.button.large { padding: 16px 20px; font-size: 15px; }
.clock-hint { margin-top: 12px; text-align: center; font-size: 12px; }
.list-block { margin-top: 16px; }
@media (max-width: 760px) {
    .clock-grid { grid-template-columns: 1fr; }
}

.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.dashboard-panels.stack { margin-top: 22px; }

.info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    padding: 11px 0;
    border-bottom: 1px solid #f0f4f1;
    font-size: 13.5px;
}
.info-row:last-child { border-bottom: 0; }
.info-row > span:first-child { color: var(--muted); font-weight: 600; }
.info-row > span:last-child { color: var(--ink); font-weight: 700; text-align: right; }
.dashboard-panels .form-panel { margin: 0; }
.dashboard-panels .text-link { margin-top: 16px; }

/* ==========================================================================
   Dashboard analytics
   ========================================================================== */
.stat-row.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1360px) { .stat-row.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .stat-row.six { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.dash-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.dash-grid > .panel,
.dash-3 > .panel { margin: 0; }
@media (max-width: 1100px) {
    .dash-grid,
    .dash-3 { grid-template-columns: 1fr; }
}

.trend-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.trend-total { display: block; font: 800 25px/1.1 var(--font-display); color: var(--ink); }
.trend-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.trend-delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 800;
}
.trend-delta small { font-weight: 600; opacity: .75; }
.trend-delta.up { background: var(--green-bg); color: var(--green); }
.trend-delta.down { background: var(--red-bg); color: var(--red); }

.trend-chart { padding: 30px 24px 20px; }
.trend-bars { display: flex; align-items: flex-end; gap: 10px; height: 200px; }
.trend-col { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.trend-track { flex: 1; display: flex; align-items: flex-end; }
.trend-bar {
    position: relative;
    width: 100%;
    min-height: 6px;
    border-radius: 9px 9px 3px 3px;
    background: linear-gradient(180deg, var(--accent), #a9d977);
    transition: filter .15s ease, transform .15s ease;
}
.trend-bar:hover { filter: brightness(1.04); transform: translateY(-2px); }
.trend-col.is-today .trend-bar { background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.trend-label { margin-top: 10px; text-align: center; color: var(--muted); font-size: 11px; font-weight: 700; }
.trend-col.is-today .trend-label { color: var(--brand-2); }
.trend-tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .14s ease;
    z-index: 5;
}
.trend-bar:hover .trend-tip { opacity: 1; }

.paymix { display: flex; align-items: center; gap: 22px; padding: 2px 24px 24px; flex-wrap: wrap; }
.donut { position: relative; width: 132px; height: 132px; flex-shrink: 0; border-radius: 50%; }
.donut::after { content: ""; position: absolute; inset: 26px; border-radius: 50%; background: var(--surface); }
.donut-center { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.donut-center strong { font: 800 22px/1 var(--font-display); color: var(--ink); }
.donut-center small { margin-top: 4px; color: var(--muted); font-size: 9.5px; font-weight: 800; letter-spacing: .1em; }
.paymix-legend { flex: 1; min-width: 150px; display: grid; gap: 12px; }
.legend-row { display: flex; align-items: center; gap: 9px; }
.legend-dot { width: 10px; height: 10px; flex-shrink: 0; border-radius: 3px; }
.legend-meta { flex: 1; min-width: 0; }
.legend-meta strong { display: block; color: var(--ink); font-size: 12.5px; }
.legend-meta small { color: var(--muted); font-size: 11px; }
.legend-percent { color: var(--ink); font-weight: 800; font-size: 12.5px; font-variant-numeric: tabular-nums; }

.rank-list { display: grid; gap: 15px; margin-top: 16px; }
.rank-row { display: grid; gap: 6px; }
.rank-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; }
.rank-top strong { color: var(--ink); }
.rank-top span { color: var(--muted); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-track { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.rank-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand-2), var(--accent-2)); }
.rank-row > small { color: var(--muted); font-size: 11px; }

.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-title-row h2 { margin: 0; }
.mini-label { margin: 20px 0 4px; color: var(--muted); font-size: 9.5px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.mini-label:first-of-type { margin-top: 6px; }

.attention { display: grid; margin-top: 8px; }
.attention-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f4f1; color: inherit; }
.attention-row:last-child { border-bottom: 0; }
.attention-row:hover .attention-title { color: var(--brand-2); }
.attention-row .grow { flex: 1; min-width: 0; }
.attention-title { display: block; color: var(--ink); font-size: 13.5px; font-weight: 700; }
.attention-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; }

@media (max-width: 640px) {
    .trend-bars { height: 165px; gap: 6px; }
    .paymix { gap: 18px; }
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; text-align: left; }

th {
    padding: 13px 24px;
    background: var(--surface-2);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    white-space: nowrap;
}
td {
    padding: 15px 24px;
    border-bottom: 1px solid #f0f4f1;
    color: var(--ink-2);
    vertical-align: middle;
}
tbody tr { transition: background-color .14s ease; }
tbody tr:hover { background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
td strong { color: var(--ink); font-weight: 700; }
td small { display: block; margin-top: 3px; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.row-actions,
.table-actions { display: flex; align-items: center; gap: 14px; }

.empty {
    padding: 54px 24px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}
.empty strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 15px; }
.panel-body .empty { padding: 20px 0; text-align: left; }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}
.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
}
.badge.active { background: var(--green-bg); color: var(--green); }
.badge.soon { background: var(--amber-bg); color: var(--amber); }
.badge.expired { background: var(--red-bg); color: var(--red); }
.badge.inactive { background: #f0f2f1; color: #77867e; }
.badge.info { background: var(--blue-bg); color: var(--blue); }
.badge.neutral { background: #eef1ef; color: #6c7b73; }

/* ==========================================================================
   Notices
   ========================================================================== */
.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 13px 15px;
    border: 1px solid var(--green-line);
    border-radius: 12px;
    background: var(--green-bg);
    color: #226b45;
    font-weight: 600;
    font-size: 13.5px;
}
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.notice.error { border-color: var(--red-line); background: var(--red-bg); color: var(--red); }
.notice.info { border-color: var(--blue-line); background: var(--blue-bg); color: var(--blue); }
.notice.warning { border-color: var(--amber-line); background: var(--amber-bg); color: var(--amber); }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
    margin-top: 22px;
}
.form-grid .full-span { grid-column: 1 / -1; }

label {
    display: grid;
    gap: 7px;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease;
}
input::placeholder, textarea::placeholder { color: #a6b2ab; }
input:focus, select:focus, textarea:focus {
    border-color: #8fb39a;
    box-shadow: 0 0 0 4px rgba(143, 179, 154, .18);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand-2); }
textarea { min-height: 96px; resize: vertical; }

.field-help { color: var(--muted); font-size: 12px; font-weight: 500; }
.error { color: var(--red); font-size: 12px; font-weight: 600; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.panel > .form-actions { margin-top: 0; padding: 20px 24px; }

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: 640px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.inline-form .grow { flex: 1; min-width: 200px; }

.review-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-form input,
.review-form select { width: 150px; padding: 7px 9px; font-size: 12px; }

/* Sale line builder */
.sale-lines { display: grid; gap: 12px; margin-top: 18px; }
.sale-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px auto;
    align-items: end;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}
.sale-line label { margin: 0; }
.sale-line .remove-line { padding-bottom: 11px; }
.line-actions { margin-top: 12px; }
.sale-preview {
    margin-top: 18px;
    padding: 16px 18px;
    border: 1px dashed var(--line-strong);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-weight: 600;
}
.form-section { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.form-section h2 { margin: 0 0 4px; }
.form-section > p { margin: 0; }
@media (max-width: 640px) {
    .sale-line { grid-template-columns: 1fr; }
    .sale-line .remove-line { padding-bottom: 0; justify-self: start; }
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 18px;
    font-weight: 600;
}
.checkbox-field input { width: auto; }

/* ==========================================================================
   Toolbars & search
   ========================================================================== */
.search,
.toolbar {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}
.search input { width: 230px; }
.search select { width: auto; min-width: 150px; padding: 10px 12px; }
.search button,
.toolbar button {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink-2);
    font-weight: 700;
    font-size: 13px;
    transition: background-color .16s ease, border-color .16s ease;
}
.search button:hover,
.toolbar button:hover { background: var(--surface-2); border-color: var(--line-strong); }

.filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-2);
    font-size: 12px;
    font-weight: 700;
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ==========================================================================
   Lists & people
   ========================================================================== */
.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid #f0f4f1;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row strong { color: var(--ink); }
.list-row small { display: block; margin-top: 3px; color: var(--muted); }

.person { display: flex; align-items: center; gap: 12px; }
.avatar {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #e4efdf;
    color: #55765e;
    font-weight: 800;
    font-size: 13px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.pagination { padding: 16px 24px; border-top: 1px solid var(--line); }
.pagination nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination nav > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 700;
}
.pagination a:hover { background: var(--surface-2); border-color: var(--line-strong); }
.pagination span[aria-current="page"] > span,
.pagination span[aria-current="page"] {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.pagination span.disabled,
.pagination [aria-disabled="true"] { opacity: .45; }
.pagination p { margin: 0; font-size: 12.5px; color: var(--muted); }
.pagination svg { width: 16px; height: 16px; }

/* ==========================================================================
   Login
   ========================================================================== */
.login-body {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
    background: var(--bg);
}
.login-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    overflow: hidden;
    padding: 52px;
    color: #eaf5ee;
    background:
        radial-gradient(900px 500px at 10% 0%, #24503c 0%, rgba(36, 80, 60, 0) 55%),
        linear-gradient(160deg, #0f231c 0%, #17332a 60%, #102a20 100%);
}
.login-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(700px 420px at 30% 20%, #000 0%, transparent 75%);
    pointer-events: none;
}
.login-aside > * { position: relative; }
.login-aside .login-brand { margin-bottom: 0; }
.login-aside .login-logo { width: min(100%, 260px); color: #f4f9f3; }
.login-aside-note { margin: 0; color: #7f9a8b; font-size: 12px; text-align: left; }
.login-aside h2 { color: #fff; font-size: clamp(26px, 3vw, 38px); line-height: 1.1; }
.login-aside p { color: #a9c0b4; max-width: 430px; font-size: 14.5px; }
.login-points { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.login-points li { display: flex; align-items: center; gap: 10px; color: #c9d9cf; font-size: 13.5px; }
.login-points span {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: rgba(212, 242, 106, .14);
    color: var(--sidebar-accent);
    font-size: 12px;
    font-weight: 800;
}
.login-main { display: grid; place-items: center; padding: 40px 24px; position: relative; }
.login-lang { position: absolute; top: 20px; right: 24px; }
.login-card {
    width: min(100%, 430px);
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 30px; }
.login-logo { display: block; width: min(100%, 220px); height: auto; color: #2b2626; }
.login-card h1 { font-size: 28px; }
.login-card form { display: grid; gap: 17px; margin-top: 26px; }
.login-card .button.full { justify-content: space-between; margin-top: 4px; }
.login-foot { margin-top: 24px; color: var(--muted); font-size: 12px; text-align: center; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (min-width: 1024px) {
    .sidebar { position: sticky; top: 0; height: 100vh; overflow: hidden; }
}

@media (max-width: 1023px) {
    .app { display: block; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(86vw, var(--sidebar-width));
        height: 100dvh;
        overflow: hidden;
        transform: translateX(-102%);
        transition: transform .25s ease;
        box-shadow: 24px 0 60px rgba(6, 18, 13, .35);
    }
    body.nav-open { overflow: hidden; }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop { display: block; opacity: 1; }
    .sidebar-close { display: grid; }
    .mobile-toggle { display: grid; }
    .topbar { padding: 10px 18px; }
    .content { padding: 28px 18px 50px; }
    footer { padding: 0 18px 22px; }
}

@media (max-width: 900px) {
    .login-body { grid-template-columns: 1fr; }
    .login-aside { display: none; }
}

@media (max-width: 800px) {
    .stat-row { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; }
    .panel-head { align-items: flex-start; flex-direction: column; }
    .search, .search input { width: 100%; }
    .search select { width: 100%; }
    .topbar-date { display: none; }
}

@media (max-width: 560px) {
    .content { padding: 22px 14px 44px; }
    .topbar-crumbs { display: none; }
    .topbar { padding: 10px 14px; min-height: 64px; }
    footer { padding: 0 14px 18px; }
    .page-actions, .head-actions { width: 100%; }
    .page-actions .button, .page-actions .secondary,
    .head-actions .button, .head-actions .secondary { flex: 1; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .login-card { padding: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
    .sidebar, .topbar, footer, .form-actions, .page-head .secondary,
    .notice, .pagination, .no-print { display: none !important; }
    .app { display: block; }
    .main { display: block; }
    .content { max-width: none; padding: 0; }
    .panel { box-shadow: none; border: 0; }
    body { background: #fff; }
    table { page-break-inside: avoid; }
}
