:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --surface: #ffffff;
  --bg: #f4f6fb;
  --border: #e2e8f0;
  --sidebar: #12172b;
  --sidebar-hover: #1c2340;
  --sidebar-active: #2a3358;
  --accent: #4f6bfe;
  --accent-soft: #eef1ff;
  --accent-ink: #3348d6;
  --green: #16a34a;
  --green-soft: #e9f9ef;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fef3e2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --shadow-lift: 0 12px 32px -12px rgba(15, 23, 42, 0.22);
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login ─── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(79, 107, 254, 0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(79, 107, 254, 0.2), transparent 45%),
    var(--sidebar);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lift);
  animation: rise 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem; margin-bottom: 18px;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block; font-size: 0.76rem; font-weight: 650; color: var(--ink-soft);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
.field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 0.92rem; color: var(--ink); background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary-ngo {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 11px 18px; font-weight: 650; font-size: 0.9rem; width: 100%;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: 0 6px 16px -6px rgba(79, 107, 254, 0.55);
}
.btn-primary-ngo:hover { background: var(--accent-ink); transform: translateY(-1px); }
.btn-primary-ngo:active { transform: translateY(0); }

/* ─── App Shell ─── */

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

.sidebar {
  width: 250px; flex-shrink: 0; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; padding: 18px 12px;
  position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 20px;
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center; font-size: 0.95rem;
}
.sidebar-brand .txt { font-weight: 750; font-size: 0.92rem; line-height: 1.15; }
.sidebar-brand .txt small { display: block; font-weight: 450; font-size: 0.68rem; color: #93a0c9; }

.nav-group-label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #6d7aa8; font-weight: 700; padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: none; background: transparent; color: #c3cae6; padding: 9px 12px;
  border-radius: 9px; font-size: 0.85rem; font-weight: 550; margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
}
.nav-item i { width: 16px; text-align: center; font-size: 0.85rem; opacity: 0.85; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item.active i { color: var(--accent); opacity: 1; }

.sidebar-footer { margin-top: auto; padding: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; background: var(--sidebar-hover);
  border-radius: 12px; padding: 9px 10px;
}
.user-chip .av {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.78rem; flex-shrink: 0;
}
.user-chip .meta { line-height: 1.2; flex: 1; min-width: 0; }
.user-chip .meta .n { font-size: 0.8rem; font-weight: 650; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta .r { font-size: 0.66rem; color: #93a0c9; }
.user-chip button { background: none; border: none; color: #93a0c9; padding: 4px; transition: color var(--transition); }
.user-chip button:hover { color: #fff; }

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

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 1.15rem; font-weight: 750; margin: 0; color: var(--ink); }
.topbar .sub { font-size: 0.78rem; color: var(--muted); margin-top: 1px; }

.content { padding: 24px 28px 60px; max-width: 1360px; width: 100%; margin: 0 auto; flex: 1; }

.mobile-toggle { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lift); }
  .main-area { margin-left: 0; }
  .mobile-toggle { display: inline-flex; }
  .sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.4); z-index: 39; }
  .sidebar-scrim.show { display: block; }
}

/* ─── Cards & Stats ─── */

.panel {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 18px; border: 1px solid var(--border);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 0.96rem; font-weight: 700; margin: 0; color: var(--ink); }
.panel-head .hint { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); transition: transform var(--transition), box-shadow var(--transition);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi .icon {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 0.85rem; margin-bottom: 10px;
}
.kpi .val { font-size: 1.28rem; font-weight: 750; color: var(--ink); line-height: 1.1; }
.kpi .lbl { font-size: 0.72rem; color: var(--muted); font-weight: 600; margin-top: 3px; }
.kpi.warn .icon { background: var(--red-soft); color: var(--red); }
.kpi.warn .val { color: var(--red); }
.kpi.good .icon { background: var(--green-soft); color: var(--green); }

/* ─── Buttons ─── */

.btn-ngo {
  border: none; border-radius: var(--radius-sm); padding: 8px 15px; font-size: 0.82rem; font-weight: 620;
  display: inline-flex; align-items: center; gap: 6px; transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
  cursor: pointer;
}
.btn-ngo-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px -4px rgba(79,107,254,0.5); }
.btn-ngo-primary:hover { background: var(--accent-ink); transform: translateY(-1px); }
.btn-ngo-ghost { background: #fff; color: var(--ink-soft); border: 1.5px solid var(--border); }
.btn-ngo-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-ngo-success { background: var(--green-soft); color: var(--green); border: 1.5px solid transparent; }
.btn-ngo-success:hover { background: var(--green); color: #fff; }
.btn-ngo-danger { background: var(--red-soft); color: var(--red); border: 1.5px solid transparent; }
.btn-ngo-danger:hover { background: var(--red); color: #fff; }
.btn-ngo-sm { padding: 5px 11px; font-size: 0.74rem; }
.btn-ngo:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Tables ─── */

.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
table.tbl thead th {
  text-align: left; padding: 10px 14px; background: #f8fafc; color: var(--muted);
  font-weight: 700; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.tbl tbody td { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; color: var(--ink-soft); }
table.tbl tbody tr { transition: background var(--transition); }
table.tbl tbody tr:hover { background: #fafbff; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--faint); padding: 34px 12px; font-size: 0.85rem; }
.empty-row i { display: block; font-size: 1.4rem; margin-bottom: 8px; opacity: 0.5; }

/* ─── Pills / badges ─── */

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 20px; padding: 3px 10px; font-size: 0.68rem; font-weight: 700; white-space: nowrap; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-gray { background: #f1f5f9; color: var(--muted); }
.pill-blue { background: var(--accent-soft); color: var(--accent-ink); }

/* ─── Banner ─── */

.banner { border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; display: flex; gap: 14px; align-items: flex-start; }
.banner.ok { background: var(--green-soft); border: 1px solid #b8ecc9; }
.banner.bad { background: var(--red-soft); border: 1px solid #f6c4c4; }
.banner .bicon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 0.95rem; }
.banner.ok .bicon { background: var(--green); color: #fff; }
.banner.bad .bicon { background: var(--red); color: #fff; }
.banner .btitle { font-weight: 700; font-size: 0.88rem; color: var(--ink); }
.banner .bsub { font-size: 0.78rem; color: var(--ink-soft); margin-top: 2px; }

/* ─── Modal polish ─── */

.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lift); }
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-header .modal-title { font-weight: 750; font-size: 1rem; }
.modal-body { padding: 20px 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 22px; }

/* ─── Toasts ─── */

#toastStack { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; width: 320px; }
.toast-ngo {
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-lift);
  padding: 13px 15px; display: flex; align-items: flex-start; gap: 10px; border-left: 4px solid var(--accent);
  animation: toastIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-ngo.success { border-left-color: var(--green); }
.toast-ngo.error { border-left-color: var(--red); }
.toast-ngo .ticon { font-size: 0.95rem; margin-top: 1px; }
.toast-ngo.success .ticon { color: var(--green); }
.toast-ngo.error .ticon { color: var(--red); }
.toast-ngo .tmsg { font-size: 0.82rem; color: var(--ink-soft); flex: 1; line-height: 1.4; }
.toast-ngo.leaving { animation: toastOut 180ms ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ─── Loading skeleton ─── */

.skel { background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner-ngo { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Misc form helpers ─── */

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 4px; }
.form-check-ngo { display: flex; align-items: center; gap: 8px; padding-top: 22px; }
.section-title { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin: 18px 0 10px; }
.section-title:first-child { margin-top: 0; }
