/* =========================================================================
   Dchama — "Kinship Ledger" design system
   Tailwind (preflight disabled) supplies utilities, Bootstrap 5.3 supplies
   components. This file supplies tokens, shell, and product components.
   ========================================================================= */

:root {
    --bg: #f5f7f2;
    --bg-accent: #eaf1e4;
    --surface: #ffffff;
    --surface-2: #f0f4ec;
    --surface-3: #e7eee2;
    --border: #dde5d7;
    --border-strong: #c8d4c1;
    --text: #132018;
    --text-soft: #39473d;
    --muted: #66756a;
    --primary: #067a2e;
    --primary-hover: #056325;
    --primary-soft: #e3f4e8;
    --primary-contrast: #ffffff;
    --accent: #0e7490;
    --gold: #b7791f;
    --danger: #b42318;
    --danger-soft: #feeceb;
    --warn: #b45309;
    --warn-soft: #fdf3e2;
    --info: #0f7490;
    --info-soft: #e4f4f8;
    --success: #067a2e;
    --success-soft: #e3f4e8;
    --sidebar-bg: #0b2a1b;
    --sidebar-bg-2: #061a10;
    --sidebar-text: #d5e6d9;
    --sidebar-muted: #8fae97;
    --sidebar-active: rgba(52, 211, 153, 0.16);
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px rgba(19, 32, 24, 0.06);
    --shadow: 0 10px 30px -18px rgba(19, 32, 24, 0.35), 0 2px 6px rgba(19, 32, 24, 0.04);
    --shadow-lg: 0 28px 60px -30px rgba(10, 40, 22, 0.45);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-lg: 22px;
    --sidebar-width: 268px;
    --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
    --bs-primary: #067a2e;
    --bs-primary-rgb: 6, 122, 46;
}

[data-theme="dark"] {
    --bg: #0a110d;
    --bg-accent: #0e1a13;
    --surface: #121b15;
    --surface-2: #16211a;
    --surface-3: #1d2b22;
    --border: #26382d;
    --border-strong: #34493b;
    --text: #e7f0e9;
    --text-soft: #c6d5ca;
    --muted: #93a79a;
    --primary: #34d399;
    --primary-hover: #6ee7b7;
    --primary-soft: rgba(52, 211, 153, 0.12);
    --primary-contrast: #062514;
    --accent: #22d3ee;
    --gold: #f6c15b;
    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, 0.12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --info: #38bdf8;
    --info-soft: rgba(56, 189, 248, 0.12);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.12);
    --sidebar-bg: #07120c;
    --sidebar-bg-2: #030a06;
    --sidebar-text: #cfe3d5;
    --sidebar-muted: #7f9c88;
    --sidebar-active: rgba(52, 211, 153, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow: 0 14px 34px -20px rgba(0, 0, 0, 0.8), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 30px 70px -34px rgba(0, 0, 0, 0.9);
    color-scheme: dark;
}

* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    font-feature-settings: "cv02", "cv03", "cv04";
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(900px 480px at 105% -10%, rgba(6, 122, 46, 0.08), transparent 60%),
        radial-gradient(700px 420px at -15% 110%, rgba(183, 121, 31, 0.07), transparent 60%);
}

[data-theme="dark"] body::before {
    background:
        radial-gradient(900px 480px at 105% -10%, rgba(52, 211, 153, 0.07), transparent 60%),
        radial-gradient(700px 420px at -15% 110%, rgba(34, 211, 238, 0.05), transparent 60%);
}

h1, h2, h3, h4, h5, .display-font { font-family: var(--font-display); letter-spacing: -0.015em; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

::selection { background: rgba(6, 122, 46, 0.2); }

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

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(560px 280px at 10% 0%, rgba(52, 211, 153, 0.14), transparent 65%),
        linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: var(--sidebar-text);
    z-index: 1040;
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    transition: transform 0.24s ease;
}

.sidebar-head {
    padding: 22px 20px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #34d399, #0f7a3d 70%);
    color: #04160c;
    box-shadow: 0 10px 24px -12px rgba(52, 211, 153, 0.7);
    flex: none;
}

.brand-mark .material-symbols-outlined { font-size: 24px; font-variation-settings: 'FILL' 1; }

.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.16rem; color: #fff; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--sidebar-muted); }

.chama-pill {
    margin: 4px 16px 12px;
    padding: 13px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid var(--sidebar-border);
    display: flex;
    gap: 11px;
    align-items: center;
}

.chama-pill .avatar { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; }
.chama-pill small { display: block; color: var(--sidebar-muted); font-size: 0.7rem; }
.chama-pill strong { color: #fff; font-size: 0.86rem; font-weight: 650; display: block; line-height: 1.2; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px 18px; scrollbar-width: thin; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 999px; }

.nav-section { margin-top: 14px; }
.nav-section-label {
    padding: 8px 12px 7px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
}

.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 11px;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
    position: relative;
    transition: background 0.16s ease, color 0.16s ease;
}

.side-link .material-symbols-outlined { font-size: 21px; color: var(--sidebar-muted); transition: color 0.16s ease; }
.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-link:hover .material-symbols-outlined { color: #d1fae5; }
.side-link.active { background: var(--sidebar-active); color: #fff; font-weight: 650; }
.side-link.active .material-symbols-outlined { color: #6ee7b7; font-variation-settings: 'FILL' 1; }
.side-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 3px;
    background: #34d399;
}

.side-badge {
    margin-left: auto;
    min-width: 21px;
    height: 21px;
    border-radius: 999px;
    padding: 0 7px;
    display: grid;
    place-items: center;
    background: #34d399;
    color: #04160c;
    font-size: 0.7rem;
    font-weight: 800;
}

.sidebar-foot {
    padding: 14px 16px 18px;
    border-top: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    gap: 11px;
}

.sidebar-foot .avatar { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-foot small { color: var(--sidebar-muted); display: block; font-size: 0.7rem; }
.sidebar-foot strong { color: #fff; font-size: 0.84rem; display: block; line-height: 1.2; }

.app-main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.app-shell.no-sidebar .sidebar,
.app-shell.no-sidebar .sidebar-backdrop { display: none; }
.app-shell.no-sidebar .app-main { margin-left: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 26px;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.topbar-title strong { color: var(--text); font-weight: 650; font-size: 0.92rem; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    display: grid;
    place-items: center;
    transition: all 0.16s ease;
    position: relative;
}

.icon-btn:hover { border-color: var(--border-strong); color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-btn .material-symbols-outlined { font-size: 21px; }
.icon-btn .dot {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--danger);
    border: 2px solid var(--surface);
}

.search-box { position: relative; width: min(330px, 34vw); }
.search-box .material-symbols-outlined {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    color: var(--muted);
}
.search-box input {
    width: 100%;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 0 14px 0 40px;
    font-size: 0.875rem;
}
.search-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.page-wrap { padding: 26px; flex: 1; }
.page-container { max-width: 1440px; margin: 0 auto; width: 100%; }

.mobile-hamburger { display: none; }
.sidebar-backdrop { display: none; }

/* -------------------------------------------------------------- typography */
.page-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--primary);
    margin-bottom: 6px;
}
.page-title { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); font-weight: 800; margin: 0; letter-spacing: -0.025em; }
.page-sub { color: var(--muted); font-size: 0.9rem; margin-top: 6px; max-width: 72ch; }
.section-title { font-size: 1.02rem; font-weight: 750; margin: 0; letter-spacing: -0.01em; }
.section-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.text-muted-2 { color: var(--muted) !important; }
.text-strong { color: var(--text); font-weight: 650; }
.numeric { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

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

.card-pad { padding: 22px; }
.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.card-hover { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }

.inset { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card::after {
    content: "";
    position: absolute;
    right: -28px;
    top: -34px;
    width: 110px;
    height: 110px;
    border-radius: 999px;
    background: var(--primary-soft);
    opacity: 0.7;
}
.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    position: relative;
    z-index: 1;
}
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.stat-value { font-family: var(--font-display); font-size: clamp(1.35rem, 1.1rem + 0.7vw, 1.7rem); font-weight: 800; letter-spacing: -0.03em; margin-top: 10px; position: relative; z-index: 1; }
.stat-hint { font-size: 0.75rem; color: var(--muted); margin-top: 6px; position: relative; z-index: 1; }
.stat-card.tone-gold .stat-icon { background: rgba(183, 121, 31, 0.14); color: var(--gold); }
.stat-card.tone-info .stat-icon { background: var(--info-soft); color: var(--info); }
.stat-card.tone-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-card.tone-violet .stat-icon { background: rgba(124, 58, 237, 0.13); color: #7c3aed; }

/* --------------------------------------------------------------- chips */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
}
.chip-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 20%, transparent); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.chip-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.chip-muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.chip-emerald { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.chip-violet { background: rgba(124, 58, 237, 0.12); color: #6d28d9; border-color: rgba(124, 58, 237, 0.2); }
.chip-sky { background: rgba(2, 132, 199, 0.12); color: #0369a1; border-color: rgba(2, 132, 199, 0.2); }
.chip-teal { background: rgba(13, 148, 136, 0.12); color: #0f766e; border-color: rgba(13, 148, 136, 0.2); }

[data-theme="dark"] .chip-violet { color: #c4b5fd; }
[data-theme="dark"] .chip-sky { color: #7dd3fc; }
[data-theme="dark"] .chip-teal { color: #5eead4; }

/* --------------------------------------------------------------- buttons */
.btn { border-radius: 10px; font-weight: 600; font-size: 0.875rem; padding: 0.55rem 1rem; transition: all 0.16s ease; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--primary-soft); outline: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-contrast); }
.btn-outline-primary { border-color: color-mix(in srgb, var(--primary) 45%, transparent); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); }
.btn-soft:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 0.36rem 0.7rem; font-size: 0.8rem; border-radius: 9px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; }
.btn .material-symbols-outlined { font-size: 18px; }
.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn-check:checked + .btn { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }

/* --------------------------------------------------------------- forms */
.form-label { font-size: 0.8rem; font-weight: 650; color: var(--text-soft); margin-bottom: 6px; }
.form-control, .form-select {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-control::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); border-radius: 10px; font-size: 0.82rem; }
.field-error { color: var(--danger); font-size: 0.76rem; margin: 5px 0 0; }
.form-hint { color: var(--muted); font-size: 0.75rem; margin-top: 5px; }
.form-check-input { border-color: var(--border-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.form-check-label { font-size: 0.86rem; color: var(--text-soft); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 40px; }
.filter-bar .search-grow { flex: 1 1 220px; }

/* --------------------------------------------------------------- tables */
.table-shell { overflow-x: auto; }
.table { color: var(--text); margin: 0; --bs-table-bg: transparent; --bs-table-color: var(--text); }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: var(--border); padding: 12px 14px; vertical-align: middle; }
.table thead th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table tbody tr:hover > * { background: color-mix(in srgb, var(--surface-2) 65%, transparent); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td .amount { font-variant-numeric: tabular-nums; font-weight: 650; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

table.dataTable { border-collapse: separate !important; border-spacing: 0; }
.dataTables_wrapper .row { --bs-gutter-x: 1rem; }
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 9px;
    padding: 6px 10px;
}
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 9px;
    padding: 5px 8px;
}
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { color: var(--muted); font-size: 0.8rem; }
.page-link { color: var(--text-soft); background: var(--surface); border-color: var(--border); }
.page-link:hover { color: var(--primary); background: var(--primary-soft); border-color: var(--border); }
.active > .page-link, .page-link.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.dt-buttons .btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); }
.dt-buttons .btn:hover { background: var(--surface-2); color: var(--text); }
div.dt-container div.dt-processing { color: var(--muted); }

/* --------------------------------------------------------------- avatars */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    font-weight: 750;
    font-size: 0.82rem;
    background: var(--primary-soft);
    color: var(--primary);
    flex: none;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 0.7rem; }
.avatar-lg { width: 62px; height: 62px; border-radius: 18px; font-size: 1.1rem; }
.avatar-xl { width: 88px; height: 88px; border-radius: 24px; font-size: 1.5rem; }

/* --------------------------------------------------------------- lists */
.data-list { margin: 0; padding: 0; list-style: none; }
.data-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.data-list li:last-child { border-bottom: 0; }
.timeline { position: relative; padding-left: 20px; margin: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline li { position: relative; padding-bottom: 16px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -19px; top: 4px; width: 10px; height: 10px; border-radius: 999px; background: var(--surface); border: 2px solid var(--primary); }

.progress { background: var(--surface-3); border-radius: 999px; height: 8px; }
.progress-bar { background: linear-gradient(90deg, var(--primary), #34d399); border-radius: 999px; }

/* --------------------------------------------------------------- alerts */
.alert { border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 13px 15px; font-size: 0.875rem; }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 24%, transparent); color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 24%, transparent); color: var(--danger); }
.alert-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 24%, transparent); color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 24%, transparent); color: var(--info); }

/* --------------------------------------------------------------- toast */
.toast-stack {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1090;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 24px));
    justify-items: stretch;
    pointer-events: none;
}
.toast-stack > * { pointer-events: auto; }
.toast-card {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 14px 15px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.22s ease;
}
.toast-card.success { border-left: 4px solid var(--success); }
.toast-card.error { border-left: 4px solid var(--danger); }
.toast-card.info { border-left: 4px solid var(--info); }
.toast-card .material-symbols-outlined { font-size: 20px; }
.toast-card.success .material-symbols-outlined { color: var(--success); }
.toast-card.error .material-symbols-outlined { color: var(--danger); }
.toast-card.info .material-symbols-outlined { color: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* --------------------------------------------------------------- modal */
.modal-content { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 22px; }
.modal-title { font-size: 1.05rem; font-weight: 750; }
.btn-close { filter: var(--close-filter, none); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1) brightness(1.6); }

/* --------------------------------------------------------------- empty */
.empty-state { text-align: center; padding: 44px 22px; }
.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: inline-grid;
    place-items: center;
    background: var(--surface-2);
    color: var(--muted);
    margin-bottom: 14px;
}
.empty-state .empty-icon .material-symbols-outlined { font-size: 30px; }
.empty-state h3 { font-size: 1rem; font-weight: 750; margin: 0 0 5px; }
.empty-state p { color: var(--muted); font-size: 0.85rem; max-width: 46ch; margin: 0 auto 14px; }

/* --------------------------------------------------------------- skeletons */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton-text { height: 12px; margin-bottom: 8px; }
.skeleton-title { height: 22px; width: 45%; margin-bottom: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --------------------------------------------------------------- misc */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.divider-label { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.14em; }
.divider-label::before, .divider-label::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.link-quiet { color: var(--text-soft); font-weight: 600; }
.link-quiet:hover { color: var(--primary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.kv { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 14px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 0.875rem; margin: 0; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child, .kv dt { color: var(--muted); margin: 0; font-weight: 500; }
.kv span:last-child, .kv dd { font-weight: 600; text-align: right; margin: 0 0 0 auto; }
.kv dt, .kv dd { flex: 0 0 auto; }
.kv dd { max-width: 62%; word-break: break-word; }
.metric-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.metric-row:last-child { border-bottom: 0; }
.metric-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.metric-icon .material-symbols-outlined { font-size: 19px; }
.scroll-y { overflow-y: auto; }
.dot-sep::before { content: "·"; margin: 0 6px; color: var(--muted); }
.badge-soft { background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--border); font-weight: 600; border-radius: 8px; padding: 4px 9px; font-size: 0.74rem; }
.breadcrumb { --bs-breadcrumb-divider-color: var(--muted); font-size: 0.8rem; margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb-item.active { color: var(--text-soft); }
.page-header { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 210px; }
.legend-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; margin-right: 6px; }

.role-accent { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700; }

/* --------------------------------------------------------------- auth */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand {
    background:
        radial-gradient(800px 400px at 80% 0%, rgba(52, 211, 153, 0.2), transparent 60%),
        radial-gradient(600px 500px at 0% 100%, rgba(183, 121, 31, 0.16), transparent 60%),
        linear-gradient(160deg, #0b2a1b, #05140c 75%);
    color: #e7f3ea;
    padding: 46px 52px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.auth-brand::after {
    content: "";
    position: absolute;
    inset: auto -140px -180px auto;
    width: 440px;
    height: 440px;
    border-radius: 50%;
    border: 1px solid rgba(110, 231, 183, 0.18);
    box-shadow: 0 0 0 60px rgba(110, 231, 183, 0.04), 0 0 0 120px rgba(110, 231, 183, 0.03);
}
.auth-brand .brand-name { font-size: 1.5rem; }
.auth-brand .brand-sub { font-size: 0.74rem; }
.auth-copy { margin-top: auto; max-width: 46ch; position: relative; z-index: 1; }
.auth-copy h2 { font-size: clamp(1.8rem, 1.2rem + 1.6vw, 2.6rem); color: #fff; font-weight: 800; letter-spacing: -0.03em; line-height: 1.12; margin-bottom: 16px; }
.auth-copy p { color: #a9c7b2; font-size: 0.95rem; line-height: 1.65; }
.auth-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 30px; }
.auth-metric { border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04); border-radius: 14px; padding: 14px 15px; }
.auth-metric strong { display: block; font-size: 1.22rem; color: #fff; font-family: var(--font-display); letter-spacing: -0.02em; }
.auth-metric span { font-size: 0.7rem; color: #93b39d; text-transform: uppercase; letter-spacing: 0.1em; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 38px 24px; background: var(--bg); }
.auth-card { width: min(440px, 100%); }
.auth-card .card { padding: 34px 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.auth-logo-mobile { display: none; }
.auth-features { display: grid; gap: 12px; margin-top: 26px; }
.auth-feature { display: flex; gap: 11px; align-items: flex-start; }
.auth-feature .material-symbols-outlined { color: #6ee7b7; font-size: 20px; margin-top: 2px; }
.auth-feature strong { color: #e7f3ea; font-size: 0.86rem; display: block; }
.auth-feature span { color: #93b39d; font-size: 0.78rem; }

/* --------------------------------------------------------------- pwa */
.pwa-shell { max-width: 520px; margin: 0 auto; min-height: 100vh; background: var(--bg); padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.pwa-top {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: calc(16px + env(safe-area-inset-top)) 18px 14px;
    background: linear-gradient(180deg, var(--bg) 70%, transparent);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 12px;
}
.pwa-body { padding: 0 16px 24px; }
.pwa-bottom-nav {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: min(500px, calc(100vw - 20px));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px 6px;
    z-index: 30;
}
.pwa-nav-item {
    min-height: 52px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 650;
    letter-spacing: 0.02em;
}
.pwa-nav-item .material-symbols-outlined { font-size: 22px; }
.pwa-nav-item.active { background: var(--primary-soft); color: var(--primary); }
.pwa-nav-item.active .material-symbols-outlined { font-variation-settings: 'FILL' 1; }

.hero-balance {
    border-radius: var(--radius-lg);
    padding: 22px;
    color: #eafff1;
    background:
        radial-gradient(420px 200px at 100% 0%, rgba(110, 231, 183, 0.28), transparent 60%),
        linear-gradient(150deg, #0b3d25, #06180e);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.hero-balance::after {
    content: "";
    position: absolute;
    right: -40px;
    bottom: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 1px solid rgba(110, 231, 183, 0.25);
    box-shadow: 0 0 0 34px rgba(110, 231, 183, 0.05);
}
.hero-balance .label { color: #a5d6b5; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 650; }
.hero-balance .amount { font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; margin: 6px 0 2px; color: #fff; }
.hero-balance .delta { color: #6ee7b7; font-size: 0.8rem; font-weight: 600; }
.pwa-quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.pwa-quick {
    min-height: 78px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--text-soft);
    font-size: 0.7rem;
    font-weight: 650;
}
.pwa-quick .material-symbols-outlined { font-size: 23px; color: var(--primary); }
.pwa-quick:active { transform: scale(0.97); }
.pwa-search {
    display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 46px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
}
.pwa-search .material-symbols-outlined { font-size: 20px; color: var(--muted); }
.pwa-search input {
    flex: 1 1 auto; min-width: 0; border: 0; background: transparent; color: var(--text);
    font-size: 0.85rem; padding: 12px 0; outline: none;
}
.pwa-module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 399px) { .pwa-module-grid { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 720px) { .pwa-module-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pwa-module {
    display: flex; align-items: center; gap: 10px; min-height: 68px; padding: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    color: inherit; text-decoration: none; overflow: hidden;
}
.pwa-module:active { transform: scale(0.98); background: var(--surface-2); }
.pwa-module .pwa-list-icon { width: 36px; height: 36px; border-radius: 11px; }
.pwa-module strong {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    font-size: 0.8rem; line-height: 1.2; overflow: hidden;
}
.pwa-module small { display: block; color: var(--muted); font-size: 0.66rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwa-module-chev { font-size: 18px; color: var(--muted); flex: 0 0 auto; }
.pwa-section-title { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 10px; margin: 20px 4px 10px; }
.pwa-section-title .chip { flex: 0 0 auto; }
.pwa-section-title h2 { font-size: 0.98rem; font-weight: 750; margin: 0; }
.pwa-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; }
.pwa-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pwa-row:last-child { border-bottom: 0; }
.pwa-cta { min-height: 52px; border-radius: 16px; font-weight: 700; width: 100%; }

.safe-bottom { padding-bottom: env(safe-area-inset-bottom); }

/* offline banner */
.net-banner { display: none; position: sticky; top: 0; z-index: 1080; background: var(--warn); color: #1c1204; text-align: center; font-size: 0.78rem; font-weight: 700; padding: 7px 12px; }
body.is-offline .net-banner { display: block; }
.offline-pill { display: none; }
body.is-offline .offline-pill { display: inline-flex; }

.pending-queue { border-left: 4px solid var(--warn); }

/* --------------------------------------------------------- pwa app chrome */
.pwa-brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); text-decoration: none; }
.pwa-brand .brand-mark {
    width: 42px; height: 42px; border-radius: 14px; flex: 0 0 auto;
    display: grid; place-items: center; color: #6ee7b7;
    background: linear-gradient(150deg, #0b3d25, #06180e);
    box-shadow: var(--shadow-sm);
}
.pwa-brand strong { display: block; font-family: var(--font-display); font-size: 0.98rem; line-height: 1.1; letter-spacing: -0.01em; }
.pwa-brand small { display: block; color: var(--muted); font-size: 0.7rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pwa-icon-btn {
    min-width: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 14px;
    background: var(--surface); color: var(--text-soft); display: inline-grid; place-items: center;
    position: relative; text-decoration: none;
}
.pwa-icon-btn:hover { color: var(--text); background: var(--surface-2); }
.pwa-icon-btn .pwa-badge {
    position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.62rem;
    font-weight: 750; display: grid; place-items: center; border: 2px solid var(--bg);
}
.pwa-sync-pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 999px;
    background: var(--warn-soft); color: var(--warn); font-size: 0.68rem; font-weight: 700;
}
.pwa-sync-pill .material-symbols-outlined { font-size: 15px; }
.pwa-status-strip {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 13px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
    font-size: 0.72rem; font-weight: 600; margin-bottom: 14px;
}
.pwa-status-strip .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
body.is-offline .pwa-status-strip .dot { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.pwa-page-title { font-family: var(--font-display); font-size: 1.42rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 2px; }
.pwa-page-sub { color: var(--muted); font-size: 0.8rem; margin: 0 0 16px; }
.pwa-hero-badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; position: relative; z-index: 1; }
.pwa-hero-badges .badge-cell { background: rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 9px 10px; backdrop-filter: blur(6px); }
.pwa-hero-badges .badge-cell span { display: block; color: #a5d6b5; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 650; }
.pwa-hero-badges .badge-cell strong { display: block; color: #fff; font-size: 0.9rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.pwa-mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.pwa-mini-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px; }
.pwa-mini-stat span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.pwa-mini-stat span .material-symbols-outlined { font-size: 15px; color: var(--primary); }
.pwa-mini-stat strong { display: block; margin-top: 5px; font-family: var(--font-display); font-size: 1.1rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pwa-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.pwa-list-item:last-child { border-bottom: 0; }
.pwa-list-icon {
    width: 40px; height: 40px; border-radius: 13px; flex: 0 0 auto; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
}
.pwa-list-icon.warn { background: var(--warn-soft); color: var(--warn); }
.pwa-list-icon.info { background: var(--info-soft); color: var(--info); }
.pwa-list-icon.danger { background: var(--danger-soft); color: var(--danger); }
.pwa-list-icon .material-symbols-outlined { font-size: 20px; }
.pwa-list-main { min-width: 0; flex: 1 1 auto; }
.pwa-list-main strong { display: block; font-size: 0.84rem; line-height: 1.25; }
.pwa-list-main small { display: block; color: var(--muted); font-size: 0.7rem; margin-top: 2px; }
.pwa-list-value { text-align: right; flex: 0 0 auto; }
.pwa-list-value strong { display: block; font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.pwa-list-value small { display: block; color: var(--muted); font-size: 0.66rem; margin-top: 2px; }
.pwa-row-link { color: inherit; text-decoration: none; }
.pwa-row-link:active { background: var(--surface-2); }
.pwa-unread { background: var(--primary-soft); }
.pwa-unread strong { font-weight: 800; }
.pwa-form .form-control, .pwa-form .form-select { min-height: 48px; border-radius: 13px; }
.pwa-form .form-label { font-size: 0.78rem; }
.pwa-form .btn { min-height: 50px; border-radius: 14px; font-weight: 700; }
.pwa-modal .modal-dialog {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto;
    max-width: 560px; max-height: 94vh;
}

.pwa-modal .modal-content {
    border-radius: 22px 22px 0 0; border: 0; max-height: 94vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: var(--shadow-lg);
}
.pwa-modal .modal-header { border-bottom: 1px solid var(--border); padding: 16px 18px 12px; flex: 0 0 auto; }
.pwa-modal .modal-body { padding: 16px 18px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pwa-modal .modal-footer {
    border-top: 1px solid var(--border); padding: 12px 18px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    flex: 0 0 auto; background: var(--surface);
}
.pwa-modal .modal-title { font-family: var(--font-display); font-size: 1.02rem; font-weight: 750; }
.pwa-modal .modal-content > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.pwa-modal .modal-content > form > .modal-body { flex: 1 1 auto; min-height: 0; }
.pwa-modal .modal-dialog-scrollable { height: auto; }
.pwa-modal .modal-dialog-scrollable .modal-content { max-height: 94vh; }
.pwa-inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.pwa-inline-form > * { min-width: 0; }
.pwa-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.pwa-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.pwa-table th, .pwa-table td { padding: 9px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: left; }
.pwa-table th { color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; white-space: nowrap; }
.pwa-table td.numeric, .pwa-table th.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pwa-table tr:last-child td { border-bottom: 0; }
.pwa-day-row.is-missing { background: var(--warn-soft); }
.pwa-day-row.is-posted td:first-child { font-weight: 700; }
@media (max-width: 419.98px) {
    .pwa-day-table thead { display: none; }
    .pwa-day-table, .pwa-day-table tbody { display: block; }
    .pwa-day-table tr {
        display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
        gap: 4px 10px; padding: 10px 12px; margin-bottom: 8px;
        border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
    }
    .pwa-day-table td { display: block; border: 0; padding: 0; min-width: 0; }
    .pwa-day-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
    .pwa-day-table td:nth-child(2) { grid-column: 1; grid-row: 2; text-align: left; font-weight: 700; }
    .pwa-day-table td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; }
    .pwa-day-table td:nth-child(4) { grid-column: 2; grid-row: 2; }
    .pwa-day-table .pwa-row-actions { justify-content: flex-end; }
}
.pwa-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pwa-note { font-size: 0.74rem; color: var(--muted); }
.pwa-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pwa-form-grid .span-2 { grid-column: 1 / -1; }
.pwa-results { max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
.pwa-results table { margin: 0; font-size: 0.74rem; }
.pwa-results thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.pwa-toggle-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.pwa-toggle-list label { display: flex; gap: 7px; align-items: center; font-size: 0.76rem; }
.pwa-toggle-list input { width: 18px; height: 18px; accent-color: var(--primary); }
.pwa-date-nav { display: flex; align-items: center; gap: 8px; }
.pwa-date-nav .form-control { flex: 1; min-width: 0; }
.pwa-date-btn { min-width: 44px; min-height: 44px; padding: 0; display: inline-grid; place-items: center; flex: 0 0 auto; }
.pwa-row-actions { display: inline-flex; align-items: center; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.pwa-row-actions .btn { min-height: 40px; min-width: 40px; padding: 4px 8px; }
.pwa-action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pwa-action-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 72px; padding: 12px 10px; border-radius: 16px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 0.72rem; font-weight: 650; text-align: center;
    text-decoration: none; cursor: pointer;
}
.pwa-action-btn .material-symbols-outlined { font-size: 22px; color: var(--primary); }
.pwa-action-btn:hover { border-color: var(--primary); color: var(--text); }
.pwa-action-btn:active { transform: scale(0.98); }

@media (max-width: 767.98px) {
    .pwa-modal.fade .modal-dialog { transform: translateY(100%); transition: transform .28s ease-out; }
    .pwa-modal.show .modal-dialog { transform: none; }
    .pwa-row-actions .btn { min-height: 44px; min-width: 44px; }
}
@media (max-width: 359.98px) {
    .pwa-form-grid, .pwa-toggle-list { grid-template-columns: 1fr; }
    .pwa-modal .row > .col-6 { flex: 0 0 100%; max-width: 100%; }
    .pwa-date-btn { min-width: 40px; }
}
@media (min-width: 768px) {
    .pwa-modal .modal-dialog {
        position: relative; inset: auto; margin: 1.75rem auto;
        max-width: 640px; max-height: calc(100vh - 3.5rem);
    }
    .pwa-modal .modal-content { border-radius: 22px; max-height: calc(100vh - 3.5rem); }
    .pwa-modal .modal-footer { padding-bottom: 12px; }
    .pwa-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
    .pwa-modal .modal-dialog { max-width: 720px; }
}
.pwa-empty-note { text-align: center; padding: 28px 18px; color: var(--muted); }
.pwa-empty-note .material-symbols-outlined { font-size: 34px; color: var(--border-strong); display: block; margin-bottom: 8px; }
.pwa-empty-note strong { display: block; color: var(--text); font-size: 0.9rem; margin-bottom: 4px; }
.pwa-empty-note p { font-size: 0.76rem; margin: 0; }
.pwa-checkin-qr { background: #0b2a1b; border-radius: 16px; padding: 16px; display: grid; place-items: center; }
.pwa-cycle-track { position: relative; margin: 6px 0 0; }
.pwa-cycle-step { display: flex; gap: 12px; padding: 10px 0; }
.pwa-cycle-step .step-line { display: flex; flex-direction: column; align-items: center; }
.pwa-cycle-step .step-dot { width: 28px; height: 28px; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--border); display: grid; place-items: center; font-size: 0.66rem; font-weight: 800; color: var(--muted); flex: 0 0 auto; }
.pwa-cycle-step.is-mine .step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.pwa-cycle-step .step-line::after { content: ""; flex: 1; width: 2px; background: var(--border); margin: 4px 0; }
.pwa-cycle-step:last-child .step-line::after { display: none; }
.pwa-cycle-step .step-body { flex: 1; min-width: 0; padding-bottom: 8px; }
.pwa-cycle-step .step-body strong { display: block; font-size: 0.82rem; }
.pwa-cycle-step .step-body small { display: block; color: var(--muted); font-size: 0.68rem; margin-top: 2px; }
.pwa-cycle-step.is-mine .step-body strong { color: var(--primary); }
.pwa-calc-out { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.pwa-calc-out span { color: var(--muted); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.pwa-calc-out strong { font-family: var(--font-display); font-size: 1.18rem; font-variant-numeric: tabular-nums; }
.pwa-offline-doc { max-width: 460px; margin: 0 auto; padding: calc(38px + env(safe-area-inset-top)) 22px calc(30px + env(safe-area-inset-bottom)); min-height: 100vh; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.pwa-offline-doc .offline-mark { width: 84px; height: 84px; margin: 0 auto 22px; border-radius: 28px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.pwa-offline-doc .offline-mark .material-symbols-outlined { font-size: 40px; }
.pwa-offline-doc h1 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.pwa-offline-doc p { color: var(--muted); font-size: 0.9rem; margin-bottom: 22px; }
.pwa-offline-doc .btn { min-height: 50px; border-radius: 14px; font-weight: 700; }
.offline-links { display: grid; gap: 9px; margin-top: 4px; text-align: left; }
.offline-links a { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 0.84rem; font-weight: 650; }
.offline-links a:hover { border-color: var(--primary); color: var(--primary); }
.offline-links a .material-symbols-outlined { font-size: 20px; color: var(--primary); }
.pwa-offline-doc .offline-links { margin-top: 12px; }
.pwa-offline-doc .offline-links a { background: var(--surface); }


/* --------------------------------------------------------------- responsive */
@media (max-width: 1199.98px) {
    .search-box { width: 240px; }
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: min(320px, 86vw); flex-basis: auto; }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(4, 16, 9, 0.55); backdrop-filter: blur(2px); z-index: 1035; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
    .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }
    .app-main { margin-left: 0; }
    .mobile-hamburger { display: grid; }
    .page-wrap { padding: 18px; }
    .topbar { padding: 11px 16px; }
    .search-box { display: none; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-logo-mobile { display: flex; margin-bottom: 22px; align-items: center; gap: 12px; }
    .auth-logo-mobile .brand-name { color: var(--text); }
    .auth-logo-mobile .brand-sub { color: var(--muted); }
    .auth-panel { min-height: 100vh; }
}

@media (max-width: 767.98px) {
    .page-header { align-items: flex-start; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .stat-card { padding: 16px; }
    .card-pad { padding: 17px; }
    .card-header-flex { padding: 15px 17px; }
    .table > :not(caption) > * > * { padding: 10px 11px; }
    .modal-dialog { margin: 0.6rem; }
    .toast-stack { top: max(12px, env(safe-area-inset-top)); width: calc(100vw - 20px); }
    .hide-sm { display: none !important; }
}

@media (max-width: 575.98px) {
    .page-title { font-size: 1.45rem; }
    .btn { padding: 0.5rem 0.85rem; }
    .auth-card .card { padding: 26px 20px; }
    .pwa-quick-grid { gap: 8px; }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .pwa-shell { max-width: 720px; }
    .pwa-bottom-nav { max-width: 680px; }
}

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

/* --------------------------------------------------------------- print */
@media print {
    .sidebar, .topbar, .pwa-bottom-nav, .page-actions, .no-print, .toast-stack { display: none !important; }
    .app-main { margin-left: 0; }
    .page-wrap { padding: 0; }
    body { background: #fff; color: #000; }
    .card { box-shadow: none; border-color: #ccc; }
    a { color: #000; text-decoration: none; }
    .print-only { display: block !important; }
}
.print-only { display: none; }

/* ------------------------------------------------- module management */
.min-w-0 { min-width: 0; }

.chama-module-card .card-header-flex { gap: .75rem; }

.module-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .5rem;
}

.module-toggle {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .55rem .7rem;
    border: 1px solid var(--bs-border-color, #e5e7eb);
    border-radius: 12px;
    background: var(--bs-body-bg, #fff);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
    min-width: 0;
}

.module-toggle:hover { border-color: var(--bs-primary, #0f766e); }

.module-toggle.is-on {
    border-color: var(--bs-primary, #0f766e);
    background: rgba(15, 118, 110, .06);
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, .18);
}

.module-toggle input.form-check-input { margin-top: .2rem; flex: 0 0 auto; }

.module-toggle-icon { font-size: 1.15rem; color: var(--bs-primary, #0f766e); line-height: 1.2; }

.module-toggle span:last-child { display: flex; flex-direction: column; min-width: 0; }

.module-toggle strong { font-size: .82rem; line-height: 1.25; overflow-wrap: anywhere; }

.module-toggle small {
    font-size: .7rem;
    line-height: 1.3;
    color: var(--bs-secondary-color, #6b7280);
    overflow-wrap: anywhere;
}

@media (max-width: 420px) {
    .module-toggle-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------- text overflow safety */
.card,
.stat-card,
.pwa-card,
.pwa-body,
.app-main {
    min-width: 0;
}

.card-header-flex > *,
.pwa-top > *,
.pwa-list-item > *,
.pwa-mini-stat,
.stat-card .stat-value,
.stat-card .stat-label,
.pwa-section-title > * {
    min-width: 0;
}

.card-header-flex h1,
.card-header-flex h2,
.card-header-flex h3,
.section-title,
.pwa-section-title h2,
.pwa-page-title {
    overflow-wrap: anywhere;
}

.table-shell,
.table-responsive { max-width: 100%; }

.table th,
.table td {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table .numeric,
.table .mono { white-space: nowrap; }

.chip,
.badge,
.status-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.pwa-list-main strong,
.pwa-list-main small,
.pwa-page-sub,
.pwa-empty-note p,
.pwa-empty-note strong,
.hero-balance .label,
.hero-balance .delta,
.badge-cell strong,
.badge-cell span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pwa-list-value { flex: 0 0 auto; max-width: 45%; text-align: right; }

.pwa-list-value strong,
.pwa-list-value small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero-balance .amount {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.pwa-cycle-step .step-body strong,
.pwa-cycle-step .step-body small {
    overflow-wrap: anywhere;
}

.btn { white-space: nowrap; }

.card-pad,
.page-header,
.page-wrap { min-width: 0; }
