/* ============ Manageschool · School Management System ============ */
:root {
  --sidebar-w: 250px;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --green: #16a34a;
  --amber: #d97706;
  --blue: #2563eb;
  --sidebar: #0f172a;
  --sidebar-ink: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Shell layout ---------- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }
.content { flex: 1; padding: 1.5rem; }
.footer { padding: .9rem 1.5rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); background: var(--card); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset-block: 0; left: 0; width: var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; z-index: 40;
  overflow-y: auto;
}
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { font-size: 1.7rem; }
.brand-name { font-weight: 700; color: #fff; font-size: .95rem; line-height: 1.2; }
.brand-sub { font-size: .72rem; color: #94a3b8; }
.nav { padding: .6rem; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .52rem .7rem; margin: .12rem 0; border-radius: 8px;
  color: var(--sidebar-ink); font-size: .88rem; text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-icon { width: 1.3rem; text-align: center; font-size: 1rem; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .68rem; font-weight: 700; border-radius: 999px; padding: .05rem .45rem;
}
.sidebar-foot { padding: .8rem 1rem; font-size: .7rem; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: .65rem 1.5rem; position: sticky; top: 0; z-index: 30;
}
.page-title { font-size: 1.12rem; margin: 0; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.userchip { display: flex; align-items: center; gap: .55rem; }
.userchip-name { font-weight: 600; font-size: .85rem; line-height: 1.1; }
.userchip-role { font-size: .72rem; color: var(--muted); }
.hamburger { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; }

/* ---------- Cards / grids ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.grid { display: grid; gap: 1.1rem; }
.two-col { grid-template-columns: 1fr 1fr; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 1.1rem; }
.stat-card { text-align: center; padding: 1rem; }
.stat-value { font-size: 1.55rem; font-weight: 800; }
.stat-label { color: var(--muted); font-size: .78rem; margin-top: .15rem; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
tbody tr:hover { background: #f8fafc; }
tfoot th, tfoot td { border-top: 2px solid var(--line); font-weight: 700; background: #f8fafc; }
.actions { white-space: nowrap; display: flex; gap: .35rem; align-items: center; }
.wrap-cell { max-width: 320px; }
.empty { text-align: center; color: var(--muted); padding: 1.4rem 0 !important; }
.muted { color: var(--muted); }
.text-red { color: var(--danger); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }

table.timetable th { background: #f8fafc; font-size: .8rem; }
table.timetable td { text-align: center; min-width: 108px; }
.tt-subject { font-weight: 700; font-size: .82rem; }
.tt-meta { font-size: .7rem; color: var(--muted); }
.tt-free { color: #cbd5e1; }
.tt-del { margin-top: .25rem; }
.tt-del button { background: none; border: none; color: #cbd5e1; cursor: pointer; font-size: .8rem; }
.tt-del button:hover { color: var(--danger); }

.kv-table th { width: 40%; color: var(--muted); font-weight: 500; }
.kv-table td { font-weight: 600; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-block; padding: .14rem .6rem; border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #e2e8f0; color: #475569; }

.pill-row { display: flex; gap: .8rem; flex-wrap: wrap; }
.pill {
  display: flex; flex-direction: column; align-items: center;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem 1.1rem; min-width: 90px;
}
.pill-num { font-weight: 800; font-size: 1.1rem; }
.pill span:last-child { font-size: .72rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font-size: .85rem; font-weight: 600; padding: .5rem 1rem;
  text-decoration: none; transition: background .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: .28rem .65rem; font-size: .78rem; }
.btn-block { width: 100%; }
.inline-form { display: inline-block; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: .8rem; }
.form-narrow { max-width: 480px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1rem; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid-3 .span-3 { grid-column: span 3; }
.form-actions { display: flex; gap: .6rem; align-items: center; }
.field { display: flex; flex-direction: column; gap: .28rem; }
.field > span { font-size: .76rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem;
  font-size: .9rem; font-family: inherit; background: #fff; color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(79, 70, 229, .25); border-color: var(--primary);
}
.field-inline { flex-direction: row; align-items: center; gap: .5rem; margin: .5rem 0; }
.field-inline span { text-transform: none; font-size: .85rem; }
.input-sm { padding: .3rem .5rem; font-size: .82rem; }
textarea { resize: vertical; }

.filter-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filter-form input, .filter-form select { width: auto; min-width: 140px; }

.radio-group { display: flex; gap: .4rem; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex; align-items: center; gap: .25rem;
  border: 1px solid var(--line); border-radius: 999px; padding: .22rem .6rem;
  font-size: .8rem; cursor: pointer;
}
.radio-pill:has(input:checked) { border-color: var(--primary); background: #eef2ff; color: var(--primary-dark); font-weight: 600; }
.radio-pill input { width: auto; margin: 0; }

/* ---------- Lists / misc ---------- */
.list-item { display: flex; gap: .9rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-title { font-weight: 700; font-size: .92rem; }
.list-sub { font-size: .78rem; color: var(--muted); }
.event-date {
  background: #eef2ff; color: var(--primary-dark); font-weight: 800; font-size: .78rem;
  border-radius: 10px; padding: .45rem .6rem; text-align: center; min-width: 56px;
}
.event-item p { margin: .25rem 0 0; }
.well {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem .9rem; margin: .6rem 0; white-space: pre-wrap; font-size: .88rem;
}
.link-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }

.announcement { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.announcement:last-child { border-bottom: none; }
.announcement-head { display: flex; justify-content: space-between; gap: .8rem; align-items: flex-start; }
.announcement-body { margin: .5rem 0 0; white-space: pre-wrap; }

.flashes { margin-bottom: 1rem; }
.flash { padding: .65rem .9rem; border-radius: 10px; margin-bottom: .5rem; font-size: .88rem; font-weight: 500; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #eef2ff; color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem;
}
.avatar-lg { width: 62px; height: 62px; font-size: 1.4rem; }
.profile-grid { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile-name { font-size: 1.2rem; font-weight: 800; }

.report-card { border-top: 4px solid var(--primary); }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.report-name { font-weight: 800; font-size: 1.05rem; }
.report-meta { color: var(--muted); font-size: .82rem; }
.report-exam { background: #eef2ff; color: var(--primary-dark); font-weight: 700; padding: .4rem .8rem; border-radius: 8px; font-size: .85rem; }

.tabs { display: flex; gap: .3rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab {
  padding: .45rem .95rem; border-radius: 8px; font-weight: 600; font-size: .85rem;
  color: var(--muted); background: var(--card); border: 1px solid var(--line);
}
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tabs-sm .tab { padding: .28rem .7rem; font-size: .78rem; }
.tabs-sm { margin: 0; }

.pay-form { display: inline-flex; gap: .35rem; align-items: center; }

/* ---------- Login ---------- */
.login-body {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 55%, #4338ca 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
  background: #fff; border-radius: 16px; padding: 2.2rem 2rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); text-align: center;
}
.login-logo { font-size: 2.6rem; }
.login-card h1 { font-size: 1.3rem; margin: .4rem 0 0; }
.login-sub { color: var(--muted); margin: .2rem 0 1.4rem; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: .9rem; }
.login-foot { color: rgba(255,255,255,.65); text-align: center; font-size: .78rem; margin-top: 1.2rem; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid-3 .span-3 { grid-column: span 1; }
}
@media (max-width: 768px) {
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .hamburger { display: block; }
  .userchip-info { display: none; }
  .content { padding: 1rem; }
  .topbar { padding: .55rem 1rem; }
}
