/* ==========================================================================
   OrderKas — stylesheet utama
   ========================================================================== */

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e4e8f0;
  --border-strong: #cfd6e2;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-50: #eff4ff;
  --primary-100: #dbe6fe;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --info-bg: #e0f2fe;
  --info-text: #075985;

  /* Warna grafik (palet dataviz tervalidasi) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.18);

  --sidebar-w: 256px;
  --topbar-h: 64px;
  --content-max: 1280px;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body.modal-open, body.drawer-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
input, select, textarea { font: inherit; color: inherit; }
svg.icon { flex: none; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.money, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger-text); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.hidden, [hidden] { display: none !important; }

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

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.nav-link.active svg { color: var(--primary); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.user-chip .user-name { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.user-chip .user-role { font-size: 12px; color: var(--muted); }
.user-chip .btn { margin-left: auto; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 39;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: rgba(244, 246, 251, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; }
.topbar .hamburger { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-date { color: var(--muted); font-size: 13px; }

.content { padding: 24px; max-width: var(--content-max); width: 100%; margin: 0 auto; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h2 { font-size: 18px; }
.page-head .page-desc { color: var(--muted); font-size: 13px; width: 100%; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 12px; }
.section-title h3 { font-size: 15px; font-weight: 700; }
.section-title:first-child { margin-top: 0; }
.section-title .link { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Kartu ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 15px; }
.card-header .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-body { padding: 20px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-hero { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-members { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  min-width: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.stat-value {
  font-size: clamp(1.15rem, 1rem + 0.9vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
.stat-sub { font-size: 12.5px; color: var(--muted); }
.stat-small .stat-value { font-size: clamp(1rem, 0.95rem + 0.4vw, 1.2rem); }
.stat-small { padding: 14px 16px; }

.tone-success .stat-icon { background: var(--success-bg); color: var(--success-text); }
.tone-danger .stat-icon { background: var(--danger-bg); color: var(--danger-text); }
.tone-primary .stat-icon { background: var(--primary-100); color: var(--primary-700); }
.tone-warning .stat-icon { background: var(--warning-bg); color: var(--warning-text); }
.tone-danger .stat-value { color: var(--danger-text); }
.tone-success .stat-value { color: var(--success-text); }

/* Kartu prioritas: pendapatan bersih per orang */
.hero-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #ffffff 0%, #f3f7ff 100%);
  border: 1px solid var(--primary-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  min-width: 0;
}
.hero-card::after {
  content: "";
  position: absolute; right: -40px; top: -40px;
  width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.10) 0%, rgba(37, 99, 235, 0) 70%);
}
.hero-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hero-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.hero-caption { font-size: 12px; color: var(--muted); }
.hero-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.hero-value {
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--primary-700);
  line-height: 1.15;
  overflow-wrap: anywhere;
  margin: 2px 0 10px;
}
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.hero-meta b { font-weight: 600; color: var(--text); }
.hero-meta .deduct b { color: var(--danger-text); }

.avatar {
  display: inline-grid; place-items: center;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  flex: none;
}
.avatar-md { width: 40px; height: 40px; font-size: 14px; }
.avatar-sm { width: 30px; height: 30px; font-size: 12px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.av-1 { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.av-2 { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.av-3 { background: linear-gradient(135deg, #0d9488, #2dd4bf); }
.av-4 { background: linear-gradient(135deg, #db2777, #f472b6); }
.av-5 { background: linear-gradient(135deg, #ea580c, #fb923c); }

/* Kartu anggota (Pembagian) */
.member-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.member-head { display: flex; align-items: center; gap: 12px; }
.member-name { font-weight: 700; font-size: 16px; line-height: 1.2; overflow-wrap: anywhere; }
.member-pos { font-size: 12px; color: var(--muted); }
.member-head .btn-icon { margin-left: auto; }
.member-rows { display: grid; gap: 8px; }
.member-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13.5px; }
.member-row .k { color: var(--muted); }
.member-row .v { font-weight: 600; }
.member-row.total { border-top: 1px dashed var(--border-strong); padding-top: 10px; margin-top: 2px; }
.member-row.total .k { color: var(--text); font-weight: 600; }
.member-row.total .v { font-size: 18px; font-weight: 800; color: var(--primary-700); }
.member-card.fourth { border-style: dashed; background: var(--surface-2); }
.member-card.fourth .member-row.total .v { color: var(--danger-text); }
.rename-form { display: flex; gap: 8px; align-items: center; }
.rename-form input { flex: 1; min-width: 0; }

/* ---------- Tombol ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s, border-color 0.15s;
  text-decoration: none;
}
.btn:hover { background: #e3e8f0; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25); }
.btn-primary:hover { background: var(--primary-600); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-soft-danger { background: var(--danger-bg); color: var(--danger-text); }
.btn-soft-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 5px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn .spinner { width: 14px; height: 14px; border-width: 2px; }

/* ---------- Badge ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-primary { background: var(--primary-100); color: var(--primary-700); }

/* ---------- Form ---------- */

.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger-text); }
.input, input[type="text"], input[type="date"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  min-height: 40px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
input[aria-invalid="true"] { border-color: var(--danger); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 38px; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-right: 0; border-radius: 10px 0 0 10px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.input-prefix input { border-radius: 0 10px 10px 0; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
  transition: all 0.15s;
  background: var(--surface);
}
.segmented input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; }
.segmented input:checked + label.seg-success { background: var(--success-bg); border-color: var(--success); color: var(--success-text); }
.segmented input:checked + label.seg-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger-text); }

.checkbox { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; margin-top: 2px; min-height: 0; accent-color: var(--primary); }

.preview-box { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; }
.preview-box .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.preview-box .row .k { color: var(--muted); }
.preview-box .row .v { font-weight: 600; }
.preview-box.success { border-color: var(--success); background: #f0fdf4; }
.preview-box.danger { border-color: var(--danger); background: #fef2f2; }

.derived-panel { display: grid; gap: 10px; }
.derived-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; align-items: center; font-size: 13px; }
.derived-row .k { color: var(--muted); }
.derived-row .v { font-weight: 700; }
.derived-row .f { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.derived-row.warn { background: var(--warning-bg); }
.derived-row.warn .v { color: var(--warning-text); }

/* ---------- Tabel ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.card > .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
table.table { width: 100%; border-collapse: collapse; min-width: 760px; }
table.table th, table.table td { padding: 12px 16px; text-align: left; vertical-align: middle; }
table.table th { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.table td { border-top: 1px solid var(--border); font-size: 13.5px; }
table.table tbody tr:first-child td { border-top: 0; }
table.table tbody tr:hover td { background: #fafbfe; }
table.table td.num, table.table th.num { text-align: right; }
table.table .cell-main { font-weight: 600; }
table.table .cell-sub { font-size: 12px; color: var(--muted); }
table.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
table.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border-strong); }
.table-compact th, .table-compact td { padding: 9px 12px; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-no { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; background: var(--surface-3); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: 13px; }
.pager-btns { display: flex; align-items: center; gap: 8px; }
.pager-page { font-size: 13px; color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .input-icon { flex: 1 1 220px; min-width: 180px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

/* ---------- Periode ---------- */

.period-control { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 600; font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.custom-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.custom-range input[type="date"] { width: auto; min-width: 150px; }
.range-sep { color: var(--muted); font-size: 13px; }
.period-compact .chips { gap: 4px; }
.period-compact .chip { padding: 5px 10px; font-size: 12px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.filter-bar .period-label { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding-top: 6px; }

/* ---------- Validasi ---------- */

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.check { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.check.ok .check-icon { color: var(--success); }
.check.fail { background: var(--danger-bg); }
.check.fail .check-icon { color: var(--danger); }
.check-label { font-weight: 600; font-size: 13px; }
.check-formula { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; color: var(--text-2); margin: 2px 0; overflow-wrap: anywhere; }
.check-detail { font-size: 12px; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.status-pill.ok { background: var(--success-bg); color: var(--success-text); }
.status-pill.fail { background: var(--danger-bg); color: var(--danger-text); }

/* ---------- Grafik ---------- */

.chart { position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .bar { transition: opacity 0.15s; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover ~ .bars-group .bar { opacity: 1; }
.chart .slot.hover .bar { filter: brightness(1.12); }
.chart .slot.hover .hover-band { fill: rgba(15, 23, 42, 0.04); }
.chart .hover-band { fill: transparent; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: var(--shadow-md);
  min-width: 150px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.1s;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tooltip .tt-row .lbl { display: inline-flex; align-items: center; gap: 6px; color: #cbd5e1; }
.chart-tooltip .tt-row .key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-tooltip .tt-row b { font-weight: 700; }
.chart-empty { padding: 32px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Rekap harian ---------- */

.daily-list { display: grid; gap: 10px; }
.daily-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.daily-head {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 14px 16px; color: inherit;
}
.daily-head:hover { background: var(--surface-2); }
.daily-date { font-weight: 700; font-size: 14px; white-space: nowrap; }
.daily-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--text-2); }
.daily-summary b { color: var(--text); font-weight: 600; }
.daily-summary .loss b { color: var(--danger-text); }
.daily-chevron { color: var(--muted); transition: transform 0.2s; }
.daily-item.open .daily-chevron { transform: rotate(180deg); }
.daily-body { display: none; border-top: 1px solid var(--border); padding: 14px 16px; background: var(--surface-2); }
.daily-item.open .daily-body { display: block; }
.daily-members { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.mini-member { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; font-size: 13px; }
.mini-member .name { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.mini-member .r { display: flex; justify-content: space-between; gap: 8px; }
.mini-member .r .k { color: var(--muted); }
.mini-member .r.net { font-weight: 700; border-top: 1px dashed var(--border-strong); padding-top: 6px; margin-top: 2px; }
.mini-member.fourth { border-style: dashed; }

/* ---------- Audit ---------- */

.audit-list { display: grid; }
.audit-item { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); }
.audit-item:first-child { border-top: 0; }
.audit-dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.audit-dot.create { background: var(--success-bg); color: var(--success-text); }
.audit-dot.update { background: var(--info-bg); color: var(--info-text); }
.audit-dot.delete { background: var(--danger-bg); color: var(--danger-text); }
.audit-dot.settings { background: var(--warning-bg); color: var(--warning-text); }
.audit-desc { font-size: 13.5px; overflow-wrap: anywhere; }
.audit-meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; transition: opacity 0.18s;
  overflow-y: auto;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s;
  margin: auto;
}
.modal-backdrop.show .modal { transform: none; }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(760px, 100%); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.modal-header h2 { font-size: 17px; }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.confirm-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.confirm-icon.danger { background: var(--danger-bg); color: var(--danger); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.detail-grid .full { grid-column: 1 / -1; }
.detail-item .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.detail-item .v { font-size: 14px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.detail-note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 13.5px; }
.snapshot-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.snapshot-box h4 { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.snapshot-box .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }
.snapshot-box .row .v { font-weight: 600; }

/* ---------- Toast ---------- */

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success svg { color: #4ade80; }
.toast-error svg { color: #f87171; }
.toast-info svg { color: #93c5fd; }

/* ---------- Status kosong / loading ---------- */

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-3); color: var(--muted); display: grid; place-items: center; margin: 0 auto 12px; }
.empty-state h3 { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.empty-state p { font-size: 13px; margin-bottom: 14px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(100, 116, 139, 0.25); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
.btn-primary .spinner { border-color: rgba(255, 255, 255, 0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.is-refreshing { opacity: 0.55; transition: opacity 0.15s; pointer-events: none; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13px; }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert-danger { background: var(--danger-bg); color: var(--danger-text); }
.alert svg { flex: none; margin-top: 1px; }

.formula-box { display: grid; gap: 12px; }
.formula-line { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: 13.5px; }
.formula-line .step { width: 26px; height: 26px; border-radius: 8px; background: var(--primary-50); color: var(--primary-700); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.formula-line code { background: var(--surface-3); padding: 2px 6px; border-radius: 6px; font-size: 12.5px; }

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

.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 10% -10%, rgba(37, 99, 235, 0.14), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, rgba(124, 58, 237, 0.12), transparent 60%),
    var(--bg);
}
.login-card { width: min(400px, 100%); padding: 32px 28px; }
.login-card .brand { padding: 0 0 20px; }
.login-card h2 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.login-form { display: grid; gap: 14px; }

/* ---------- Halaman cetak ---------- */

.print-page { max-width: 1000px; margin: 0 auto; padding: 24px; background: #fff; color: #000; }
.print-toolbar { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.print-head { border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 16px; }
.print-head h1 { font-size: 22px; }
.print-head .meta { color: #444; font-size: 13px; margin-top: 4px; }
.print-page h3 { font-size: 14px; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 0.05em; color: #333; }
.print-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.print-table th, .print-table td { border: 1px solid #cbd5e1; padding: 6px 8px; text-align: left; }
.print-table th { background: #f1f5f9; font-weight: 700; }
.print-table td.num, .print-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.print-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; }
.print-kv div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted #cbd5e1; padding: 4px 0; font-size: 13px; }
.print-kv b { font-variant-numeric: tabular-nums; }

/* ---------- Responsif ---------- */

@media (max-width: 1023px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.drawer-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar .hamburger { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
}

@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  .topbar h1 { font-size: 17px; }
  .topbar-date { display: none; }
  .content { padding: 12px; }
  .grid { gap: 10px; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-hero, .grid-2, .grid-members { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
  .card-pad, .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .btn-label { display: none; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 18px 18px 0 0; margin: 0; }
  .modal-footer { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  #toast-root { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .daily-head { grid-template-columns: 1fr auto; }
  .daily-summary { grid-column: 1 / -1; }
  .pager { justify-content: center; }
  .pager-info { width: 100%; text-align: center; }
  .toolbar select { flex: 1; }
  table.table th, table.table td { padding: 10px 12px; }
}

/* ---------- Cetak ---------- */

@media print {
  @page { margin: 12mm; }
  body { background: #fff; }
  .sidebar, .sidebar-backdrop, .topbar, .no-print, #toast-root, #modal-root { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .print-page { padding: 0; max-width: none; }
  .card, .stat-card { box-shadow: none; break-inside: avoid; }
  .daily-item { break-inside: avoid; }
  .daily-body { display: block !important; }
  a { color: inherit; }
}
