/* ==========================================================================
   Bank Sampah Guyup Rukun — Analytics UI
   ========================================================================== */
:root {
  --green-900: #0b4d38;
  --green-800: #0f6e4d;
  --green-700: #14855e;
  --green-600: #1b9c6e;
  --green-100: #e4f4ec;
  --green-50:  #f0f9f4;
  --bg:        #f4f7f5;
  --surface:   #ffffff;
  --text:      #15241d;
  --muted:     #6c7d73;
  --border:    #e2ebe5;
  --shadow:    0 1px 2px rgba(16, 55, 40, .04), 0 8px 24px rgba(16, 55, 40, .05);
  --shadow-lg: 0 18px 48px rgba(11, 77, 56, .14);
  --accent:    #1b9c6e;
  --surface-2: #f8fbf9;
  --ring:      0 0 0 3px rgba(27, 156, 110, .14);
  --up:        #0f9d6e;
  --down:      #d65454;
  --amber:     #c8891d;
  --sidebar-w: 246px;
  --radius:    16px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1100px 520px at 90% -10%, #e6f5ed 0%, transparent 60%), var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green-700); text-decoration: none; }
svg { display: block; }
[hidden] { display: none !important; }

/* ---------- boot ---------- */
.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); }
.boot-spinner { width: 34px; height: 34px; border: 3px solid var(--green-100); border-top-color: var(--green-700); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }
.auth-art {
  background: linear-gradient(155deg, #0b4d38 0%, #0f6e4d 55%, #1b9c6e 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-art::after { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255,255,255,.13); right: -180px; bottom: -180px; }
.auth-art::before { content: ''; position: absolute; width: 320px; height: 320px; border-radius: 50%; border: 1px solid rgba(255,255,255,.13); right: -60px; bottom: 40px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.auth-brand .logo { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.15); display: grid; place-items: center; }
.auth-art h1 { font-size: 38px; line-height: 1.18; max-width: 520px; margin: 0 0 18px; font-weight: 700; letter-spacing: -.8px; }
.auth-art p { max-width: 460px; color: rgba(255,255,255,.8); font-size: 15px; }
.auth-foot { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,.65); }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.5px; }
.auth-card .sub { color: var(--muted); margin: 0 0 28px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.auth-card input { width: 100%; }
.auth-links { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; }
.auth-alert { margin-bottom: 18px; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); color: #fff;
  background: linear-gradient(165deg, #0b4d38 0%, #0f6e4d 52%, #14855e 100%);
  border-right: 1px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column; z-index: 40; overflow: hidden;
}
.sidebar::before {
  content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%;
  right: -120px; top: -90px; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.16), transparent 68%);
}
.sidebar::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.06), transparent 32%);
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar .brand { display: flex; gap: 11px; align-items: center; padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.14); }
.brand .logo { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; flex: none; }
.brand-text strong { display: block; font-size: 13px; line-height: 1.25; color: #fff; }
.brand-text span { display: block; font-size: 10.5px; color: rgba(255,255,255,.68); margin-top: 2px; }
.nav { padding: 14px 10px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.55); padding: 10px 10px 6px; font-weight: 700; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; margin-bottom: 3px;
  border-radius: 10px; color: rgba(255,255,255,.78); font-size: 13px; font-weight: 550;
  transition: background .18s ease, color .18s ease, transform .18s ease;
  position: relative;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; transform: translateX(2px); }
.nav a.active {
  background: rgba(255,255,255,.18); color: #fff; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14);
}
.nav a.active::before { content: ''; position: absolute; left: -10px; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: #b9f0d0; }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav a .pill { margin-left: auto; font-size: 10px; background: rgba(255,255,255,.18); color: #fff; padding: 1px 6px; border-radius: 20px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.14); padding: 12px 12px 14px; }
.user-menu { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; width: 100%; text-align: left; background: transparent; border: 0; }
.user-chip:hover, .user-chip[aria-expanded="true"] { background: rgba(255,255,255,.12); }
.user-caret { width: 7px; height: 7px; border-right: 1.6px solid rgba(255,255,255,.8); border-bottom: 1.6px solid rgba(255,255,255,.8); transform: rotate(45deg); margin: 0 4px 3px 0; flex: none; transition: transform .18s ease; }
.user-chip[aria-expanded="true"] .user-caret { transform: rotate(225deg); margin-bottom: 0; }
.user-dropdown {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 40;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 7px; box-shadow: 0 14px 34px rgba(0,0,0,.22);
  animation: popin .16s ease;
}
.user-dropdown::after { content: ''; position: absolute; right: 18px; bottom: -6px; width: 11px; height: 11px; background: #fff; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: rotate(45deg); }
.user-dropdown-head { padding: 7px 9px 9px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.user-dropdown-head strong { display: block; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown-head span { font-size: 10px; color: var(--muted); }
.user-dropdown button {
  width: 100%; display: flex; align-items: center; gap: 9px; border: 0; background: transparent;
  color: var(--text); font-size: 11.5px; font-weight: 600; text-align: left;
  padding: 8px 9px; border-radius: 8px;
}
.user-dropdown button:hover { background: var(--green-50); color: var(--green-800); }
.user-dropdown button.danger { color: #a83232; }
.user-dropdown button.danger:hover { background: #fff1f1; }
.user-dropdown button svg { width: 15px; height: 15px; flex: none; }
.user-dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 5px 3px; }
.user-dropdown [hidden] { display: none !important; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.user-meta { min-width: 0; flex: 1; }
.user-meta strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.user-meta span { font-size: 10px; color: rgba(255,255,255,.68); }
.sidebar .icon-btn { color: rgba(255,255,255,.8); }
.sidebar .icon-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 7px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--green-100); color: var(--green-800); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  height: 66px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px;
  padding: 0 28px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: -.2px; }
.topbar-logo { display: none; }
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.topbar .crumb { color: var(--muted); font-size: 11px; }
.topbar .spacer { flex: 1; }
.conn { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); border: 1px solid var(--border); padding: 5px 10px; border-radius: 20px; background: #fff; }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: #b6c2ba; }
.conn.live .dot { background: var(--up); box-shadow: 0 0 0 3px rgba(15,157,110,.14); }
.conn.off .dot { background: var(--amber); }
.content { padding: 24px 28px 48px; max-width: 1560px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.4px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.page-head .spacer { flex: 1; }

/* Transisi halus saat halaman berganti, tanpa mengganggu interaksi. */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.content > * { animation: rise .24s ease both; }

/* ---------- controls ---------- */
input, select, textarea {
  border: 1px solid var(--border); background: #fff; border-radius: 9px; padding: 9px 11px;
  outline: none; transition: border-color .15s, box-shadow .15s; min-height: 38px;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--green-600); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: #a9b6ae; }
.field label, .lbl { display: block; font-size: 11px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field { min-width: 0; }
.input-search { position: relative; }
.input-search svg { position: absolute; left: 11px; top: 11px; color: var(--muted); width: 15px; height: 15px; }
.input-search input { padding-left: 34px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 9px; padding: 9px 14px; font-size: 12px; font-weight: 600; min-height: 38px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--green-600); color: var(--green-800); background: var(--green-50); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: linear-gradient(135deg, var(--green-700), var(--green-900)); border-color: var(--green-800); color: #fff; box-shadow: 0 6px 16px rgba(15, 110, 77, .18); }
.btn.primary:hover { background: linear-gradient(135deg, var(--green-800), #083b2b); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--down); border-color: #f2cccc; }
.btn.danger:hover { background: #fff4f4; border-color: var(--down); }
.btn.sm { padding: 6px 10px; min-height: 30px; font-size: 11px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: #eef3ef; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 11px; border-radius: 7px; font-size: 11px; font-weight: 600; color: var(--muted); transition: .15s; }
.segmented button:hover { color: var(--green-800); }
.segmented button.active { background: #fff; color: var(--green-800); box-shadow: 0 1px 4px rgba(0,0,0,.09); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.toolbar .field { width: 170px; }
.toolbar .field.grow { flex: 1; min-width: 220px; }
.toolbar .field.sm { width: 140px; }
.period-note { font-size: 11px; color: var(--muted); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-head .sub { font-size: 11px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.card-body { padding: 8px 18px 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow); position: relative; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.kpi:hover { transform: translateY(-2px); border-color: #cfe7d8; box-shadow: var(--shadow-lg); }
.kpi::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(180deg, var(--green-600), var(--green-900)); opacity: .9; }
.kpi .kpi-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 600; }
.kpi .kpi-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--green-50); color: var(--green-700); display: grid; place-items: center; }
.kpi .kpi-icon svg { width: 15px; height: 15px; }
.kpi .value { font-size: 23px; font-weight: 700; letter-spacing: -.6px; margin: 12px 0 6px; font-variant-numeric: tabular-nums; }
.kpi .compare { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.delta { font-weight: 700; display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 20px; font-size: 10px; }
.delta.up { color: var(--up); background: #e7f7ef; }
.delta.down { color: var(--down); background: #fdecec; }
.delta.flat { color: var(--muted); background: #f0f3f1; }
.delta.none { color: var(--muted); background: #f4f5f4; }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2.equal { grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 330px; }
.chart-box.short { height: 250px; }
.chart-hint { font-size: 10px; color: var(--muted); padding: 0 18px 12px; }

/* ---------- insights ---------- */
.insights { display: grid; gap: 8px; }
.insight { display: flex; gap: 10px; padding: 10px 12px; background: var(--green-50); border: 1px solid #d8ecdf; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.insight .ico { width: 22px; height: 22px; border-radius: 7px; background: #fff; color: var(--green-700); display: grid; place-items: center; flex: none; }
.insight .ico svg { width: 13px; height: 13px; }
.insight.warn { background: #fff8e9; border-color: #f5e3bd; }
.insight.warn .ico { color: var(--amber); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--border);
  background: #fafcfb; white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--green-700); }
table.data td { padding: 11px 14px; border-bottom: 1px solid #eef2ef; vertical-align: middle; }
table.data tbody tr:hover { background: #fbfdfc; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .link { color: var(--green-700); font-weight: 650; }
table.data .link:hover { text-decoration: underline; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 650; padding: 3px 8px; border-radius: 20px; background: #eef3ef; color: var(--muted); white-space: nowrap; }
.badge.selesai, .badge.completed { background: #e7f7ef; color: var(--up); }
.badge.draft { background: #fff5e3; color: var(--amber); }
.badge.cancelled { background: #fdecec; color: var(--down); }
.badge.active { background: #e7f7ef; color: var(--up); }
.badge.inactive { background: #f0f3f1; color: var(--muted); }
.badge.role { background: var(--green-100); color: var(--green-800); }
.pagination { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.pagination .spacer { flex: 1; }

/* ---------- states ---------- */
.empty, .error-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty .ico, .error-state .ico { width: 52px; height: 52px; border-radius: 16px; background: var(--green-50); color: var(--green-700); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .ico svg, .error-state .ico svg { width: 24px; height: 24px; }
.empty h3, .error-state h3 { margin: 0 0 6px; color: var(--text); font-size: 15px; }
.empty p, .error-state p { margin: 0 auto 16px; max-width: 420px; font-size: 12px; }
.skeleton { background: linear-gradient(90deg, #eef2ef 25%, #f7faf8 50%, #eef2ef 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- form ---------- */
.form-card { padding: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-4 { grid-column: 1 / -1; }
.items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.items-table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.items-table td { padding: 7px 8px; border-bottom: 1px solid #f0f3f1; }
.items-table input, .items-table select { width: 100%; min-height: 34px; padding: 6px 8px; font-size: 12px; }
.items-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.items-table .subtotal-cell { font-weight: 650; }
.form-footer { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }
.total-box { margin-right: auto; background: var(--green-50); border: 1px solid #d8ecdf; border-radius: 10px; padding: 9px 14px; font-size: 12px; }
.total-box strong { color: var(--green-900); font-size: 17px; display: block; font-variant-numeric: tabular-nums; }
.hint { font-size: 10.5px; color: var(--muted); }
.error-text { color: var(--down); font-size: 11px; margin-top: 4px; }

/* ---------- drawer / modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(11, 40, 28, .38); backdrop-filter: blur(2px); z-index: 80; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: #fff;
  z-index: 81; box-shadow: -12px 0 40px rgba(0,0,0,.12); display: flex; flex-direction: column;
  animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-head .sub { font-size: 11px; color: var(--muted); }
.drawer-head .spacer { flex: 1; }
.drawer-body { padding: 20px 22px 32px; overflow-y: auto; flex: 1; }
.modal {
  position: fixed; z-index: 81; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.2);
  width: min(480px, calc(100vw - 32px)); padding: 24px; animation: pop .16s ease;
}
@keyframes pop { from { transform: translate(-50%, -48%); opacity: .5; } }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 8px; }
.toast { background: #142b20; color: #fff; border-radius: 10px; padding: 11px 15px; font-size: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); display: flex; gap: 9px; align-items: center; max-width: 360px; animation: popin .18s ease; }
.toast.ok { background: #0f6e4d; }
.toast.err { background: #a83232; }
@keyframes popin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- detail ---------- */
.detail-sheet { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.detail-head { display: flex; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--green-800); padding-bottom: 16px; margin-bottom: 18px; }
.detail-head .logo-big { width: 50px; height: 50px; border-radius: 14px; background: var(--green-800); color: #fff; display: grid; place-items: center; flex: none; }
.detail-head h2 { margin: 0; font-size: 18px; }
.detail-head p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.meta-grid .lbl { margin-bottom: 3px; }
.meta-grid .val { font-size: 13px; font-weight: 600; }
.detail-total { display: flex; justify-content: flex-end; gap: 28px; padding: 16px 4px 0; font-size: 13px; }
.detail-total strong { font-size: 19px; color: var(--green-900); }

/* ---------- report ---------- */
.report-paper {
  --report-width: 794px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 30px; max-width: min(100%, var(--report-width));
  margin: 0 auto; color: #24352c;
}
.report-paper[data-paper="f4"] { --report-width: 816px; }
.report-paper[data-paper="letter"] { --report-width: 816px; }
.report-paper[data-paper="legal"] { --report-width: 816px; }
.report-letterhead { display: flex; align-items: center; gap: 12px; text-align: left; border-bottom: 2px solid var(--green-800); padding-bottom: 10px; margin-bottom: 14px; }
.report-identity { min-width: 0; }
.report-letterhead h2 { margin: 0; font-size: 15px; text-transform: uppercase; letter-spacing: .3px; color: var(--green-900); }
.report-letterhead p { margin: 2px 0 0; font-size: 10px; line-height: 1.45; color: var(--muted); }
.report-title { text-align: center; margin-bottom: 14px; }
.report-title h3 { margin: 0; font-size: 15px; letter-spacing: .2px; text-decoration: underline; text-underline-offset: 3px; }
.report-title p { margin: 3px 0 0; font-size: 10.5px; color: var(--muted); }
.report-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.report-stat { border: 1px solid #e1ece5; border-radius: 9px; padding: 8px 10px; background: linear-gradient(180deg, #fbfdfc, #f5faf7); }
.report-stat span { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: .3px; }
.report-stat strong { display: block; margin-top: 3px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--green-900); }
.report-section { margin: 15px 0 8px; font-size: 11.5px; font-weight: 700; color: var(--green-900); border-left: 3px solid var(--green-700); padding-left: 8px; letter-spacing: .2px; }
.report-paper .insights { gap: 5px; }
.report-paper .insight { padding: 7px 10px; font-size: 10.5px; line-height: 1.45; border-radius: 8px; }
.report-paper .insight .ico { width: 19px; height: 19px; }
.report-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.report-charts .chart-box { height: 178px; }
.report-charts .chart-hint { padding: 2px 8px 0; font-size: 9.5px; }
.report-weight .chart-box { height: 130px; }
.report-paper table.data { font-size: 10.5px; }
.report-paper table.data th, .report-paper table.data td { padding: 5px 7px; }
.report-sign { margin-top: 18px; display: flex; justify-content: flex-end; text-align: center; font-size: 10.5px; }
.sign-block { min-width: 210px; line-height: 1.5; }
.sign-block .sign-space { height: 30px; }
.report-sign .line { width: 210px; border-top: 1px solid var(--text); margin-bottom: 5px; }
.report-sign strong { color: var(--green-900); font-weight: 700; }

/* ---------- preferensi tampilan ringkas ---------- */
body.compact .card-body { padding: 12px 14px; }
body.compact table.data th { padding: 7px 10px; }
body.compact table.data td { padding: 6px 10px; font-size: 12px; }
body.compact .table-wrap { max-height: 62vh; }
body.compact .detail-sheet { padding: 18px; }

/* ---------- logo bank sampah ---------- */
.logo img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.auth-brand .logo img { border-radius: 9px; }
.logo-preview {
  width: 74px; height: 74px; border-radius: 14px; background: #f4f8f5;
  border: 1px dashed var(--border); display: grid; place-items: center; flex: none;
  overflow: hidden; color: var(--green-800);
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.report-logo { display: flex; flex: none; }
.report-logo .logo { width: 62px; height: 62px; border-radius: 14px; background: #fff; border: 1px solid var(--border); padding: 4px; }
.detail-head .logo-big img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-2.equal { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  .sidebar { width: min(220px, 84vw); transform: translateX(-100%); transition: transform .22s ease; box-shadow: 8px 0 30px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; width: 100%; }
  .topbar { padding: 0 12px; height: 58px; gap: 8px; }
  .topbar > div:not(.spacer) { min-width: 0; }
  .topbar h1 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-logo {
    display: grid; place-items: center; flex: none; overflow: hidden;
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--green-50); color: var(--green-700);
    box-shadow: inset 0 0 0 1px #d8ecdf;
  }
  #crumb { display: none !important; }
  .conn { padding: 5px 8px; font-size: 10px; flex: none; }
  .content { padding: 14px 12px calc(28px + env(safe-area-inset-bottom)); width: 100%; }
  .page-head { align-items: stretch; margin-bottom: 14px; }
  .page-head > div:first-child { min-width: 0; }
  .page-head h2 { font-size: 19px; }
  .page-head p { font-size: 11px; }

  .btn-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
  .btn-group .btn { width: 100%; padding-inline: 8px; }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: end; }
  .toolbar .field, .toolbar .field.sm, .toolbar .field.grow { width: 100%; min-width: 0; }
  .toolbar .field.grow { grid-column: 1 / -1; }
  .toolbar .segmented, .toolbar .period-note, .toolbar > .btn { grid-column: 1 / -1; justify-self: start; max-width: 100%; }
  .segmented { flex-wrap: wrap; }

  .grid-3, .report-charts { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { padding: 32px 18px; }
  .auth-card { max-width: none; }
  .report-paper { padding: 16px; }
  .report-stats, .meta-grid { grid-template-columns: 1fr 1fr; }
  .report-letterhead { gap: 10px; }
  .report-logo .logo { width: 52px; height: 52px; }
  .detail-head { flex-wrap: wrap; }
  .detail-total, .form-footer, .pagination { flex-wrap: wrap; }
  .form-footer .total-box { width: 100%; margin-right: 0; }
  .pagination > span:first-child { flex: 1 1 100%; }
  .pagination .spacer { display: none; }

  /* Tabel jadi kartu: tidak ada geser horizontal, tiap baris pas di layar. */
  .table-wrap { overflow: visible; }
  .table-wrap table, table.data, .items-table { display: block; width: 100%; }
  .table-wrap thead, table.data thead, .items-table thead { display: none; }
  .table-wrap tbody, table.data tbody, .items-table tbody { display: grid; gap: 10px; }
  .table-wrap tbody tr, table.data tbody tr, .items-table tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 11px 12px; box-shadow: 0 2px 10px rgba(16, 55, 40, .05);
  }
  .table-wrap tbody td, table.data tbody td, .items-table tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%; min-width: 0; padding: 4px 0; border-bottom: 0;
    text-align: left !important; white-space: normal !important; overflow-wrap: anywhere;
  }
  .table-wrap tbody td[data-label]::before, table.data tbody td[data-label]::before, .items-table tbody td[data-label]::before {
    content: attr(data-label); flex: 0 0 auto;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--muted);
  }
  .table-wrap tbody td:not([data-label]) { justify-content: flex-end; }
  .table-wrap tbody td > input, .table-wrap tbody td > select,
  table.data tbody td > input, .items-table tbody td > input, .items-table tbody td > select {
    flex: 0 1 58%; width: 58%; max-width: 58%; min-width: 0;
  }
  body.compact .table-wrap { max-height: none; }

  .pdf-preview { width: calc(100vw - 16px); height: 92vh; }
  .pdf-preview-head { padding: 12px; flex-wrap: wrap; }
  .pdf-preview-head > div:first-child { flex: 1 1 100%; }
  .pdf-preview-head .spacer { display: none; }
  .pdf-preview-head .btn { flex: 1 1 auto; }
  .sign-block { min-width: 0; width: 100%; }
  .report-sign .line { width: 100%; }
}

@media (max-width: 520px) {
  .kpi-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .form-grid .span-4 { grid-column: auto; }
  .report-stats, .meta-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar { grid-template-columns: minmax(0, 1fr); }
  .toolbar .field.grow { grid-column: auto; }
  .btn-group { grid-template-columns: minmax(0, 1fr); }
  .conn-text { display: none; }
  .report-logo .logo { width: 46px; height: 46px; }
  .report-letterhead h2 { font-size: 15px; }
  .pdf-preview-head .btn { width: 100%; }
}

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

/* ---------- pratinjau PDF ---------- */
.pdf-preview {
  position: fixed; z-index: 81; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(1040px, calc(100vw - 28px)); height: min(88vh, 900px);
  background: #fff; border-radius: 18px; box-shadow: 0 28px 80px rgba(0,0,0,.26);
  display: flex; flex-direction: column; overflow: hidden; animation: pop .18s ease;
}
.pdf-preview-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(90deg, #fff, var(--green-50)); }
.pdf-preview-head h3 { margin: 0; font-size: 15px; }
.pdf-preview-head .sub { font-size: 11px; color: var(--muted); }
.pdf-preview-head .spacer { flex: 1; }
.pdf-preview-body { flex: 1; min-height: 0; background: #e9efeb; padding: 12px; }
.pdf-preview-body iframe { width: 100%; height: 100%; border: 0; border-radius: 10px; background: #fff; box-shadow: 0 6px 24px rgba(11, 77, 56, .12); }

/* Ukuran halaman default; halaman laporan menggantinya lewat #report-page-style. */
@page { size: 210mm 297mm; margin: 12mm; }

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .overlay, .drawer, .pdf-preview, .toast-stack { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .report-paper, .detail-sheet { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .content > * { animation: none !important; }
  /* Kembalikan tabel ke bentuk semula saat dicetak, termasuk dari viewport HP. */
  .table-wrap { overflow: visible !important; }
  .table-wrap table, table.data, .items-table { display: table !important; width: 100% !important; }
  .table-wrap thead, table.data thead, .items-table thead { display: table-header-group !important; }
  .table-wrap tbody, table.data tbody, .items-table tbody { display: table-row-group !important; }
  .table-wrap tbody tr, table.data tbody tr, .items-table tbody tr {
    display: table-row !important; border: 0 !important; padding: 0 !important;
    box-shadow: none !important; background: transparent !important;
  }
  .table-wrap tbody td, table.data tbody td, .items-table tbody td {
    display: table-cell !important; width: auto !important; padding: 5px 7px !important;
    border-bottom: 1px solid #eef2ef !important; text-align: left !important;
  }
  .table-wrap tbody td[data-label]::before, table.data tbody td[data-label]::before, .items-table tbody td[data-label]::before { content: none !important; }
  .table-wrap tbody td.num, table.data tbody td.num { text-align: right !important; }
  .report-paper { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .report-charts, .report-stats { break-inside: avoid; }
  .report-section { break-after: avoid; }
  .report-paper table.data { break-inside: auto; }
  .report-paper table.data tr { break-inside: avoid; }
}
