/* =========================================================
   Almisri Dairy – responsive admin shell (desktop + mobile)
   ========================================================= */

:root {
    --header-h: 54px;
    --sidebar-w: 208px;

    --primary: #0f766e;
    --primary-600: #115e59;
    --primary-50: #e7f5f2;
    --accent: #14b8a6;
    --butter: #f5b83d;
    --focus-ring: rgba(20, 184, 166, .25);

    --bg: #f6f3ec;
    --surface: #ffffff;
    --surface-soft: #faf8f3;
    --border: #e8e2d6;
    --input-border: #d6cfc1;
    --text: #1d2b29;
    --muted: #6a7672;

    --success: #15803d;
    --success-bg: #dcfce7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --info: #0369a1;
    --info-bg: #e0f2fe;

    --sidebar-bg: #0e3a35;
    --sidebar-bg-2: #0a2c28;
    --sidebar-text: #c9e0da;
    --sidebar-muted: #7fa59d;
    --sidebar-active: #ffffff;

    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1100px 520px at 100% -10%, rgba(20, 184, 166, .09), transparent 60%),
        radial-gradient(900px 480px at -10% 110%, rgba(245, 184, 61, .08), transparent 60%),
        var(--bg);
    background-attachment: fixed;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.3rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.input[readonly] { background: var(--surface-soft); color: var(--muted); }
small { font-size: .82rem; }

/* ---------- Top fixed header ---------- */
.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--header-h);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.topbar::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent) 60%, var(--butter));
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; }

/* ---------- Top header tabs: B2C / B2B / Mgmt ---------- */
.top-tabs { display: flex; align-items: center; gap: 4px; margin-left: 14px; padding: 3px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 999px; }
.top-tab {
    display: inline-flex; align-items: center; justify-content: center; min-width: 58px;
    padding: 5px 14px; border-radius: 999px;
    color: var(--muted); font-weight: 700; font-size: .86rem; letter-spacing: .03em;
}
.top-tab:hover { color: var(--text); text-decoration: none; background: rgba(15, 118, 110, .07); }
.top-tab.active { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(15, 118, 110, .3); }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border: 0; border-radius: 8px;
    background: transparent; color: var(--text);
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }

/* ---------- User menu (top right) ---------- */
.user-menu { position: relative; }
.user-menu-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px;
    border: 1px solid transparent; border-radius: 999px;
    background: transparent; color: var(--text);
    font: inherit; cursor: pointer;
    max-width: 260px;
}
.user-menu-btn:hover, .user-menu.open .user-menu-btn { background: var(--bg); border-color: var(--border); }
.user-menu-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.chevron { transition: transform .15s ease; flex-shrink: 0; }
.user-menu.open .chevron { transform: rotate(180deg); }

.avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff; font-weight: 600; font-size: .85rem; letter-spacing: .5px;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar-xl { width: 60px; height: 60px; font-size: 1.3rem; }

.dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.user-menu.open .dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header { display: flex; align-items: center; gap: 12px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown-header-text { display: flex; flex-direction: column; min-width: 0; }
.dropdown-header-text > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 10px;
    border: 0; border-radius: 6px; background: transparent;
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--bg); text-decoration: none; outline: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-form { margin: 0; }

/* ---------- Left navigation ---------- */
.sidebar {
    position: fixed;
    top: var(--header-h); left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 900;
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    overflow-y: auto;
    transition: transform .2s ease;
}
.nav { padding: 10px 8px; flex: 1; }
.nav-section { padding: 14px 10px 6px; font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-link {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; margin-bottom: 2px;
    border-radius: 8px;
    color: var(--sidebar-text); font-weight: 500; font-size: .92rem;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255, 255, 255, .12); color: var(--sidebar-active); font-weight: 600; }
.nav-link.active::before {
    content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 4px;
    border-radius: 0 4px 4px 0; background: var(--butter);
}
.nav-count {
    margin-left: auto; min-width: 20px; padding: 0 6px;
    border-radius: 999px; background: var(--butter); color: #3b2a05;
    font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.sidebar-footer { padding: 12px 18px; font-size: .74rem; color: var(--sidebar-muted); border-top: 1px solid rgba(255, 255, 255, .08); }

.backdrop {
    position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(15, 23, 42, .45);
    z-index: 850;
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s;
}

/* Inside the Android app: the app draws its own header, tabs and menu, so the website's are hidden. */
.embedded .topbar, .embedded .sidebar, .embedded .backdrop { display: none !important; }
.embedded .main { margin-left: 0 !important; padding-top: 0 !important; }
.embedded .container { padding-top: 10px; }

/* ---------- Main content ---------- */
.main {
    margin-left: var(--sidebar-w);
    padding-top: var(--header-h);
    min-height: 100vh;
    min-height: 100dvh;
    transition: margin-left .2s ease;
}
.container { padding: 16px 20px; max-width: 1280px; }
/* The last block on a page must not leave a margin that pushes the page past the fold. */
#page > :last-child, #page > .grid-2 > .card { margin-bottom: 0; }

/* Desktop: hamburger collapses the sidebar */
body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
body.sidebar-collapsed .main { margin-left: 0; }

.page-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    margin-bottom: 12px;
}
.page-header h1 { font-size: 1.08rem; }
.page-header p { margin: 1px 0 0; font-size: .78rem; }
.back-link { display: inline-block; font-size: .85rem; margin-bottom: 4px; }

/* ---------- Title and sub-tabs on one row ---------- */
.page-top {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 4px 20px;
    margin-bottom: 12px; border-bottom: 1px solid var(--border);
}
.page-top .page-header { margin-bottom: 0; padding-bottom: 7px; flex: 0 1 auto; min-width: 0; }
.page-top .page-tabs { margin-bottom: 0; border-bottom: 0; flex: 1 1 auto; }
.page-top .page-header .price-toggle { margin-left: 16px; }

/* ---------- In-page tabs ---------- */
.page-tabs {
    display: flex; gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.page-tabs::-webkit-scrollbar { display: none; }
.page-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; margin-bottom: -1px;
    border-bottom: 3px solid transparent;
    color: var(--muted); font-weight: 600; white-space: nowrap;
}
.page-tab:hover { color: var(--text); text-decoration: none; background: rgba(15, 118, 110, .05); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
    min-width: 22px; padding: 0 7px;
    border-radius: 999px; background: #ece6da; color: var(--muted);
    font-size: .75rem; line-height: 20px; text-align: center;
}
.page-tab.active .tab-count { background: var(--primary); color: #fff; }

/* ---------- Cards & stats ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
}
.card-narrow { max-width: 820px; padding: 18px 20px; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.card-body { padding: 14px 16px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.stat-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; }
.stat-icon.blue { background: var(--primary-50); color: var(--primary); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.amber { background: #fef3c7; color: #b45309; }
.stat-icon.purple { background: #ede9fe; color: #6d28d9; }
.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .88rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.grid-2 .card { margin-bottom: 0; }

.profile-summary { display: flex; align-items: center; gap: 16px; padding: 14px 16px; }
.profile-summary p { margin: 2px 0 6px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfbf7; }
.table th.text-right, .table td.text-right { text-align: right; }
.table-compact th, .table-compact td { padding: 8px 10px; }
.table-compact th:first-child, .table-compact td:first-child { padding-left: 16px; }
.table-compact th:last-child, .table-compact td:last-child { padding-right: 16px; }
.table .empty { text-align: center; color: var(--muted); padding: 24px; }

.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell > div { display: flex; flex-direction: column; min-width: 0; }
.actions { display: inline-flex; gap: 8px; align-items: center; justify-content: flex-end; }
.actions form { margin: 0; }

.stacked-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

.empty-state { text-align: center; padding: 32px 20px; color: var(--muted); }
.empty-state svg { color: var(--accent); margin-bottom: 8px; }
.empty-state h2 { color: var(--text); margin-bottom: 4px; }
.empty-state p { margin: 0; }

/* ---------- Backup page ---------- */
.info-strip { display: flex; gap: 14px; padding: 14px 16px; }
.info-strip-icon {
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--primary-50); color: var(--primary);
}
.info-strip-body { min-width: 0; }
.info-strip-body p { margin: 2px 0 8px; }
.kv { display: flex; flex-wrap: wrap; gap: 6px 32px; margin: 0 0 8px; }
.kv dt { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88em; background: var(--surface-soft); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }
.callout { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; font-size: .88rem; border-left: 4px solid; }
.callout-warning { background: var(--warning-bg); color: #7c4a03; border-color: var(--butter); }
.callout-danger { background: var(--danger-bg); color: #7f1d1d; border-color: var(--danger); }
.summary-list { margin: 0 0 8px; padding-left: 20px; }
.summary-list li { margin: 2px 0; }
.no-top { margin-top: 0; }
.small-note { font-size: .85rem; margin: 0 0 12px; }
.input-file { padding: 8px; font-size: .9rem; }
.input-file::file-selector-button {
    margin-right: 12px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--primary-50); color: var(--primary); font: inherit; font-weight: 600; cursor: pointer;
}

/* ---------- Milk collection ---------- */
.text-center { text-align: center !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 600; }
.is-disabled { opacity: .4; pointer-events: none; }
.error-list { margin: 4px 0 0; padding-left: 18px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-title { margin: 0 0 12px; }

.day-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.day-nav .input { width: auto; padding: 5px 10px; }
.day-nav-label { margin-left: 4px; }

.rate-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 20px; padding: 12px 16px; }
.rate-field { display: flex; flex-direction: column; gap: 3px; min-width: 190px; }
.rate-field label { font-weight: 600; font-size: .85rem; }
.rate-field .input { max-width: 190px; }
.rate-note { flex: 1 1 260px; margin: 0; font-size: .82rem; align-self: center; }

.milk-table thead .group-row th { border-bottom: 0; padding-bottom: 2px; }
.milk-table .shift-head { color: var(--primary); letter-spacing: .06em; }
.milk-table .qty-cell { width: 13%; }
.input-qty { text-align: right; padding: 5px 8px; min-width: 76px; font-variant-numeric: tabular-nums; }
.input-qty:disabled { background: var(--surface-soft); border-style: dashed; cursor: not-allowed; }
.input-qty::placeholder { color: #c3bcad; }
.milk-table tfoot th, .table tfoot th { background: var(--surface-soft); color: var(--text); font-size: .85rem; text-transform: none; letter-spacing: 0; border-top: 2px solid var(--border); }
.milk-table td[data-row-litres], .milk-table td[data-row-amount] { font-weight: 600; }

.sheet-actions {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: -4px; padding: 10px 16px;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(4px);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 -4px 14px rgba(15, 30, 28, .06);
}
.sheet-actions .muted { font-size: .82rem; }

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 12px 16px; }
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field label { font-weight: 600; font-size: .85rem; }
.filter-field .input { padding: 6px 10px; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.stat-letter { font-weight: 800; font-size: 1.05rem; }
.grid-rates { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
.print-only { display: none; }

@media print {
    .topbar, .sidebar, .backdrop, .page-tabs, .no-print, .alert, .sheet-actions, .modal-backdrop { display: none !important; }
    .main { margin: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
    .card, .stat-card { box-shadow: none; break-inside: avoid; }
    .print-only { display: block; font-weight: 700; margin: 0 0 8px; }
}

/* ---------- Daily Milk Entry ---------- */
/* Prices exist in the page only for admins, and stay hidden until "Show prices" is switched on. */
.prices-hidden .price { display: none !important; }
.price-toggle { font-size: .9rem; white-space: nowrap; }
.stats-auto { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.alert-warning { background: var(--warning-bg); color: #7c4a03; border-color: #fcd34d; }
.replace-box p { margin: 4px 0 10px; }
.replace-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }

.entry-layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 14px; align-items: start; }
.entry-layout > .card { margin-bottom: 0; }
.entry-layout.entry-single { grid-template-columns: minmax(0, 460px); }
[data-when][hidden] { display: none !important; }
/* Litre slider: stops 0, 0.25, 1, 2 ... 10 (index 0-11) */
.qty-slider { width: 100%; margin: 8px 0 0; accent-color: var(--primary); height: 28px; cursor: grab; touch-action: pan-y; }
.qty-slider:active { cursor: grabbing; }
.qty-ticks { position: relative; display: block; height: 14px; font-size: .7rem; color: var(--muted); }
.qty-ticks span { position: absolute; left: calc(8px + (100% - 16px) * var(--i) / 11); transform: translateX(-50%); }
.milk-qty.is-na .qty-slider, .milk-qty.is-na .qty-ticks { display: none; }
.counter-pay .form-group { margin-bottom: 8px; }
.counter-amount { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--primary-50); font-size: .88rem; }
.counter-amount [data-counter-total] { font-size: 1.25rem; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.day-money { background: var(--surface-soft); }
.price-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: .85rem; }
.price-form label { font-weight: 600; margin: 0; }
.price-form .price-input { display: inline-flex; align-items: center; gap: 4px; }
.price-form .input { width: 90px; padding: 5px 8px; }
.counter-info { flex-wrap: wrap; font-size: .92rem; }
.counter-info-label { font-weight: 600; font-size: .88rem; }
.counter-info .shift-auto { margin-left: auto; font-size: .8rem; padding: 4px 10px; }
.day-link { display: block; margin-top: 12px; text-align: center; font-size: .88rem; font-weight: 600; }
.day-sales { max-width: 760px; }
.day-add { margin-left: auto; }
.entry-card { padding: 16px 18px; }
.entry-date { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.entry-date label { font-weight: 600; font-size: .88rem; }
.entry-date .input { width: auto; padding: 6px 10px; }

.input-lg { padding: 10px 12px; font-size: 16px; }
.input-xl { padding: 10px 14px; font-size: 1.6rem; font-weight: 700; text-align: center; letter-spacing: .02em; }
.btn-lg { min-height: 48px; font-size: 1.02rem; }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; }
.segmented label { position: relative; margin: 0 !important; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented label > span {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-height: 48px; padding: 6px 10px;
    border: 1.5px solid var(--input-border); border-radius: 10px; background: #fff;
    font-weight: 600; text-align: center; transition: border-color .12s ease, background .12s ease;
}
.segmented label > span small { font-weight: 500; color: var(--muted); font-size: .76rem; }
.segmented input:checked + span { border-color: var(--primary); background: var(--primary-50); color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.segmented input:focus-visible + span { box-shadow: 0 0 0 3px var(--focus-ring); }
.segmented input:disabled + span { opacity: .4; cursor: not-allowed; background: var(--surface-soft); }

.milk-qty-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.customer-find { margin-bottom: 6px; padding: 7px 11px; }
.entry-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: -16px -18px 12px; padding: 10px 18px;
    background: var(--surface-soft); border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.entry-head-label { font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.segmented-sm { display: inline-grid; grid-template-columns: auto auto; gap: 6px; }
.segmented-sm label > span { min-height: 34px; padding: 4px 16px; font-size: .84rem; letter-spacing: .04em; }
.milk-qty {
    display: flex !important; flex-direction: column; gap: 6px; margin: 0 !important;
    padding: 10px; border: 1.5px solid var(--border); border-radius: 10px; background: #fff;
    font-weight: 400 !important;
}
.form-group .milk-qty { padding: 10px; }
.milk-qty:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.milk-qty-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.milk-qty-head small { font-size: .76rem; color: var(--muted); }
.milk-qty .input-xl { font-size: 1.35rem; padding: 8px 10px; }
.milk-qty-na { display: none; font-size: .76rem; color: var(--muted); text-align: center; }
.milk-qty.is-na { background: var(--surface-soft); border-style: dashed; }
.milk-qty.is-na .input { display: none; }
.milk-qty.is-na .milk-qty-na { display: block; padding: 12px 0; }
.replace-list { margin: 0 0 8px; padding-left: 18px; }
.amount-preview {
    margin: 0 0 12px; padding: 10px 12px; border-radius: 8px;
    background: var(--surface-soft); border: 1px dashed var(--border);
    text-align: center; font-variant-numeric: tabular-nums; color: var(--muted);
}
.amount-preview strong { color: var(--text); font-size: 1.1rem; }
.amount-preview.is-warning { background: var(--warning-bg); color: #7c4a03; border-color: #fcd34d; }

.day-totals { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.day-totals > div { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; padding: 10px 16px; border-right: 1px solid var(--border); }
.day-totals > div:last-child { border-right: 0; }
.day-totals span { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.day-totals strong { font-variant-numeric: tabular-nums; }
.entry-feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }
.entry-feed li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--border); }
.entry-feed li:last-child { border-bottom: 0; }
.entry-feed li > div { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Approvals / My Requests ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px;
    border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
    color: var(--text); font-size: .86rem; font-weight: 600;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-count { font-size: .75rem; opacity: .8; }
.bulk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; }
.bulk-select { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.bulk-hint { flex: 1; font-size: .82rem; }
.request-list { display: flex; flex-direction: column; gap: 10px; }
.request-list .card { margin-bottom: 0; }
.request-card { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; }
.request-check { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }
.request-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.request-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.request-details { margin: 4px 0 0; padding-left: 18px; font-size: .88rem; }
.request-details li { margin: 1px 0; overflow-wrap: anywhere; }
.request-actions { display: flex; gap: 8px; align-items: flex-start; flex-shrink: 0; }
.request-actions form { margin: 0; }
.reject-box { position: relative; }
.reject-box summary { list-style: none; }
.reject-box summary::-webkit-details-marker { display: none; }
.reject-box[open] form {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 280px;
    display: flex; flex-direction: column; gap: 8px; padding: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.review-note { margin: 4px 0 0; padding: 6px 10px; border-radius: 6px; background: var(--surface-soft); font-size: .88rem; }
.review-note.is-bad { background: var(--danger-bg); color: #7f1d1d; }
.entry-side { display: flex; flex-direction: column; gap: 14px; }
.entry-side > .card { margin-bottom: 0; }
.pending-card { border-color: #fcd34d; }
.pending-note { margin: 0; padding: 8px 16px; font-size: .82rem; }

/* ---------- Milk Deliveries: monthly chart ---------- */
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.lg-yes { background: #d9f2e6; border-color: #9fd9bd; }
.lg-no { background: #fde8e8; border-color: #f5b5b5; }
.lg-na { background: repeating-linear-gradient(135deg, #f3efe6, #f3efe6 3px, #fff 3px, #fff 6px); }
.chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.delivery-chart { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .82rem; }
.delivery-chart th, .delivery-chart td { border-bottom: 1px solid var(--border); border-right: 1px solid #f0ebe0; padding: 0; text-align: center; }
.delivery-chart thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-soft); color: var(--muted); font-weight: 600; padding: 6px 2px; }
.delivery-chart .day-col { min-width: 30px; }
.delivery-chart .day-col span { display: block; color: var(--text); }
.delivery-chart .day-col small { display: block; font-size: .66rem; font-weight: 500; }
.delivery-chart .day-col.is-sunday { color: var(--danger); }
.delivery-chart .day-col.is-today { background: var(--primary); color: #fff; }
.delivery-chart .day-col.is-today span { color: #fff; }
.delivery-chart .sticky-col {
    position: sticky; left: 0; z-index: 1; text-align: left; padding: 6px 10px; min-width: 170px; max-width: 220px;
    background: var(--surface); border-right: 2px solid var(--border);
}
.delivery-chart thead .sticky-col { z-index: 3; background: var(--surface-soft); }
.delivery-chart tbody .sticky-col strong { display: block; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delivery-chart tbody .sticky-col small { font-size: .72rem; }
.day-cell { height: 34px; min-width: 30px; font-variant-numeric: tabular-nums; }
.day-cell a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: 34px; color: inherit; font-weight: 600; }
.day-cell a:hover { text-decoration: none; outline: 2px solid var(--accent); outline-offset: -2px; }
.day-cell.yes { background: #eaf7f0; color: #14532d; }
.day-cell.no { background: #fdf0f0; color: #b91c1c; font-size: .75rem; }
.day-cell.na { background: repeating-linear-gradient(135deg, #f7f4ec, #f7f4ec 3px, #fff 3px, #fff 6px); }
.delivery-chart .total-col { padding: 6px 10px; white-space: nowrap; min-width: 70px; background: var(--surface-soft); }
.delivery-chart .total-col.has-missed { color: #b45309; }
.delivery-chart tfoot th, .delivery-chart tfoot td { background: var(--surface-soft); font-weight: 700; color: var(--text); padding: 6px 2px; font-size: .78rem; }
.delivery-chart tfoot .sticky-col { background: var(--surface-soft); }
@media print {
    .chart-wrap { overflow: visible; }
    .delivery-chart { font-size: 9px; }
    .delivery-chart .sticky-col { min-width: 110px; }
}

/* ---------- Two-step delete dialog ---------- */
body.modal-open { overflow: hidden; }
.modal-backdrop {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(15, 30, 28, .55);
    animation: fade-in .15s ease;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    width: 100%; max-width: 420px;
    background: var(--surface); border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
    animation: pop-in .18s ease;
}
.modal-icon {
    display: flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--danger-bg); color: var(--danger);
    margin-bottom: 12px;
}
.modal-step { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.modal h3 { font-size: 1.15rem; margin: 4px 0 8px; overflow-wrap: anywhere; }
.modal p { margin: 0 0 16px; }
.modal .input { margin-bottom: 4px; letter-spacing: .06em; }
.confirm-word { color: var(--danger); letter-spacing: .08em; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 2px 10px; margin: 2px 4px 2px 0;
    border-radius: 999px; font-size: .75rem; font-weight: 600;
    background: var(--primary-50); color: var(--primary);
}
.badges { display: flex; flex-wrap: wrap; justify-content: inherit; }
.badge { white-space: nowrap; }
.badge-primary { background: var(--primary); color: #fff; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted { background: #f1ede4; color: var(--muted); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 7px 16px; min-height: 36px;
    border: 1px solid transparent; border-radius: 8px;
    font: inherit; font-weight: 600; line-height: 1.2;
    cursor: pointer; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(15, 118, 110, .25); }
.btn-primary:hover { background: var(--primary-600); }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary-light { background: var(--primary-50); color: var(--primary); }
.btn-primary-light:hover { background: #d3ede8; }
.btn-danger-light { background: var(--danger-bg); color: var(--danger); }
.btn-danger-light:hover { background: #fecaca; }
.btn-sm { padding: 4px 11px; min-height: 30px; font-size: .84rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-group { margin: 0 0 12px; border: 0; padding: 0; min-width: 0; }
.form-group label, .form-group legend { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; padding: 0; }
.req { color: var(--danger); }
.input {
    width: 100%; padding: 8px 11px;
    border: 1px solid var(--input-border); border-radius: 8px;
    background: #fff; color: var(--text);
    font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.input.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .15); }
textarea.input { resize: vertical; }
.input-search { width: 260px; max-width: 100%; padding: 6px 11px; }
.field-error { color: var(--danger); font-size: .82rem; margin-top: 4px; }

.input-with-action { position: relative; }
.input-with-action .input { padding-right: 64px; }
.input-action {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--primary);
    font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; padding: 6px 8px;
}

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.checkbox-grid-sm { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.checkbox-card {
    display: flex !important; align-items: flex-start; gap: 10px;
    padding: 12px; border: 1px solid var(--border); border-radius: 8px;
    font-weight: 400 !important; cursor: pointer; margin: 0 !important;
}
.form-group .checkbox-card { padding: 9px 12px; }
.checkbox-grid-sm .checkbox-card { align-items: center; }
.checkbox-grid-sm .checkbox-card input { margin-top: 0; }
.checkbox-card:hover { border-color: var(--accent); }
.checkbox-card:has(input:checked) { border-color: var(--accent); background: var(--primary-50); }
.checkbox-card input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); }
.checkbox-card span { display: flex; flex-direction: column; }

.switch { display: inline-flex !important; align-items: center; gap: 10px; cursor: pointer; font-weight: 500 !important; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 42px; height: 24px; border-radius: 999px; background: var(--input-border); transition: background .15s ease; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s ease; }
.switch input:checked ~ .switch-track { background: var(--success); }
.switch input:checked ~ .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible ~ .switch-track { box-shadow: 0 0 0 3px var(--focus-ring); }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.field-help { margin: 0 0 8px; font-size: .86rem; }
.perm-group { margin-bottom: 12px; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
    font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-size: .8rem;
    font-weight: 600; text-transform: none; letter-spacing: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Alerts ---------- */
.alert {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 9px 14px; margin-bottom: 12px;
    border-radius: 8px; border: 1px solid transparent; font-size: .92rem;
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #bae6fd; }
.alert-close { border: 0; background: transparent; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 4px; }

/* ---------- Login & error pages ---------- */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    background: radial-gradient(circle at 15% 15%, rgba(20, 184, 166, .85) 0, transparent 45%),
                radial-gradient(circle at 90% 90%, rgba(245, 184, 61, .35) 0, transparent 40%),
                linear-gradient(135deg, #0a2c28 0%, #0f766e 100%);
}
.login-wrapper { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 400px;
    background: var(--surface); border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 22px 24px;
}
.login-brand { text-align: center; margin-bottom: 14px; }
.login-brand img { width: 44px; height: 44px; margin-bottom: 4px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { margin: 2px 0 0; font-size: .9rem; }
.login-hint {
    display: flex; flex-direction: column; gap: 2px;
    margin-top: 14px; padding: 8px 12px;
    background: var(--bg); border-radius: 8px;
    font-size: .82rem; color: var(--muted);
}
.login-hint strong { color: var(--text); }
.error-card { text-align: center; }
.error-card h1 { margin-bottom: 8px; }
.error-card p { margin: 0 0 24px; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 8px; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Tablet & mobile: sidebar becomes an off-canvas drawer */
@media (max-width: 991.98px) {
    .main { margin-left: 0; }
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .backdrop { opacity: 1; visibility: visible; }
    body.sidebar-open { overflow: hidden; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-rates { grid-template-columns: 1fr; }
    .entry-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .container { padding: 12px; }
    h1 { font-size: 1.3rem; }
    .topbar { padding: 0 8px; }
    .user-menu-name, .user-menu-btn .chevron { display: none; }
    .brand-name { display: none; }
    .top-tabs { margin-left: 4px; gap: 2px; }
    .top-tab { min-width: 0; padding: 5px 10px; font-size: .8rem; }
    .user-menu-btn { padding: 2px; }
    .dropdown { position: fixed; top: calc(var(--header-h) + 6px); right: 8px; left: 8px; width: auto; }

    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
    .stat-icon { width: 40px; height: 40px; }
    .stat-value { font-size: 1.35rem; }

    .form-grid { grid-template-columns: 1fr; }
    .card-narrow { padding: 14px; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .page-header .btn { width: 100%; }
    .input-search { width: 100%; }
    .profile-summary { flex-direction: column; text-align: center; }

    /* Tables collapse into stacked cards on phones */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td {
        display: flex; justify-content: space-between; align-items: center; gap: 12px;
        padding: 4px 0; border: 0; text-align: right;
    }
    .table-stack td::before {
        content: attr(data-label);
        font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
        color: var(--muted); text-align: left; flex-shrink: 0;
    }
    .table-stack .badges { justify-content: flex-end; }
    .table-stack .stacked-cell { align-items: flex-end; }
    .milk-table tbody tr { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
    .milk-table tbody td[data-label="Dairy"], .milk-table tbody td[data-label="Customer"] { grid-column: 1 / -1; }
    .milk-table tbody td.qty-cell { flex-direction: column; align-items: stretch; gap: 2px; }
    .milk-table tbody td.qty-cell::before { text-align: left; }
    .milk-table .input-qty { width: 100%; }
    .milk-table .qty-cell { width: auto; }
    .page-tab svg { display: none; }
    .page-tab { font-size: .84rem; padding: 9px 4px; }
    .page-top { gap: 0; }
    .page-top .page-header { width: 100%; padding-bottom: 4px; }
    .page-top .page-tabs { width: 100%; }
    .milk-table tfoot, .table-stack tfoot { display: block; }
    .table-stack tfoot tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 10px 14px; }
    .table-stack tfoot th { display: flex; justify-content: space-between; border: 0; padding: 2px 0; background: none; }
    .table-stack tfoot th:empty { display: none; }
    .table-stack tfoot th::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; }
    .sheet-actions { flex-direction: column; align-items: stretch; }
    .sheet-actions .btn { width: 100%; }
    .rate-field, .rate-field .input { min-width: 0; max-width: none; width: 100%; }
    .rate-field { flex: 1 1 140px; }
    .quick-ranges { margin-left: 0; }
    .grid-rates { grid-template-columns: 1fr; }
    .info-strip { flex-direction: column; }
    .request-card { flex-wrap: wrap; }
    .request-actions { width: 100%; justify-content: flex-end; }
    .reject-box[open] form { width: min(280px, 80vw); }
    .day-totals > div { flex: 1 1 34%; border-bottom: 1px solid var(--border); }
    .stats-auto { grid-template-columns: 1fr 1fr; }
    .entry-card { padding: 14px; }
    .entry-head { margin: -14px -14px 12px; padding: 8px 14px; }
    .table-stack.table-compact td:first-child, .table-stack.table-compact td:last-child { padding-left: 0; padding-right: 0; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
    .table-stack td[data-label="User"], .table-stack td[data-label="Customer"], .table-stack td[data-label="Item"] { justify-content: flex-start; text-align: left; padding-bottom: 8px; }
    .table-stack td[data-label="User"]::before, .table-stack td[data-label="Customer"]::before,
    .table-stack td[data-label="Item"]::before { display: none; }

    .page-tab { flex: 1; justify-content: center; padding: 9px 6px; }
    .table-stack td.empty { justify-content: center; }
    .table-stack td.empty::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; }
}

/* ===== Customer Dues ===== */
.card-title { font-size: 1rem; margin: 0 0 12px; }
.bal-due { color: var(--danger); font-weight: 600; }
.bal-adv { color: var(--success); font-weight: 600; }
.bal-zero { color: var(--muted); }
.dues-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.dues-summary .card { margin-bottom: 0; padding: 12px 16px; }
.dues-period h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.dues-period dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.dues-period dt { font-size: .74rem; color: var(--muted); font-weight: 600; }
.dues-period dd { margin: 2px 0 0; font-size: 1.02rem; font-weight: 700; }
.dues-period .dues-bal dd { font-size: 1.12rem; }
.dues-table th, .dues-table td { white-space: nowrap; }
.dues-table .dues-group { border-left: 2px solid var(--border); font-size: .74rem; }
.dues-table .dues-start { border-left: 2px solid var(--border); }
.dues-group-row th { border-bottom: 0; }
.dues-note { font-size: .8rem; padding: 10px 16px; margin: 0; border-top: 1px solid var(--border); }
.dues-rates { font-size: .82rem; }
.day-nav-card { padding: 12px 16px 0; }
.statement-opening td { background: var(--surface-soft); }
.rate-history { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.rate-history h3 { font-size: .85rem; margin: 0 0 4px; }
.rate-history .entry-feed li { padding: 7px 0; }
tr.is-selected td { background: var(--primary-50); }
@media (max-width: 900px) {
    .dues-summary { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 640px) {
    .dues-table .dues-group-row { display: none; }
    .dues-table .dues-start { border-left: 0; }
    .dues-table tbody tr { display: grid !important; grid-template-columns: 1fr 1fr 1fr; gap: 2px 10px; }
    .dues-table tbody td { flex-direction: column; align-items: flex-end; gap: 0; }
    .dues-table tbody td::before { font-size: .66rem; }
    .dues-table tbody td[data-label="Customer"] { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: flex-start; }
    .dues-table tbody td[data-label="Customer"]::before { display: none; }
    .dues-table tfoot tr { grid-template-columns: 1fr 1fr 1fr; }
    .dues-table tfoot th:first-child { grid-column: 1 / -1; }
}
