/* Mira's design system: the landing page, the parent dashboard, the admin console and the policy pages.
   (The kid classroom has its own friendlier styles in index.html, on the same brand colours.) */
:root {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f9fafb; --hover: #f1f5f9;
  --border: #e5e7eb; --border-strong: #d1d5db;
  --text: #0f172a; --text-2: #334155; --muted: #64748b; --subtle: #94a3b8;
  --brand: #4f46e5; --brand-600: #4338ca; --brand-soft: #eef2ff; --brand-line: #c7d2fe; --brand-ring: rgb(79 70 229 / .22);
  --ok: #047857; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --bad: #b91c1c; --bad-soft: #fef2f2;
  --radius: 8px; --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / .05);
  --shadow: 0 1px 3px rgb(15 23 42 / .06), 0 12px 32px rgb(15 23 42 / .07);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); } .subtle { color: var(--subtle); } .small { font-size: 13px; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
       border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
       font: 500 14px var(--font); white-space: nowrap; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgb(79 70 229 / .3); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: #fecaca; }
.btn-lg { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head p { margin-top: 2px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---- layout helpers ---- */
.stack { display: grid; gap: 16px; } .stack-sm { display: grid; gap: 8px; } .stack-lg { display: grid; gap: 24px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }

/* ---- KPI tiles ---- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { margin-top: 6px; font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .hint { margin-top: 2px; font-size: 12px; color: var(--subtle); }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px;
         background: #f1f5f9; color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { position: sticky; top: 0; z-index: 1; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
            text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.wrap { max-width: 420px; }

/* ---- progress ---- */
.progress { height: 8px; border-radius: 999px; background: #eef0f4; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .4s; }
.progress.ok > i { background: #10b981; }

/* ---- forms ---- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff;
         font: 14px var(--font); color: var(--text); transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; padding: 10px 12px; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { flex: none; width: 16px; height: 16px; margin-top: 3px; accent-color: var(--brand); }
.error { color: var(--bad); font-size: 14px; font-weight: 500; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button { flex: none; padding: 10px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none;
               font: 500 14px var(--font); color: var(--muted); cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* ---- app shell: sidebar + content ---- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
           background: var(--surface); border-right: 1px solid var(--border); }
.logo-link { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.logo-link:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 9px; color: #fff; font-weight: 800; font-size: 15px;
        background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 2px 6px rgb(99 102 241 / .35); }
/* sidebar: the name with its Family/Admin tag underneath (the full name and the tag don't fit side by side) */
.sidebar .logo-link { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; white-space: nowrap; }
.sidebar .logo-link .logo { grid-row: span 2; }
.sidebar .logo-link small { justify-self: start; margin-left: 0; }
.logo-link small { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 600; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); color: var(--text-2); font-size: 14px; font-weight: 500; }
.nav a:hover { background: var(--hover); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav-label { padding: 14px 10px 6px; font-size: 11px; font-weight: 600; color: var(--subtle); letter-spacing: .06em; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--border); min-width: 0; }
.sidebar-foot .who { min-width: 0; font-size: 13px; line-height: 1.3; }
.sidebar-foot .who b, .sidebar-foot .who span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { color: var(--muted); }
.main { width: 100%; max-width: 1180px; padding: 28px 36px 56px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; color: var(--muted); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.back svg { width: 16px; height: 16px; }

/* ---- avatars ---- */
.avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; overflow: hidden;
          background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 20px; }
.avatar img, .avatar svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.avatar.lg { width: 56px; height: 56px; font-size: 28px; }

/* ---- banners, empty states, lists ---- */
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--brand-line);
          border-radius: var(--radius-lg); background: var(--brand-soft); color: #312e81; font-size: 14px; }
.banner svg { width: 18px; height: 18px; flex: none; }
.banner.warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.banner.bad { background: var(--bad-soft); border-color: #fecaca; color: #7f1d1d; }
.banner .spacer { min-width: 8px; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; color: var(--subtle); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow > * { display: block; overflow: hidden; text-overflow: ellipsis; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- charts (no library) ---- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bars > div { flex: 1; min-width: 4px; max-width: 44px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.bars > div > i { display: block; width: 100%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--brand); opacity: .85; transition: opacity .15s; }
.bars > div:hover > i { opacity: 1; }
.bars > div > span { font-size: 11px; color: var(--subtle); white-space: nowrap; }

/* ---- modal, drawer, toast ---- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgb(15 23 42 / .45); animation: fade .15s; }
.modal-card { position: relative; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 24px;
              background: var(--surface); border-radius: 16px; box-shadow: 0 24px 64px rgb(15 23 42 / .25); animation: rise .2s ease-out; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.drawer { position: fixed; inset: 0; z-index: 50; display: flex; justify-content: flex-end; background: rgb(15 23 42 / .35); animation: fade .15s; }
.drawer-panel { width: min(760px, 100%); height: 100%; overflow: auto; padding: 24px 28px; background: var(--bg); box-shadow: var(--shadow); animation: slide .2s ease-out; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%); padding: 10px 16px; border-radius: 10px;
         background: var(--text); color: #fff; font-size: 14px; box-shadow: var(--shadow); animation: toast .2s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---- small screens: the sidebar becomes a top bar with a scrollable menu ---- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 4px; padding: 8px 12px;
             border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
  .logo-link { padding: 0 8px 0 0; }
  .logo-link > span:not(.logo), .logo-link small, .nav-label, .sidebar-foot { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { flex: none; padding: 8px 10px; }
  .main { padding: 20px 16px 48px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .drawer-panel { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
