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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2a2e45;
  --accent: #6c63ff;
  --accent2: #00d4aa;
  --accent3: #ff6b6b;
  --text: #e8eaf6;
  --text-dim: #8892b0;
  --sidebar-w: 220px;
  --radius: 14px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo-icon { font-size: 22px; }

nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 500;
  transition: all .2s;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,.15); color: var(--accent); }

/* ── MAIN ── */
.main { margin-left: var(--sidebar-w); flex: 1; padding: 32px; overflow-y: auto; }

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.page-header h1 { font-size: 24px; font-weight: 700; }

.page-hint { color: var(--text-dim); font-size: 13px; margin-bottom: 20px; }

.year-select-wrap select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

/* ── STAT CARDS ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.stat-label { color: var(--text-dim); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--accent); }

/* ── CHARTS ── */
.charts-row { display: grid; grid-template-columns: 1.8fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
}
.chart-card.full { }
.chart-card h3 { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-bottom: 18px; text-transform: uppercase; letter-spacing: .5px; }
.chart-card canvas { max-height: 280px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface2); }
th, td { padding: 12px 16px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); font-weight: 600; }
td:first-child, th:first-child { text-align: left; }
td:last-child, th:last-child { text-align: center; }
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }
.grand-total-cell { font-weight: 700; color: var(--accent); }
.cicilan-cell { color: var(--accent2); }

/* ── FORM SECTIONS ── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 900px;
}

.form-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: none; }

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-icon { font-size: 16px; }

.form-row { display: grid; gap: 14px; }
.form-row.two-col { grid-template-columns: repeat(2, 1fr); }
.form-row.three-col { grid-template-columns: repeat(3, 1fr); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.req { color: var(--accent3); }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-prefix {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.input-wrap input { padding-left: 32px !important; }

.form-group input, .form-group select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  width: 100%;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--border); }

/* ── FORM PREVIEW ── */
.form-preview {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 20px;
  padding: 18px 24px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.preview-item { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.preview-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); font-weight: 600; }
.preview-val { font-size: 18px; font-weight: 700; color: var(--text); }
.preview-val.accent { color: var(--accent); }
.preview-divider { width: 1px; height: 40px; background: var(--border); margin: 0 24px; }

/* ── FORM ACTIONS ── */
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: .85; }
.btn-primary.btn-update { background: var(--accent2); color: #000; }

.btn-secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--text); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.action-btn {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; font-size: 13px; transition: background .15s;
}
.edit-btn { color: var(--accent2); }
.edit-btn:hover { background: rgba(0,212,170,.1); }
.del-btn { color: var(--accent3); }
.del-btn:hover { background: rgba(255,107,107,.1); }

/* ── UPDATE PAGE ── */
.update-search-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  max-width: 500px;
  margin-bottom: 24px;
}

.update-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,212,170,.1);
  border: 1px solid var(--accent2);
  color: var(--accent2);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 28px; right: 28px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 20px; font-size: 13px; color: var(--text);
  opacity: 0; transform: translateY(12px); transition: all .3s;
  pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: var(--accent2); color: var(--accent2); }
.toast.error { border-color: var(--accent3); color: var(--accent3); }

@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .form-row.three-col { grid-template-columns: repeat(2, 1fr); }
  .form-row.two-col { grid-template-columns: 1fr; }
}
