/* ==========================================================================
   SmartSchool PORTAL design system
   ==========================================================================
   This stylesheet belongs to the private portals only (/admin, /teacher,
   /staff, /student, /parent). The public website has its own stylesheet at
   /site/site.css and shares nothing with this one — that separation is what
   stops the management system from ever looking like the marketing site.

   No CDN, no build step: system fonts and CSS custom properties only.
   ========================================================================== */

:root {
  --nav-bg: #0d1526;
  --nav-bg-soft: #16203a;
  --nav-ink: #e8ecf6;
  --nav-ink-dim: #94a3c4;
  --nav-accent: #5b8cff;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e4e8f0;
  --border-strong: #cfd6e4;
  --ink: #131a2b;
  --ink-2: #475069;
  --muted: #6f7a94;

  --brand: #2f5bea;
  --brand-dark: #2044c8;
  --brand-soft: #eaf0ff;
  --ok: #0f9d58;
  --ok-soft: #e6f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf5e3;
  --bad: #d0342c;
  --bad-soft: #fdecea;
  --info: #0b7285;
  --info-soft: #e3f4f7;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .18);
  --sidebar-w: 252px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--nav-bg);
  color: var(--nav-ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--nav-accent), #7c3aed);
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 15px;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.brand-sub { font-size: 11px; color: var(--nav-ink-dim); }

.nav-scroll { flex: 1; overflow-y: auto; padding: 10px 10px 24px; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--nav-ink-dim); padding: 14px 10px 6px; font-weight: 700;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 10px; cursor: pointer;
  color: var(--nav-ink); font-size: 13.5px; font-weight: 500;
  border: 0; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--nav-bg-soft); text-decoration: none; }
.nav-item.active { background: linear-gradient(90deg, rgba(91, 140, 255, .22), rgba(91, 140, 255, .06)); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.nav-badge {
  margin-left: auto; background: var(--bad); color: #fff; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px;
}

.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 11px; color: var(--nav-ink-dim);
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.shell.nav-collapsed .main { margin-left: 0; }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
}
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 10px; width: 36px; height: 36px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.crumbs { min-width: 0; }
.crumb-title { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sub { font-size: 11.5px; color: var(--muted); }

.top-search {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 0 10px; height: 36px; min-width: 220px;
}
.top-search input { border: 0; background: none; outline: none; font-size: 13px; width: 100%; color: var(--ink); }

.who {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px;
  border-radius: 10px; cursor: pointer; border: 1px solid transparent;
}
.who:hover { background: var(--surface-2); border-color: var(--border); }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.who-name { font-size: 12.5px; font-weight: 700; line-height: 1.1; }
.who-role { font-size: 10.5px; color: var(--muted); }

.menu-pop {
  position: absolute; right: 0; top: 46px; min-width: 230px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: none; padding: 9px 10px; border-radius: 9px;
  font: inherit; color: var(--ink); cursor: pointer; text-align: left;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* --------------------------------------------------------------------------
   Content
   -------------------------------------------------------------------------- */
.content { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-title { font-size: 24px; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.stat-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat-hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-dark); font-size: 15px; float: right;
}

/* tables */
.tbl-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border); white-space: nowrap;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill-brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 13px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.inp, select.inp, textarea.inp {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 8px 11px; font: inherit; font-size: 13px; outline: none;
  max-width: 100%;
}
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 91, 234, .12); }
.lbl { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
.field { margin-bottom: 13px; }
.field-help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.field-error { font-size: 11.5px; color: var(--bad); margin-top: 4px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .35; }
.empty h3 { font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.empty p { margin: 0 0 14px; font-size: 13px; }

.skeleton { background: linear-gradient(90deg, #eef1f7 25%, #e3e8f2 37%, #eef1f7 63%); background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.banner {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 13px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2);
}
.banner-warn { background: var(--warn-soft); border-color: #f0dfb4; color: #7a5a12; }
.banner-bad { background: var(--bad-soft); border-color: #f5ccc8; color: #93231d; }
.banner-ok { background: var(--ok-soft); border-color: #bfe6d2; color: #0b6b41; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13, 21, 38, .5);
  display: grid; place-items: center; z-index: 90; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column;
}
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 9px; z-index: 120; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 11px;
  box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .18s ease;
}
.toast-ok { background: #0f5132; }
.toast-error { background: #842029; }
.toast-warn { background: #7a5a12; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab {
  border: 0; background: none; padding: 9px 13px; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* misc */
.muted { color: var(--muted); }
.t-sm { font-size: 12px; }
.t-xs { font-size: 11.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .shell.nav-collapsed .main { margin-left: 0; }
  .top-search { min-width: 120px; }
  .content { padding: 16px 14px 48px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .hide-sm { display: none; }
  .kv { grid-template-columns: 130px 1fr; }
}
@media (max-width: 560px) {
  .who-name, .who-role { display: none; }
  .top-search { display: none; }
  .page-title { font-size: 20px; }
}
