:root {
  --color-primary: #0f9d58;
  --color-primary-dark: #0b7a43;
  --color-primary-light: #34c37a;
  --color-secondary: #1a73e8;
  --color-danger: #e5484d;
  --color-warning: #ffb703;
  --color-bg: #f4f7f6;
  --color-surface: #ffffff;
  --color-sidebar: #0f1512;
  --color-text: #16211a;
  --color-text-muted: #5a6b62;
  --shadow-sm: 0 2px 8px rgba(15,157,88,0.08);
  --shadow-md: 0 8px 24px rgba(15,157,88,0.12);
  --radius-sm: 10px;
  --radius-md: 16px;
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0f1512; --color-surface: #17201a; --color-text: #e9f3ec; --color-text-muted: #9db3a6;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3); --shadow-md: 0 8px 24px rgba(0,0,0,0.35);
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans','Segoe UI',system-ui,sans-serif; background: var(--color-bg); color: var(--color-text); }
a { text-decoration:none; color:inherit; }
ul { list-style:none; }

/* --- Login screen --- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(15,157,88,0.12), transparent 45%), var(--color-bg);
}
.login-card {
  background: var(--color-surface); padding: 44px 40px; border-radius: 24px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 380px; text-align: center; animation: fadeIn 0.5s ease;
}
.login-card img { width: 56px; height: 56px; border-radius: 14px; margin-bottom: 14px; }
.login-card h1 { font-size: 1.3rem; margin-bottom: 6px; }
.login-card p { color: var(--color-text-muted); font-size: 0.88rem; margin-bottom: 28px; }
.field { text-align: left; margin-bottom: 16px; }
.field label { display:block; font-size: 0.8rem; font-weight: 700; margin-bottom: 6px; color: var(--color-text-muted); }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid rgba(15,157,88,0.18);
  background: var(--color-bg); font-family: inherit; font-size: 0.95rem; color: var(--color-text);
}
.field input:focus { outline:none; border-color: var(--color-primary); box-shadow: 0 0 0 4px rgba(15,157,88,0.12); }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; padding: 12px 22px; border-radius: 999px; font-weight:700; font-size:0.9rem; border:none; cursor:pointer; transition: var(--transition); font-family:inherit; }
.btn-primary { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)); color:#fff; box-shadow: var(--shadow-sm); width:100%; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-outline { background: transparent; border: 1.5px solid rgba(15,157,88,0.3); color: var(--color-primary); }
.btn-danger { background: rgba(229,72,77,0.12); color: var(--color-danger); }
.err-msg { color: var(--color-danger); font-size: 0.85rem; margin-top: 10px; min-height: 18px; }

/* --- App shell --- */
#app-shell { display: none; min-height: 100vh; grid-template-columns: 260px 1fr; }
#app-shell.active { display: grid; }
.sidebar {
  background: var(--color-sidebar); color: #dce9e1; padding: 24px 18px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { display:flex; align-items:center; gap:10px; font-weight:800; padding: 0 10px 24px; color: #fff; }
.sidebar .brand img { width: 32px; height: 32px; border-radius: 8px; }
.sidebar a.nav-link {
  display:flex; align-items:center; gap: 12px; padding: 11px 14px; border-radius: 10px; font-size: 0.88rem; font-weight: 600;
  color: #a9bcb1; transition: var(--transition); cursor: pointer;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.nav-link.active { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); color: #fff; }
.sidebar .nav-section { margin-top: 18px; padding: 0 14px 6px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: #607565; }
.sidebar .spacer { flex: 1; }

.main { padding: 28px 36px; overflow-y: auto; max-height: 100vh; }
.topbar { display:flex; justify-content: space-between; align-items:center; margin-bottom: 28px; }
.topbar h1 { font-size: 1.5rem; font-weight: 800; }
.topbar .who { display:flex; align-items:center; gap: 12px; font-size: 0.88rem; color: var(--color-text-muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--color-primary), var(--color-secondary)); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:700; }

.kpi-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 20px; margin-bottom: 28px; }
.kpi-card { background: var(--color-surface); border-radius: var(--radius-md); padding: 22px; box-shadow: var(--shadow-sm); transition: var(--transition); animation: fadeIn 0.4s ease; }
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.kpi-card .label { font-size: 0.8rem; color: var(--color-text-muted); font-weight:600; }
.kpi-card .value { font-size: 1.5rem; font-weight: 800; margin-top: 8px; }
.kpi-card .icon { font-size: 1.4rem; margin-bottom: 10px; }

.panel { background: var(--color-surface); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 24px; animation: fadeIn 0.4s ease; }
.panel-head { display:flex; justify-content: space-between; align-items:center; margin-bottom: 18px; }
.panel-head h3 { font-size: 1.05rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid rgba(15,157,88,0.08); }
th { color: var(--color-text-muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: rgba(15,157,88,0.03); }

.badge { display:inline-block; padding: 4px 11px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.badge-green { background: rgba(15,157,88,0.12); color: var(--color-primary-dark); }
.badge-yellow { background: rgba(255,183,3,0.15); color: #a86a00; }
.badge-red { background: rgba(229,72,77,0.12); color: var(--color-danger); }
.badge-blue { background: rgba(26,115,232,0.12); color: var(--color-secondary); }
.badge-gray { background: rgba(90,107,98,0.12); color: var(--color-text-muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }
.loading { text-align: center; padding: 40px; color: var(--color-text-muted); }
.section-view { display: none; }
.section-view.active { display: block; animation: fadeIn 0.3s ease; }

.form-row { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; margin-bottom: 16px; }

@keyframes fadeIn { from { opacity:0; transform: translateY(10px);} to { opacity:1; transform:translateY(0);} }

@media (max-width: 900px) {
  #app-shell.active { grid-template-columns: 1fr; }
  .sidebar { display:none; }
}
