:root {
  --ges-dark: #004D2C;
  --ges-dark-hover: #003820;
  --ges-accent: #76B82A;
  --ges-accent-hover: #659a24;
  --nav-bg: #1a2332;
  --nav-text: #94a3b8;
  --nav-active: #76B82A;
  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --info: #0ea5e9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --sidebar-width: 260px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
}

a { color: var(--ges-dark); text-decoration: none; }
a:hover { color: var(--ges-accent); }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: #fff;
}

.sidebar-brand .logo-sub {
  font-size: 0.7rem;
  color: var(--ges-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--nav-text);
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: all 0.15s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-link.active {
  background: rgba(118, 184, 42, 0.15);
  color: var(--ges-accent);
  border-left: 3px solid var(--ges-accent);
  padding-left: calc(1rem - 3px);
}

.nav-icon {
  width: 20px;
  height: 20px;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
  color: var(--nav-text);
}

/* Main content */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-primary);
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.875rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ges-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.main-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2, .card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-body { padding: 1.25rem; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 3px solid var(--ges-accent);
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ges-dark);
  margin: 0.25rem 0;
}

.kpi-change {
  font-size: 0.8rem;
  color: var(--success);
}

.kpi-change.negative { color: var(--danger); }

/* Quick actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

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

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

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

.btn-dark:hover {
  background: var(--ges-dark-hover);
  color: #fff;
}

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

.btn-outline:hover {
  border-color: var(--ges-accent);
  color: var(--ges-dark);
}

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

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--ges-accent);
  box-shadow: 0 0 0 3px rgba(118, 184, 42, 0.15);
}

.form-control.calculated {
  background: rgba(118, 184, 42, 0.08);
  border-color: var(--ges-accent);
  font-weight: 700;
  color: var(--ges-dark);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:hover { background: #f8fafc; }

.table-search {
  max-width: 320px;
  margin-bottom: 1rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* Toast */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  color: #fff;
  font-weight: 500;
  font-size: 0.875rem;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 { margin: 0; font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Pagination */
.pagination-nav { margin-top: 1rem; }
.pagination {
  display: flex;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}

.page-link {
  display: block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.page-item.active .page-link {
  background: var(--ges-dark);
  color: #fff;
  border-color: var(--ges-dark);
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card { min-height: 300px; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--nav-bg) 0%, var(--ges-dark) 100%);
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  color: var(--ges-dark);
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.login-accent {
  width: 48px;
  height: 4px;
  background: var(--ges-accent);
  border-radius: 2px;
  margin: 1rem auto 0;
}

/* Grid layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: block; }
  .grid-2 { grid-template-columns: 1fr; }

  .topbar {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }
  .topbar-right {
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 576px) {
  .main-content { padding: 1rem; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 1.35rem; }

  .page-title { font-size: 1.05rem; }
  .user-chip { display: none; }

  .quick-actions {
    flex-direction: column;
  }
  .quick-actions .btn {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 0.6rem 0.75rem;
  }

  .modal-backdrop { padding: 0; }
  .modal {
    max-width: none;
    max-height: none;
    height: 100vh;
    border-radius: 0;
  }
  .modal-header, .modal-body, .modal-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .modal-footer {
    gap: 0.5rem;
  }
  .modal-footer .btn {
    flex: 1;
  }
}
