/* /admin — หลังบ้านผู้ดูแล (docs/admin-2026.md).
 *
 * Loaded AFTER index.css, which this page still needs for the self-hosted
 * Mitr / IBM Plex Sans Thai faces and the toast styles. Everything here is
 * scoped to the ad- prefix so the app's own rules and these never meet — with
 * two exceptions index.css forces on every page: `body:not(.landing-disabled)`
 * locks scrolling (this page never sets landing-disabled), and at ≤768px the
 * touch-target overhaul makes every button `inline-flex`, centred, 600-weight
 * with !important. The rules below that carry !important are answering those.
 */

:root {
  --ad-navy: #163B89;
  --ad-navy-ink: #0F2A66;
  --ad-navy-deep: #0E2C6E;
  --ad-red: #E02121;
  --ad-red-ink: #B91C1C;
  --ad-ink: #14213D;
  --ad-ink-2: #3D4760;
  --ad-muted: #5A6478;
  --ad-faint: #8A93A6;
  --ad-bg: #F5F7FB;
  --ad-surface: #FFFFFF;
  --ad-line: #E3E8F2;
  --ad-line-soft: #EEF1F7;
  --ad-line-strong: #CBD5E6;
  --ad-tint: #EAF0FB;
  --ad-ok-bg: #E6F4EC; --ad-ok: #0B5E3C;
  --ad-bad-bg: #FDECEC; --ad-bad: #B91C1C;
  --ad-warn-bg: #FEF3E2; --ad-warn: #8A4B08;
  --ad-mute-bg: #F1F4FA;
  --ad-head: 'Mitr', 'IBM Plex Sans Thai', sans-serif;
  --ad-body: 'IBM Plex Sans Thai', sans-serif;
}

html, body.ad-body {
  height: 100%;
}
body.ad-body {
  margin: 0;
  display: block !important;
  overflow: auto !important;
  background: var(--ad-bg) !important;
  background-image: none !important;
  font-family: var(--ad-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ad-ink);
}
.ad-body a { color: var(--ad-navy); }
.ad-body a:hover { color: var(--ad-navy-ink); }
.ad-body [hidden] { display: none !important; }

/* ── Shell: sidebar + header + scrolling main ───────────────────────── */
.ad-shell {
  display: flex;
  min-height: 100vh;
}
.ad-side {
  width: 248px;
  flex-shrink: 0;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  background: linear-gradient(180deg, var(--ad-navy-deep) 0%, var(--ad-navy) 100%);
  color: #FFFFFF;
}
.ad-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 14px;
  text-decoration: none;
}
.ad-brand-name {
  font-family: var(--ad-head);
  font-weight: 600;
  font-size: 22px;
  color: #FFFFFF;
}
.ad-brand-name em { font-style: normal; color: #FF6B6B; }
.ad-brand-tag {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--ad-red);
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
}
.ad-nav-group {
  padding: 12px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #9FB4E0;
}
.ad-body a.ad-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 15px;
  color: #E6ECF8;
}
.ad-body a.ad-nav-item:hover { background: rgba(255,255,255,.08); color: #FFFFFF; }
.ad-body a.ad-nav-item[aria-current="page"] {
  background: #FFFFFF;
  color: var(--ad-navy);
  font-weight: 700;
}
.ad-nav-ic { width: 22px; text-align: center; flex-shrink: 0; }
.ad-nav-label { flex-grow: 1; }
.ad-nav-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: 99px;
  background: var(--ad-red);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-side-note {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  font-size: 12px;
  line-height: 1.5;
  color: #C9D8F7;
}

.ad-main-col {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.ad-header {
  min-height: 76px;
  flex-shrink: 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  background: var(--ad-surface);
  border-bottom: 1px solid var(--ad-line);
}
.ad-header-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.ad-body .ad-title {
  margin: 0;
  font-family: var(--ad-head);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.3;
  color: var(--ad-navy);
}
.ad-subtitle { font-size: 14px; color: var(--ad-muted); }
.ad-who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--ad-line);
}
.ad-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--ad-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ad-head);
}
.ad-who-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.ad-who-text b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.ad-who-text span { font-size: 12px; color: var(--ad-muted); }

.ad-main {
  flex-grow: 1;
  padding: 24px 32px 32px;
  box-sizing: border-box;
}
.ad-page { display: flex; flex-direction: column; gap: 18px; }
.ad-page:not(.is-active) { display: none; }

/* ── Building blocks ────────────────────────────────────────────────── */
.ad-card {
  background: var(--ad-surface);
  border: 1px solid var(--ad-line);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ad-card.is-flush { padding: 0; gap: 0; overflow: hidden; }
.ad-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ad-card.is-flush > .ad-card-head { padding: 16px 20px; }
.ad-body .ad-h2 {
  margin: 0;
  font-family: var(--ad-head);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.35;
  color: var(--ad-navy);
}
.ad-note { font-size: 13px; color: var(--ad-muted); margin: 0; }
.ad-link { font-size: 14px; font-weight: 600; }

.ad-grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.ad-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ad-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--ad-surface);
  border: 1px solid var(--ad-line);
  color: var(--ad-navy);
  text-decoration: none;
  min-width: 0;
}
.ad-kpi-l { font-size: 14px; color: var(--ad-muted); }
.ad-kpi-v { font-family: var(--ad-head); font-size: 28px; line-height: 1.25; }
.ad-kpi-s { font-size: 13px; color: var(--ad-muted); }
.ad-kpi.is-navy { background: var(--ad-navy); border-color: var(--ad-navy); color: #FFFFFF; }
.ad-kpi.is-navy .ad-kpi-l, .ad-kpi.is-navy .ad-kpi-s { color: #FFFFFF; opacity: .9; }
.ad-kpi.is-tint { background: var(--ad-tint); border-color: var(--ad-tint); }
.ad-kpi.is-tint .ad-kpi-l, .ad-kpi.is-tint .ad-kpi-s { color: var(--ad-navy); }
.ad-kpi.is-bad { background: var(--ad-bad-bg); border-color: var(--ad-bad-bg); color: var(--ad-bad); }
.ad-kpi.is-bad .ad-kpi-l, .ad-kpi.is-bad .ad-kpi-s { color: var(--ad-bad); }
.ad-kpi.is-warn { background: var(--ad-warn-bg); border-color: var(--ad-warn-bg); color: var(--ad-warn); }
.ad-kpi.is-warn .ad-kpi-l, .ad-kpi.is-warn .ad-kpi-s { color: var(--ad-warn); }

/* A table drawn as rows of a CSS grid, the way the design draws them. Each
   table sets --cols on .ad-table. */
.ad-table { overflow-x: auto; }
.ad-tr {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 10px;
  padding: 10px 20px;
  border-top: 1px solid var(--ad-line-soft);
  font-size: 14px;
  align-items: center;
  min-width: var(--min, 0);
}
.ad-tr.is-head {
  border-top: 0;
  background: var(--ad-bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--ad-ink-2);
}
.ad-tr > * { min-width: 0; }
.ad-cell-stack { display: flex; flex-direction: column; min-width: 0; }
.ad-cell-stack b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-sub { font-size: 13px; color: var(--ad-muted); overflow-wrap: anywhere; }
.ad-sub-sm { font-size: 12px; color: var(--ad-muted); }
.ad-empty { padding: 28px; text-align: center !important; color: var(--ad-muted); }
.ad-tr-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--ad-line-soft);
  font-size: 14px;
  color: var(--ad-muted);
}

.ad-chip {
  justify-self: start;
  align-self: center;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--ad-mute-bg);
  color: var(--ad-ink-2);
}
.ad-cell-stack > .ad-chip { align-self: flex-start; }
.ad-chip.is-ok { background: var(--ad-ok-bg); color: var(--ad-ok); }
.ad-chip.is-bad { background: var(--ad-bad-bg); color: var(--ad-bad); }
.ad-chip.is-warn { background: var(--ad-warn-bg); color: var(--ad-warn); }
.ad-chip.is-info { background: var(--ad-tint); color: var(--ad-navy); }

/* Buttons. The ≤768px overhaul in index.css sets display/justify/weight on
   every button with !important, so the variants that need otherwise say so. */
.ad-body .ad-btn {
  height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--ad-line-strong);
  background: var(--ad-surface);
  color: var(--ad-navy);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
}
.ad-body .ad-btn:hover { border-color: var(--ad-navy); }
.ad-body .ad-btn.is-primary { border: 0; background: var(--ad-navy); color: #FFFFFF; padding: 0 18px; }
.ad-body .ad-btn.is-primary:hover { background: var(--ad-navy-ink); }
.ad-body .ad-btn.is-danger { border-color: #F5B5B5; color: var(--ad-red-ink); }
.ad-body .ad-btn.is-danger-solid { border: 0; background: var(--ad-red); color: #FFFFFF; }
.ad-body .ad-btn.is-sm { height: 38px; padding: 0 12px; font-size: 13px; border-radius: 8px; min-height: 0 !important; }
.ad-body .ad-btn:disabled { background: var(--ad-line-strong); border-color: var(--ad-line-strong); color: #FFFFFF; cursor: not-allowed; }
.ad-btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ad-btn-row.is-end { justify-content: flex-end; }

.ad-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.ad-body .ad-pill {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 99px;
  border: 1px solid var(--ad-line-strong);
  background: var(--ad-surface);
  color: var(--ad-ink-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
}
.ad-body .ad-pill[aria-pressed="true"] { border-color: var(--ad-navy); background: var(--ad-navy); color: #FFFFFF; font-weight: 700 !important; }

.ad-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; min-width: 0; }
.ad-field small { font-weight: 400; font-size: 12px; color: var(--ad-muted); }
.ad-body .ad-input,
.ad-body .ad-select,
.ad-body .ad-textarea {
  height: 44px;
  padding: 0 12px;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--ad-line-strong);
  background: var(--ad-surface);
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: var(--ad-ink);
  width: 100%;
  min-width: 0;
}
.ad-body .ad-textarea { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.ad-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.ad-check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.ad-check input { width: 18px; height: 18px; }

/* The switch the design uses for on/off settings (role="switch"). */
.ad-body .ad-switch {
  width: 52px;
  height: 30px;
  min-height: 0 !important;
  flex-shrink: 0;
  padding: 3px;
  box-sizing: border-box;
  border: 0;
  border-radius: 99px;
  display: flex !important;
  justify-content: flex-start !important;
  background: var(--ad-line-strong);
  cursor: pointer;
}
.ad-body .ad-switch::after { content: ""; width: 24px; height: 24px; border-radius: 99px; background: #FFFFFF; }
.ad-body .ad-switch[aria-checked="true"] { justify-content: flex-end !important; background: var(--ad-navy); }
.ad-body .ad-switch:disabled { opacity: .5; cursor: not-allowed; }

.ad-banner { padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6; }
.ad-banner.is-ok { background: var(--ad-ok-bg); color: var(--ad-ok); font-weight: 600; }
.ad-banner.is-bad { background: var(--ad-bad-bg); color: var(--ad-bad); }
.ad-banner.is-warn { background: var(--ad-warn-bg); color: var(--ad-warn); }
.ad-banner.is-info { background: var(--ad-tint); color: var(--ad-navy); }

/* Horizontal bars (funnel, feature adoption) and vertical columns (charts),
   drawn in CSS — no chart library. */
.ad-hbar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 90px; gap: 12px; align-items: center; font-size: 14px; }
.ad-hbar { height: 16px; border-radius: 6px; background: var(--ad-line-soft); overflow: hidden; }
.ad-hbar > span { display: block; height: 100%; border-radius: 6px; background: var(--ad-navy); }
.ad-hbar.is-thick { height: 18px; }
.ad-hbar-v { text-align: right !important; font-family: var(--ad-head); }
.ad-cols {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0 6px;
  border-bottom: 1px solid var(--ad-line-strong);
}
.ad-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.ad-col-v { font-size: 12px; color: var(--ad-ink-2); }
.ad-col-bar { width: 100%; max-width: 56px; border-radius: 6px 6px 0 0; background: var(--ad-navy); min-height: 1px; }
.ad-col-labels { display: flex; gap: 10px; padding: 0 6px; }
.ad-col-labels span { flex: 1; min-width: 0; display: flex; justify-content: center; font-size: 12px; color: var(--ad-muted); white-space: nowrap; }

/* ── Dialogs ────────────────────────────────────────────────────────── */
.ad-body dialog.ad-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-sizing: border-box;
  padding: 24px;
  border: 0;
  border-radius: 20px;
  background: var(--ad-surface);
  color: var(--ad-ink);
  box-shadow: 0 20px 50px rgba(20,33,61,.25);
  overflow-y: auto;
}
.ad-body dialog.ad-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.ad-body dialog.ad-dialog::backdrop { background: rgba(20,33,61,.45); }
.ad-dialog-msg { font-size: 15px; line-height: 1.7; color: var(--ad-ink-2); white-space: pre-line; margin: 0; }

/* ── Sign-in / refused / loading ────────────────────────────────────── */
.ad-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  box-sizing: border-box;
  background: linear-gradient(180deg, var(--ad-navy-deep) 0%, var(--ad-navy) 100%);
}
.ad-gate-card {
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  background: var(--ad-surface);
  border-radius: 20px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.ad-gate-card .ad-brand { padding: 0; }
.ad-gate-card .ad-brand-name { color: var(--ad-navy); }
.ad-gate-card .ad-brand-name em { color: var(--ad-red); }
.ad-or { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ad-muted); }
.ad-or::before, .ad-or::after { content: ""; flex-grow: 1; height: 1px; background: var(--ad-line); }
.ad-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2);
  border-top-color: #FFFFFF;
  animation: adSpin 1s linear infinite;
}
@keyframes adSpin { to { transform: rotate(360deg); } }

/* ── Narrow screens: the sidebar becomes a bar across the top ───────── */
@media (max-width: 900px) {
  .ad-shell { flex-direction: column; }
  .ad-side {
    width: auto;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .ad-brand { padding: 0 8px 0 4px; flex-shrink: 0; }
  .ad-brand-name { font-size: 18px; }
  .ad-nav-group, .ad-side-note { display: none; }
  .ad-body a.ad-nav-item { flex-shrink: 0; white-space: nowrap; min-height: 40px; }
  .ad-header { padding: 12px 16px; flex-wrap: wrap; }
  .ad-body .ad-title { font-size: 22px; }
  .ad-who { border-left: 0; padding-left: 0; }
  .ad-main { padding: 16px; }
  .ad-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ad-grid-2 { grid-template-columns: minmax(0, 1fr); }
  .ad-hbar-row { grid-template-columns: 110px minmax(0, 1fr) 70px; }
}
@media (max-width: 480px) {
  .ad-kpis { grid-template-columns: minmax(0, 1fr); }
}

/* ── บัญชีครู ───────────────────────────────────────────────────────── */
.ad-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ad-inline-field { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ad-ink-2); }
.ad-plan-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ad-body .ad-plan-opt {
  display: flex !important;
  flex-direction: column;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--ad-line);
  background: var(--ad-surface);
  color: var(--ad-ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.ad-body .ad-plan-opt b { font-size: 15px; }
.ad-body .ad-plan-opt span { font-size: 13px; font-weight: 400; color: var(--ad-muted); }
.ad-body .ad-plan-opt[aria-checked="true"] { border: 2px solid var(--ad-navy); background: var(--ad-tint); color: var(--ad-navy); }
.ad-body .ad-plan-opt:disabled { cursor: not-allowed; opacity: .6; }
@media (max-width: 900px) {
  .ad-toolbar #adTeacherQ { width: 100% !important; }
}

/* ── อนุมัติสลิป ────────────────────────────────────────────────────── */
.ad-slips { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.ad-slip-list { display: flex; flex-direction: column; gap: 8px; }
.ad-body .ad-slip-item {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--ad-line);
  background: var(--ad-surface);
  color: var(--ad-ink);
  font-family: inherit;
  font-weight: 400 !important;
  text-align: left;
  cursor: pointer;
}
.ad-body .ad-slip-item[aria-pressed="true"] { border: 2px solid var(--ad-navy); background: var(--ad-tint); }
.ad-slip-item .ad-cell-stack { flex-grow: 1; align-items: flex-start; }
.ad-slip-body { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; }
.ad-slip-img {
  min-height: 420px;
  max-height: 560px;
  border-radius: 16px;
  border: 1px solid var(--ad-line-strong);
  background: var(--ad-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.ad-slip-img img { max-width: 100%; height: auto; display: block; }
.ad-checks { border: 1px solid var(--ad-line); border-radius: 12px; overflow: hidden; }
.ad-checks .ad-tr { padding: 10px 14px; }
@media (max-width: 1100px) {
  .ad-slips, .ad-slip-body { grid-template-columns: minmax(0, 1fr); }
  .ad-slip-img { min-height: 240px; }
}

/* ── รายได้ ─────────────────────────────────────────────────────────── */
.ad-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ad-ink-2); }
.ad-legend span { display: flex; align-items: center; gap: 6px; }
.ad-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.ad-col-stack { width: 100%; max-width: 54px; display: flex; flex-direction: column; }
.ad-col-stack > span { display: block; }
.ad-col-stack > span:first-child { border-radius: 6px 6px 0 0; }
.ad-cols.is-tall { height: 300px; }

/* ── Activation funnel ──────────────────────────────────────────────── */
.ad-steps { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 10px; }
.ad-step { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ad-step b { font-size: 14px; line-height: 1.35; }
.ad-step-bar { height: 200px; display: flex; align-items: flex-end; border-radius: 12px; background: var(--ad-bg); overflow: hidden; }
.ad-step-bar > span { display: block; width: 100%; }
.ad-step-v { font-family: var(--ad-head); font-size: 22px; color: var(--ad-navy); }
@media (max-width: 900px) {
  .ad-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ad-step-bar { height: 120px; }
}

/* ── ราคาและคูปอง ───────────────────────────────────────────────────── */
.ad-price-row { display: grid; grid-template-columns: repeat(2, minmax(0, 240px)) auto; gap: 14px; align-items: end; justify-content: start; }
.ad-coupon-new { display: grid; grid-template-columns: 170px 120px 120px 170px auto; gap: 10px; align-items: end; justify-content: start; padding: 16px 20px; border-top: 1px solid var(--ad-line); background: #FBFCFE; }
.ad-coupon-code { font-family: var(--ad-head); letter-spacing: .04em; }
@media (max-width: 900px) {
  .ad-price-row, .ad-coupon-new { grid-template-columns: 1fr 1fr; }
}

/* ── ประกาศถึงครู ───────────────────────────────────────────────────── */
.ad-notice { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.ad-phone { border-radius: 24px; border: 8px solid var(--ad-ink); background: var(--ad-bg); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 300px; }
.ad-phone-card { background: var(--ad-surface); border: 1px solid var(--ad-navy); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.ad-phone-card b { font-size: 16px; color: var(--ad-navy); overflow-wrap: anywhere; }
.ad-phone-card span:last-child { font-size: 14px; line-height: 1.6; color: var(--ad-ink-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.ad-phone-from { font-size: 12px; font-weight: 700; color: var(--ad-red-ink); }
.ad-line-bubble { align-self: flex-start; max-width: 85%; background: #05843A; color: #FFFFFF; border-radius: 16px 16px 16px 4px; padding: 10px 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .ad-notice { grid-template-columns: minmax(0, 1fr); } }

/* ── คำขอ PDPA ──────────────────────────────────────────────────────── */
.ad-dsr { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 18px; align-items: start; }
.ad-body .ad-dsr-row {
  display: grid !important;
  grid-template-columns: var(--cols);
  gap: 10px;
  width: 100%;
  align-items: center !important;
  justify-content: stretch !important;
  padding: 12px 20px;
  border: 0;
  border-top: 1px solid var(--ad-line-soft);
  background: var(--ad-surface);
  color: var(--ad-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400 !important;
  text-align: left;
  cursor: pointer;
  min-width: var(--min, 0);
}
.ad-body .ad-dsr-row[aria-pressed="true"] { background: var(--ad-tint); }
.ad-dsr-step { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; }
.ad-dsr-dot { width: 28px; height: 28px; flex-shrink: 0; border-radius: 99px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: var(--ad-line-soft); color: var(--ad-muted); }
.ad-dsr-dot.is-done { background: #0F7B4F; color: #FFFFFF; }
.ad-dsr-dot.is-now { background: var(--ad-navy); color: #FFFFFF; }
@media (max-width: 1100px) { .ad-dsr { grid-template-columns: minmax(0, 1fr); } }

/* ── แจ้งเตือน LINE ─────────────────────────────────────────────────── */
.ad-switch-row { display: flex; align-items: center; gap: 14px; min-height: 64px; border-top: 1px solid var(--ad-line-soft); }
.ad-switch-row.is-strong { border-top-color: var(--ad-line); }
.ad-switch-row .ad-cell-stack { flex-grow: 1; }
.ad-switch-row b { font-size: 15px; }

/* ── ภาพรวม ─────────────────────────────────────────────────────────── */
.ad-grid-2.is-flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.ad-dash-log { display: grid; grid-template-columns: 120px 150px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid var(--ad-line-soft); font-size: 14px; }
.ad-dash-log > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .ad-grid-2.is-flip { grid-template-columns: minmax(0, 1fr); }
  .ad-dash-log { grid-template-columns: 1fr; gap: 2px; }
}

/* ── จัดการคลังครูฮับ (admin-resources.js, docs/resources-hub.md) ─────── */
.ad-body #adRsListView, .ad-body #adRsFormView, .ad-body #adRsPreviewView { display: flex; flex-direction: column; gap: 18px; }
.ad-body #adRsListView[hidden], .ad-body #adRsFormView[hidden], .ad-body #adRsPreviewView[hidden] { display: none; }
.ad-rs-toolbar #adRsQ { width: 320px; }
.ad-rs-toolbar .ad-select { width: auto; }
.ad-rs-grow { flex-grow: 1; }
.ad-rs-cards { display: none; flex-direction: column; gap: 10px; }
.ad-rs-card { padding: 14px; border-radius: 14px; background: var(--ad-surface); border: 1px solid var(--ad-line); display: flex; flex-direction: column; gap: 8px; }
.ad-rs-card > b { font-size: 15px; line-height: 1.4; }
.ad-rs-card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ad-muted); }
.ad-rs-card .ad-btn-row > * { flex: 1; }
.ad-rs-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 24px; text-align: center; }
.ad-rs-empty > span:first-child { font-size: 36px; color: var(--ad-navy); }
.ad-rs-empty b { font-size: 19px; }
.ad-rs-empty span { color: var(--ad-ink-2); }
.ad-body .ad-rs-textbtn { border: 0; background: none; color: var(--ad-navy); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.ad-rs-feat { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ad-rs-feat li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--ad-bg); }
.ad-rs-feat li b { flex-grow: 1; min-width: 0; font-size: 14px; }
.ad-rs-feat li.ad-note { background: none; padding: 0; }
.ad-rs-featn { width: 28px; height: 28px; flex-shrink: 0; border-radius: 99px; background: var(--ad-navy); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.ad-body .ad-rs-feat .ad-btn.is-sm, .ad-body .ad-rs-step-head .ad-btn.is-sm { min-width: 44px; height: 44px; }

/* chooser + done dialogs */
.ad-rs-choose { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ad-body a.ad-rs-choice { padding: 18px; border-radius: 16px; border: 1.5px solid var(--ad-line-strong); text-decoration: none; color: var(--ad-ink); display: flex; flex-direction: column; gap: 6px; }
.ad-body a.ad-rs-choice:hover { border-color: var(--ad-navy); background: var(--ad-tint); }
.ad-rs-choice b { font-size: 18px; color: var(--ad-navy); }
.ad-rs-choice.is-prm b { color: var(--ad-red-ink); }
.ad-rs-choice span { font-size: 14px; color: var(--ad-ink-2); }
.ad-rs-done-ic { width: 56px; height: 56px; border-radius: 99px; background: #0F7B4F; color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.ad-rs-link { padding: 12px 14px; border-radius: 10px; background: var(--ad-bg); border: 1px solid var(--ad-line); font-size: 14px; overflow-wrap: anywhere; }

/* the form */
.ad-rs-bar-top { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px; padding: 12px 16px; margin: -24px -32px 0; background: var(--ad-surface); border-bottom: 1px solid var(--ad-line); }
.ad-rs-bar-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.ad-rs-bar-text b { font-family: var(--ad-head); font-weight: 500; font-size: 18px; color: var(--ad-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-rs-bar-text span { font-size: 13px; color: var(--ad-muted); }
.ad-rs-bar-text span.is-warn { color: var(--ad-warn); }
.ad-rs-bar-text span.is-bad { color: var(--ad-bad); font-weight: 600; }
.ad-rs-bar-acts { flex-shrink: 0; }
.ad-rs-bar-bottom { display: none; }
.ad-rs-form { display: flex; flex-direction: column; gap: 18px; max-width: 1040px; }
.ad-rs-form > .ad-card > b { font-size: 16px; }
.ad-rs-restore { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; max-width: 1040px; }
.ad-rs-g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ad-rs-cover { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.ad-rs-field > label, .ad-rs-field > span:first-child { font-size: 15px; font-weight: 700; color: var(--ad-ink); }
.ad-rs-need { color: var(--ad-warn); font-size: 13px; font-weight: 600; }
.ad-rs-need.is-req { color: var(--ad-red-ink); }
.ad-rs-opt { color: var(--ad-muted); font-size: 13px; font-weight: 400; }
.ad-rs-err { font-size: 14px; color: var(--ad-red-ink); font-weight: 600; }
.ad-body .ad-input.is-bad, .ad-body .ad-textarea.is-bad, .ad-body .ad-select.is-bad { border: 1.5px solid var(--ad-red); background: #FFF7F7; }
.ad-rs-errlist { margin: 6px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.ad-rs-errlist a { color: var(--ad-bad); font-weight: 600; }
.ad-rs-slug { display: flex; align-items: stretch; height: 44px; border-radius: 10px; border: 1px solid var(--ad-line-strong); overflow: hidden; background: var(--ad-surface); }
.ad-rs-slug span { display: flex; align-items: center; padding: 0 10px; background: var(--ad-bg); color: var(--ad-muted); font-size: 14px; font-weight: 400; border-right: 1px solid var(--ad-line); white-space: nowrap; }
.ad-rs-slug input { flex: 1; min-width: 0; border: 0; padding: 0 12px; font: inherit; font-weight: 400; font-size: 15px; color: var(--ad-ink); background: transparent; }
.ad-rs-slug input:focus { outline: none; }
.ad-rs-slug:focus-within { outline: 3px solid var(--ad-red); outline-offset: 2px; }
.ad-rs-slug.is-locked, .ad-rs-slug.is-locked span { background: var(--ad-bg); }
.ad-rs-slug input.is-bad { background: #FFF7F7; }
.ad-rs-drop { min-height: 170px; border-radius: 14px; border: 2px dashed var(--ad-line-strong); background: #FBFCFE; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; text-align: center; font-size: 14px; font-weight: 400; }
.ad-rs-drop.is-over { border-color: var(--ad-navy); background: var(--ad-tint); }
.ad-rs-drop.is-bad { border-color: var(--ad-red); }
.ad-rs-upic { font-size: 26px; color: var(--ad-navy); }
.ad-rs-thumb { display: block; width: 100%; max-height: 150px; object-fit: contain; border-radius: 8px; }
.ad-rs-bar { width: 80%; height: 8px; border-radius: 99px; background: var(--ad-line); overflow: hidden; }
.ad-rs-bar span { display: block; height: 100%; background: var(--ad-navy); }
.ad-rs-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.ad-rs-shots .ad-rs-drop { min-height: 140px; }
.ad-body #adRsSteps { display: flex; flex-direction: column; gap: 10px; }
.ad-rs-step { padding: 14px; border-radius: 14px; border: 1px solid var(--ad-line); background: var(--ad-bg); display: flex; flex-direction: column; gap: 8px; }
.ad-rs-step-head { display: flex; align-items: center; gap: 8px; }
.ad-rs-step-head b { flex-grow: 1; }
.ad-rs-step-opts { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 12px; align-items: center; }
.ad-rs-step-img .ad-rs-drop { min-height: 120px; }
.ad-body #adRsFaqs { display: flex; flex-direction: column; gap: 8px; }
.ad-rs-faq { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 8px; align-items: start; }
.ad-rs-var { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 10px; align-items: center; }
.ad-rs-mark { justify-self: start; background: #FFE9A8; color: var(--ad-ink); border-bottom: 2px solid #C77700; padding: 0 4px; border-radius: 4px; font-weight: 600; }
.ad-body #adRsVars { display: flex; flex-direction: column; gap: 8px; }

/* preview */
.ad-rs-pvbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-radius: 16px; background: #FFF8E6; border: 1px solid #F3D19C; }
.ad-rs-pvic { font-size: 22px; }
.ad-rs-pvtext { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }
.ad-rs-pvtext b { font-size: 16px; }
.ad-rs-pvframe { height: calc(100vh - 230px); min-height: 520px; border-radius: 16px; border: 1px solid var(--ad-line); background: #E9EEF7; overflow: hidden; display: flex; justify-content: center; }
.ad-rs-pvframe iframe { width: 100%; height: 100%; border: 0; background: #FFFFFF; }
.ad-rs-pvframe.is-phone { padding: 16px 0; }
.ad-rs-pvframe.is-phone iframe { width: 390px; border-radius: 18px; box-shadow: 0 6px 24px rgba(20,33,61,.18); }

@media (max-width: 900px) {
  .ad-rs-table { display: none !important; }
  .ad-rs-cards { display: flex; }
  .ad-rs-toolbar #adRsQ { width: 100%; }
  .ad-rs-grow { display: none; }
  .ad-rs-bar-top { position: static; margin: -16px -16px 0; padding: 10px 12px; flex-wrap: wrap; }
  .ad-rs-bar-acts { display: none; }
  .ad-rs-bar-bottom { position: sticky; bottom: 0; z-index: 4; display: flex; gap: 8px; padding: 10px 12px; margin: 0 -16px -16px; background: var(--ad-surface); border-top: 1px solid var(--ad-line); }
  .ad-rs-bar-bottom .ad-btn { flex: 1; }
  .ad-rs-g2, .ad-rs-cover, .ad-rs-choose, .ad-rs-step-opts { grid-template-columns: minmax(0, 1fr); }
  .ad-rs-faq { grid-template-columns: minmax(0, 1fr) auto; }
  .ad-rs-faq textarea { grid-column: 1; }
  .ad-rs-var { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .ad-rs-pvframe { height: 70vh; }
}
.ad-body .ad-rs-feat .ad-btn:disabled, .ad-body .ad-rs-step-head .ad-btn:disabled { background: var(--ad-surface); border-color: var(--ad-line); color: var(--ad-faint); }
