:root {
  --ink: #211d35;
  --muted: #68647b;
  --line: #e5e2ef;
  --bg: #f8f7fc;
  --card: #ffffff;
  --brand: #1c1350;
  --brand-2: #6a5cf0;
  --brand-soft: #efedff;
  --accent: #f5b52e;
  --accent-soft: #fff4d6;
  --good: #1f8a4c;
  --good-soft: #e3f4ea;
  --bad: #c0392b;
  --bad-soft: #fbe9e7;
  --warn: #a86400;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 19, 80, .06), 0 4px 16px rgba(28, 19, 80, .07);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; line-height: 1.5; }
a { color: var(--brand-2); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .6rem clamp(1rem, 4vw, 2rem); background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--brand); }
.brand img { width: 42px; height: 42px; flex: none; }
.brand-lockup { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-size: .82rem; font-weight: 800; letter-spacing: .12em; }
.brand-academy { margin-top: .18rem; font-size: .78rem; font-weight: 500; letter-spacing: .29em; }
.brand-tagline { margin-top: .22rem; color: var(--muted); font-size: .47rem; font-weight: 700; letter-spacing: .13em; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: .25rem auto 1.25rem; color: var(--brand); }
.auth-brand img { display: block; width: 76px; height: 76px; flex: none; }
.auth-brand-copy { display: flex; flex-direction: column; line-height: 1; }
.auth-brand-name { font-size: .88rem; font-weight: 800; letter-spacing: .14em; }
.auth-brand-academy { margin-top: .22rem; font-size: 1.18rem; font-weight: 600; letter-spacing: .2em; }
.auth-brand-tagline { margin-top: .38rem; color: var(--muted); font-size: .58rem; font-weight: 700; letter-spacing: .11em; }
.topnav { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.topnav a, .topnav button { text-decoration: none; color: var(--ink); padding: .45rem .7rem; border-radius: 10px; font-size: .95rem; }
.topnav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.topnav .badge { margin-left: .25rem; }
main { max-width: 1120px; margin: 0 auto; padding: 1.25rem clamp(1rem, 4vw, 2rem) 6rem; outline: none; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.bottomnav { display: none; }

.topnav a.btn { color: #fff; }
@media (max-width: 760px) {
  .topbar { gap: .5rem; padding: .5rem .75rem; }
  .brand { gap: .5rem; }
  .brand img { width: 36px; height: 36px; }
  .topnav a:not(.keep-sm) { display: none; }
  .brand-tagline { display: none; }
  main { padding: 1rem .75rem calc(6rem + env(safe-area-inset-bottom)); }
  .grid.two { grid-template-columns: minmax(0, 1fr); }
  .grid.three, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: .9rem; }
  .row > * { min-width: 0; }
  .table-wrap { overflow: visible; }
  .table-wrap.card { padding: .75rem; }
  table.table { display: block; width: 100%; }
  .table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .table tbody { display: grid; gap: .65rem; }
  .table tbody tr {
    display: grid; gap: 0; padding: .2rem .65rem; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  }
  .table tbody td {
    display: grid; grid-template-columns: minmax(5.5rem, 36%) minmax(0, 1fr); gap: .5rem;
    align-items: start; padding: .45rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere;
  }
  .table tbody td:last-child { border-bottom: 0; }
  .table tbody td::before {
    content: attr(data-label); color: var(--muted); font-size: .75rem; font-weight: 700; line-height: 1.4;
  }
  .table tbody td[data-label=""]::before { content: none; }
  .table tbody tr > th {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .global-footer { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
    padding: .3rem .25rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; text-decoration: none; color: var(--muted); font-size: .72rem; padding: .25rem 0; }
  .bottomnav a .ico { font-size: 1.25rem; line-height: 1; }
  .bottomnav a.active { color: var(--brand); font-weight: 600; }
}

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.section { margin-top: 2rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: .25rem; }
a.card { display: block; text-decoration: none; color: inherit; transition: transform .12s, box-shadow .12s; }
a.card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(16, 40, 44, .12); }

.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat .num { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.stat .lbl { font-size: .85rem; color: var(--muted); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: #fff; padding: .6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; text-decoration: none;
  min-height: 42px;
}
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.accent { background: var(--accent); color: var(--brand); }
.btn.danger { background: var(--bad); }
.btn.small { padding: .35rem .7rem; min-height: 34px; font-size: .9rem; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid #cbd5d3; border-radius: 10px; background: #fff; color: var(--ink);
  min-height: 42px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid rgba(106, 92, 240, .3); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.checks label { font-weight: 500; display: inline-flex; gap: .35rem; align-items: center; border: 1px solid var(--line); padding: .35rem .6rem; border-radius: 999px; background: #fff; cursor: pointer; }
.checks input { width: auto; min-height: 0; }
.error { color: var(--bad); font-size: .9rem; margin: .5rem 0; }

.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--warn); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.grey { background: #eef1f0; color: var(--muted); }
.badge { display: inline-flex; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; align-items: center; justify-content: center; border-radius: 999px; background: var(--accent); color: var(--brand); font-size: .72rem; font-weight: 700; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: none; padding: .6rem .9rem; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }

table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table-wrap { overflow-x: auto; }

.progress { height: 10px; background: #e8eeec; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: inherit; }
.progress.accent > span { background: linear-gradient(90deg, var(--accent), #ffd66f); border-radius: inherit; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); border: 1px dashed #cbd5d3; border-radius: var(--radius); background: #fff; }

/* ---------- landing ---------- */
.hero {
  position: relative; border-radius: 22px; padding: clamp(1.5rem, 5vw, 3.5rem); color: #fff; overflow: hidden;
  background: radial-gradient(1200px 400px at 90% -10%, rgba(245, 181, 46, .38), transparent 60%), linear-gradient(135deg, #1c1350, #34287e 60%, #6a5cf0);
}
.hero h1 { color: #fff; max-width: 20ch; }
.hero p.lead { font-size: 1.1rem; max-width: 52ch; opacity: .95; }
.searchbar { display: flex; gap: .5rem; flex-wrap: wrap; background: #fff; padding: .5rem; border-radius: 14px; max-width: 680px; margin-top: 1.25rem; }
.searchbar select, .searchbar input { border: none; flex: 1 1 160px; }
.cat-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.cat { display: flex; flex-direction: column; gap: .2rem; padding: .9rem; border-radius: 14px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.cat .ico { font-size: 1.6rem; }
.cat small { color: var(--muted); font-size: .78rem; }
.feature { display: flex; gap: .8rem; align-items: flex-start; }
.feature .ico { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); font-size: 1.3rem; }
.audience { border-top: 4px solid var(--accent); }
footer.site { margin-top: 3rem; padding: 1.5rem 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.global-footer {
  max-width: 1120px; margin: 0 auto; padding: 1rem clamp(1rem, 4vw, 2rem) 1.25rem;
  border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .8rem;
}
.global-footer strong { color: var(--brand); font-weight: 600; }

/* ---------- explore ---------- */
.explore { display: grid; grid-template-columns: 290px 1fr; gap: 1.25rem; align-items: start; }
.filters { position: sticky; top: 76px; }
@media (max-width: 900px) { .explore { grid-template-columns: 1fr; } .filters { position: static; } }
#map { height: 320px; border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 1rem; background: #e8eeec; }
.class-card .meta { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .88rem; color: var(--muted); margin: .4rem 0; }
.class-card .price { font-weight: 700; color: var(--ink); }
.stars { color: var(--accent); letter-spacing: 1px; }

/* ---------- dashboards ---------- */
.kid { display: flex; gap: .75rem; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--brand-2); flex: none; }
.timeline-item { display: flex; gap: .9rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .time { font-weight: 700; color: var(--brand); min-width: 54px; }
.att-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.att-toggle button { border: none; background: #fff; padding: .4rem .6rem; font: inherit; font-size: .85rem; cursor: pointer; min-width: 38px; }
.att-toggle button + button { border-left: 1px solid var(--line); }
.att-toggle button.on.present { background: var(--good); color: #fff; }
.att-toggle button.on.absent { background: var(--bad); color: #fff; }
.att-toggle button.on.late { background: var(--accent); color: var(--brand); }
.att-toggle button.on.excused { background: #8a9a9e; color: #fff; }
.notif { display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.notif.unread { font-weight: 600; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: .45rem; flex: none; }
.notif.read .dot { background: transparent; }
.child-photo { width: 44px; height: 44px; flex: none; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.event-card h2 { margin-top: .7rem; }
.event-description { white-space: pre-wrap; overflow-wrap: anywhere; }
.child-profile-details p:last-child { margin-bottom: 0; }

.chat { display: flex; flex-direction: column; gap: .5rem; max-height: 55vh; overflow-y: auto; padding: .5rem; background: var(--bg); border-radius: 12px; }
.bubble { max-width: 78%; padding: .55rem .8rem; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.bubble time { display: block; font-size: .7rem; opacity: .7; margin-top: .2rem; }

/* ---------- toast & modal ---------- */
#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; }
#toast .t { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); margin-top: .5rem; max-width: 90vw; }
#toast .t.err { background: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(10, 25, 28, .45); display: grid; place-items: center; z-index: 40; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 18px; padding: 1.25rem; width: min(560px, 100%); max-height: 90vh; overflow: auto; }

/* ---------- place search results ---------- */
.place-results { margin-top: .35rem; }
.place-results:empty { display: none; }
.place-item {
  display: flex; gap: .6rem; align-items: flex-start; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; margin-bottom: .35rem; color: var(--ink);
}
.place-item:hover, .place-item:focus-visible { border-color: var(--brand-2); background: var(--brand-soft); }
.place-item .ico { flex: none; }
.place-hint { font-size: .85rem; color: var(--muted); padding: .35rem 0; }
.google-attr { font-family: Roboto, Arial, sans-serif; font-weight: 400; font-size: 12px; color: #5E5E5E; padding: 2px 0 6px; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.support-launcher {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40; min-height: 48px; padding: .65rem 1rem;
  border: 0; border-radius: 999px; background: var(--brand); color: #fff; font: inherit; font-weight: 700;
  box-shadow: var(--shadow); cursor: pointer;
}
.support-panel {
  position: fixed; right: 1rem; bottom: 5rem; z-index: 41; width: min(400px, calc(100vw - 2rem));
  max-height: min(700px, calc(100dvh - 6rem)); display: flex; flex-direction: column; gap: .75rem;
  padding: 1rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 12px 40px rgba(28, 19, 80, .2);
}
.support-panel[hidden], .support-chat-form[hidden], .support-ticket-form[hidden] { display: none; }
.support-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.support-privacy { margin: 0; padding: .6rem; border-radius: 8px; background: var(--accent-soft); font-size: .76rem; }
.support-chat { display: flex; flex-direction: column; gap: .5rem; min-height: 100px; max-height: 230px; overflow-y: auto; padding: .25rem; }
.support-message { max-width: 90%; padding: .55rem .7rem; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.support-message.assistant { align-self: flex-start; background: var(--bg); }
.support-message.user { align-self: flex-end; background: var(--brand-soft); }
.support-chat-form { display: flex; gap: .5rem; }
.support-chat-form input { min-width: 0; }
.support-ticket-toggle { border: 0; padding: .25rem; background: transparent; color: var(--brand-2); font: inherit; text-align: left; text-decoration: underline; cursor: pointer; }
.support-ticket-form { overflow-y: auto; max-height: 280px; border-top: 1px solid var(--line); padding-top: .75rem; }
.support-ticket-form textarea { min-height: 90px; }
.support-request-body { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .support-launcher { right: .75rem; bottom: calc(4.8rem + env(safe-area-inset-bottom)); }
  .support-panel { right: .5rem; bottom: calc(9rem + env(safe-area-inset-bottom)); width: calc(100vw - 1rem); max-height: calc(100dvh - 10rem); }
}
