/* ==========================================================================
   디자인 시스템 — 토스 스타일 (밝은 회색 배경 + 흰 카드, 파란 강조, 큰 타이포)
   색은 모두 토큰으로 쓰고, 다크 모드는 토큰만 바꾼다.
   ========================================================================== */

:root {
  --blue-50: #e8f3ff;
  --blue-100: #c9e2ff;
  --blue-500: #3182f6;
  --blue-600: #2272eb;
  --blue-700: #1b64da;
  --red-50: #ffeeee;
  --red-500: #f04452;
  --orange-50: #fff3e0;
  --orange-500: #fe9800;
  --green-50: #f0faf6;
  --green-500: #03b26c;

  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-2: #f9fafb; /* 입력칸, hover */
  --surface-3: #f2f4f6; /* 보조 버튼 */
  --border: #e5e8eb;
  --border-strong: #d1d6db;
  --text: #191f28;
  --text-2: #4e5968;
  --text-3: #8b95a1;
  --text-4: #b0b8c1;
  --primary: var(--blue-500);
  --primary-hover: var(--blue-600);
  --primary-weak: var(--blue-50);
  --primary-weak-text: var(--blue-600);
  --danger: var(--red-500);
  --danger-weak: var(--red-50);
  --warning: var(--orange-500);
  --warning-weak: var(--orange-50);
  --success: var(--green-500);
  --success-weak: var(--green-50);
  --toast-bg: rgba(51, 61, 75, 0.96);
  --backdrop: rgba(0, 23, 51, 0.38);
  --shadow: 0 2px 8px rgba(0, 27, 55, 0.05);
  --shadow-lg: 0 16px 48px rgba(0, 27, 55, 0.16);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  --topbar-h: 60px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101013;
    --surface: #1c1c21;
    --surface-2: #26262c;
    --surface-3: #2c2c34;
    --border: #2f2f37;
    --border-strong: #3d3d47;
    --text: #f2f3f5;
    --text-2: #c3c8cf;
    --text-3: #8d939c;
    --text-4: #5f646c;
    --primary-weak: rgba(49, 130, 246, 0.16);
    --primary-weak-text: #64a8ff;
    --danger-weak: rgba(240, 68, 82, 0.16);
    --warning-weak: rgba(254, 152, 0, 0.16);
    --success-weak: rgba(3, 178, 108, 0.16);
    --toast-bg: rgba(60, 60, 70, 0.96);
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: none;
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* --- 기본 ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.02em; line-height: 1.35; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0 0 12px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
[x-cloak] { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.pre { white-space: pre-wrap; }
.num { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }

/* --- 레이아웃 --------------------------------------------------------------- */

.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.page-narrow { max-width: 640px; }
.page-header { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header .sub { margin: 4px 0 0; color: var(--text-3); font-size: 15px; }
.page-header .actions { margin-left: auto; display: flex; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.back:hover { color: var(--text-2); }

.card { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.card-header h3 { margin-right: auto; }
.card.flush { padding: 8px 0; }
.card.flush > .card-header { padding: 16px 24px 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

/* --- 상단 바 / 하단 탭 바 ---------------------------------------------------- */

.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1080px; margin: 0 auto; height: var(--topbar-h); padding: 0 24px; display: flex; align-items: center; gap: 4px; }
.brand { font-size: 18px; font-weight: 800; color: var(--text); margin-right: 20px; letter-spacing: -0.03em; }
.brand:hover { color: var(--text); }
.nav-link { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: 15px; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-3); }
.topbar .who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 14px; }

.tabbar { display: none; }

@media (max-width: 768px) {
  .page { padding: 20px 16px calc(var(--tabbar-h) + 32px); }
  .topbar .nav-link, .topbar .who { display: none; }
  .topbar-inner { padding: 0 16px; height: 52px; }
  h1 { font-size: 22px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tabbar > a, .tabbar > button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--text-4); font: 600 11px var(--font); background: none; border: 0; cursor: pointer;
  }
  .tabbar > * > svg { width: 24px; height: 24px; }
  .tabbar > .active { color: var(--text); }
  .page-header .actions { margin-left: 0; width: 100%; }
}

/* --- 버튼 ------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius);
  font: 600 15px/1 var(--font); letter-spacing: -0.01em; white-space: nowrap;
  background: var(--primary); color: #fff; cursor: pointer;
  transition: background-color .15s, transform .1s, opacity .15s;
}
.btn:hover { background: var(--primary-hover); color: #fff; }
.btn:active { transform: scale(0.97); }
.btn:disabled, .btn.htmx-request { opacity: .5; pointer-events: none; }
.btn:focus-visible { outline: 3px solid var(--blue-100); outline-offset: 1px; }
.btn-weak { background: var(--primary-weak); color: var(--primary-weak-text); }
.btn-weak:hover { background: color-mix(in srgb, var(--primary-weak) 80%, var(--primary) 20%); color: var(--primary-weak-text); }
.btn-secondary { background: var(--surface-3); color: var(--text-2); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger-weak); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger-weak) 75%, var(--danger) 25%); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-3); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 56px; padding: 0 24px; font-size: 17px; border-radius: 16px; }
.btn-block { display: flex; width: 100%; }

/* --- 입력 ------------------------------------------------------------------ */

.field { display: block; margin-bottom: 20px; }
.field-label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.field-label .req { color: var(--primary); margin-left: 2px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, textarea.input {
  display: block; width: 100%; height: 48px; padding: 0 16px;
  font: 400 16px var(--font); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  outline: none; transition: border-color .15s, box-shadow .15s, background-color .15s;
  appearance: none;
}
.field textarea, textarea.input { height: auto; min-height: 96px; padding: 12px 16px; line-height: 1.6; resize: vertical; }
.field select { padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b95a1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder, textarea.input::placeholder { color: var(--text-4); }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, textarea.input:focus {
  background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
[aria-invalid=true], [aria-invalid=true]:focus { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent) !important; }
.field-help, .field-error { display: block; margin-top: 6px; font-size: 13px; }
.field-help { color: var(--text-3); }
.field-error { color: var(--danger); font-weight: 500; }
.error { color: var(--danger); }

.search { position: relative; flex: 1; min-width: 200px; }
.search .input { padding-left: 44px; background-color: var(--surface); }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-4); pointer-events: none; }

/* 체크박스 */
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; cursor: pointer; font-size: 15px; color: var(--text-2); user-select: none; }
.check input { appearance: none; margin: 0; width: 22px; height: 22px; flex: none; border-radius: 7px; border: 2px solid var(--border-strong); background: var(--surface); cursor: pointer; transition: all .15s; }
.check input:checked { border-color: var(--primary); background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center/14px no-repeat; }

/* 칩 (라디오 필터) */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips label { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface); color: var(--text-2); font-size: 14px; font-weight: 600; border: 1px solid var(--border); transition: all .15s; }
.chips input:checked + span { background: var(--text); border-color: var(--text); color: var(--surface); }
.chips input:focus-visible + span { outline: 3px solid var(--blue-100); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* --- 표 (목록) -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table .name { color: var(--text); font-weight: 600; }
.table .name:hover { color: var(--primary); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 4px; }
.table tr.inactive td { color: var(--text-4); }
.empty { padding: 48px 16px !important; text-align: center; color: var(--text-3); }
.htmx-request.table-body, tbody.htmx-request { opacity: .5; transition: opacity .2s; }

/* --- 배지 ------------------------------------------------------------------ */

.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-blue, .badge.active { background: var(--primary-weak); color: var(--primary-weak-text); }
.badge-orange, .badge.paused { background: var(--warning-weak); color: var(--warning); }
.badge-grey, .badge.withdrawn { background: var(--surface-3); color: var(--text-3); }
.badge-red { background: var(--danger-weak); color: var(--danger); }
.badge-green { background: var(--success-weak); color: var(--success); }

/* --- 대시보드 숫자 카드 --------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { display: block; background: var(--surface); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow); color: inherit; transition: transform .15s; }
a.stat:hover { color: inherit; transform: translateY(-2px); }
.stat .label { font-size: 14px; font-weight: 500; color: var(--text-3); }
.stat .value { margin-top: 6px; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 17px; font-weight: 600; margin-left: 2px; color: var(--text-2); }
.stat.is-alert .value { color: var(--danger); }

/* --- 탭 -------------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); margin: 0 0 20px; scrollbar-width: none; }
.tabs button { flex: none; position: relative; padding: 12px 12px 14px; border: 0; background: none; cursor: pointer; font: 600 16px var(--font); color: var(--text-4); transition: color .15s; }
.tabs button:hover { color: var(--text-2); }
.tabs button.active { color: var(--text); }
.tabs button.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }

/* --- 키-값 목록 ------------------------------------------------------------- */

.kv { margin: 0; }
.kv > div { display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { flex: none; width: 120px; color: var(--text-3); font-size: 15px; }
.kv dd { margin: 0; flex: 1; min-width: 0; color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- 항목 목록 (보호자, 상담) --------------------------------------------------- */

.list-item { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--text); }
.list-item .desc { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-weak); color: var(--primary-weak-text); font-weight: 700; font-size: 15px; }
.memo { padding: 16px 0; border-bottom: 1px solid var(--border); }
.memo:last-child { border-bottom: 0; }
.memo .meta { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-3); margin-bottom: 6px; }
.memo .meta strong { color: var(--text-2); font-weight: 600; }
.memo .body { color: var(--text); white-space: pre-wrap; }
.subform { margin-top: 16px; padding: 20px; border-radius: 16px; background: var(--surface-2); }

/* --- 모달 (데스크톱은 가운데, 모바일은 바텀시트) ------------------------------------- */

dialog.modal {
  width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 64px); padding: 0; border: 0;
  border-radius: var(--radius-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: auto; animation: modal-in .2s ease-out;
}
dialog.modal::backdrop { background: var(--backdrop); animation: fade-in .2s ease-out; }
.modal-header { display: flex; align-items: center; padding: 24px 24px 8px; }
.modal-header h2 { margin-right: auto; font-size: 22px; }
.modal-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-3); color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 24px 8px; }
.modal-desc { color: var(--text-3); font-size: 14px; margin: -4px 0 20px; }
.modal-footer { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 16px 24px 24px; background: var(--surface); }
.modal-footer .btn { flex: 1; height: 52px; font-size: 16px; border-radius: 14px; }
.modal-footer .btn-secondary { flex: 0 0 35%; }

@media (max-width: 768px) {
  dialog.modal {
    width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0; animation: sheet-in .25s cubic-bezier(.2, .8, .2, 1);
  }
  .modal-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
dialog.confirm { width: min(360px, calc(100% - 48px)); margin: auto; border-radius: var(--radius-xl); animation: modal-in .2s ease-out; }
dialog.confirm .modal-body { padding: 28px 24px 8px; font-size: 17px; font-weight: 600; color: var(--text); white-space: pre-line; }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }

/* --- 토스트 ----------------------------------------------------------------- */

.toasts { position: fixed; left: 0; right: 0; bottom: 32px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: calc(100% - 32px); padding: 14px 20px; border-radius: 14px; background: var(--toast-bg); color: #fff; font-size: 15px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toast-in .25s cubic-bezier(.2, .8, .2, 1); }
.toast.error::before { content: "!"; display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 8px; border-radius: 50%; background: var(--danger); font-size: 13px; font-weight: 800; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: all .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@media (max-width: 768px) { .toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }

/* --- 로그인 ----------------------------------------------------------------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 400px; }
.login-box h1 { font-size: 28px; margin-bottom: 8px; }
.login-box .sub { color: var(--text-3); margin-bottom: 32px; }
.login-box .card { padding: 32px 28px; }
.alert { padding: 14px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; margin-bottom: 20px; }
.alert-error { background: var(--danger-weak); color: var(--danger); }
.alert-success { background: var(--success-weak); color: var(--success); }

/* --- 단계 안내 / 업로드 -------------------------------------------------------- */

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 8px; }
.steps li { counter-increment: step; position: relative; padding: 0 0 16px 40px; color: var(--text-2); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-weak); color: var(--primary-weak-text); font-size: 13px; font-weight: 700; }
.dropzone { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 20px; border: 2px dashed var(--border-strong); border-radius: 16px; background: var(--surface-2); }
.dropzone input[type=file] { flex: 1; min-width: 200px; font: 500 14px var(--font); color: var(--text-2); }
.dropzone input[type=file]::file-selector-button { margin-right: 12px; height: 36px; padding: 0 14px; border: 0; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font: 600 14px var(--font); cursor: pointer; }

.result-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 16px; font-size: 26px; font-weight: 800; }
.result-icon.ok { background: var(--primary-weak); color: var(--primary); }
.result-icon.fail { background: var(--danger-weak); color: var(--danger); }

/* 회색 페이지 배경 위의 보조 버튼은 흰 바탕으로 (카드 안에서는 회색) */
.page-header .btn-secondary, .page > .toolbar .btn-secondary { background: var(--surface); box-shadow: var(--shadow); }
.page-header .btn-secondary:hover, .page > .toolbar .btn-secondary:hover { background: var(--surface-2); }

/* 모바일 전용 / 데스크톱 전용 */
.m-only { display: none; }
.table td.num, .nowrap { white-space: nowrap; }
@media (max-width: 768px) {
  .d-only { display: none !important; }
  .m-only { display: block; }
  .table th:first-child, .table td:first-child { padding-left: 20px; }
  .table th:last-child, .table td:last-child { padding-right: 20px; }
  .table td { padding: 14px 8px; }
  .table .desc { margin-top: 2px; font-size: 13px; color: var(--text-3); font-weight: 400; }
}

/* --- 경고 / 세그먼트 / 시간표 슬롯 ------------------------------------------------- */

.alert-warning { background: var(--warning-weak); color: var(--text-2); }
.alert-warning strong { display: block; color: var(--warning); margin-bottom: 4px; }
.alert ul { margin: 4px 0 6px; padding-left: 18px; }

.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--border); margin-bottom: 20px; }
.segmented a { padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-3); }
.segmented a:hover { color: var(--text-2); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.slots { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { display: inline-flex; align-items: center; gap: 10px; padding: 10px 8px 10px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.slot .day { font-weight: 700; color: var(--primary); }
.slot .time { font-weight: 600; font-variant-numeric: tabular-nums; }
.slot .btn { height: 28px; width: 28px; padding: 0; border-radius: 50%; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; flex: 1; min-width: 120px; }
.inline-form .field.narrow { flex: 0 0 110px; min-width: 0; }

.sched-list { display: flex; flex-wrap: wrap; gap: 4px; }
.sched-list span { font-size: 13px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }

tr.is-cancelled td { color: var(--text-4); }
tr.is-cancelled td.when { text-decoration: line-through; }
tr.is-past td { color: var(--text-3); }
tr.is-today { background: color-mix(in srgb, var(--primary-weak) 55%, transparent); }

.search-results { margin-top: 8px; max-height: 280px; overflow: auto; }
.search-results .list-item { padding: 10px 0; }

/* --- FullCalendar 테마 ----------------------------------------------------------- */

.calendar-card { padding: 16px 16px 8px; }
.fc { --fc-border-color: var(--border); --fc-page-bg-color: var(--surface); --fc-neutral-bg-color: var(--surface-2);
      --fc-today-bg-color: color-mix(in srgb, var(--primary-weak) 50%, transparent); --fc-now-indicator-color: var(--danger);
      --fc-event-border-color: transparent; font-size: 13px; }
.fc .fc-toolbar { flex-wrap: wrap; gap: 8px; }
.fc .fc-toolbar-title { font-size: 20px; font-weight: 700; color: var(--text); }
.fc .fc-button { height: 36px; padding: 0 14px; border: 0; border-radius: 10px !important; background: var(--surface-3); color: var(--text-2);
                 font: 600 14px var(--font); box-shadow: none !important; text-transform: none; }
.fc .fc-button:hover { background: var(--border); color: var(--text); }
.fc .fc-button-primary:not(:disabled).fc-button-active, .fc .fc-button-primary:not(:disabled):active { background: var(--text); color: var(--surface); }
.fc .fc-button:disabled { opacity: .4; background: var(--surface-3); color: var(--text-2); }
.fc .fc-button-group { gap: 4px; }
.fc .fc-col-header-cell-cushion { padding: 10px 4px; color: var(--text-2); font-weight: 600; }
.fc .fc-timegrid-slot-label-cushion, .fc .fc-timegrid-axis-cushion { color: var(--text-3); font-size: 12px; }
.fc .fc-timegrid-slot { height: 2.2em; }
.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--border); }
.fc .fc-scrollgrid { border-radius: 12px; overflow: hidden; }
.fc-v-event, .fc-h-event { border-width: 0 0 0 3px !important; border-radius: 6px !important; cursor: pointer; }
.fc-v-event .fc-event-main { color: inherit; padding: 3px 5px; }
.fc-event-title { font-weight: 700; }
.fc .ev-meta { font-size: 11px; opacity: .85; }
.fc .is-cancelled { opacity: .45; }
.fc .is-cancelled .fc-event-title { text-decoration: line-through; }
.fc .is-makeup { border-left-style: dashed !important; }
.fc .fc-list-event:hover td { background: var(--surface-2); }
.fc .fc-list-day-cushion { background: var(--surface-2); }
@media (max-width: 768px) { .fc .fc-toolbar-title { font-size: 17px; } }

/* --- 출결 ------------------------------------------------------------------- */

.t-blue { color: var(--primary); }
.t-orange { color: var(--warning); }
.t-red { color: var(--danger); }
.btn-icon { width: 40px; padding: 0; }

.day-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.day-label { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); font-size: 16px; cursor: pointer; }
.day-label input[type=date] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.day-label input[type=date]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.session-list { display: grid; gap: 12px; }
.session-card { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); color: inherit; transition: transform .1s; }
.session-card:hover { color: inherit; }
.session-card:active { transform: scale(.99); }
.session-card .time { flex: none; width: 56px; display: flex; flex-direction: column; }
.session-card .time strong { font-size: 18px; font-weight: 700; }
.session-card .time span { font-size: 13px; color: var(--text-3); }
.session-card .main { flex: 1; min-width: 0; }
.session-card .title { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.session-card .title .color-dot { margin-right: 2px; }
.session-card .desc { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.session-card.is-cancelled { opacity: .55; }
.progress { height: 6px; margin-top: 12px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 3px; background: var(--primary); transition: width .3s; }
.mini-counts { display: flex; gap: 10px; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--text-3); }

.att-counts { display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 16px; padding: 16px 8px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.att-counts .label { display: block; font-size: 13px; color: var(--text-3); }
.att-counts strong { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.att-tile { position: relative; }
.att-tile .main {
  width: 100%; min-height: 96px; padding: 14px 10px; border-radius: 18px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); font-family: var(--font); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: background-color .12s, border-color .12s, transform .08s; -webkit-tap-highlight-color: transparent; user-select: none;
}
.att-tile .main:active { transform: scale(.95); }
.att-tile .main:disabled { cursor: default; opacity: .7; }
.att-tile .name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.att-tile .state { font-size: 13px; font-weight: 600; color: var(--text-4); }
.att-tile.present .main { background: var(--primary-weak); border-color: var(--primary); }
.att-tile.present .state { color: var(--primary); }
.att-tile.late .main { background: var(--warning-weak); border-color: var(--warning); }
.att-tile.late .state { color: var(--warning); }
.att-tile.absent .main { background: var(--danger-weak); border-color: var(--danger); }
.att-tile.absent .state { color: var(--danger); }
.att-tile.excused .main { background: var(--surface-3); border-color: var(--border-strong); }
.att-tile.excused .state { color: var(--text-2); }
.att-tile.htmx-request .main { opacity: .6; }
.att-tile .more { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); font-size: 16px; line-height: 1; cursor: pointer; }
.att-tile .more:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.memo-dot { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 0 6px; border-radius: 4px; background: color-mix(in srgb, var(--text) 6%, transparent); }

@media (max-width: 768px) {
  .att-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .att-tile .main { min-height: 88px; }
  .att-counts strong { font-size: 20px; }
  .session-card { padding: 16px; }
}

/* 학생 출결 이력 요약 */
.att-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; margin-bottom: 16px; }
.att-summary .item { padding: 14px 16px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.att-summary .label { font-size: 13px; color: var(--text-3); }
.att-summary strong { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-nav strong { font-size: 17px; min-width: 96px; text-align: center; }

/* --- 수납 ------------------------------------------------------------------- */

.banner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; padding: 18px 20px; border-radius: var(--radius-lg); background: var(--primary-weak); }
.banner > div { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.banner strong { color: var(--primary-weak-text); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.link-btn:hover { color: var(--primary); }
.quick-method select { height: 48px; min-width: 150px; background-color: var(--surface); }
.segmented a.disabled { color: var(--text-4); cursor: default; }
@media (max-width: 768px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 16px; }
  .stat .value { font-size: 22px; }
  .stat .value small { font-size: 14px; }
}

/* --- 알림 ------------------------------------------------------------------- */

.channel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card .channel-cards { margin-bottom: 0; }
.channel-card { padding: 16px 18px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card .channel-card { box-shadow: none; background: var(--surface-2); }
.channel-card .head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.channel-card p { margin: 0; font-size: 14px; color: var(--text-2); }
.channel-card.is-test { border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.channel-card.is-bad { border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.msg-cell { max-width: 420px; font-size: 14px; }
.grid-test { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin: 16px 0; }
.grid-test .card + .card { margin-top: 0; }

.tpl-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 768px) { .tpl-grid { grid-template-columns: 1fr; } }
.tpl-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-btn { height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); color: var(--text-2); font: 500 13px var(--font); cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.phone-preview { padding: 16px; border-radius: 20px; background: var(--surface-3); }
.bubble { display: inline-block; max-width: 100%; padding: 12px 14px; border-radius: 4px 18px 18px 18px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-all; box-shadow: var(--shadow); }
.bubble.is-failed { opacity: .6; }
.inbox { display: grid; gap: 14px; }
.inbox-item .meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.inbox-item .bubble { background: var(--surface-2); box-shadow: none; border: 1px solid var(--border); }

.switch { position: relative; flex: none; width: 52px; height: 32px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--border-strong); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--danger); }
.switch input:checked + span::after { transform: translateX(20px); }

/* --- 입금 매칭 --------------------------------------------------------------- */

pre.code { margin: 8px 0 0; padding: 12px; border-radius: 10px; background: var(--surface-3); font-size: 12px; white-space: pre-wrap; word-break: break-all; color: var(--text-2); }
.link-total { margin-top: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.list-item.check { align-items: flex-start; }
.list-item.check input { margin-top: 2px; }

/* --- 대시보드 ---------------------------------------------------------------- */

.dash-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.dash-grid .stack > .card + .card { margin-top: 16px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.card-header a.small { display: inline-flex; align-items: center; gap: 2px; color: var(--text-3); font-weight: 500; }
.card-header a.small svg { width: 16px; height: 16px; }
.dash-session { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); color: inherit; }
.dash-session:last-child { border-bottom: 0; }
.dash-session:hover { color: inherit; }
.dash-session .time { flex: none; width: 46px; font-weight: 700; padding-top: 1px; }
.dash-session .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-session .title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dash-session .title .color-dot { margin-right: 0; }
.dash-session .desc { font-size: 13px; color: var(--text-3); }
.dash-session .progress { margin-top: 6px; height: 4px; }
.dash-session.is-cancelled { opacity: .55; }
.todo { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); font-weight: 500; }
.todo:last-child { border-bottom: 0; }
.todo:hover { color: var(--primary); }
.todo .main { flex: 1; }
.pay-progress { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.pay-progress span { display: block; height: 100%; background: var(--primary); border-radius: 5px; }
a.banner:hover { color: inherit; }

/* --- 데모판 배너 ----------------------------------------------------------------- */

.demo-banner { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; background: var(--text); color: var(--surface); font-size: 13px; text-align: center; }
.demo-banner strong { padding: 1px 8px; border-radius: 6px; background: var(--primary); color: #fff; font-size: 12px; }
