/* 관리자 패널의 계정 관리(account-admin.js): 계정 표, 계정 작업 창, 일괄 초기화 창. */
body.aa-open { overflow: hidden; }
.aa-modal.hidden, .aa-modal [hidden], .aa-section [hidden] { display: none !important; }

/* 표 위 고르기 */
.aa-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.aa-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
#adminView .aa-tools :is(select, input) { min-height: 42px; }
#adminView .aa-tools select { width: auto; }
#adminView .aa-tools input { width: 200px; }
.aa-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; }
.aa-list-head p { margin: 0; color: var(--ms-muted); font-size: calc(13.5px * var(--reading-scale, 1)); }
.aa-mini { min-height: 38px; padding: 0 12px; color: var(--ms-ink); font: inherit; font-size: calc(14px * var(--reading-scale, 1)); font-weight: 700; white-space: nowrap; cursor: pointer; background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 11px; }
.aa-mini:hover:not(:disabled) { background: var(--ms-soft); }
.aa-mini:disabled { opacity: .5; cursor: default; }
.aa-list-status:empty { display: none; }
.aa-status { min-height: 1.5em; margin: 14px 0 0; font-size: calc(14px * var(--reading-scale, 1)); line-height: 1.6; }
.aa-status[data-tone='loading'] { color: var(--ms-muted); }
.aa-status[data-tone='ok'] { color: var(--ms-green); }
.aa-status[data-tone='error'], .aa-blocked { color: var(--ms-coral); }
.aa-list-status { padding: 9px 14px; font-weight: 600; background: var(--ms-soft); border-radius: 12px; }
.aa-list-status[data-tone='ok'] { background: var(--ms-green-soft); }
.aa-list-status[data-tone='error'] { background: var(--ms-coral-soft); }
.aa-ai-note { grid-column: 1 / -1; margin: 0; color: var(--ms-coral); font-size: calc(13.5px * var(--reading-scale, 1)); }
#adminView .aa-bulk-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; font-size: calc(15px * var(--reading-scale, 1)); border-color: var(--ms-ink) !important; border-radius: 14px; }
.aa-bulk-open svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#adminView .aa-card { margin-top: 14px; }

/* 계정 표 */
.aa-table-wrap { overflow-x: auto; background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 14px; }
#adminView .aa-table { width: 100%; min-width: 800px; margin: 0; border-collapse: collapse; }
.aa-table caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#adminView .aa-table :is(th, td) { position: static; box-sizing: border-box; padding: 8px 14px; color: var(--ms-text); font-size: calc(14.5px * var(--reading-scale, 1)); font-weight: 400; text-align: left; vertical-align: middle; white-space: nowrap; background: transparent; border: 0; border-bottom: 1px solid var(--ms-hair); }
#adminView .aa-table thead th { padding: 10px 14px; color: var(--ms-muted); font-size: calc(13px * var(--reading-scale, 1)); font-weight: 700; background: var(--ms-soft); border-bottom-color: var(--ms-line); }
#adminView .aa-table tbody tr:last-child > * { border-bottom: 0; }
#adminView .aa-table tbody th strong { display: block; color: var(--ms-ink); font-weight: 700; }
#adminView .aa-table tbody th span { display: block; color: var(--ms-muted); font-size: calc(13px * var(--reading-scale, 1)); }
#adminView .aa-table tr.is-reset > * { background: var(--ms-row-on); }
.aa-kind span { margin-left: 8px; color: var(--ms-muted); font-size: calc(14px * var(--reading-scale, 1)); font-variant-numeric: tabular-nums; }
.aa-state::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; background: var(--ms-meter); border-radius: 50%; }
#adminView .aa-table .aa-state.is-off { color: var(--ms-coral); font-weight: 600; }
.aa-state.is-off::before { background: var(--ms-action); }
.aa-usage__line { display: flex; align-items: center; gap: 10px; }
.aa-usage__line + .aa-usage__line { margin-top: 6px; }
/* 위쪽 숫자 칸은 여섯 개입니다(학생, 교사, 스케치, 간편, 한도, AI 스위치). 세 칸씩 두 줄로 놓고(칸의 최소 너비가 줄의 3분의 1),
   칸이 170px보다 좁으면 AI 스위치 단추가 글에 겹치므로 줄을 바꿉니다. */
@media (min-width: 651px) { #aaTiles { grid-template-columns: repeat(auto-fit, minmax(max(170px, calc((100% - 24px) / 3)), 1fr)); } }
.aa-usage strong { color: var(--ms-ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.aa-usage strong.is-full { color: var(--ms-coral); }
.aa-usage__none { color: var(--ms-muted); font-weight: 600; }
.aa-usage__failed { flex: none; color: var(--ms-coral); font-size: calc(13px * var(--reading-scale, 1)); font-weight: 600; white-space: nowrap; }
.aa-usage-note { margin: 12px 0 0; color: var(--ms-muted); font-size: calc(13.5px * var(--reading-scale, 1)); line-height: 1.6; }
.ap-tile em .is-failed { color: var(--ms-coral); font-weight: 600; white-space: nowrap; }
.aa-meter { flex: none; display: block; width: 96px; height: 8px; overflow: hidden; background: var(--ms-track); border-radius: 4px; }
.aa-meter i { display: block; height: 100%; background: var(--ms-meter); }
.aa-meter.is-full i { background: var(--ms-action); }
/* 단추가 셋이어도 표가 넓어지지 않게, 칸이 좁으면 단추가 다음 줄로 내려갑니다. */
#adminView .aa-table .aa-actions { text-align: right; white-space: normal; }
.aa-actions .aa-mini { margin-block: 2px; }
.aa-actions .aa-mini + .aa-mini { margin-left: 6px; }
.aa-empty { padding: 34px 16px; color: var(--ms-muted); text-align: center; background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 14px; }
.aa-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 14px; color: var(--ms-muted); font-size: calc(14px * var(--reading-scale, 1)); font-variant-numeric: tabular-nums; }
#adminView .aa-pagination .btn { min-height: 38px; padding: 0 14px; font-size: calc(14px * var(--reading-scale, 1)); border-radius: 12px; }

/* 창 */
body .aa-modal { z-index: 65; padding: 20px; background: rgb(28 30 52 / 52%); }
.aa-modal .aa-panel { box-sizing: border-box; width: min(640px, 100%); max-height: calc(100dvh - 40px); overflow: auto; overscroll-behavior: contain; padding: 24px 26px 22px; color: var(--ms-text); background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: var(--ms-radius); box-shadow: 0 18px 48px rgb(44 53 102 / 22%); }
.aa-modal .aa-bulk { width: min(580px, 100%); }
.aa-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.aa-head p, .aa-head h2 { margin: 0; }
.aa-head p:not(.aa-bulk__intro) { color: var(--ms-muted); font-size: calc(13px * var(--reading-scale, 1)); font-weight: 700; }
.aa-head h2 { color: var(--ms-ink); font-size: calc(21px * var(--reading-scale, 1)); font-weight: 800; letter-spacing: -.03em; }
/* 창은 #adminView 밖(body)에 붙어서 패널의 단추 규칙이 닿지 않습니다. */
body.sb-theme.curriculum-app.readable-app.app-open .aa-modal .btn:not(.secondary):not(.ghost) { color: var(--ms-action-ink) !important; background: var(--ms-action) !important; border: 0 !important; border-radius: 14px; box-shadow: none !important; }
body.sb-theme.curriculum-app.readable-app.app-open .aa-modal .btn.secondary { color: var(--ms-ink) !important; background: var(--ms-card) !important; border: 1px solid var(--ms-line) !important; border-radius: 14px; box-shadow: none !important; }
.aa-modal .btn { width: auto; }
.aa-head .btn { flex: none; min-height: 38px !important; padding: 0 13px !important; font-size: calc(14px * var(--reading-scale, 1)) !important; }
.aa-intro { margin: 10px 0 0; color: var(--ms-muted); font-size: calc(13.5px * var(--reading-scale, 1)); line-height: 1.6; }
.aa-modal label { display: block; color: var(--ms-ink); font-size: calc(14px * var(--reading-scale, 1)); font-weight: 700; }
.aa-modal input:not([type="radio"]):not([type="checkbox"]) { box-sizing: border-box; width: 100%; min-height: 44px; padding: 0 13px; color: var(--ms-ink); font: inherit; font-size: calc(15px * var(--reading-scale, 1)); background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 12px; }
#aaSelected { margin-top: 14px; }
#aaSelected h3, .aa-preview h3 { margin: 0 0 6px; color: var(--ms-ink); font-size: calc(17px * var(--reading-scale, 1)); font-weight: 800; }
#aaSelected p { margin: 2px 0; font-size: calc(14px * var(--reading-scale, 1)); }
.aa-uid { overflow-wrap: anywhere; font-size: calc(14px * var(--reading-scale, 1)); font-weight: 700; }
.aa-operations { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.aa-operations .btn { min-height: 42px !important; padding: 0 14px !important; font-size: calc(14.5px * var(--reading-scale, 1)) !important; }
body.sb-theme.curriculum-app.readable-app.app-open .aa-modal .btn.aa-delete, body.sb-theme.curriculum-app.readable-app.app-open .aa-modal #aaApply[data-operation='delete'] { color: var(--ms-coral) !important; background: var(--ms-coral-soft) !important; border: 1px solid #eeb9ad !important; }
.aa-preview { padding: 14px 16px; background: var(--ms-soft); border-radius: 13px; }
.aa-preview ul { margin: 8px 0; padding-left: 20px; font-size: calc(14px * var(--reading-scale, 1)); line-height: 1.6; }
#aaForm { display: grid; gap: 8px; }
#aaConfirmationText { display: block; overflow-wrap: anywhere; user-select: all; padding: 8px 10px; font-size: calc(14px * var(--reading-scale, 1)); background: var(--ms-card); border-radius: 8px; }
.aa-blocked { font-size: calc(14px * var(--reading-scale, 1)); font-weight: 700; line-height: 1.6; }
.aa-blocked:empty { display: none; }
.aa-modal button:disabled { opacity: .55; cursor: default; }
.aa-modal :is(button, input):focus-visible { outline: 2px solid var(--ms-ink); outline-offset: 2px; }

/* 일괄 초기화 */
.aa-bulk__intro { margin-top: 4px !important; color: var(--ms-muted); font-size: calc(14.5px * var(--reading-scale, 1)); }
.aa-bulk__scope { display: flex; flex-direction: column; gap: 8px; margin: 18px 0 0; padding: 0; border: 0; }
.aa-bulk__scope legend { padding: 0; margin-bottom: 8px; color: var(--ms-ink); font-size: calc(14.5px * var(--reading-scale, 1)); font-weight: 700; }
.aa-modal .aa-bulk__scope label { display: flex; align-items: center; gap: 10px; min-height: 50px; box-sizing: border-box; padding: 0 14px; color: var(--ms-text); font-size: calc(15px * var(--reading-scale, 1)); font-weight: 600; cursor: pointer; border: 1px solid var(--ms-line); border-radius: 13px; }
.aa-modal .aa-bulk__scope label.is-on { color: var(--ms-ink); font-weight: 700; background: var(--ms-row-on); border-color: var(--ms-fill-line); }
.aa-bulk__scope input { width: 18px; height: 18px; margin: 0; accent-color: var(--ms-ink); }
.aa-bulk__scope small { margin-left: auto; color: var(--ms-muted); font-size: calc(14px * var(--reading-scale, 1)); font-weight: 500; font-variant-numeric: tabular-nums; }
.aa-bulk__scope label.is-on small { color: var(--ms-text); }
.aa-bulk__narrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 14px; }
.aa-bulk__grades { display: flex; gap: 6px; }
.aa-bulk__grades button { min-height: 40px; padding: 0 13px; color: var(--ms-text); font: inherit; font-size: calc(14.5px * var(--reading-scale, 1)); font-weight: 600; cursor: pointer; background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 999px; }
.aa-bulk__grades button[aria-pressed="true"] { color: var(--ms-fill-ink); font-weight: 700; background: var(--ms-fill); border-color: var(--ms-fill-line); }
.aa-modal .aa-bulk__check { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--ms-text); font-size: calc(14.5px * var(--reading-scale, 1)); font-weight: 600; cursor: pointer; }
.aa-bulk__check input { width: 18px; height: 18px; margin: 0; accent-color: var(--ms-ink); }
.aa-bulk__summary { margin: 16px 0 0; padding: 13px 16px; color: var(--ms-muted); font-size: calc(14.5px * var(--reading-scale, 1)); font-weight: 600; line-height: 1.6; background: var(--ms-soft); border-radius: 13px; }
.aa-bulk__summary[data-tone='warn'] { color: var(--ms-amber); background: var(--ms-amber-soft); }
.aa-modal .aa-bulk__label { margin: 16px 0 6px; font-size: calc(14.5px * var(--reading-scale, 1)); }
.aa-bulk__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.aa-bulk__actions .btn { min-height: 46px !important; padding: 0 18px !important; font-size: calc(15px * var(--reading-scale, 1)) !important; }
.aa-bulk .aa-status:empty { display: none; }

@media (max-width: 650px) {
  .aa-tools { flex: 1 1 100%; margin-left: 0; }
  #adminView .aa-tools input { flex: 1 1 0; width: auto; min-width: 0; }
  #adminView .aa-bulk-open { flex: 1 1 100%; justify-content: center; }
  /* 계정 표는 카드로 쌓습니다. */
  .aa-table-wrap { overflow: visible; background: none; border: 0; }
  #adminView .aa-table, #adminView .aa-table tbody { display: block; min-width: 0; }
  #adminView .aa-table thead { display: none; }
  #adminView .aa-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 11px 14px 12px; background: var(--ms-card); border: 1px solid var(--ms-line); border-radius: 15px; }
  #adminView .aa-table tr + tr { margin-top: 8px; }
  #adminView .aa-table :is(th, td) { height: auto; padding: 0; white-space: normal; border: 0; }
  #adminView .aa-table tbody th { grid-column: 1; }
  #adminView .aa-table tbody th span { display: none; }
  #adminView .aa-table .aa-kind { grid-column: 1 / -1; grid-row: 2; font-size: calc(13.5px * var(--reading-scale, 1)); }
  #adminView .aa-table .aa-state { grid-column: 2; grid-row: 1; font-size: calc(13px * var(--reading-scale, 1)); }
  #adminView .aa-table .aa-usage { grid-column: 1 / -1; margin-top: 2px; }
  .aa-meter { flex: 1 1 auto; width: auto; }
  /* 초기화 단추가 셋(횟수, 스케치, 간편)이면 한 줄에 다 들지 않으므로 줄을 바꾸고, 관리 단추는 늘 오른쪽 끝에 둡니다. */
  #adminView .aa-table .aa-actions { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 6px; margin-top: 6px; }
  .aa-actions .aa-mini { min-height: 40px; margin-block: 0; }
  .aa-actions .aa-mini:first-child:not(:last-child) { flex: 1 1 auto; }
  .aa-actions .aa-mini + .aa-mini { margin-left: 0; }
  .aa-actions .aa-mini:last-child { margin-left: auto; }
  body .aa-modal { align-items: end; padding: 0; }
  .aa-modal .aa-panel { width: 100%; max-height: 94dvh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 18px 18px 0 0; }
  .aa-operations .btn { flex: 1; }
  .aa-modal .aa-bulk__check { margin-left: 0; }
}
