/* ============================================================
   KidStart Hub — shared design system
   One stylesheet for every module. Use these classes only;
   avoid per-page ad-hoc styles so the portal stays coherent.
   ============================================================ */

:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --ink: #16211d;
  --ink-soft: #5c6b65;
  --ink-faint: #9aa8a2;
  --line: #e2e8e5;
  --primary: #0e6b54;
  --primary-deep: #0a5342;
  --primary-tint: #e3f1ec;
  --accent: #e8a13c;
  --accent-tint: #fdf3e2;
  --danger: #c14a3a;
  --danger-tint: #faece9;
  --ok: #2f8a5b;
  --ok-tint: #e7f4ec;
  /* discipline colors */
  --ot: #0e6b54;   --ot-tint: #e3f1ec;
  --slp: #5b4bb5;  --slp-tint: #edeaf9;
  --bi: #c05a2e;   --bi-tint: #faeee7;
  --adm: #4a6274;  --adm-tint: #eaf0f4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22,33,29,.05), 0 4px 16px rgba(22,33,29,.06);
  --sidebar-w: 236px;
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- App layout ---------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 48px; max-width: 1200px; width: 100%; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--primary-deep); color: #eaf4f0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  color: #fff; letter-spacing: -.01em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--primary-deep);
  display: grid; place-items: center;
  font-weight: 800; font-size: .95rem;
}
.nav { flex: 1; padding: 6px 10px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 8px; color: #cfe3db; font-size: .92rem;
  text-decoration: none;
}
.nav a svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav .ext-flag { margin-left: auto; opacity: .55; }
.nav .ext-flag svg { width: 12px; height: 12px; }
.sidebar .foot { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar .foot button {
  width: 100%; background: none; border: none; color: #cfe3db;
  font: inherit; font-size: .88rem; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
}
.sidebar .foot button svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar .foot button:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-tint); color: var(--primary-deep);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.role-chip {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px;
  background: var(--accent-tint); color: #8a5a12;
}

/* ---------- Notification bell ---------- */
.bell-wrap { position: relative; }
.bell-btn {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
}
.bell-btn:hover { background: var(--bg); color: var(--ink); }
.bell-btn svg { width: 19px; height: 19px; }
.bell-dot {
  position: absolute; top: 5px; right: 6px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--danger); color: #fff;
  border-radius: 999px; font-size: .65rem; font-weight: 700;
  display: grid; place-items: center;
}
.bell-panel {
  position: absolute; right: 0; top: 44px; width: 320px; max-height: 380px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); z-index: 40; display: none;
}
.bell-panel.open { display: block; }
.bell-item { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: .87rem; }
.bell-item:last-child { border-bottom: none; }
.bell-item.unread { background: var(--primary-tint); }
.bell-item .t { font-weight: 600; }
.bell-item .d { color: var(--ink-soft); font-size: .8rem; margin-top: 2px; }
.bell-empty { padding: 22px; text-align: center; color: var(--ink-faint); font-size: .85rem; }

/* ---------- Cards & grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.card-sub { color: var(--ink-soft); font-size: .84rem; }
.card .count-pill {
  font-family: var(--font-display); font-weight: 700; font-size: 1.35rem;
  color: var(--primary-deep);
}

/* ---------- Module tiles (launcher) ---------- */
.tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; color: var(--ink); text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(22,33,29,.1); text-decoration: none; }
.tile .tile-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; background: var(--primary-tint); color: var(--primary);
}
.tile .tile-icon svg { width: 20px; height: 20px; }
.tile .tile-name { font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
.tile .tile-sub { color: var(--ink-soft); font-size: .8rem; }
.tile.d-ot  { border-left-color: var(--ot); }  .tile.d-ot  .tile-icon { background: var(--ot-tint);  color: var(--ot); }
.tile.d-slp { border-left-color: var(--slp); } .tile.d-slp .tile-icon { background: var(--slp-tint); color: var(--slp); }
.tile.d-bi  { border-left-color: var(--bi); }  .tile.d-bi  .tile-icon { background: var(--bi-tint);  color: var(--bi); }
.tile.d-adm { border-left-color: var(--adm); } .tile.d-adm .tile-icon { background: var(--adm-tint); color: var(--adm); }

/* ---------- Tables ---------- */
table.ks { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.ks th {
  text-align: left; font-weight: 600; color: var(--ink-soft);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.ks td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
table.ks tr:last-child td { border-bottom: none; }

/* ---------- Forms & buttons ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-tint);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; font: inherit; font-weight: 600; font-size: .9rem;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink-faint); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Badges & states ---------- */
.badge { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.badge-ok { background: var(--ok-tint); color: var(--ok); }
.badge-warn { background: var(--accent-tint); color: #8a5a12; }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--ink-soft); }

.empty { color: var(--ink-faint); font-size: .87rem; padding: 14px 0; text-align: center; }
.card-error {
  background: var(--danger-tint); color: var(--danger);
  border-radius: 8px; padding: 10px 12px; font-size: .84rem;
}
.skeleton {
  height: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef1f0 25%, #e4e9e7 50%, #eef1f0 75%);
  background-size: 200% 100%; animation: sk 1.2s infinite; margin: 8px 0;
}
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } .tile { transition: none; } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px;
  font-size: .88rem; box-shadow: var(--shadow); z-index: 100; display: none;
}

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--primary-deep) 0%, var(--primary) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%; max-width: 400px; padding: 34px 32px;
}
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card .brand-mark { width: 38px; height: 38px; font-size: 1.1rem; }
.login-card h1 { font-size: 1.25rem; }
.login-note { font-size: .83rem; color: var(--ink-soft); margin-top: 14px; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; left: -100%; z-index: 50; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .menu-btn { display: grid !important; }
}
.menu-btn {
  display: none; background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; place-items: center; color: var(--ink);
}
.menu-btn svg { width: 20px; height: 20px; }
