/* Reusable components: icons, buttons, chips, cards, lists, forms, switches, banners, dialogs, toast, states. */
.i { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 3rem; padding: 0 1.15em; border-radius: 14px;
  font-weight: 700; background: var(--brand); color: var(--brand-ink); text-align: center;
}
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.line { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: var(--surface); }
.btn.danger-line { background: var(--surface); color: var(--bad); border: 1px solid var(--line); }
.btn.mari { background: var(--mari); color: var(--mari-ink); }
.btn.sm { min-height: 2.4rem; padding: 0 .9em; font-size: .9rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.btn[aria-busy="true"]::before { content: ""; width: 1em; height: 1em; border-radius: 50%; border: 2.5px solid currentColor; border-top-color: transparent; animation: sp .8s linear infinite; }
.link { color: var(--brand); font-weight: 600; }
.icon-btn { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); flex: none; }
.btnrow { display: flex; gap: .5rem; flex-wrap: wrap; }

/* chips, avatar */
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .1em .6em; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.bad, .chip.em { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }
.avatar { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); font-family: var(--display); font-weight: 700; line-height: 1; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* cards and lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 1rem; }
.card > h2, .sec-title { font-size: 1.15rem; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.sec-k { font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); font-weight: 700; margin: .4rem 0 -.4rem; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: .1rem 1rem; }
.row { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--line); width: 100%; text-decoration: none; color: inherit; }
.row:last-child { border-bottom: 0; }
button.row { text-align: left; }
.row[disabled] { opacity: .5; cursor: not-allowed; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-weight: 600; }
.row .grow small { display: block; color: var(--ink-2); font-size: .84rem; line-height: 1.35; }
.ico { width: 2.3rem; height: 2.3rem; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; }
.ico.m { background: var(--mari-soft); color: var(--warn); }
.ico.r { background: var(--bad-soft); color: var(--bad); }
.ico.em { background: var(--bad-soft); color: var(--bad); }     /* emergencies; the parent theme makes these strong red */
.ico.ev { background: var(--ok-soft); color: var(--ok); }      /* calendar events; lavender for parents */
.ico.pt { background: var(--info-soft); color: var(--info); }  /* parent-teacher meetings */
.ico.b { background: var(--info-soft); color: var(--info); }
.ico.g { background: var(--ok-soft); color: var(--ok); }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: .86rem; }

/* forms */
.form { display: flex; flex-direction: column; gap: .95rem; }
.fld { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.fld > label, .fld > .lbl { font-size: .84rem; font-weight: 700; color: var(--ink-2); }
.fld .req { color: var(--bad); }
.in {
  width: 100%; min-height: 3rem; padding: .6rem .8rem;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
}
.in:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.in[aria-invalid="true"] { border-color: var(--bad); }
textarea.in { min-height: 6rem; resize: vertical; line-height: 1.4; }
select.in { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 1.1rem) 50%, calc(100% - .8rem) 50%; background-size: .3rem .3rem; background-repeat: no-repeat; padding-right: 2.2rem; }
.fld-err { color: var(--bad); font-size: .85rem; font-weight: 600; }
.fld .hint { font-size: .82rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: .95rem; }
.pw { position: relative; }
.pw .in { padding-right: 4.2rem; }
.pw button { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); padding: .35rem .6rem; border-radius: 10px; font-weight: 700; font-size: .85rem; color: var(--brand); }
.check { display: flex; gap: .7rem; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 1.3rem; height: 1.3rem; margin: .1rem 0 0; accent-color: var(--brand); flex: none; }
.form-err { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .85rem; border-radius: 14px; background: var(--bad-soft); color: var(--ink); font-size: .9rem; }
.form-err .i { color: var(--bad); }

/* switch, segmented */
.sw { position: relative; width: 2.9rem; height: 1.7rem; flex: none; }
.sw input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.sw span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; pointer-events: none; }
.sw span::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--surface); transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.sw input:checked + span { background: var(--brand); }
.sw input:checked + span::after { transform: translateX(1.2rem); }
.sw input:focus-visible + span { outline: 2.5px solid var(--mari); outline-offset: 2px; }
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 3px; gap: 2px; }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: .5rem .4rem; border-radius: 11px; text-align: center; font-weight: 600; font-size: .9rem; color: var(--ink-2); pointer-events: none; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2.5px solid var(--mari); }

/* banners */
.banner { display: flex; gap: .6rem; align-items: flex-start; padding: .75rem .9rem; border-radius: 16px; background: var(--info-soft); font-size: .9rem; line-height: 1.4; }
.banner > .i { color: var(--info); margin-top: .05rem; }
.banner.ok { background: var(--ok-soft); } .banner.ok > .i { color: var(--ok); }
.banner.warn { background: var(--warn-soft); } .banner.warn > .i { color: var(--warn); }
.banner.bad, .banner.em { background: var(--bad-soft); } .banner.bad > .i, .banner.em > .i { color: var(--bad); }

/* states */
.spin { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 1.6rem 1rem; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.empty .ico { width: 3rem; height: 3rem; }
.empty b { color: var(--ink); font-size: 1.05rem; }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--ink-2); font-weight: 600; padding: .8rem 0; }
.loading .spin { width: 1.3rem; height: 1.3rem; border-width: 3px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .6rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: .75rem .85rem; min-width: 0; }
.stat small { color: var(--ink-2); font-size: .78rem; font-weight: 700; }
.stat b { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.meter { height: .45rem; border-radius: 9px; background: var(--surface-2); overflow: hidden; margin-top: .4rem; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 9px; }
.meter i.warn { background: var(--mari); } .meter i.bad { background: var(--bad); }

/* search, toolbars, tables, facts */
.search { position: relative; }
.search .i { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.search .in { padding-left: 2.6rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.toolbar > .grow { flex: 1 1 12rem; min-width: 0; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .76rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); padding: .55rem .7rem; background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: .55rem .7rem; border-top: 1px solid var(--line); vertical-align: top; }
.tbl code, code { font-family: var(--mono); font-size: .92em; background: var(--surface-2); padding: .05em .35em; border-radius: 6px; white-space: nowrap; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .4rem 1rem; margin: 0; font-size: .95rem; }
.facts dt { color: var(--ink-2); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.subhead { font-size: 1rem; font-family: var(--display); margin-top: .3rem; }
.guardian { border: 1.5px dashed var(--line); border-radius: var(--r-opt); padding: .9rem; display: flex; flex-direction: column; gap: .8rem; }
.problem-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; max-height: 22rem; overflow: auto; }
.problem-list li { background: var(--bad-soft); border-radius: 12px; padding: .55rem .75rem; font-size: .88rem; }
.problem-list b { display: block; }
.progress { height: .6rem; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .2s; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; }
.class-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: .85rem; display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: inherit; min-width: 0; }
.class-card b { font-family: var(--display); font-size: 1.25rem; }
.class-card small { color: var(--ink-2); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.stat { text-decoration: none; color: inherit; }

/* overlay: dialog + toast */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
@media (min-width: 640px) { .scrim { align-items: center; } }
.dialog {
  width: 100%; max-width: 30rem; max-height: 90dvh; overflow: auto;
  background: var(--bg); border-radius: 24px 24px 0 0; padding: 1.2rem max(1.2rem, env(safe-area-inset-right, 0px)) calc(1.4rem + env(safe-area-inset-bottom, 0px)) max(1.2rem, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: .9rem; animation: up .2s ease-out;
}
@media (min-width: 640px) { .dialog { border-radius: 24px; } }
.dialog h2 { font-size: 1.3rem; }
.dialog .btnrow { justify-content: flex-end; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; left: 0; right: 0; bottom: calc(5.6rem + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: .4rem; pointer-events: none; padding: 0 1rem; }
.toast { pointer-events: auto; max-width: 30rem; width: 100%; background: var(--ink); color: var(--bg); padding: .75rem 1rem; border-radius: 14px; font-size: .92rem; font-weight: 500; box-shadow: var(--shadow); animation: up .2s ease-out; display: flex; gap: .6rem; align-items: flex-start; }
.toast.bad { background: var(--bad); color: var(--surface); }
