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

:root {
  --primary: #2e7d32;
  --primary-light: #4caf50;
  --primary-dark: #1b5e20;
  --primary-bg: #e8f5e9;
  --accent: #ff8f00;
  --danger: #d32f2f;
  --text: #263238;
  --text-light: #546e7a;
  --bg: #f1f8e9;
  --card: #ffffff;
  --border: #c8e6c9;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --transition: 0.25s ease;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  text-align: center;
}

.sidebar-header .logo {
  font-size: 28px;
  margin-bottom: 4px;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-header p {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-left-color: #fff;
}

.sidebar-nav a .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  opacity: 0.7;
  text-align: center;
}

/* ===== Main ===== */
.main {
  margin-left: 250px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--card);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .page-title {
  font-size: 20px;
  font-weight: 700;
}

.topbar .date-display {
  font-size: 13px;
  color: var(--text-light);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.content {
  padding: 24px 28px;
  flex: 1;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card .card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 6px;
  font-weight: 600;
}

.card .card-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.card .card-icon {
  font-size: 32px;
  opacity: 0.2;
  position: absolute;
  top: 16px;
  right: 20px;
}

.card.income {
  border-left: 4px solid var(--primary-light);
}

.card.income .card-value {
  color: var(--primary-dark);
}

.card.expense {
  border-left: 4px solid var(--danger);
}

.card.expense .card-value {
  color: var(--danger);
}

.card.balance {
  border-left: 4px solid var(--accent);
}

.card.balance .card-value {
  color: var(--accent);
}

.card {
  position: relative;
}

/* ===== Section ===== */
.section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.section-header .badge {
  background: var(--primary-bg);
  color: var(--primary-dark);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ===== Forms ===== */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border var(--transition);
  background: var(--card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ===== Buttons ===== */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b71c1c;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
}

.btn-icon:hover {
  background: var(--primary-bg);
}

.btn-icon.danger:hover {
  background: #ffebee;
}

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: #fafff5;
}

tbody tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.tag-green {
  background: #e8f5e9;
  color: #2e7d32;
}

.tag-red {
  background: #ffebee;
  color: #c62828;
}

.tag-blue {
  background: #e3f2fd;
  color: #1565c0;
}

.tag-orange {
  background: #fff3e0;
  color: #e65100;
}

.tag-purple {
  background: #f3e5f5;
  color: #6a1b9a;
}

.tag-teal {
  background: #e0f2f1;
  color: #00695c;
}

.text-right {
  text-align: right;
}

.text-green {
  color: var(--primary-dark);
  font-weight: 600;
}

.text-red {
  color: var(--danger);
  font-weight: 600;
}

.text-muted {
  color: var(--text-light);
  font-size: 12px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.filter-bar label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

.filter-bar select,
.filter-bar input {
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--card);
}

.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
}

/* ===== Chart ===== */
.chart-wrap {
  position: relative;
  height: 280px;
  width: 100%;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal .form-actions {
  margin-top: 16px;
}

/* ===== Empty State ===== */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

.empty .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty p {
  font-size: 14px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .content {
    padding: 16px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card .card-value {
    font-size: 22px;
  }
}

/* ===== Print ===== */
@media print {
  .sidebar,
  .topbar,
  .form-actions,
  .btn,
  .filter-bar,
  #btnHapusSemua {
    display: none !important;
  }

  .main {
    margin-left: 0;
  }

  .page {
    display: block !important;
  }

  .card,
  .section {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary-dark);
  color: #fff;
  padding: 14px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

/* ===== Summary Report ===== */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-item {
  text-align: center;
  padding: 12px;
  background: var(--primary-bg);
  border-radius: 8px;
}

.summary-item .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  font-weight: 600;
}

.summary-item .value {
  font-size: 20px;
  font-weight: 800;
  margin-top: 4px;
}

.summary-item .value.green {
  color: var(--primary-dark);
}

.summary-item .value.red {
  color: var(--danger);
}

/* ===== Overlay for mobile sidebar ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 90;
}

.sidebar-overlay.open {
  display: block;
}

@media (min-width: 769px) {
  .sidebar-overlay {
    display: none !important;
  }
}
