@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #fafafa;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-hover: #f5f5f5;
  --bg-input: #ffffff;
  --bg-stripe: #fafafa;
  --text: #171717;
  --text-muted: #737373;
  --text-dim: #a3a3a3;
  --border: #e5e5e5;
  --border-input: #d4d4d4;
  --primary: #171717;
  --primary-hover: #404040;
  --primary-soft: #f5f5f5;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --unpaid: #d4d4d4;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 8px;
  --header-row1-h: 34px;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-card: #171717;
  --bg-header: #171717;
  --bg-hover: #262626;
  --bg-input: #1c1c1c;
  --bg-stripe: #1c1c1c;
  --text: #fafafa;
  --text-muted: #a3a3a3;
  --text-dim: #737373;
  --border: #262626;
  --border-input: #404040;
  --primary: #fafafa;
  --primary-hover: #d4d4d4;
  --primary-soft: #262626;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --success-soft: #052e16;
  --unpaid: #404040;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ===== Header halaman (BUKAN sticky) ===== */
.header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.header-actions { display: flex; gap: 6px; align-items: center; }

/* ===== Icon button ===== */
.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon:active { transform: scale(0.95); }
.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Container ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; width: 100%; }

/* ===== Toolbar ===== */
.toolbar { margin-bottom: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar input {
  flex: 1;
  min-width: 200px;
  max-width: 380px;
  padding: 10px 14px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: 0.15s;
}
.toolbar input::placeholder { color: var(--text-dim); }
.toolbar input:focus { border-color: var(--text-muted); }

/* ===== Table wrap ===== */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: auto;
  border: 1px solid var(--border);
  max-height: 72vh;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13.5px;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

/* ===== Freeze pane header ===== */
th {
  background: var(--bg-hover);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  z-index: 3;
  box-sizing: border-box;
}

/* Baris 1 header: judul bulan + NAMA */
thead tr:nth-child(1) th {
  top: 0;
  height: var(--header-row1-h);
  line-height: var(--header-row1-h);
  padding-top: 0;
  padding-bottom: 0;
  z-index: 4;
}

/* Baris 2 header: M1-M4 + Minggu */
thead tr:nth-child(2) th {
  top: var(--header-row1-h);
  z-index: 3;
}

/* Kolom nama: sticky kiri, di body */
th.col-name, td.col-name {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 1;
  font-weight: 600;
  padding-left: 16px;
}

/* th.col-name baris 1 — sticky kiri + atas, z-index tertinggi */
thead tr:nth-child(1) th.col-name {
  top: 0;
  left: 0;
  z-index: 20;
  background: var(--bg-hover);
  height: var(--header-row1-h);
  line-height: var(--header-row1-h);
  padding-top: 0;
  padding-bottom: 0;
}

/* th.col-name baris 2 — sticky kiri + bawah baris 1, z-index tertinggi */
thead tr:nth-child(2) th.col-name {
  top: var(--header-row1-h);
  left: 0;
  z-index: 20;
  background: var(--bg-hover);
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}

/* zebra + hover */
tbody tr:nth-child(even) td { background: var(--bg-stripe); }
tbody tr:nth-child(even) td.col-name { background: var(--bg-stripe); }
tbody tr:hover td { background: var(--bg-hover); }
tbody tr:hover td.col-name { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

.month-group { border-left: 1px solid var(--border); }

/* ===== Cell status ===== */
.cell-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transition: 0.15s;
}
.cell-status svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cell-status.paid {
  background: var(--success-soft);
  color: var(--success);
}
.cell-status.unpaid {
  background: transparent;
  color: var(--unpaid);
}
.cell-status:hover { transform: scale(1.1); }

/* ===== Buttons ===== */
.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  transition: 0.15s;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary {
  background: var(--text);
  color: var(--bg-card);
}
.btn-primary:hover { opacity: 0.85; }
.btn-outline {
  background: var(--bg-card);
  border-color: var(--border-input);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 380px;
}
.modal-box h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}
.modal-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-input);
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 10px;
  outline: none;
}
.modal-box input:focus { border-color: var(--text-muted); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }
.error { color: var(--danger); font-size: 13px; margin-bottom: 8px; }
.loading, .empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--text);
}

/* ===== Tooltip ===== */
.tooltip {
  position: fixed;
  background: var(--text);
  color: var(--bg-card);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.tooltip.hidden { display: none; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px 20px 32px;
  margin-top: auto;
}
.footer a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: 0.15s;
}
.footer a:hover {
  color: var(--text);
}
