:root {
  /* Tema Hijau Pedesaan (Rural Green) */
  --primary-green: #2c5f2d; /* Forest Green for headers */
  --primary-hover: #1e4520;
  --secondary-green: #97bc62; /* Soft leaf green for buttons/accents */
  
  --bg-color: #f7f9f4; /* Very light earthy beige/green for main bg */
  --sidebar-bg: #eef2e6; /* Sage-tinted light background */
  --sidebar-active: #dce4cd;
  --sidebar-hover: #e5ead9;
  
  --card-bg: #ffffff;
  --text-main: #2b3a2f; /* Dark pine green instead of pure black */
  --text-muted: #647468;
  
  --warning-bg: #fcedcf;
  --warning-text: #8c6b1d;
  --warning-border: #ebd59e;
  
  --success-bg: #dcf2d9;
  --success-text: #2c5f2d;
  
  --danger-bg: #fbe3e3;
  --danger-text: #962c2c;
  
  --border-color: #dce2d5;
  
  /* Soft, organic borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 2px 4px rgba(44, 95, 45, 0.05);
  --shadow-md: 0 6px 12px rgba(44, 95, 45, 0.08);
}

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

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
}

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

.top-navbar {
  background: linear-gradient(135deg, #15803d 0%, #14532d 100%);
  color: white;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(20, 83, 45, 0.15);
  border-bottom: 1px solid #166534;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.navbar-brand img, .navbar-brand svg {
  height: 44px;
  width: 44px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 8px;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
}
.navbar-brand:hover svg {
  transform: rotate(-5deg) scale(1.05);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 16px 6px 6px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: background 0.2s;
  position: relative;
}
.navbar-user:hover {
  background: rgba(255, 255, 255, 0.2);
}

.profile-dropdown {
  display: none;
  position: absolute;
  top: 120%;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  min-width: 180px;
  padding: 8px;
  z-index: 1000;
  border: 1px solid #e2e8f0;
}
.profile-dropdown.show {
  display: block;
}
.profile-dropdown form button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 12px 16px;
  border-radius: 8px;
  color: #ef4444;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}
.profile-dropdown form button:hover {
  background: #fef2f2;
}

.user-avatar {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.main-wrapper {
  display: flex;
  flex: 1;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background-color: #ffffff;
  padding: 24px 16px;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 2px 0 12px rgba(0,0,0,0.02);
  z-index: 10;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  border-radius: 12px;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.nav-item:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.nav-item.active {
  background-color: #f0fdf4;
  color: var(--primary-green);
  font-weight: 600;
}

.nav-item svg {
  color: #94a3b8;
  transition: color 0.2s;
}
.nav-item:hover svg {
  color: #475569;
}
.nav-item.active svg {
  color: var(--primary-green);
}

.btn-logout:hover {
  background-color: #fef2f2 !important;
  color: #ef4444 !important;
}
.btn-logout:hover svg {
  color: #ef4444 !important;
}

/* Content Area */
.content-area {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-green);
  margin-bottom: 24px;
}

/* Cards & Containers */
.card-plain {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  background-color: var(--sidebar-bg);
  color: var(--primary-green);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-info h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-info p {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary-green);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--secondary-green);
  color: white;
}
.btn-secondary:hover {
  background-color: #83aa51;
}

.btn-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border-color: var(--warning-border);
}
.btn-warning:hover {
  background-color: #fae1b4;
}

/* Alerts / Notices */
.alert-card {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--warning-text);
  font-weight: 600;
  font-size: 0.9rem;
}
.alert-card h2 {
  color: var(--text-main);
  font-size: 1.4rem;
  margin-bottom: 8px;
}

/* Forms */
.input-group {
  margin-bottom: 20px;
}

.input-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background-color: #fafbf9;
  color: var(--text-main);
  transition: border-color 0.2s;
}

.input-field:focus {
  outline: none;
  border-color: var(--secondary-green);
  background-color: white;
  box-shadow: 0 0 0 3px rgba(151, 188, 98, 0.2);
}

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th {
  background-color: var(--sidebar-bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 14px 16px;
  border-bottom: 2px solid var(--border-color);
}
th:first-child { border-top-left-radius: var(--radius-md); }
th:last-child { border-top-right-radius: var(--radius-md); }

td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

tr:hover td {
  background-color: #fbfcf9;
}

/* Badges */
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-pending {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success-text);
}

.badge-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
}

/* Utility */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }

/* Flashes */
.error-msg {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-weight: 500;
  border: 1px solid #f9c2c2;
}

.success-msg {
  background-color: var(--success-bg);
  color: var(--success-text);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-weight: 500;
  border: 1px solid #c2e8bd;
}

/* Activity List */
.activity-list {
  list-style: none;
  position: relative;
  padding-left: 0;
  margin-top: 16px;
}

.activity-list::before {
  content: '';
  position: absolute;
  left: 21px;
  top: 10px;
  bottom: 0;
  width: 2px;
  background-color: #e2e8f0;
}

.activity-item {
  position: relative;
  padding-bottom: 24px;
  padding-left: 48px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.activity-dot {
  position: absolute;
  left: 16px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--primary-green);
  border: 2px solid white;
  box-shadow: 0 0 0 3px #dcf2d9;
  z-index: 2;
}

.activity-dot.yellow {
  background-color: var(--warning-text);
  box-shadow: 0 0 0 3px #fcedcf;
}

.activity-time {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
  min-width: 60px;
  padding-top: 2px;
}

.activity-content {
  flex: 1;
  background: white;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-text h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: #0f172a;
}
.activity-text p {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* Responsiveness for Mobile */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  /* Hide standard sidebar */
  .sidebar {
    display: none !important;
  }
  
  /* Bottom Navigation for Mobile */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    z-index: 999;
    padding: 8px 16px;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #e2e8f0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  
  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 8px;
    border-radius: 12px;
    transition: all 0.2s;
  }
  
  .bottom-nav-item.active {
    color: var(--primary-green);
  }
  .bottom-nav-item.active svg {
    background: #f0fdf4;
    padding: 6px;
    border-radius: 10px;
    margin-top: -12px;
    width: 32px;
    height: 32px;
    box-shadow: 0 4px 8px rgba(22, 101, 52, 0.15);
  }

  /* Navbar */
  .top-navbar {
    padding: 0 16px;
  }
  .navbar-brand {
    font-size: 1.1rem;
  }
  .navbar-brand span.hidden-mobile {
    display: none;
  }
  .navbar-user span.hidden-mobile {
    display: none;
  }

  /* Main Layout */
  .main-wrapper {
    flex-direction: column;
    padding-bottom: 70px; /* Space for bottom nav */
  }

  /* Content */
  .content-area {
    padding: 16px 12px;
  }

  .page-title {
    font-size: 1.4rem;
    margin-bottom: 16px;
  }

  .card, .card-plain {
    padding: 16px;
  }

  /* Flex elements */
  .flex.gap-4 {
    flex-direction: column;
    gap: 12px;
  }
  
  .flex.justify-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .flex.justify-between > div:last-child,
  .flex.justify-between > a {
    width: 100%;
  }
  
  .flex.justify-between button {
    width: 100%;
  }
  
  .activity-item {
    flex-direction: column;
    padding-left: 36px;
  }
  .activity-dot {
    left: 4px;
  }
  .activity-list::before {
    left: 9px;
  }
  
  /* Responsive Cards for Tables */
  table:not(.ledger-table) {
    border: 0 !important;
  }
  table:not(.ledger-table) thead {
    display: none;
  }
  table:not(.ledger-table) tr {
    border: 1px solid var(--border-color) !important;
    display: block;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    overflow: hidden;
  }
  table:not(.ledger-table) td {
    border: none !important;
    border-bottom: 1px solid #f1f5f9 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    text-align: right;
    padding: 12px 16px !important;
    min-height: 44px;
  }
  table:not(.ledger-table) td::before {
    content: attr(data-label);
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-right: 16px;
    text-align: left;
    flex-shrink: 0;
  }
  table:not(.ledger-table) td:last-child {
    border-bottom: 0 !important;
  }

  /* KOP Grid Fix for Mobile */
  .kop-grid > div {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 12px;
  }
  .kop-grid > div .kop-label {
    margin-bottom: 0;
    font-size: 0.85rem;
  }
  .kop-grid > div strong, .kop-grid > div span {
    font-size: 0.95rem;
    text-align: right;
  }
  
  /* Optimize Ledger Table for Mobile Scrolling */
  .ledger-table {
    font-size: 0.85rem;
  }
  .ledger-table th, .ledger-table td {
    padding: 8px 6px !important;
  }
  .btn-action {
    padding: 4px 8px;
    font-size: 10px;
  }
}
