:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dbe4f0;
  --text: #18212f;
  --muted: #637085;
  --blue: #2157d5;
  --blue-2: #143a91;
  --green: #198754;
  --amber: #c98a12;
  --red: #d64545;
  --chip: #eef3ff;
  --shadow: 0 12px 30px rgba(20, 40, 90, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  background: var(--blue);
  color: white;
  padding: 0.8rem 1rem;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover { transform: translateY(-1px); }
button.secondary {
  background: #eef2f8;
  color: var(--text);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fff;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #112349 0%, #182c57 100%);
  color: white;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
}

.brand p {
  margin: 0.2rem 0 0;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
}

.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255,255,255,0.12);
  font-size: 1.4rem;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 0.35rem;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: white;
  border: 1px solid transparent;
  padding: 0.9rem 1rem;
}

.nav-btn.active,
.nav-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 0.8rem;
}

.stacked-label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: rgba(255,255,255,0.8);
}

.stacked-label select {
  background: rgba(255,255,255,0.12);
  color: white;
  border-color: rgba(255,255,255,0.14);
}

.main {
  padding: 1.35rem;
}

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

.topbar h2 {
  margin: 0;
  font-size: 1.8rem;
}

.topbar p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.toolbar, .toolbar-inline {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

#globalSearch {
  min-width: 280px;
}

.view { display: none; }
.view.active { display: block; }

.grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 1.1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--panel);
  border: 1px solid #edf1f8;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.card-header h3, .card-subsection h4 {
  margin: 0;
}

.card-subsection {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.pill {
  background: var(--chip);
  color: var(--blue-2);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.kpi-grid .card, .kpi {
  padding: 1rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid #edf1f8;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.kpi .label {
  color: var(--muted);
  font-size: 0.92rem;
}

.kpi .value {
  font-size: 1.9rem;
  font-weight: 700;
  margin-top: 0.35rem;
}

.kpi .meta {
  color: var(--muted);
  margin-top: 0.25rem;
  font-size: 0.85rem;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.list, .cards-grid {
  display: grid;
  gap: 0.8rem;
}

.cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.item, .org-card, .event-card, .badge-card, .message-card, .submission-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  background: #fff;
}

.item h4, .org-card h4, .event-card h4, .badge-card h4, .message-card h4, .submission-card h4 {
  margin: 0 0 0.35rem 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.55rem 0;
}

.tag, .status {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.58rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #f2f5fb;
  color: var(--muted);
}

.status.pending { background: #fff6df; color: #8e6700; }
.status.approved, .status.completed, .status.open { background: #e8f7ef; color: #0a7a43; }
.status.rejected, .status.closed { background: #fdeaea; color: #b32d2d; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.actions button {
  padding: 0.55rem 0.78rem;
  font-size: 0.92rem;
}

.progress-bar {
  height: 10px;
  background: #edf1f7;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.6rem;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #4b79f2);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  padding: 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.86rem;
  background: #f8faff;
}

.subtle {
  color: var(--muted);
  margin: 0.2rem 0 0.75rem;
  font-size: 0.92rem;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.alert {
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: #edf4ff;
  color: var(--blue-2);
  border: 1px solid #d7e5ff;
  margin-bottom: 1rem;
}

.alert.success { background: #eaf8f0; border-color: #caecd8; color: #17693d; }
.alert.warn { background: #fff7e6; border-color: #f0e1b3; color: #8a6300; }

.bullets {
  padding-left: 1.2rem;
  margin: 0;
}

.bullets li { margin-bottom: 0.6rem; }

.inline-stat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.inline-stat:last-child {
  border-bottom: 0;
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar { flex-direction: column; align-items: stretch; }
  #globalSearch { min-width: 0; width: 100%; }
}
