/*
  School Pass 디자인 시스템 v2  ("Steel, calm")
  - 신뢰 우선의 제품 UI: 차분한 철강 중성색 + 역할별 단일 강조색. 네이티브 CSS, 프레임워크 없음.
  - 다이얼: DESIGN_VARIANCE 3 / MOTION_INTENSITY 3 / VISUAL_DENSITY 5
  - 규칙
      * 역할 페이지는 <body class="role-student|parent|teacher|admin"> 하나만 지정 (한 페이지 = 강조색 하나)
      * 빨강/초록/주황은 상태(반려/승인/대기) 전용. 강조색과 섞어 쓰지 않는다
      * 모서리: 컨트롤 10px / 카드 14px / 알약(배지·아바타)만 999px, 이 세 가지만 사용
      * 그림자보다 1px 테두리. 그림자는 모달/메뉴에만, 배경색에 맞춰 틴트
      * 아이콘은 Phosphor(MIT) 스프라이트: <svg class="ic"><use href="/static/icons/sprite.svg#이름"/></svg>
      * 라이트/다크 모두 지원 (prefers-color-scheme), 모션은 prefers-reduced-motion 존중
*/

/* ---------- 1. 토큰 ---------- */
:root {
  color-scheme: light dark;

  /* 중성색 (라이트) : 순백/순흑 사용 안 함 */
  --bg: #eef1f5;
  --surface: #fbfcfd;
  --surface-2: #f3f5f8;
  --line: #dde2ea;
  --line-strong: #c4ccd8;
  --ink: #141a24;
  --ink-2: #384355;
  --muted: #566176;           /* 배경 #eef1f5 기준 대비 5.4:1 */

  /* 상태 색 (상태 전용) */
  --ok: #17744a;      --ok-soft: #e1f3ea;
  --warn: #9a5b00;    --warn-soft: #fbefd6;
  --bad: #c0302b;     --bad-soft: #fbe5e3;
  --info: #1f5fbf;    --info-soft: #e2ecfb;
  --on-ok: #f6fbf8;   --on-bad: #fff7f6;    /* 승인/반려 채움 버튼 위 글자색 */

  /* 역할 강조색 (기본 = 학생) */
  --accent: #2b59c8;
  --accent-strong: #1f46a3;
  --accent-soft: #e4ebfa;
  --accent-ink: #f8fafd;      /* 강조색 위 글자 (대비 6:1 이상) */

  --cyan: #0aa5c0;            /* 로고 포인트 전용 */

  /* 모서리 : 세 가지만 */
  --r-ctl: 10px;
  --r-card: 14px;
  --r-pill: 999px;

  --shadow-pop: 0 1px 2px rgb(20 30 50 / .06), 0 16px 40px -16px rgb(20 30 50 / .28);

  /* 영문은 Geist(웹폰트), 한글은 기기 글꼴: 아이폰·맥 애플SD산돌고딕 / 안드로이드 Noto CJK / 윈도우 맑은 고딕 */
  --font: "Geist", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  /* 글자 역할 (크기는 이 다섯 가지만, 굵기는 400·500·600·700만) */
  --fs-title: 1.5rem;     /* 화면 제목 h1 */
  --fs-heading: 1.125rem; /* 패널·섹션·팝업 제목 h2 */
  --fs-body: 1rem;        /* 본문, 표, 값, 버튼 */
  --fs-meta: .875rem;     /* 라벨, 힌트, 배지, 표 머리, 작은 버튼, 그룹 제목 */
  --fs-fine: .75rem;      /* 바닥글, 상단 바 역할 표시 */

  --bar-h: 56px;
  --gap: 16px;
  --z-bar: 20;
  --z-modal: 40;
  --z-toast: 50;
}

body.role-student { --accent:#2b59c8; --accent-strong:#1f46a3; --accent-soft:#e4ebfa; }
body.role-parent  { --accent:#17754f; --accent-strong:#105c3d; --accent-soft:#e0f1e8; }
body.role-teacher { --accent:#5d4bb8; --accent-strong:#4a3a9c; --accent-soft:#ebe8f8; }
body.role-admin   { --accent:#2c3a52; --accent-strong:#1c283c; --accent-soft:#e3e8f0; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d121a;
    --surface: #141b26;
    --surface-2: #1a2230;
    --line: #263042;
    --line-strong: #364258;
    --ink: #e7ecf3;
    --ink-2: #c3ccda;
    --muted: #97a3b7;

    --ok: #56c88b;   --ok-soft: #14291f;
    --warn: #e6aa4a; --warn-soft: #2d2411;
    --bad: #f08580;  --bad-soft: #321a19;
    --info: #7fb0f5; --info-soft: #14233a;
    --on-ok: #0a1d14; --on-bad: #2a0c0b;

    --accent: #7ea2f2;  --accent-strong: #a3bff7;  --accent-soft: #18243d;  --accent-ink: #0d1422;
    --cyan: #3ccde6;
    --shadow-pop: 0 1px 2px rgb(0 0 0 / .4), 0 16px 40px -16px rgb(0 0 0 / .7);
  }
  body.role-student { --accent:#7ea2f2; --accent-strong:#a3bff7; --accent-soft:#18243d; }
  body.role-parent  { --accent:#5ccb9a; --accent-strong:#8adcb7; --accent-soft:#122a21; }
  body.role-teacher { --accent:#a798ee; --accent-strong:#c2b7f4; --accent-soft:#211d3d; }
  body.role-admin   { --accent:#a9b8d2; --accent-strong:#c9d3e5; --accent-soft:#1d2636; --accent-ink:#0d1422; }
}

/* 항상 어두운 화면(게이트 스캔 단말 등): <body class="theme-dark ...">. 값은 바로 위 다크 블록과 같게 유지 */
body.theme-dark {
  color-scheme: dark;
  --bg: #0d121a; --surface: #141b26; --surface-2: #1a2230; --line: #263042; --line-strong: #364258;
  --ink: #e7ecf3; --ink-2: #c3ccda; --muted: #97a3b7;
  --ok: #56c88b; --ok-soft: #14291f; --warn: #e6aa4a; --warn-soft: #2d2411; --bad: #f08580; --bad-soft: #321a19;
  --info: #7fb0f5; --info-soft: #14233a; --on-ok: #0a1d14; --on-bad: #2a0c0b;
  --accent: #7ea2f2; --accent-strong: #a3bff7; --accent-soft: #18243d; --accent-ink: #0d1422; --cyan: #3ccde6;
  --shadow-pop: 0 1px 2px rgb(0 0 0 / .4), 0 16px 40px -16px rgb(0 0 0 / .7);
}
body.theme-dark.role-teacher { --accent:#a798ee; --accent-strong:#c2b7f4; --accent-soft:#211d3d; }
body.theme-dark.role-admin   { --accent:#a9b8d2; --accent-strong:#c9d3e5; --accent-soft:#1d2636; }

/* 항상 밝은 영역(QR 외출증: 다크 모드 기기에서도 스캐너가 읽도록 흰 바탕). 값은 맨 위 라이트 토큰과 같게 유지 */
.theme-light {
  color-scheme: light;
  --bg: #eef1f5; --surface: #fbfcfd; --surface-2: #f3f5f8; --line: #dde2ea; --line-strong: #c4ccd8;
  --ink: #141a24; --ink-2: #384355; --muted: #566176;
  --ok: #17744a; --ok-soft: #e1f3ea; --warn: #9a5b00; --warn-soft: #fbefd6; --bad: #c0302b; --bad-soft: #fbe5e3;
  --info: #1f5fbf; --info-soft: #e2ecfb; --on-ok: #f6fbf8; --on-bad: #fff7f6;
  --accent: #2b59c8; --accent-strong: #1f46a3; --accent-soft: #e4ebfa; --accent-ink: #f8fafd; --cyan: #0aa5c0;
  --shadow-pop: 0 1px 2px rgb(20 30 50 / .06), 0 16px 40px -16px rgb(20 30 50 / .28);
  color: var(--ink);
}
.role-parent  .theme-light { --accent:#17754f; --accent-strong:#105c3d; --accent-soft:#e0f1e8; }
.role-teacher .theme-light { --accent:#5d4bb8; --accent-strong:#4a3a9c; --accent-soft:#ebe8f8; }
.role-admin   .theme-light { --accent:#2c3a52; --accent-strong:#1c283c; --accent-soft:#e3e8f0; }

/* ---------- 2. 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.55 var(--font);   /* rem: 브라우저 글자 크기 설정을 따름 */
  letter-spacing: -0.005em;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; font-weight: 700; color: var(--ink); }
h1 { font-size: var(--fs-title); }
h2 { font-size: var(--fs-heading); }
h3 { font-size: var(--fs-body); }
p { margin: 0; }
a { color: var(--accent-strong); text-underline-offset: 3px; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
/* 브라우저 기본 요소도 역할 색으로: 입력 커서, 체크박스·라디오, 스크롤바 */
body { accent-color: var(--accent); caret-color: var(--accent); }  /* body: 역할 색(--accent)이 body에 정의됨 */
html { scrollbar-color: var(--line-strong) transparent; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-meta); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.ic { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; vertical-align: -0.2em; }
.ic-lg { width: 1.5rem; height: 1.5rem; }
.ic-xl { width: 2rem; height: 2rem; }

/* ---------- 3. 레이아웃 ---------- */
.appbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  min-height: var(--bar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar .brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; min-width: 0; }
.appbar .sp-mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.appbar .school-logo { width: 30px; height: 30px; object-fit: contain; flex: none; }  /* 학교 로고: 기본 마크와 같은 크기 */
.appbar .brand b { font-size: var(--fs-body); font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* 공간이 모자라면 역할·화면 표시(small)가 시스템 이름보다 먼저 줄어듦 */
.appbar .brand small { color: var(--muted); font-size: var(--fs-fine); font-weight: 500; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; flex-shrink: 100; }
.appbar > .btn { flex: none; }
.appbar .spacer { flex: 1; }
/* 좁은 화면이나 글자를 키운 경우: 상단 바 오른쪽 버튼(로그아웃, 현황판 등)은 아이콘만 (글자는 스크린 리더용으로 남김)
   em 기준이라 기본 글자(16px)면 384px 미만, 글자 200%면 768px 미만에서 적용 */
@media (max-width: 24em) {
  .appbar .btn-sm > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .appbar .btn-sm { width: 44px; padding: 0; }
}
.appbar .who { font-size: var(--fs-meta); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

.container { width: min(720px, 100% - 32px); margin: 0 auto; padding: 24px 0 56px; }
.container-wide { width: min(1160px, 100% - 32px); margin: 0 auto; padding: 24px 0 64px; }
.container-narrow { width: min(440px, 100% - 32px); margin: 0 auto; padding: 24px 0 56px; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { color: var(--muted); margin-top: 4px; font-size: var(--fs-body); }
.page-head .photo { width: 64px; height: 64px; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.split { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 880px) { .split-2 { grid-template-columns: 1.4fr 1fr; align-items: start; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px;
}
.panel-flush { padding: 0; overflow: hidden; }
.panel > h2, .panel > .panel-title { margin-bottom: 12px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 10px; }
/* 그룹 제목: 목록 항목(16px)보다 작게 두되 회색 대신 진한 글자로 제목임을 드러냄 */
.section-title h2 { font-size: var(--fs-meta); color: var(--ink-2); font-weight: 700; letter-spacing: 0; }

.avatar { width: 48px; height: 48px; border-radius: var(--r-pill); object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); flex: none; }
.photo { border-radius: var(--r-card); object-fit: cover; background: var(--surface-2); border: 1px solid var(--line); }

/* ---------- 4. 버튼 ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  font: 600 var(--fs-body)/1 var(--font); letter-spacing: -0.01em;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.btn-ok:hover { filter: brightness(.92); background: var(--ok); }
.btn-danger { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-solid-danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn-solid-danger:hover { background: var(--bad); filter: brightness(.92); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-meta); }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
/* 터치 기기: 작은 버튼·탭도 손가락 크기(44px)로. 마우스 화면은 촘촘한 크기 유지 */
@media (pointer: coarse) {
  .btn-sm { min-height: 44px; }
  .btn-icon.btn-sm { width: 44px; }
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }

/* ---------- 5. 폼 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: var(--fs-meta); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-meta); color: var(--muted); }
.field .error { font-size: var(--fs-meta); color: var(--bad); display: none; }
.field.has-error .error { display: block; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--bad); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: 400 1rem/1.4 var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }  /* 대비 4.5:1 이상 */
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form-grid { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }

/* 한 줄에 같은 폭으로 나란히, 글자가 커져 안 들어가면 다음 줄로 넘어감 */
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.segmented > button, .segmented > label, .segmented > a {
  text-decoration: none;
  flex: 1 1 0;
  appearance: none; border: 0; background: transparent; cursor: pointer;
  min-height: 38px; padding: 0 10px; border-radius: 7px;
  font: 600 var(--fs-meta)/1 var(--font); color: var(--ink-2);
  transition: background-color .15s, color .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
@media (pointer: coarse) { .segmented > button, .segmented > label, .segmented > a { min-height: 44px; } }
.segmented > .active, .segmented > [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-body); }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }

/* 스위치 (켜짐/꺼짐 토글: <label class="switch"><input type="checkbox"><span class="slider"></span></label>) */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: -7px -4px; width: calc(100% + 8px); height: calc(100% + 14px); margin: 0; /* 보이는 크기는 50x30, 누르는 범위는 58x44 */ opacity: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: var(--line-strong); border-radius: var(--r-pill); transition: background-color .15s; }
.switch .slider::before { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; background: var(--surface); border-radius: 50%; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 6. 목록 / 메뉴 ---------- */
.action-list { display: flex; flex-direction: column; gap: 10px; }
.action {
  display: flex; align-items: center; gap: 14px;
  min-height: 64px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  color: var(--ink); text-decoration: none; text-align: left; width: 100%;
  font: inherit; cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .08s;
}
.action:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.action:active { transform: translateY(1px); }
.action .ico { width: 40px; height: 40px; border-radius: var(--r-ctl); background: var(--accent-soft); color: var(--accent-strong); display: grid; place-items: center; flex: none; }
.action .txt { flex: 1; min-width: 0; }
.action .txt b { display: block; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.action .txt span { display: block; font-size: var(--fs-meta); color: var(--muted); margin-top: 2px; }
.action .go { color: var(--muted); }
.action.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); min-height: 84px; padding: 18px; }
.action.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.action.primary .ico { background: color-mix(in srgb, var(--accent-ink) 18%, transparent); color: var(--accent-ink); width: 48px; height: 48px; }
.action.primary .txt b { font-size: var(--fs-heading); }
.action.primary .txt span, .action.primary .go { color: color-mix(in srgb, var(--accent-ink) 92%, transparent); }  /* 모든 역할 색에서 4.5:1 이상 */
.action.is-disabled { opacity: .55; pointer-events: none; }
.action.is-live { border-color: var(--bad); }
.action.is-live .ico { background: var(--bad-soft); color: var(--bad); }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .grow b { font-weight: 600; }
.panel .list-row:first-child { padding-top: 0; }
.panel .list-row:last-child { padding-bottom: 0; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: var(--fs-body); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; }
.kv dd.num { white-space: normal; }  /* 글자를 키워 칸이 좁아지면 "14:30 ~ 18:00"이 띄어쓰기에서 줄바꿈 */

.entry { display: flex; flex-direction: column; gap: 8px; padding: 16px 20px; }
.entry + .entry { border-top: 1px solid var(--line); }
.entry .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.entry .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: var(--fs-body); }
.entry .meta span { display: inline-flex; align-items: center; gap: 6px; }
.entry .meta .ic { color: var(--muted); }

/* ---------- 7. 배지 / 상태 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: var(--fs-meta); font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.badge .ic { width: 1em; height: 1em; vertical-align: -0.15em; }
.badge-ok   { background: var(--ok-soft);   color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge-bad  { background: var(--bad-soft);  color: var(--bad);  border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-card); border: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-body); color: var(--ink-2); }
.notice .ic { margin-top: 2px; color: var(--muted); }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--ink); }
.notice-warn .ic { color: var(--warn); }
.notice-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.notice-bad .ic { color: var(--bad); }
.notice-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.notice-ok .ic { color: var(--ok); }

/* ---------- 8. 표 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: var(--fs-meta); font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td .cell { display: block; }
.table td.num, .table th.num { white-space: nowrap; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr[tabindex] { cursor: pointer; }
.table tbody tr[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table tbody tr[tabindex]:focus-visible td { background: var(--surface-2); }
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table-stack td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; }
  .table-stack td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-meta); flex: none; padding-top: 2px; }
  .table-stack td .cell { text-align: right; }
  .table-stack td.na { display: none; }
  .table-stack td[colspan] { display: block; }
  .table-stack td[colspan]::before { content: none; }
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.stat { padding: 16px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .v { font: 600 1.75rem/1.1 var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.stat .l { font-size: var(--fs-meta); color: var(--muted); margin-top: 6px; }

/* ---------- 9. 모달 / 토스트 / 상태 화면 ---------- */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: none; align-items: center; justify-content: center; padding: 16px; background: rgb(8 12 20 / .55); }
.modal.open, .modal[style*="flex"] { display: flex; }
.modal-card { width: min(420px, 100%); max-height: 88dvh; overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
@media (max-width: 560px) { .modal { align-items: flex-end; padding: 0; } .modal-card { border-radius: var(--r-card) var(--r-card) 0 0; width: 100%; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 8px); z-index: var(--z-toast); max-width: min(92vw, 420px); padding: 12px 16px; background: var(--ink); color: var(--bg); border-radius: var(--r-ctl); font-size: var(--fs-body); box-shadow: var(--shadow-pop); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s, transform .2s, visibility .2s; }
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { width: 2rem; height: 2rem; margin-bottom: 10px; color: var(--line-strong); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-ctl); min-height: 16px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--line) 70%, transparent), transparent); animation: sk 1.4s infinite; }
@keyframes sk { to { transform: translateX(100%); } }

.footer { text-align: center; color: var(--muted); font-size: var(--fs-fine); margin-top: 32px; padding: 8px 0 24px; }

/* 처리 중 오버레이: 서버 요청 동안 화면을 막음 (표시/숨김은 인라인 display 로 전환) */
.busy { position: fixed; inset: 0; z-index: var(--z-modal); display: none; align-items: center; justify-content: center; background: rgb(8 12 20 / .5); }
.busy .busy-card { min-width: 220px; padding: 18px 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); text-align: center; font-weight: 600; }
.busy .bar { position: relative; height: 4px; margin-top: 12px; overflow: hidden; border-radius: var(--r-pill); background: var(--surface-2); }
.busy .bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: inherit; background: var(--accent); animation: bar 1.1s ease-in-out infinite; }
@keyframes bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .slider { opacity: .45; }

/* ---------- 9-1. 시간/날짜 선택기(flatpickr) 테마 ---------- */
.flatpickr-calendar { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-pop); font-family: var(--font); }
.flatpickr-calendar:before, .flatpickr-calendar:after { display: none; }
.flatpickr-time { border-top: 1px solid var(--line); }
.flatpickr-time input, .flatpickr-time .flatpickr-am-pm { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.flatpickr-time input:hover, .flatpickr-time .flatpickr-am-pm:hover, .flatpickr-time input:focus { background: var(--surface-2); }
.flatpickr-time .flatpickr-time-separator { color: var(--muted); }
.numInputWrapper span.arrowUp:after { border-bottom-color: var(--muted); }
.numInputWrapper span.arrowDown:after { border-top-color: var(--muted); }

/* ---------- 10. 진입 모션 (절제) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .reveal > * { animation: rise .45s cubic-bezier(.16,1,.3,1) both; }
  .reveal > *:nth-child(2) { animation-delay: .04s; }
  .reveal > *:nth-child(3) { animation-delay: .08s; }
  .reveal > *:nth-child(4) { animation-delay: .12s; }
  .reveal > *:nth-child(5) { animation-delay: .16s; }
  .reveal > *:nth-child(n+6) { animation-delay: .2s; }
  .modal-card { animation: pop .18s cubic-bezier(.16,1,.3,1); }
}

/* 공용 화면 모션 (static/js/motion.js): "패스로 나갔다 들어오는" 이야기를 모든 화면에서 이어 받음
   - 제목 아래 외출 경로(점이 문에 도착한 모습), 로그인 뒤 그 화면을 처음 열 때만 점이 걸어 들어옴
   - 내용이 차례로 올라옴, 마우스를 올리면 메뉴 카드의 아이콘·화살표가 앞으로, 누르면 누른 자리에서 물결 */
.arrive { position: relative; display: block; width: min(220px, 70%); height: 2px; margin: 14px 0 6px;
          background: repeating-linear-gradient(90deg, var(--line-strong) 0 7px, transparent 7px 12px); transform-origin: left; }
.arrive .dot { position: absolute; z-index: 1; top: -5px; left: calc(100% - 8px); width: 12px; height: 12px; border-radius: 50%;
               background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.arrive .gate { position: absolute; top: -7px; right: -2px; width: 2px; height: 16px; border-radius: 2px; background: var(--line-strong); }
.action, .btn { position: relative; overflow: hidden; }
.ripple { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; pointer-events: none;
          background: color-mix(in srgb, var(--accent) 22%, transparent); }
.action.primary .ripple, .btn-primary .ripple { background: color-mix(in srgb, var(--accent-ink) 30%, transparent); }
.btn-ok .ripple { background: color-mix(in srgb, var(--on-ok) 30%, transparent); }
@media (prefers-reduced-motion: no-preference) {
  .action .ico, .action .go { transition: transform .2s cubic-bezier(.16,1,.3,1); }
  .action:hover .ico { transform: translateX(2px); }
  .action:hover .go { transform: translateX(4px); }
  .ripple { animation: ripple .5s ease-out forwards; }
  .motion-in { animation: enter .55s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(.12s + var(--i, 0) * 55ms); }
  .arrive { animation: route .5s .1s cubic-bezier(.65,0,.35,1) both; }
  .arrive .dot { animation: arrive .7s .1s cubic-bezier(.65,0,.35,1) both, ping .8s .8s ease-out; }
  .arrive .gate { animation: gate .3s .45s ease-out both; }

  /* 화면 사이 이동: 브라우저 기본 기능(View Transitions). 위 막대는 그대로 두고 본문만 왼쪽으로 나가고 오른쪽에서 들어옴 (지원 안 하는 브라우저는 그냥 이동) */
  @view-transition { navigation: auto; }
  .appbar { view-transition-name: appbar; }
  ::view-transition-old(root) { animation: page-out .18s ease-in both; }
  ::view-transition-new(root) { animation: page-in .32s cubic-bezier(.16,1,.3,1) both; }
}
@keyframes enter { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes page-out { to { opacity: 0; transform: translateX(-24px); } }
@keyframes page-in { from { opacity: 0; transform: translateX(32px); } }
@keyframes route { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes arrive { from { left: -6px; } to { left: calc(100% - 8px); } }
@keyframes gate { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ping { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } to { box-shadow: 0 0 0 10px transparent; } }
@keyframes ripple { to { transform: scale(28); opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
/* 동작 줄이기: 움직임(이동·확대·흐르는 효과)만 끄고, 색 변화와 "처리 중" 표시는 깜빡임으로 남김 */
@media (prefers-reduced-motion: reduce) {
  .btn:active, .action:active { transform: none; }
  .switch .slider::before { transition: none; }
  .skeleton::after { animation: none; }
  .busy .bar::after { width: 100%; transform: none; animation: blink 1.4s ease-in-out infinite; }
}
@keyframes blink { 50% { opacity: .35; } }
