:root {
  --bg: #f6f8fb;
  --surface: #fff;
  --surface-soft: #f9fafc;
  --line: #e2e8f0;
  --text: #111827;
  --muted: #667085;
  --blue: #2f6fb7;
  --blue-soft: #eaf2ff;
  --green: #2f9e44;
  --green-soft: #eaf8ef;
  --red: #e31b2f;
  --red-soft: #fff0f2;
  --gold: #c7922b;
  --gold-soft: #fff6df;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --sidebar-w: 286px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button { cursor: pointer; }

a { color: inherit; text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 20px 18px 16px;
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 12px;
  align-items: center;
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.brand-title {
  font-size: 20px;
  font-weight: 900;
}

.brand-subtitle,
.muted {
  color: var(--muted);
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 12px;
}

.school-ribbon {
  margin: 0 18px 18px;
  height: 5px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 10px;
  overflow: hidden;
  border-radius: 999px;
}

.school-ribbon span:nth-child(1) { background: var(--green); }
.school-ribbon span:nth-child(2) { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.school-ribbon span:nth-child(3) { background: var(--red); }
.school-ribbon span:nth-child(4) { background: var(--gold); }

.quick-search {
  margin: 0 18px 14px;
  position: relative;
}

.quick-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: #94a3b8;
}

.quick-search input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px 0 36px;
  background: var(--surface-soft);
  outline: none;
}

.quick-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 183, 0.14);
  background: #fff;
}

.nav-scroll {
  padding: 0 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-group-title {
  padding: 0 8px 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.nav-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 9px;
  align-items: center;
  padding: 0 10px;
  color: #1f2937;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-btn i {
  width: 19px;
  height: 19px;
  color: #64748b;
}

.nav-btn:hover { background: #f1f5f9; }

.nav-btn.active {
  background: var(--blue-soft);
  color: #174d8b;
  box-shadow: inset 3px 0 0 var(--blue);
}

.nav-btn.active i { color: var(--blue); }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 18px 20px;
  border-top: 1px solid var(--line);
}

.profile-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: #8a5b09;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-name {
  font-weight: 800;
  font-size: 14px;
}

.profile-role {
  color: var(--muted);
  font-size: 12px;
}

.logout-link {
  margin-top: 14px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
}

.logout-link i {
  width: 17px;
  height: 17px;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
}

.menu-toggle {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}

.page-kicker {
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
}

.page-title {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 900;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.date-chip,
.icon-btn,
.primary-btn,
.soft-btn {
  height: 42px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  font-weight: 800;
  white-space: nowrap;
}

.date-chip,
.soft-btn {
  padding: 0 14px;
}

.icon-btn {
  width: 42px;
}

.primary-btn {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  padding: 0 15px;
}

.date-chip i,
.icon-btn i,
.primary-btn i,
.soft-btn i {
  width: 18px;
  height: 18px;
}

.content {
  padding: 24px;
  display: grid;
  gap: 20px;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  min-height: 124px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

.metric-icon,
.item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
}

.metric-icon i,
.item-icon i,
.module-tile > i {
  width: 19px;
  height: 19px;
}

.blue,
.metric-icon.blue,
.item-icon.blue { background: var(--blue-soft); color: var(--blue); }
.green,
.metric-icon.green,
.item-icon.green { background: var(--green-soft); color: var(--green); }
.red,
.metric-icon.red,
.item-icon.red { background: var(--red-soft); color: var(--red); }
.gold,
.metric-icon.gold,
.item-icon.gold { background: var(--gold-soft); color: #9a640f; }

.overview-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 20px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stack {
  display: grid;
  gap: 14px;
}

.margin-top {
  margin-top: 20px;
}

.panel,
.module-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel.pad {
  padding: 20px;
}

.panel-head {
  min-height: 64px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel h2,
.module-tile h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.panel p,
.module-tile p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.badge.blue { background: var(--blue-soft); color: #174d8b; }
.badge.green { background: var(--green-soft); color: #167234; }
.badge.red { background: var(--red-soft); color: #b42331; }
.badge.gold { background: var(--gold-soft); color: #8a5b09; }

.list {
  display: grid;
}

.list-item {
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item strong {
  display: block;
  font-weight: 900;
}

.list-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.empty-box {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.module-tile {
  min-height: 150px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.module-tile > i {
  width: 38px;
  height: 38px;
  padding: 9px;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue);
}

.module-tile.red > i { background: var(--red-soft); color: var(--red); }
.module-tile.green > i { background: var(--green-soft); color: var(--green); }
.module-tile.gold > i { background: var(--gold-soft); color: #9a640f; }

.filters {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) minmax(140px, 180px) auto;
  gap: 10px;
  align-items: end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.two-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 12px;
  color: var(--text);
  outline: none;
}

.field select[multiple] {
  min-height: 160px;
  padding: 8px;
}

.field input[type="file"] {
  padding: 9px 12px;
}

.field textarea {
  min-height: 92px;
  padding: 11px 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 183, 0.14);
}

.full {
  grid-column: 1 / -1;
  width: 100%;
}

.inline-form {
  display: inline;
}

.mini-btn {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 10px;
  font-weight: 800;
  color: #334155;
}

.mini-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.soft-line {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #edf4ff 100%);
}

.login-shell {
  width: min(100%, 440px);
}

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.install-card {
  width: min(100%, 520px);
}

.login-brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.login-brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-brand h1 {
  margin: 0;
  font-size: 23px;
}

.login-brand p {
  margin: 3px 0 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 183, 0.14);
}

.full-btn {
  width: 100%;
}

.link-btn {
  margin-top: 14px;
}

.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 750;
  font-size: 14px;
  margin-bottom: 14px;
}

.login-form .alert {
  margin-bottom: 0;
}

.alert.error {
  background: var(--red-soft);
  color: #b42331;
  border: 1px solid #fecdd3;
}

.alert.success {
  background: var(--green-soft);
  color: #167234;
  border: 1px solid #bbf7d0;
}

@media (max-width: 1180px) {
  .overview-grid { grid-template-columns: 1fr; }
  .metric-grid,
  .module-grid,
  .three-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    z-index: 20;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 44px rgba(15, 23, 42, 0.18);
  }

  .sidebar.open { transform: translateX(0); }

  .menu-toggle { display: inline-flex; }

  .topbar { grid-template-columns: auto 1fr; }

  .top-actions {
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  .content { padding: 16px; }

  .metric-grid,
  .module-grid,
  .three-col,
  .form-grid,
  .filters { grid-template-columns: 1fr; }
}
