/* Playhouse Admin — the school office's panel. One stylesheet, no framework.
   Everything is driven by the tokens in :root so the palette can be retuned
   in one place. */

:root {
  color-scheme: light;

  --bg:            #f5f6f8;
  --surface:       #ffffff;
  --surface-sunk:  #f8f9fb;
  --sidebar:       #16202e;
  --sidebar-deep:  #101825;

  --ink:           #17202c;
  --ink-soft:      #566274;
  --ink-faint:     #8a94a4;
  --on-dark:       #e8edf4;
  --on-dark-soft:  #94a3b8;

  --line:          #e3e7ed;
  --line-strong:   #cfd6e0;

  --accent:        #1f7a68;
  --accent-deep:   #17604f;
  --accent-wash:   #e6f2ef;

  --success:       #1c7a4a;
  --success-wash:  #e4f4ea;
  --warning:       #9a6413;
  --warning-wash:  #fbf0dc;
  --danger:        #ab2b23;
  --danger-wash:   #fbeae8;

  --radius:        10px;
  --radius-sm:     7px;
  --shadow:        0 1px 2px rgba(20, 30, 45, .06), 0 4px 14px rgba(20, 30, 45, .05);
  --shadow-lift:   0 2px 6px rgba(20, 30, 45, .10), 0 12px 28px rgba(20, 30, 45, .10);

  --sidebar-w:     236px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; }

.muted { color: var(--ink-faint); }
.nowrap { white-space: nowrap; }

/* ── Shell ──────────────────────────────────────────────────────────────── */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  color: #fff;
}
.sidebar__brand:hover { text-decoration: none; }

.sidebar__mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .8rem;
  letter-spacing: .02em;
}

.sidebar__name { font-weight: 600; font-size: .9rem; }
.sidebar__sub  { font-size: .7rem; color: var(--on-dark-soft); }

.sidebar__nav { flex: 1; overflow-y: auto; padding: .875rem .625rem; }

.sidebar__group {
  padding: 1rem .625rem .375rem;
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #64748b;
}
.sidebar__group:first-child { padding-top: .25rem; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .5rem .625rem;
  border-radius: var(--radius-sm);
  color: var(--on-dark-soft);
  font-size: .855rem;
  font-weight: 500;
}
.sidebar__link:hover { background: rgba(255, 255, 255, .06); color: var(--on-dark); text-decoration: none; }
.sidebar__link[aria-current="page"] { background: var(--accent); color: #fff; }
.sidebar__link svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .85; }

.sidebar__foot {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: .875rem 1.25rem 1rem;
}
.sidebar__who   { font-size: .8rem; color: #fff; font-weight: 500; }
.sidebar__email { font-size: .7rem; color: var(--on-dark-soft); word-break: break-all; }
.sidebar__out {
  margin-top: .625rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, .18);
  color: var(--on-dark-soft);
  border-radius: var(--radius-sm);
  padding: .35rem .625rem;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  width: 100%;
}
.sidebar__out:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 1.125rem 1.75rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 1.3rem; }
.topbar__sub { color: var(--ink-soft); font-size: .85rem; margin-top: .1rem; }
.topbar__actions { display: flex; gap: .5rem; align-items: center; }

.crumbs { font-size: .78rem; color: var(--ink-faint); margin-bottom: .25rem; }
.crumbs a { color: var(--ink-soft); }
.crumbs span { margin: 0 .35rem; }

.content { padding: 1.5rem 1.75rem 3rem; max-width: 1280px; width: 100%; }

/* ── Flash ──────────────────────────────────────────────────────────────── */

.flash {
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin-bottom: 1rem;
  font-size: .875rem;
  border: 1px solid transparent;
}
.flash--notice { background: var(--success-wash); color: var(--success); border-color: #bfe3cd; }
.flash--alert  { background: var(--danger-wash);  color: var(--danger);  border-color: #f2c9c5; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card__head {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.card__head h2 { font-size: .95rem; }
.card__head .muted { font-size: .8rem; }

.card__body { padding: 1.1rem; }
.card__body > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 1.25rem; }
@media (min-width: 1000px) {
  .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--2 > .card { margin-bottom: 0; }
}

/* ── Stat tiles ─────────────────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .875rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.stat:hover { text-decoration: none; box-shadow: var(--shadow-lift); }
.stat__label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-faint);
  font-weight: 600;
}
.stat__value {
  font-size: 1.65rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .865rem;
}

.table th {
  text-align: left;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-faint);
  font-weight: 600;
  padding: .6rem 1.1rem;
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-sunk); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .primary-cell { font-weight: 550; color: var(--ink); }

.empty {
  padding: 2.5rem 1.1rem;
  text-align: center;
  color: var(--ink-faint);
}
.empty strong { display: block; color: var(--ink-soft); font-weight: 600; margin-bottom: .2rem; }

/* ── Definition list (show pages) ───────────────────────────────────────── */

.dl { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.5rem; margin: 0; }
.dl dt { color: var(--ink-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; padding-top: .1rem; }
.dl dd { margin: 0; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; gap: .15rem 0; } .dl dd { margin-bottom: .6rem; } }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .715rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge--neutral { background: var(--surface-sunk); color: var(--ink-soft);  border-color: var(--line-strong); }
.badge--muted   { background: var(--surface-sunk); color: var(--ink-faint); border-color: var(--line); }
.badge--success { background: var(--success-wash); color: var(--success);   border-color: #bfe3cd; }
.badge--warning { background: var(--warning-wash); color: var(--warning);   border-color: #ecd6ab; }
.badge--danger  { background: var(--danger-wash);  color: var(--danger);    border-color: #f2c9c5; }
.badge--accent  { background: var(--accent-wash);  color: var(--accent-deep); border-color: #b9dbd3; }

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .48rem .85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .845rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-sunk); text-decoration: none; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn--danger { color: var(--danger); border-color: #eabfbb; background: var(--surface); }
.btn--danger:hover { background: var(--danger-wash); }

.btn--sm { padding: .3rem .55rem; font-size: .785rem; }
.btn--link { border: 0; background: none; padding: .3rem .35rem; color: var(--accent-deep); }
.btn--link:hover { background: var(--accent-wash); }

.btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.btn-row--end { justify-content: flex-end; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.form { max-width: 640px; }
.form--wide { max-width: none; }

.fieldset { border: 0; padding: 0; margin: 0 0 1.5rem; }
.fieldset > legend {
  padding: 0 0 .1rem;
  font-size: .95rem;
  font-weight: 600;
}
.fieldset__hint { color: var(--ink-soft); font-size: .82rem; margin: 0 0 .9rem; }

.field { margin-bottom: 1rem; }
.field > label { display: block; font-weight: 550; font-size: .82rem; margin-bottom: .3rem; }

.field input[type=text],
.field input[type=email],
.field input[type=tel],
.field input[type=url],
.field input[type=date],
.field input[type=password],
.field input[type=file],
.field select,
.field textarea {
  width: 100%;
  padding: .5rem .625rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .875rem;
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
.field textarea { min-height: 90px; resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.field__hint  { color: var(--ink-faint); font-size: .78rem; margin: .3rem 0 0; }
.field__error { color: var(--danger); font-size: .78rem; margin: .3rem 0 0; font-weight: 500; }

.field--check { display: flex; align-items: flex-start; gap: .55rem; }
.field--check input[type=checkbox] { margin-top: .18rem; width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.field--check label { font-weight: 550; font-size: .85rem; margin: 0; }
.field--check .field__hint { margin-top: .1rem; }

.field-row { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .field-row--2 { grid-template-columns: 1fr 1fr; } }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .4rem .875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .75rem;
  background: var(--surface-sunk);
}
.checkbox-grid label { display: flex; align-items: center; gap: .45rem; font-size: .85rem; font-weight: 450; margin: 0; }
.checkbox-grid input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }

.form__actions {
  display: flex;
  gap: .625rem;
  align-items: center;
  padding-top: .25rem;
  border-top: 1px solid var(--line);
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.error-summary {
  background: var(--danger-wash);
  border: 1px solid #f2c9c5;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  margin-bottom: 1.25rem;
}
.error-summary h3 { color: var(--danger); font-size: .875rem; margin-bottom: .3rem; }
.error-summary ul { margin: 0; padding-left: 1.1rem; color: var(--danger); font-size: .84rem; }

/* ── Filter bar ─────────────────────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .625rem;
  padding: .875rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-sunk);
}
.filters .field { margin: 0; }
.filters label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.filters input, .filters select { min-width: 150px; }
.filters .filters__search input { min-width: 220px; }

/* ── Inline linking form (parent ↔ child) ───────────────────────────────── */

.inline-form {
  display: flex;
  gap: .625rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: .875rem 1.1rem;
  background: var(--surface-sunk);
  border-top: 1px solid var(--line);
}
.inline-form .field { margin: 0; flex: 1 1 200px; }
.inline-form .field--narrow { flex: 0 1 150px; }

/* ── Pager ──────────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--ink-soft);
  flex-wrap: wrap;
}
.pager__pages { display: flex; gap: .3rem; align-items: center; }
.pager__pages a, .pager__pages span {
  padding: .25rem .55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.pager__pages a:hover { background: var(--surface-sunk); text-decoration: none; }
.pager__pages .is-current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager__pages .is-gap { border-color: transparent; }

/* ── Misc content bits ──────────────────────────────────────────────────── */

.prose p { margin: 0 0 .75rem; }
.prose ul { margin: 0 0 .75rem; padding-left: 1.15rem; }
.prose li { margin-bottom: .25rem; }
.prose code { font-family: var(--mono); font-size: .82em; background: var(--surface-sunk); border: 1px solid var(--line); border-radius: 4px; padding: .05rem .3rem; }
.prose pre {
  font-family: var(--mono);
  font-size: .8rem;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .7rem .8rem;
  overflow-x: auto;
  margin: 0 0 .75rem;
}

.post-body { white-space: pre-wrap; }

.thumbs { display: flex; flex-wrap: wrap; gap: .625rem; }
.thumbs img {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-sunk);
}

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: .45rem 0 .45rem 1.5rem; position: relative; border-bottom: 1px solid var(--line); font-size: .875rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .78rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Narrow screens ─────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar__nav { display: flex; flex-wrap: wrap; gap: .25rem; padding: .625rem; }
  .sidebar__group { display: none; }
  .sidebar__link { padding: .35rem .6rem; }
  .sidebar__foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
  .sidebar__out { width: auto; margin-top: 0; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* --- Sign-in page ---------------------------------------------------
   Lived in a <style> block in the login layout. Moved here so the panel
   can run under a Content-Security-Policy with no inline styles at all. */
.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 90% at 50% 0%, #22364a 0%, var(--sidebar-deep) 55%, #0b1119 100%);
}
.login { width: 100%; max-width: 370px; }
.login__brand { display: flex; align-items: center; gap: .625rem; justify-content: center;
                margin-bottom: 1.25rem; color: #fff; }
.login__brand .sidebar__mark { width: 34px; height: 34px; flex-basis: 34px; }
.login__brand strong { font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.login__card { background: var(--surface); border-radius: 12px; padding: 1.6rem 1.5rem;
               box-shadow: 0 18px 44px rgba(0, 0, 0, .34); }
.login__card h1 { font-size: 1.08rem; margin-bottom: .2rem; }
.login__card > p { color: var(--ink-soft); font-size: .84rem; margin: 0 0 1.25rem; }
.login__card .btn { width: 100%; justify-content: center; margin-top: .25rem; }
.login__foot { text-align: center; color: #64748b; font-size: .76rem; margin-top: 1rem; }

/* Utilities replacing the last inline style attributes, so that
   style-src needs no 'unsafe-inline'. */
.gap-above { margin-top: 1rem; }
.stats--flush { margin-bottom: 0; }

/* Autocomplete */
.autocomplete {
  position: relative;
}

.autocomplete__input {
  width: 100%;
  padding: .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
}

.autocomplete__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.autocomplete__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  box-shadow: var(--shadow-lift);
}

.autocomplete__results--open {
  display: block;
}

.autocomplete__item {
  padding: .625rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line-strong);
  transition: background-color 0.15s;
}

.autocomplete__item:hover,
.autocomplete__item:focus {
  background-color: var(--surface-sunk);
  outline: none;
}

.autocomplete__item:last-child {
  border-bottom: none;
}

.autocomplete__item strong {
  color: var(--accent);
  font-weight: 600;
}

.autocomplete__empty {
  padding: .75rem;
  text-align: center;
  color: var(--ink-faint);
  font-size: .85rem;
}


.checkbox-grid__empty { grid-column: 1 / -1; margin: 0; color: var(--ink-faint); font-size: .78rem; }
