:root {
  --purple-1: #5b2a86;
  --purple-2: #7e3ff2;
  --bg: #f4f5f9;
  --text: #2b2b3a;
  --border: #e2e2ec;
  --danger: #e3493a;
  --success: #2fa96b;
  --info: #2489c5;
  --warning: #f2994a;
  --table-header-bg: #14213d;
  --table-header-text: #ffffff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--purple-1), var(--purple-2));
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p.subtitle { color: #888; margin-bottom: 24px; font-size: 14px; }

/* ---------- Layout ---------- */
.app-layout { display: flex; min-height: 100vh; }

/* Lebar sidebar dikunci fix supaya tidak pernah berubah walau pindah halaman/menu */
.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  flex: 0 0 240px;
  background: linear-gradient(180deg, var(--purple-1), var(--purple-2));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}
.sidebar .brand {
  padding: 16px 20px 8px;
  display: flex;
  align-items: center;
}
.brand-logo {
  max-width: 100%;
  height: auto;
}
.sidebar nav { flex: 1; overflow-y: auto; }

/* Menu label + groups */
.menu-label {
  padding: 16px 20px 8px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}
.menu-group { margin-bottom: 4px; }
.menu-parent {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin: 0 10px;
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  border-radius: 8px;
}
.menu-parent.active-group {
  background: #fff;
  color: var(--purple-1);
  font-weight: 700;
}
.menu-children a {
  display: block;
  position: relative;
  padding: 10px 20px 10px 44px;
  margin: 0 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 8px;
}
.menu-children a::before {
  content: '\2022';
  position: absolute;
  left: 26px;
}
.menu-children a.active {
  background: rgba(255,255,255,0.16);
  color: #fff;
  font-weight: 600;
}
.menu-children a:hover { color: #fff; }

.menu-single {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  margin: 0 10px 2px;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 14px;
  border-radius: 8px;
  width: calc(100% - 20px);
}
.menu-single.active { background: #fff; color: var(--purple-1); font-weight: 700; }
.menu-single:hover { background: rgba(255,255,255,0.12); color: #fff; }
.menu-icon { width: 20px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.menu-icon svg { display: block; }

.main { flex: 1; min-width: 0; padding: 28px 32px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar-user { display: flex; align-items: center; gap: 16px; }
.topbar-user .user-info { font-size: 14px; color: #555; }
.logout-btn {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.logout-btn:hover { background: #fdeceb; }

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.section-title { font-size: 20px; margin: 0; }
.period-selector { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #333; font-weight: 600; }
.period-selector select { width: auto; margin-bottom: 0; min-width: 110px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; margin-bottom: 6px; color: #555; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
}
.btn-primary { background: var(--purple-2); color: #fff; }
.btn-primary:hover { background: var(--purple-1); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.error-msg { color: var(--danger); font-size: 13px; margin: -8px 0 12px; min-height: 16px; }

/* ---------- Checkbox row (mis. tandai kategori Recurring Revenue) ---------- */
.checkbox-row { margin: -6px 0 16px; }
.checkbox-inline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  margin-bottom: 0;
}
.checkbox-inline input[type="checkbox"] {
  width: auto;
  margin: 2px 0 0;
  accent-color: var(--purple-2);
  flex-shrink: 0;
}

/* ---------- Card & Table ---------- */
.card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.card h3 { margin-top: 0; font-size: 16px; }
.table-toolbar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.table-toolbar input, .table-toolbar select { margin-bottom: 0; width: auto; min-width: 160px; }
.table-scroll { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
thead tr { background: var(--table-header-bg); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; word-wrap: break-word; }
th {
  color: var(--table-header-text);
  font-weight: 600;
  font-size: 13px;
  text-transform: none;
  vertical-align: middle;
  border-bottom: none;
}
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
tbody tr:hover { background: #fafafc; }
tbody tr:nth-child(even) { background: #fbfbfd; }

.col-date { white-space: nowrap; width: 110px; }
.col-amount { white-space: nowrap; width: 140px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-pct { white-space: nowrap; width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
td.col-pct { color: #777; }
.col-growth { white-space: nowrap; width: 170px; text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { white-space: nowrap; width: 150px; }
.col-kategori { width: 220px; }
.col-customer { width: 140px; }
.col-channel { width: 130px; }
.col-deskripsi { width: 260px; }
.col-deskripsi-lebar { width: 243px; }
.col-tipe { width: 160px; }
.col-klaim { white-space: nowrap; width: 14ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.col-amount-narrow { white-space: nowrap; width: 15ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.in { background: #e6f7ee; color: var(--success); }
.pill.out { background: #fdeceb; color: var(--danger); }
.pill.warn { background: #fdf1e7; color: var(--warning); }
.row-actions { white-space: nowrap; display: flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.row-actions button { padding: 6px 10px; font-size: 12px; margin: 0; white-space: nowrap; flex-shrink: 0; }
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.pagination input { width: 60px; margin-bottom: 0; text-align: center; }
#pageInfo { font-size: 70%; }

/* ---------- Ikhtisar (summary cards, chart, insights) ---------- */
.summary-cards { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.summary-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 22px;
  flex: 1;
  min-width: 220px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border-left: 4px solid transparent;
}
.summary-card.border-success { border-left-color: var(--success); }
.summary-card.border-danger { border-left-color: var(--danger); }
.summary-card.border-info { border-left-color: var(--info); }
.summary-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.summary-label { font-size: 12px; color: #888; text-transform: uppercase; font-weight: 600; letter-spacing: .3px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-success { background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-info { background: var(--info); }
.summary-value { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.summary-sub { font-size: 12px; color: #999; }

.chart-card { margin-bottom: 20px; }
.chart-legend { display: flex; gap: 20px; margin: 4px 0 16px; font-size: 13px; color: #555; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-wrap { display: flex; gap: 12px; height: 280px; }
.chart-grid {
  width: 110px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: right;
  font-size: 12px;
  color: #888;
  padding: 0 8px 24px 0;
}
.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 16px;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
}
.chart-bar-group { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; height: 100%; justify-content: flex-end; }
.chart-bar-pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; }
.chart-bar { width: 28px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-success { background: var(--success); }
.bar-danger { background: var(--danger); }
.chart-bar-label { font-size: 12px; color: #777; white-space: nowrap; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.insights-list { margin: 0; padding-left: 18px; font-size: 14px; color: #444; line-height: 1.9; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { background: #fff; border-radius: 12px; padding: 28px; width: 100%; max-width: 440px; }
.modal h2 { margin-top: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.hidden { display: none !important; }

/* ---------- Dialog (alert / confirm / prompt kustom) ---------- */
.dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(30, 15, 55, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0;
  transition: opacity .18s ease;
}
.dialog-overlay.show { opacity: 1; }
.dialog-box {
  background: #fff;
  border-radius: 18px;
  padding: 34px 30px 26px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(35, 15, 70, 0.28);
  border-top: 5px solid var(--purple-2);
  transform: scale(.9) translateY(10px);
  transition: transform .18s ease;
}
.dialog-overlay.show .dialog-box { transform: scale(1) translateY(0); }
.dialog-box.dialog-success { border-top-color: var(--success); }
.dialog-box.dialog-danger { border-top-color: var(--danger); }
.dialog-box.dialog-warning { border-top-color: var(--warning); }
.dialog-box.dialog-info { border-top-color: var(--info); }

.dialog-icon {
  width: 58px; height: 58px; margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--purple-1), var(--purple-2));
  color: #fff;
}
.dialog-box.dialog-success .dialog-icon { background: none; background-color: #e6f7ee; color: var(--success); }
.dialog-box.dialog-danger .dialog-icon { background: none; background-color: #fdeceb; color: var(--danger); }
.dialog-box.dialog-warning .dialog-icon { background: none; background-color: #fef1e4; color: var(--warning); }
.dialog-box.dialog-info .dialog-icon { background: none; background-color: #e7f2fb; color: var(--info); }

.dialog-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--text); }
.dialog-message { margin: 0 0 22px; font-size: 14px; color: #666; line-height: 1.6; white-space: pre-line; }
.dialog-input { margin-bottom: 22px; }
.dialog-actions { display: flex; justify-content: center; gap: 10px; }
.dialog-actions button { min-width: 100px; margin: 0; }
