/* =========================================================
   Tabungan Kelas — stylesheet minimalis
   ========================================================= */

:root {
    --bg: #f6f7f8;
    --surface: #ffffff;
    --surface-muted: #fafbfb;
    --border: #e7e9ec;
    --border-strong: #d9dce1;
    --text: #14181f;
    --text-soft: #4b5563;
    --muted: #8a919c;
    --accent: #0f766e;
    --accent-soft: #e6f4f1;
    --positive: #15803d;
    --positive-soft: #eaf6ee;
    --negative: #b91c1c;
    --negative-soft: #fbeceb;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(17, 24, 39, .04);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }

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

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: box-shadow .2s ease;
}

.topbar.is-scrolled { box-shadow: 0 1px 12px rgba(17, 24, 39, .06); }

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 64px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    min-width: 0;
    padding-right: 4px;
    border-radius: 8px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
    line-height: 1.2;
}

.brand-title {
    font-weight: 650;
    font-size: 14px;
    letter-spacing: -.015em;
    color: var(--text);
    white-space: nowrap;
}

.brand-sub {
    font-size: 11.5px;
    color: var(--muted);
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Navigasi berbentuk segmented control */
.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    padding: 3px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 11px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.nav::-webkit-scrollbar { display: none; }

.nav.is-scrollable {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 20px), transparent);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -.005em;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.nav-link:hover { background: #fff; color: var(--text); }

.nav-link.is-active {
    background: #fff;
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(17, 24, 39, .07), 0 0 0 1px var(--border);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    padding-left: 16px;
    border-left: 1px solid var(--border);
}

.avatar {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 650;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    line-height: 1.25;
}

.user-name {
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: 11px;
    color: var(--muted);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-form { margin: 0; display: flex; }

.logout-form .btn { height: 32px; padding: 0 12px; font-size: 12.5px; }

/* ---------- Layout ---------- */

.main { padding-top: 34px; padding-bottom: 56px; min-height: calc(100vh - 170px); }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-head h1 { font-size: 23px; font-weight: 650; letter-spacing: -.02em; }

.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-dashboard { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 550;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
    white-space: nowrap;
}

.btn-primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn-primary:hover { background: #000; border-color: #000; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: #0b5f59; border-color: #0b5f59; }

.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }

.btn-danger { background: transparent; border-color: #f0c9c6; color: var(--negative); }
.btn-danger:hover { background: var(--negative-soft); }

.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }

.btn.is-active { background: var(--text); border-color: var(--text); color: #fff; }

.btn:disabled,
.btn[disabled] {
    opacity: .45;
    cursor: not-allowed;
    background: var(--surface-muted);
    border-color: var(--border);
    color: var(--muted);
}

.btn-block { width: 100%; }

.link {
    color: var(--accent);
    font-weight: 550;
    font-size: 13px;
}

.link:hover { text-decoration: underline; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}

.back-link:hover { color: var(--text); }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }

.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.card-body { padding: 20px; }

.card-body.tight { padding: 0; }

.card-foot {
    padding: 13px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------- Stat cards ---------- */

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -.025em;
    font-variant-numeric: tabular-nums;
}

.stat-meta { font-size: 12px; color: var(--muted); }

.stat-meta strong { color: var(--positive); font-weight: 600; }

.stat-icon {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface-muted);
    color: var(--muted);
}

.stat-icon svg { width: 15px; height: 15px; }

/* ---------- Tables ---------- */

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover { background: #fbfcfc; }

.table tfoot th {
    background: var(--surface-muted);
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 12.5px;
    letter-spacing: 0;
    text-transform: none;
}

.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.table .actions { text-align: right; white-space: nowrap; }

.table .actions form { display: inline-block; margin: 0 0 0 4px; }

.cell-title { font-weight: 550; }

.cell-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

.amount-pos { color: var(--positive); font-weight: 600; font-variant-numeric: tabular-nums; }

.amount-neg { color: var(--negative); font-weight: 600; font-variant-numeric: tabular-nums; }

.amount-neutral { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 550;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-setoran { background: var(--positive-soft); color: var(--positive); }
.badge-penarikan { background: var(--negative-soft); color: var(--negative); }
.badge-muted { background: #f1f2f4; color: var(--text-soft); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* Label peran (dipakai di tabel pengguna & halaman akun) */
.role-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.role-admin { background: #eef1f6; color: #3f4a5c; }
.role-wali_kelas { background: var(--accent-soft); color: var(--accent); }

/* ---------- Forms ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field.full { grid-column: 1 / -1; }

.field label { font-size: 12.5px; font-weight: 550; color: var(--text-soft); }

.field .hint { font-size: 11.5px; color: var(--muted); }

.input,
.select,
.textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 13.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.input:hover, .select:hover, .textarea:hover { border-color: #c7ccd3; }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.textarea { min-height: 84px; resize: vertical; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%238a919c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    padding-right: 30px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-soft);
    cursor: pointer;
}

.checkbox input { width: 15px; height: 15px; accent-color: var(--accent); }

.form-actions {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
}

.filters .field { gap: 4px; }

.filters .field label { font-size: 11.5px; color: var(--muted); font-weight: 500; }

.filters .input, .filters .select { background: #fff; font-size: 13px; padding: 7px 10px; }

.filters .select { padding-right: 28px; }

.filters .input[type="month"] { min-width: 150px; }

.filters .spacer { flex: 1; }

/* ---------- Alerts ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success { background: var(--positive-soft); border-color: #cde8d5; color: #166534; }
.alert-error { background: var(--negative-soft); border-color: #f2d2d0; color: #991b1b; }
.alert-info { background: var(--accent-soft); border-color: #cfe9e5; color: #115e59; }

/* ---------- Chart ---------- */

.chart { padding: 22px 20px 16px; }

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    height: 168px;
    padding-top: 6px;
}

.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar-group {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
    height: 100%;
    width: 100%;
}

.chart-bar {
    width: 12px;
    max-width: 26%;
    min-height: 3px;
    border-radius: 4px 4px 2px 2px;
    transition: opacity .15s ease;
}

.chart-bar.setoran { background: var(--accent); }
.chart-bar.penarikan { background: #cbd5d3; }

.chart-bar-group:hover .chart-bar { opacity: .8; }

.chart-label { font-size: 11.5px; color: var(--muted); }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }

.legend span { display: inline-flex; align-items: center; gap: 6px; }

.dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.dot-setoran { background: var(--accent); }
.dot-penarikan { background: #cbd5d3; }

/* ---------- Top savers ---------- */

.saver-list { display: flex; flex-direction: column; }

.saver {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.saver:last-child { border-bottom: 0; }

.rank {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 650;
    flex-shrink: 0;
}

.rank.top { background: var(--accent-soft); color: var(--accent); }

.saver-info { flex: 1; min-width: 0; }

.saver-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.saver-sub { font-size: 11.5px; color: var(--muted); }

.saver-amount { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.progress { height: 4px; background: #eef0f2; border-radius: 999px; overflow: hidden; margin-top: 6px; }

.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Empty state ---------- */

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

.empty-title { font-size: 14px; font-weight: 600; color: var(--text-soft); margin-bottom: 3px; }

.empty p { font-size: 13px; }

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--muted);
}

.pagination-links { display: flex; align-items: center; gap: 6px; }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-soft);
    font-size: 12.5px;
}

.page-link:hover { background: var(--surface-muted); }

.page-link.is-active { background: var(--text); border-color: var(--text); color: #fff; }

.page-link.is-disabled { opacity: .4; pointer-events: none; }

/* ---------- Section helpers ---------- */

.section-title { font-size: 13px; font-weight: 650; margin-bottom: 12px; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.print-only { display: none; }

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}

.summary-row:last-child { border-bottom: 0; }

.summary-row .label { color: var(--muted); }

.summary-row.total { font-weight: 650; font-size: 14px; }

/* ---------- Login ---------- */

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 20px;
    background:
        radial-gradient(circle at 15% 0%, #e9f4f2 0%, transparent 42%),
        radial-gradient(circle at 100% 100%, #eef1f4 0%, transparent 45%),
        var(--bg);
}

.login-wrap { width: 100%; max-width: 372px; }

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(17, 24, 39, .05);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 26px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.login-brand .brand-logo { width: 52px; height: 52px; }

.login-brand .brand-title { font-size: 15.5px; }

.login-title { font-size: 19px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 3px; }

.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 22px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-form .btn { margin-top: 4px; }

.login-hint {
    margin-top: 20px;
    padding: 10px 12px;
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    color: var(--muted);
    text-align: center;
}

.login-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 18px; }

/* ---------- Footer ---------- */

.footer { border-top: 1px solid var(--border); background: #fff; }

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 18px;
    padding-bottom: 18px;
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}

/* ---------- Responsive ---------- */

/* Laptop kecil / tablet lanskap */
@media (max-width: 1080px) {
    .container { max-width: 100%; padding-left: 22px; padding-right: 22px; }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-dashboard { grid-template-columns: 1fr; }
    .grid-dashboard .stack:last-child { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .topbar-inner { gap: 16px; }
    .brand-sub { max-width: 150px; }
    .user-meta { display: none; }
    .topbar-user { padding-left: 14px; }
}

/* Tablet */
@media (max-width: 900px) {
    .topbar { position: static; }
    .topbar-inner {
        flex-wrap: wrap;
        align-items: center;
        gap: 0 12px;
        min-height: 0;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .brand { margin-right: auto; padding-right: 0; }
    .topbar-user { padding-left: 0; border-left: 0; gap: 8px; }
    .nav {
        order: 3;
        flex: 1 0 100%;
        width: 100%;
        margin: 8px 0 0;
        padding: 0;
        gap: 2px;
        background: transparent;
        border: 0;
        border-radius: 0;
        justify-content: center;
    }    .nav-link { height: 32px; padding: 0 12px; font-size: 13px; }
    .nav-link:hover { background: var(--surface-muted); }
    .nav-link.is-active {
        background: var(--accent-soft);
        color: var(--accent);
        box-shadow: none;
    }
    .main { padding-top: 26px; }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-dashboard .stack:last-child { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; }
    .filters { gap: 8px; }
    .filters .spacer { display: none; }
    .filters .field { flex: 1 1 150px; }
    .table th { padding: 9px 12px; }
    .table td { padding: 10px 12px; }
    .card-head, .card-body { padding-left: 18px; padding-right: 18px; }
    .saver { padding-left: 18px; padding-right: 18px; }
}

/* Ponsel */
@media (max-width: 720px) {
    .container { padding-left: 16px; padding-right: 16px; }
    .topbar { position: static; }
    .brand-logo { width: 30px; height: 30px; }
    .brand-title { font-size: 13.5px; }
    .brand-sub { display: none; }
    .topbar-inner { gap: 0 10px; padding-top: 9px; padding-bottom: 9px; }
    .nav { margin-top: 9px; }
    .avatar { width: 28px; height: 28px; font-size: 11.5px; }
    .logout-form .btn { height: 30px; padding: 0 10px; font-size: 12px; }
    .main { padding-top: 20px; padding-bottom: 40px; }
    .page-head { gap: 14px; margin-bottom: 18px; }
    .page-head h1 { font-size: 19px; }
    .page-head p { font-size: 12.5px; }
    .page-actions { width: 100%; gap: 7px; }
    .page-actions .btn { flex: 1 1 auto; }

    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3, .grid-2, .grid-dashboard,
    .grid-dashboard .stack:last-child { grid-template-columns: 1fr; }
    .stack { gap: 14px; }
    .grid { gap: 12px; }
    .mt-24 { margin-top: 18px; }

    .stat { padding: 14px 15px; gap: 4px; }
    .stat-value { font-size: 18.5px; }
    .stat-meta { font-size: 11.5px; }
    .stat-label { font-size: 12px; }
    .stat-icon { width: 24px; height: 24px; }

    .card-head { padding: 14px 15px; gap: 10px; flex-wrap: wrap; }
    .card-title { font-size: 13.5px; }
    .card-sub { font-size: 12px; }
    .card-body { padding: 16px 15px; }
    .card-foot { padding: 12px 15px; font-size: 12px; }
    .legend { gap: 10px; font-size: 11.5px; }

    .form-grid { grid-template-columns: 1fr; gap: 14px; }
    .form-actions { flex-wrap: wrap; gap: 8px; margin-top: 16px; padding-top: 14px; }
    .form-actions .btn { flex: 1 1 auto; }
    .input, .select, .textarea { font-size: 16px; min-height: 42px; } /* cegah zoom otomatis di iOS */
    .textarea { min-height: 84px; }
    .btn { padding: 11px 16px; }
    .btn-sm { padding: 8px 11px; }

    .filters { padding: 12px 15px; gap: 8px; }
    .filters .field { flex: 1 1 100%; }
    .filters .input, .filters .select { width: 100%; font-size: 16px; }
    .filters .btn { flex: 1 1 calc(50% - 4px); }

    .chart { padding: 18px 14px 14px; }
    .chart-bars { height: 132px; gap: 4px; }
    .chart-bar { width: 10px; }
    .chart-label { font-size: 10.5px; }

    .saver { padding: 11px 15px; gap: 9px; }
    .saver-amount { font-size: 12.5px; }

    .summary-row { font-size: 12.5px; gap: 8px; }

    .pagination { flex-wrap: wrap; justify-content: center; gap: 8px; padding: 12px; }
    .page-link { min-width: 32px; height: 32px; }

    .footer-inner { justify-content: center; text-align: center; gap: 4px; padding-top: 16px; padding-bottom: 16px; }

    /* Tabel menjadi kartu bertumpuk */
    .table-wrap { overflow: visible; }
    .table { display: block; font-size: 13px; }
    .table thead { display: none; }
    .table tbody, .table tfoot { display: block; }
    .table tr {
        display: flex;
        flex-direction: column;
        margin: 10px 12px;
        padding: 6px 0;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
    }
    .table tbody tr:last-child { margin-bottom: 12px; }
    .table tbody tr:hover { background: var(--surface); }
    .table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 14px;
        width: 100%;
        padding: 6px 14px;
        border: 0;
        text-align: right;
    }
    .table td::before {
        content: attr(data-label);
        flex: 0 0 40%;
        text-align: left;
        font-size: 11.5px;
        font-weight: 500;
        color: var(--muted);
        padding-top: 1px;
    }
    .table td:not([data-label])::before { display: none; }
    .table td[data-label=""]::before { display: none; }
    .table td.num { justify-content: space-between; }
    .table td .cell-title { font-size: 13.5px; }
    .table td .cell-sub { font-size: 11.5px; }

    /* Baris pertama jadi judul kartu */
    .table td.cell-lead {
        display: block;
        order: -1;
        text-align: left;
        padding: 8px 14px 9px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 4px;
    }
    .table td.cell-lead::before { display: none; }

    /* Kolom yang tidak perlu di ponsel */
    .hide-sm { display: none !important; }

    .table td.actions {
        justify-content: flex-end;
        gap: 6px;
        padding: 10px 14px 4px;
        margin-top: 4px;
        border-top: 1px dashed var(--border);
    }
    .table td.actions::before { display: none; }
    .table td.actions form { margin: 0; }
    .table td.actions .btn { flex: 0 1 auto; }

    /* Baris total pada laporan */
    .table tfoot tr {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px 14px;
        background: var(--surface-muted);
        padding: 12px 14px;
        border-radius: 12px;
        margin: 4px 12px 12px;
    }
    .table tfoot th {
        display: block;
        flex: 1 1 calc(50% - 7px);
        padding: 0;
        border: 0;
        background: none;
        text-align: left;
        font-size: 12.5px;
        font-weight: 600;
        white-space: normal;
        letter-spacing: 0;
        text-transform: none;
        color: var(--text);
    }
    .table tfoot th::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 500;
        color: var(--muted);
    }
    .table tfoot th.tfoot-label {
        flex: 1 1 100%;
        font-size: 11.5px;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--muted);
        font-weight: 600;
    }
    .table tfoot th.tfoot-label::before { display: none; }

    .empty { padding: 34px 18px; }
}

/* Ponsel sangat kecil */
@media (max-width: 420px) {
    .container { padding-left: 13px; padding-right: 13px; }
    .nav { flex-wrap: wrap; justify-content: center; overflow: visible; row-gap: 2px; }
    .nav.is-scrollable { -webkit-mask-image: none; mask-image: none; }
    .nav-link { height: 30px; padding: 0 10px; font-size: 12.5px; }
    .chart-bars { height: 118px; }
    .chart-bar { width: 8px; }
    .table tr { margin: 9px 10px; }
    .table td { padding: 6px 12px; gap: 10px; }
    .table td::before { flex-basis: 44%; font-size: 11px; }
    .btn { padding: 9px 13px; }
    .login-card { padding: 24px 20px; }
    .login-brand .brand-logo { width: 44px; height: 44px; }
}

@media (max-width: 360px) {
    .grid-4 { grid-template-columns: 1fr; }
    .stat-value { font-size: 19px; }
    .container { padding-left: 11px; padding-right: 11px; }
    .avatar { display: none; }
    .nav-link { height: 29px; padding: 0 9px; font-size: 12px; }
    .brand-title { font-size: 13px; }
}

/* ---------- Print ---------- */

@media print {
    .topbar, .footer, .page-actions, .filters, .pagination, .no-print, .alert { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .main { padding: 0; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    .container { max-width: 100%; padding: 0; }
    .table th { background: #f4f4f4 !important; }
    .print-only { display: block; margin-bottom: 14px; }
    .print-only h2 { font-size: 16px; }
    .print-only p { color: #555; font-size: 12px; }
    a { text-decoration: none; }
}
