@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: #f5f5f7; color: #1d1d1f; min-height: 100vh; }

/* ── Variables ── */
:root {
  --purple: #dc2626;
  --purple-dark: #b91c1c;
  --purple-light: #fef2f2;
  --red: #e63946;
  --red-light: #fff0f0;
  --white: #ffffff;
  --grey-50: #f5f5f7;
  --grey-100: #ebebed;
  --grey-200: #d8d8dc;
  --grey-400: #8e8e93;
  --grey-600: #48484a;
  --grey-900: #1d1d1f;
  --sidebar-bg: #1a0808;
  --sidebar-hover: rgba(255,255,255,0.07);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 10px;
  --radius-lg: 14px;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; overflow-y: auto;
}
.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logo-icon {
  width: 34px; height: 34px; background: var(--purple);
  border-radius: 8px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; color: white; font-size: 0.9rem;
  flex-shrink: 0;
}
.sidebar-logo-text { color: #f5f5f7; font-weight: 700; font-size: 0.95rem; }
.sidebar-user {
  margin: 0.8rem 0.8rem 0.4rem;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius); padding: 0.75rem;
}
.sidebar-user-name { color: #e5e5e7; font-weight: 600; font-size: 0.875rem; }
.sidebar-user-role {
  font-size: 0.7rem; font-weight: 600; color: var(--purple);
  background: rgba(220,38,38,0.15); border-radius: 4px;
  padding: 1px 7px; display: inline-block; margin-top: 3px;
}
.sidebar-nav { padding: 0.4rem 0.6rem; flex: 1; }
.sidebar-section {
  font-size: 0.6rem; font-weight: 700; color: #48484a;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.8rem 0.6rem 0.3rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 0.55rem 0.8rem; border-radius: 8px;
  color: #8e8e93; font-size: 0.855rem; font-weight: 500;
  text-decoration: none; transition: all 0.15s; margin-bottom: 2px;
  position: relative;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #e5e5e7; }
.sidebar-link.active { background: rgba(220,38,38,0.15); color: var(--purple); }
.sidebar-link .icon { width: 18px; text-align: center; font-size: 0.9rem; }
.notif-badge {
  background: var(--red); color: white; border-radius: 10px;
  font-size: 0.65rem; font-weight: 700; padding: 1px 6px;
  margin-left: auto;
}
.sidebar-bottom {
  padding: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 0.55rem 0.8rem; border-radius: 8px;
  color: #8e8e93; font-size: 0.855rem; font-weight: 500;
  text-decoration: none; transition: all 0.15s; width: 100%;
}
.sidebar-logout:hover { background: rgba(230,57,70,0.1); color: var(--red); }

/* ── Main content ── */
.main { margin-left: 240px; flex: 1; min-height: 100vh; }
.topbar {
  background: white; border-bottom: 1px solid var(--grey-100);
  padding: 0 1.5rem; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--grey-900); }
.topbar-subtitle { font-size: 0.78rem; color: var(--grey-400); }
.content { padding: 1.5rem; }

/* ── Cards ── */
.card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--grey-100); box-shadow: var(--shadow-sm);
  padding: 1.2rem 1.4rem; margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--grey-100);
}
.card-title { font-weight: 700; font-size: 0.95rem; color: var(--purple); }

/* ── KPI Cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
  background: white; border-radius: var(--radius-lg);
  border: 1.5px solid var(--grey-100); padding: 1.2rem;
  text-decoration: none; display: block;
  transition: all 0.15s; box-shadow: var(--shadow-sm);
}
.kpi-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-md);
  border-color: var(--purple);
}
.kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-400); }
.kpi-purple .kpi-value { color: var(--purple); }
.kpi-amber  .kpi-value { color: #d97706; }
.kpi-green  .kpi-value { color: #059669; }
.kpi-indigo .kpi-value { color: #be123c; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.855rem; }
th {
  background: var(--grey-50); padding: 0.65rem 0.9rem;
  text-align: left; font-weight: 600; font-size: 0.75rem;
  color: var(--grey-600); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1.5px solid var(--grey-100);
}
td { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--grey-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--grey-50); }

/* ── App row (expandable) ── */
.app-row { background: white; border: 1.5px solid var(--grey-100); border-radius: var(--radius-lg); margin-bottom: 0.6rem; overflow: hidden; }
.app-row-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; cursor: pointer; transition: background 0.15s;
}
.app-row-header:hover { background: var(--grey-50); }
.app-row-title { font-weight: 600; color: var(--grey-900); font-size: 0.9rem; }
.app-row-sub { font-size: 0.78rem; color: var(--grey-400); margin-top: 2px; }
.app-row-body { padding: 1.1rem 1.2rem; border-top: 1px solid var(--grey-100); display: none; }
.app-row-body.open { display: block; }
.app-detail-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; margin-bottom: 1rem; }
.app-detail-label { font-size: 0.7rem; font-weight: 600; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.06em; }
.app-detail-value { font-size: 0.875rem; color: var(--grey-900); margin-top: 2px; font-weight: 500; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.badge-not-checked { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-in-progress { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-submitted   { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-counsellor  { background: var(--purple-light); color: var(--purple); }
.badge-officer     { background: #ecfdf5; color: #065f46; }
.badge-admin       { background: #fff0f0; color: var(--red); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0.45rem 1rem; border-radius: 8px; font-weight: 600;
  font-size: 0.855rem; border: none; cursor: pointer; text-decoration: none;
  transition: all 0.15s; font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--purple); color: white; }
.btn-primary:hover { background: var(--purple-dark); color: white; transform: translateY(-1px); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #c41e2a; color: white; }
.btn-outline { background: white; color: var(--grey-600); border: 1.5px solid var(--grey-200); }
.btn-outline:hover { border-color: var(--purple); color: var(--purple); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.btn-icon { padding: 0.4rem; border-radius: 7px; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--grey-600); margin-bottom: 0.3rem; }
.form-control {
  width: 100%; padding: 0.5rem 0.75rem; border-radius: 8px;
  border: 1.5px solid var(--grey-200); font-size: 0.875rem;
  font-family: 'Inter', sans-serif; color: var(--grey-900);
  background: white; transition: border-color 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(220,38,38,0.1); }
.form-control[readonly] { background: var(--grey-50); color: var(--grey-600); cursor: not-allowed; border-color: var(--grey-100); }
.form-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ── School block ── */
.school-block {
  background: var(--grey-50); border: 1.5px solid var(--grey-100);
  border-radius: var(--radius); padding: 1rem; margin-bottom: 0.7rem;
}
.school-block-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem;
}
.school-number { font-size: 0.72rem; font-weight: 700; color: var(--purple); text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Alerts / Flash ── */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.875rem; font-weight: 500; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fff0f0; color: #c41e2a; border: 1px solid #fecaca; }
.alert-info    { background: var(--purple-light); color: var(--purple-dark); border: 1px solid #fecaca; }

/* ── Notification item ── */
.notif-item {
  background: white; border-left: 3px solid var(--purple);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem; margin-bottom: 0.5rem;
  box-shadow: var(--shadow-sm);
}
.notif-unread { border-left-color: var(--red); background: var(--red-light); }
.notif-msg { font-size: 0.875rem; font-weight: 500; color: var(--grey-900); }
.notif-meta { font-size: 0.72rem; color: var(--grey-400); margin-top: 3px; }

/* ── Search/filter bar ── */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1.2rem; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar .form-control { min-width: 160px; }

/* ── Workload table ── */
.workload-row { display: flex; align-items: center; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--grey-100); }
.workload-name { font-weight: 600; font-size: 0.875rem; width: 160px; flex-shrink: 0; }
.workload-bar-wrap { flex: 1; background: var(--grey-100); border-radius: 4px; height: 8px; overflow: hidden; }
.workload-bar { height: 100%; background: var(--purple); border-radius: 4px; }
.workload-count { font-size: 0.78rem; font-weight: 600; color: var(--grey-600); min-width: 40px; text-align: right; }

/* ── Login page ── */
.auth-page { min-height: 100vh; background: var(--grey-50); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { background: white; border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: 0 8px 32px rgba(0,0,0,0.1); border: 1px solid var(--grey-100); }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; justify-content: center; }
.auth-logo-icon { width: 44px; height: 44px; background: var(--purple); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: white; font-size: 1.1rem; }
.auth-logo-text { font-size: 1.3rem; font-weight: 800; color: var(--grey-900); }
.auth-title { font-size: 1.3rem; font-weight: 700; color: var(--grey-900); margin-bottom: 0.3rem; }
.auth-sub { font-size: 0.855rem; color: var(--grey-400); margin-bottom: 1.5rem; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid var(--grey-100); }
.auth-tab { padding: 0.6rem 1.2rem; font-weight: 600; font-size: 0.875rem; color: var(--grey-400); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.auth-tab.active { color: var(--purple); border-bottom-color: var(--purple); }
.auth-footer { text-align: center; margin-top: 1rem; font-size: 0.78rem; color: var(--grey-400); }

/* ── Tabs on pages ── */
.page-tabs { display: flex; gap: 4px; padding: 4px; background: var(--grey-100); border-radius: var(--radius); margin-bottom: 1.2rem; }
.page-tab { padding: 0.45rem 1rem; border-radius: 7px; font-size: 0.855rem; font-weight: 600; color: var(--grey-600); text-decoration: none; transition: all 0.15s; }
.page-tab.active { background: white; color: var(--purple); box-shadow: var(--shadow-sm); }
.page-tab:hover:not(.active) { color: var(--grey-900); }

/* ── Divider ── */
.divider { height: 1px; background: var(--grey-100); margin: 1rem 0; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--grey-400); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state-text { font-size: 0.875rem; }

/* ── Autocomplete ── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white; border: 1.5px solid var(--grey-200);
  border-radius: var(--radius); max-height: 220px; overflow-y: auto;
  z-index: 200; box-shadow: var(--shadow-md); display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item { padding: 0.6rem 0.8rem; font-size: 0.855rem; cursor: pointer; color: var(--grey-900); }
.autocomplete-item:hover { background: var(--purple-light); color: var(--purple); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .form-row, .form-row-3, .app-detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}
