:root {
  --maroon: #7a1e32;
  --maroon-dark: #4e101e;
  --maroon-soft: #9a2a44;
  --green: #1b6b3a;
  --green-dark: #0f4a28;
  --gold: #d4a017;
  --gold-soft: #f3d27a;
  --cream: #f4efe8;
  --surface: #ffffff;
  --ink: #1c1416;
  --muted: #6b5d61;
  --line: #eadfd6;
  --shadow: 0 10px 30px rgba(78, 16, 30, 0.08);
  --shadow-lg: 0 18px 50px rgba(78, 16, 30, 0.14);
  --radius: 16px;
  --sidebar: 268px;
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
}
a { color: var(--maroon); text-decoration: none; }
img { max-width: 100%; }

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(212,160,23,.25), transparent 50%),
    linear-gradient(160deg, var(--maroon-dark) 0%, var(--maroon) 42%, var(--green-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-wrap { width: 100%; max-width: 440px; }
.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-logo { width: 132px; height: auto; margin-bottom: 8px; }
.auth-card h1 { margin: 8px 0 4px; font-size: 22px; letter-spacing: .4px; }
.auth-card .muted { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.auth-card .form { text-align: left; }
.auth-tabs {
  display: flex;
  background: var(--cream);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.auth-tabs a {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.auth-tabs a.active { background: #fff; color: var(--maroon); box-shadow: 0 4px 12px rgba(0,0,0,.06); }
.hint { font-size: 12px; color: var(--muted); margin-top: 16px; }
code { background: var(--cream); padding: 1px 6px; border-radius: 6px; }

.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, var(--maroon-dark) 0%, var(--maroon) 55%, #5a1424 100%);
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 20;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 18px; }
.brand img { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); }
.brand b { display: block; font-size: 13px; letter-spacing: 1.6px; }
.brand span { display: block; font-size: 11px; color: rgba(255,255,255,.65); }
.nav { flex: 1; overflow: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.78);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
}
.nav a .mi { font-size: 20px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(212,160,23,.28), rgba(255,255,255,.08)); color: #fff; }
.nav .heading {
  font-size: 10px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,.42);
  margin: 16px 8px 8px;
}
.userblock {
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: 12px;
  font-size: 12px;
  color: rgba(255,255,255,.7);
}
.userblock strong { display: block; color: #fff; font-size: 13px; }
.userblock a { color: var(--gold-soft); font-weight: 700; }

.main { flex: 1; padding: 28px 32px 48px; max-width: 1280px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: .2px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: var(--maroon); color: #fff; }
.btn-primary:hover { background: var(--maroon-soft); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #218a4a; }
.btn-gold { background: var(--gold); color: #3a2a00; }
.btn-ghost { background: #fff; color: var(--maroon); border: 1px solid var(--line); }
.btn-danger { background: #fff; color: #b42318; border: 1px solid #f3c4c0; }
.btn-sm { padding: 7px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
  border-top: 3px solid var(--maroon);
}
.card.green { border-top-color: var(--green); }
.card.gold { border-top-color: var(--gold); }
.card h3 { margin: 0 0 12px; font-size: 16px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  right: -12px; top: -12px;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(122,30,50,.08);
}
.stat b { display: block; font-size: 28px; color: var(--maroon); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }

table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px; border-bottom: 1px solid #f3ece6; vertical-align: middle; }
table.data tr:hover td { background: #fbf8f5; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions form { display: inline; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.pill-ok { background: #e8f7ee; color: #146c36; }
.pill-off { background: #fde8e8; color: #b42318; }
.pill-warn { background: #fff6d9; color: #8a6a00; }

.form { display: grid; gap: 14px; }
.form h3 {
  margin: 22px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--maroon);
  letter-spacing: .2px;
}
.form h3:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.guardian-row {
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
}
.guardian-row-actions { display: flex; align-items: end; justify-content: flex-end; }
.form label, .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .3px;
}
.form label.check, .field.check {
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 42px;
}
.form input, .form select, .form textarea,
.field input, .field select, .field textarea {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.form textarea, .field textarea { min-height: 90px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(122,30,50,.18);
  border-color: var(--maroon);
}
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--cream);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
  font-size: 13px;
}
.span-2 { grid-column: span 2; }

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 600;
}
.flash.success { background: #e8f7ee; color: #146c36; }
.flash.error { background: #fde8e8; color: #b42318; }
.flash.info { background: #fff6d9; color: #8a6a00; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty img { width: 88px; opacity: .9; margin-bottom: 8px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--cream); border-radius: 99px; padding: 4px 10px; font-size: 12px; font-weight: 700; }

.contract-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  max-width: 800px;
  margin: 0 auto;
}
.vars { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.vars code { cursor: pointer; font-size: 11px; }

.obs { border-left: 4px solid var(--green); background: #f7fbf8; padding: 12px 14px; border-radius: 0 12px 12px 0; margin-bottom: 10px; }
.obs small { color: var(--muted); }

.menu-toggle { display: none; }

.avatar, .avatar-fallback {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; display: inline-flex; align-items: center; justify-content: center;
  background: var(--maroon); color: #fff; font-weight: 800; vertical-align: middle;
}
.photo-lg, .photo-lg.avatar-fallback {
  width: 112px; height: 112px; border-radius: 18px; font-size: 42px;
  object-fit: cover; box-shadow: var(--shadow);
}
.student-hero { display: flex; gap: 16px; align-items: center; }
.student-view h2 { letter-spacing: .2px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.report-card { text-decoration: none; color: inherit; display: block; transition: transform .12s; }
.report-card:hover { transform: translateY(-2px); }
.report-card .material-symbols-outlined { font-size: 32px; color: var(--maroon); }
.report-card.green .material-symbols-outlined { color: var(--green); }
.report-card.gold .material-symbols-outlined { color: var(--gold); }
.report-card h3 { margin: 8px 0 6px; }
.report-card p { margin: 0; color: var(--muted); font-size: 13px; }

@media print {
  .sidebar, .print-hide, .menu-toggle, .userblock { display: none !important; }
  .app { display: block; }
  .main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  body { background: #fff; }
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -280px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 18px 16px 40px; }
  .stats { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
