/* Back office: left menu + content. Desktop = fixed sidebar; under 900px = a drawer opened from the top bar.
   Loaded after practice/practice.css (buttons, forms and colours come from there). */
body.admin { display: block; user-select: text; font-size: 15px; }
body.admin .btn { min-height: 44px; padding: 0 20px; border-radius: 12px; border-width: 2px; font-size: 16px; box-shadow: none; }
body.admin .btn.primary { box-shadow: none; }
body.admin h3 { margin: 0 0 8px; font-size: 17px; color: var(--navy); }
body.admin h4 { margin: 0 0 6px; font-size: 15px; }
body.admin .note { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }

.admin-login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; }

.shell { display: flex; min-height: 100dvh; }
.side { position: sticky; top: 0; align-self: flex-start; height: 100dvh; width: 248px; flex: none; display: flex; flex-direction: column;
        background: #14275F; color: #D9E0F5; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.12); }
.side-head img { height: 28px; background: #fff; border-radius: 8px; padding: 3px 7px; }
.side-head span { font-weight: 600; color: #fff; }
#nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
#nav .nav-group { margin: 14px 10px 4px; font-size: 12px; letter-spacing: .02em; color: #93A2CF; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-size: 15px; }
#nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav a:hover { background: rgba(255,255,255,.08); }
#nav a.on { background: #fff; color: var(--navy); font-weight: 600; }
#nav a:focus-visible, .menu-btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.side-foot { padding: 12px 18px 16px; border-top: 1px solid rgba(255,255,255,.12); }
.side-foot .me { display: grid; margin-bottom: 6px; }
.side-foot .me b { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .me span { font-size: 13px; color: #93A2CF; }
.side-foot .link { color: #FFD27A; padding: 0; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 20px; color: var(--navy); }
.menu-btn { display: none; width: 42px; height: 42px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; padding: 11px 9px; flex-direction: column; justify-content: space-between; }
.menu-btn i { display: block; height: 2.5px; border-radius: 2px; background: var(--navy); }
body.admin main { max-width: 1120px; margin: 0; padding: 20px 24px 40px; gap: 16px; }
.page { display: flex; flex-direction: column; gap: 16px; }
.page[hidden] { display: none; }
body.admin .panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
body.admin .admin-grid .panel { border-radius: 12px; padding: 12px 14px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card-stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 2px; }
.card-stat b { font-size: 30px; line-height: 1.15; color: var(--navy); }
.card-stat span { font-size: 14px; }
.card-stat small { font-size: 12.5px; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.bar-row i { display: block; height: 14px; border-radius: 7px; background: #BFD0F5; min-width: 4px; }
.bar-row code { font-family: Consolas, monospace; }
.bar-row span { text-align: right; }

.grant-row input { flex: 1; min-width: 200px; padding: 9px 10px; border: 1.5px solid #cfd5e3; border-radius: 8px; font: inherit; }
.grant-row .err { flex-basis: 100%; margin: 0; }
.save-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.save-row .err { color: var(--red); }
.scroll-x { overflow-x: auto; }
.scroll-x table { min-width: 520px; }
.log.tall { max-height: none; }
body.admin .log div { padding: 6px 0; }
body.admin .log time { color: var(--muted); margin-right: 8px; white-space: nowrap; }

@media (max-width: 900px) {
  .side { position: fixed; left: 0; top: 0; z-index: 30; width: min(280px, 84vw); transform: translateX(-100%); transition: transform .2s ease; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .scrim { position: fixed; inset: 0; z-index: 20; background: rgba(15,23,60,.45); }
  .menu-btn { display: flex; }
  .topbar { padding: 10px 14px; }
  .topbar h1 { font-size: 18px; }
  body.admin main { padding: 14px 12px 32px; }
  body.admin .panel { padding: 14px 12px; }
  .admin-grid { grid-template-columns: 1fr; }
  .set-row { grid-template-columns: 1fr 96px; }
  .set-row.text { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card-stat b { font-size: 26px; }
  .grant-row select, .grant-row .btn { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* schools */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 14px; align-items: end; margin-top: 12px; }
.form-grid label { display: grid; gap: 4px; font-size: 14px; }
.form-grid label.wide, .form-grid .err, .form-grid .save-row { grid-column: 1 / -1; }
.form-grid input, .form-grid select { padding: 9px 10px; border: 1.5px solid #cfd5e3; border-radius: 8px; font: inherit; width: 100%; background: #fff; }
.form-grid .hint { font-size: 12.5px; color: var(--muted); }
.form-grid .err { margin: 0; color: var(--red); }
.form-grid .btn { justify-self: start; }
.head-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-row h3 { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: #E9EEFB; color: var(--navy); white-space: nowrap; }
.pill.active { background: #E3F4EA; color: #17603d; }
.pill.suspended { background: #FBE5E5; color: #8f2424; }
.pill .x { border: none; background: none; padding: 0 2px; font-size: 16px; line-height: 1; color: inherit; }
.stable small { color: var(--muted); }
#perms td, #perms th { text-align: center; }
#perms td:first-child, #perms th:first-child { text-align: left; }
#perms input { width: 20px; height: 20px; }

/* contract form: courses as a grid of tick + seats */
.course-grid th, .course-grid td { text-align: center; white-space: nowrap; }
.course-grid td:first-child, .course-grid th:first-child { text-align: left; font-family: Consolas, monospace; font-weight: 600; }
.course { display: inline-flex; align-items: center; gap: 6px; }
.course input[type=checkbox] { width: 20px; height: 20px; }
.course input[type=number] { width: 84px; padding: 6px 8px; border: 1.5px solid #cfd5e3; border-radius: 8px; font: inherit; text-align: right; }
.course input[type=number]:disabled { background: #f1f3f8; border-color: #e3e7f0; }
#contractForm { display: flex; flex-direction: column; gap: 16px; }
#contractForm[hidden] { display: none; }
.head-row h4 { margin: 0; font-size: 16px; }

/* ตรวจการชำระเงิน (docs/14-payments.md) */
.nav-count { margin-left: auto; background: #D64545; color: #fff; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 1px 8px; }
.pay-card { border: 1px solid #DDE1EE; border-radius: 14px; padding: 12px 14px; margin: 10px 0; display: grid; gap: 4px; }
.pay-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.pay-amt { font-size: 22px; font-weight: 700; color: #1E3A8A; }
.slip-box { margin: 6px 0; }
.slip-img { display: block; max-width: min(100%, 420px); border: 1px solid #DDE1EE; border-radius: 10px; }
