/* ==========================================================================
   TinySteps — design tokens
   새싹 초록 · 심플 · 가독성 우선 (본문 16px, 대비 4.5:1 이상, 터치 영역 44px)
   ========================================================================== */
:root {
  /* brand: fresh sprout green */
  --green-50: #effaf3;
  --green-100: #dcf3e4;
  --green-200: #b5e6c6;
  --green-400: #3cc873;
  --green-500: #1fa055;
  --green-600: #178046; /* text & buttons on white: 5.0:1 */
  --green-700: #116637;

  /* neutrals (slightly green-tinted) */
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #f1f4f2;
  --border: #e1e7e3;
  --border-strong: #c9d2cc;
  --text: #17201b;
  --text-2: #3d4a43;
  --muted: #5d6b64; /* 5.4:1 on white */

  /* status */
  --done: var(--green-600);
  --done-soft: var(--green-50);
  --makeup: #2563eb;
  --makeup-soft: #e8f0fe;
  --absent: #d0362f;
  --absent-soft: #fdecea;
  --cancel: #8f5f00;      /* text on light (5.6:1) */
  --cancel-mark: #c98500; /* marks & chart series (validated vs done/makeup/absent) */
  --cancel-soft: #fff4e0;
  --pending-soft: #fff7d6;
  --pending: #7a5a00;
  --holiday: #d0362f;
  --holiday-soft: #fff5f4;
  --saturday: #2563eb;
  --today-soft: #f2fbf5;

  --primary: var(--green-600);
  --primary-hover: var(--green-700);
  --primary-soft: var(--green-50);
  --danger: var(--absent);
  --focus: 0 0 0 3px rgb(31 160 85 / 0.35);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgb(16 24 20 / 0.05);
  --shadow-lg: 0 8px 28px rgb(16 24 20 / 0.12);
  --gutter: 16px;
  --topbar-h: 60px;

  font-family: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  word-break: keep-all;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
h1, h2, h3 { line-height: 1.3; letter-spacing: -0.01em; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 24px 16px; }
.prewrap { white-space: pre-wrap; }
.span-all { grid-column: 1 / -1; }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgb(255 255 255 / 0.96);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 20px;
  max-width: 1440px; min-height: var(--topbar-h); margin: 0 auto; padding: 0 var(--gutter);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none;
}
.brand img { width: 30px; height: 30px; }
.brand:hover { color: var(--text); }

.nav { order: 2; flex: 1 1 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.menu { display: flex; flex-wrap: wrap; gap: 2px; margin: 0; padding: 0; list-style: none; }
.menu a {
  display: block; padding: 7px 11px; border-radius: 999px; white-space: nowrap;
  color: var(--text-2); text-decoration: none; font-size: 0.95rem; font-weight: 500;
}
.menu a:hover { background: var(--surface-2); color: var(--text); }
.menu a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.menu-admin { padding-left: 8px; border-left: 1px solid var(--border); }
.menu-admin a { color: var(--muted); }

.usermenu { order: 3; margin-left: auto; position: relative; }
.usermenu summary {
  display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer;
  padding: 6px 8px 6px 12px; border-radius: 999px; border: 1px solid var(--border); font-size: 0.95rem;
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--surface-2); }
.username { font-weight: 600; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 160px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.dropdown a, .dropdown button {
  display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--radius-sm);
  background: none; font: inherit; text-align: left; color: var(--text); text-decoration: none; cursor: pointer;
}
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-size: 0.78rem; font-weight: 700;
}

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-toggle-label { display: none; }

@media (max-width: 900px) {
  .topbar-row { gap: 0 8px; }
  .nav-toggle-label {
    display: grid; place-items: center; order: 4; width: 44px; height: 44px; margin-right: -8px;
    font-size: 1.4rem; cursor: pointer; user-select: none; border-radius: var(--radius-sm);
  }
  .nav-toggle:focus-visible + .nav-toggle-label { box-shadow: var(--focus); }
  .usermenu summary { border: 0; padding: 6px; }
  .usermenu .badge { display: none; }
  .nav {
    display: none; order: 5; flex: 1 1 100%; flex-direction: column; align-items: stretch;
    padding: 8px 0 14px; border-top: 1px solid var(--border);
  }
  .nav-toggle:checked ~ .nav { display: flex; }
  .menu { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .menu a { padding: 12px 14px; border-radius: var(--radius); font-size: 1rem; }
  .menu-admin { border-left: 0; border-top: 1px solid var(--border); padding: 10px 0 0; margin-top: 6px; }
}

/* ==========================================================================
   Layout
   ========================================================================== */
.container { max-width: 1440px; margin: 0 auto; padding: 20px var(--gutter) 48px; }
.page-title { font-size: 1.5rem; font-weight: 800; margin: 4px 0 18px; }
.section-title { font-size: 1.1rem; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.card + .card, .card + .table-scroll, .table-scroll + .card, details.card + .table-scroll { margin-top: 16px; }
.error-code { font-size: 2.5rem; font-weight: 800; margin: 0; color: var(--green-200); }

@media (max-width: 600px) {
  .container { padding-top: 14px; }
  .page-title { font-size: 1.3rem; margin-bottom: 14px; }
  .card { padding: 16px; border-radius: var(--radius); }
}

/* ==========================================================================
   Alerts, chips
   ========================================================================== */
.alert { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius); font-weight: 500; }
.alert-ok { background: var(--done-soft); color: var(--green-700); border: 1px solid var(--green-100); }
.alert-error { background: var(--absent-soft); color: var(--absent); border: 1px solid #f8d3cf; }
.alert-info { background: var(--primary-soft); color: var(--text-2); border: 1px solid var(--green-100); }
.card.narrow { max-width: 480px; }
.form label .hint { font-weight: 400; font-size: 0.82rem; color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.status-done { background: var(--done-soft); color: var(--done); }
.status-absent { background: var(--absent-soft); color: var(--absent); }
.status-cancelled { background: var(--cancel-soft); color: var(--cancel); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.tag-makeup { background: var(--makeup-soft); color: var(--makeup); }
.tag-pending { background: var(--pending-soft); color: var(--pending); }
.tag-over { background: var(--absent-soft); color: var(--absent); }
.status-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 12px; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f1b8b3; }
.btn-danger:hover { background: var(--absent-soft); color: var(--danger); }
.btn-icon { min-height: 36px; min-width: 36px; padding: 0 8px; font-size: 1.15rem; line-height: 1; }
.btn-small { min-height: 32px; padding: 4px 12px; font-size: 0.85rem; }
.btn-lg { min-height: 50px; padding: 12px 18px; font-size: 1.05rem; flex: 1; border-radius: var(--radius); }
.btn-st-done { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-st-done:hover { background: var(--primary-hover); color: #fff; }
.btn-st-absent { color: var(--absent); border-color: #f1b8b3; }
.btn-st-absent:hover { background: var(--absent-soft); color: var(--absent); }
.btn-st-cancelled { color: var(--cancel); border-color: #f0d29c; }
.btn-st-cancelled:hover { background: var(--cancel-soft); color: var(--cancel); }
.btn-st-scheduled { color: var(--muted); font-weight: 500; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ==========================================================================
   Forms
   ========================================================================== */
input[type="text"], input[type="password"], input[type="date"], input[type="time"],
input[type="tel"], input[type="number"], select, textarea {
  font: inherit; font-size: 1rem; font-weight: 400; min-height: 44px; padding: 9px 12px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
select { width: auto; padding-right: 32px; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: var(--focus); }
input:disabled { background: var(--surface-2); color: var(--muted); }
::placeholder { color: #8c9a93; }

.form { display: flex; flex-direction: column; gap: 16px; }
.form label, .form-grid label, .form-inline label {
  display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--text-2);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; align-items: end; margin-top: 14px; }
.form-grid select { width: 100%; }
.form-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin: 10px 0; }
.form-inline input, .form-inline select { width: auto; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }

details > summary { cursor: pointer; color: var(--primary); font-weight: 600; list-style-position: inside; }
details > summary::marker { color: var(--green-400); }
details.collapsible { margin-bottom: 16px; }
details.collapsible > summary { padding: 2px 0; }
details.inline { display: inline-block; margin-right: 12px; vertical-align: top; }
details.inline > summary { font-size: 0.92rem; }
details.inline[open] {
  display: block; margin: 10px 0; padding: 14px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
}
details.sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.sub-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }

/* ==========================================================================
   Toolbar / tabs
   ========================================================================== */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 16px; }
.toolbar select { min-height: 40px; }
.ym-nav { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.ym-nav strong { font-size: 1.1rem; min-width: 7.5em; text-align: center; }
.toolbar .ym-nav { margin-bottom: 0; }
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 999px; }
.tabs a { padding: 6px 16px; border-radius: 999px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 0.92rem; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.card .table-scroll { box-shadow: none; border-radius: var(--radius); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.grid thead th {
  background: var(--surface-2); color: var(--text-2); font-size: 0.85rem; font-weight: 700; white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: #fafcfb; }
table.grid tr.muted td { color: var(--muted); }
table.grid.compact th, table.grid.compact td { padding: 8px 12px; }
table.grid td a { font-weight: 600; text-decoration: none; }
table.grid td a:hover { text-decoration: underline; }
table.kv { border-collapse: collapse; margin-bottom: 8px; }
table.kv th { text-align: left; padding: 8px 20px 8px 0; color: var(--muted); font-weight: 600; white-space: nowrap; vertical-align: top; }
table.kv td { padding: 8px 0; }
.timetable td { min-width: 130px; font-size: 0.92rem; }
.timetable td div + div { margin-top: 4px; }

/* ==========================================================================
   나의수업 calendar
   ========================================================================== */
.summary { margin: 0 0 12px; font-size: 0.98rem; color: var(--text-2); }
.summary strong { color: var(--text); font-size: 1.05rem; }
.summary .hint { display: block; margin-top: 2px; }
.c-makeup { color: var(--makeup); font-weight: 600; }
.c-cancel { color: var(--cancel); font-weight: 600; }
.c-absent { color: var(--absent); font-weight: 600; }

.classes-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.classes-layout:has(.panel:not(:empty)) { grid-template-columns: minmax(0, 1fr) 360px; }

table.cal { width: 100%; min-width: 780px; border-collapse: collapse; table-layout: fixed; }
table.cal th {
  padding: 10px 6px 4px; background: var(--surface-2); font-size: 0.9rem; font-weight: 700; color: var(--text-2);
}
table.cal .cal-types th { padding: 0 6px 8px; font-weight: 500; font-size: 0.78rem; color: var(--muted); border-bottom: 1px solid var(--border); }
table.cal td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: top; padding: 6px; height: 104px; }
table.cal td:last-child { border-right: 0; }
table.cal tbody tr:last-child td { border-bottom: 0; }
table.cal td.out { background: var(--bg); }
table.cal td.today { background: var(--today-soft); box-shadow: inset 0 0 0 2px var(--green-200); }
table.cal td.holiday { background: var(--holiday-soft); }
.cal-date { font-weight: 700; font-size: 0.9rem; margin: 0 2px 6px; display: flex; align-items: center; gap: 6px; }
td.today .cal-date::after {
  content: "오늘"; font-size: 0.7rem; font-weight: 700; color: #fff; background: var(--primary);
  padding: 0 6px; border-radius: 999px;
}
.hol-name { color: var(--holiday); font-size: 0.75rem; font-weight: 700; }
.wd-Saturday { color: var(--saturday); }
.wd-Sunday { color: var(--holiday); }

.sess {
  display: block; width: 100%; margin: 0 0 3px; padding: 4px 7px; border: 0; border-radius: var(--radius-sm);
  background: transparent; border-left: 3px solid transparent;
  font: inherit; font-size: 0.84rem; line-height: 1.45; text-align: left; color: var(--text);
  overflow-wrap: anywhere; cursor: pointer;
}
.sess:hover { background: var(--surface-2); }
.sess small { color: var(--muted); font-size: 0.75rem; }
.sess-scheduled { color: var(--text-2); }
.sess-done { background: var(--done-soft); border-left-color: var(--green-500); }
.sess-done.sess-makeup { background: var(--makeup-soft); border-left-color: var(--makeup); }
.sess-scheduled.sess-makeup { border-left-color: var(--makeup); color: var(--makeup); }
.sess-absent { background: var(--absent-soft); border-left-color: var(--absent); color: var(--absent); }
.sess-cancelled { background: var(--cancel-soft); border-left-color: var(--cancel-mark); color: var(--cancel); }
/* status is never color-only: absent / cancelled carry a text label in the calendar */
table.cal .sess-absent::after { content: " · 결석"; font-size: 0.75rem; font-weight: 700; }
table.cal .sess-cancelled::after { content: " · 휴강"; font-size: 0.75rem; font-weight: 700; }
.sess-absent small, .sess-cancelled small { color: inherit; opacity: 0.8; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 12px 0 0; align-items: center; }
.legend .sess { display: inline-block; width: auto; margin: 0; padding: 2px 10px; cursor: default; }

/* session panel: right column on desktop, bottom sheet on mobile */
.panel:empty { display: none; }
.panel {
  position: sticky; top: calc(var(--topbar-h) + 16px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-lg);
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.panel-title { font-weight: 800; font-size: 1.2rem; }
.panel .form-grid { grid-template-columns: 1fr 1fr; }
.panel .form-grid .btn { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .classes-layout:has(.panel:not(:empty)) { grid-template-columns: minmax(0, 1fr); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    max-height: 85vh; overflow-y: auto; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0; border-bottom: 0;
  }
  .panel::before {
    content: ""; display: block; width: 40px; height: 4px; margin: -8px auto 12px;
    border-radius: 2px; background: var(--border-strong);
  }
}

/* ==========================================================================
   Admin
   ========================================================================== */
.enroll { padding: 16px 0; border-top: 1px solid var(--border); }
.enroll:first-of-type { border-top: 0; padding-top: 0; }
.enroll-head { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.enroll-head strong { font-size: 1.05rem; }
.enroll-closed { opacity: 0.6; }
.enroll-actions { margin-top: 10px; }
.danger-zone { border-color: #f6d4d0; }

/* ==========================================================================
   Mobile (/m)
   ========================================================================== */
.mday { margin-bottom: 20px; }
.mday-title { font-size: 0.95rem; font-weight: 700; margin: 0 0 8px; color: var(--muted); }
.mday-today .mday-title { color: var(--primary); }
.mday .empty { padding: 12px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.scard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.scard-main { display: flex; align-items: center; gap: 14px; }
.scard-time { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 54px; }
.scard-who { flex: 1; min-width: 0; }
.scard-name { font-weight: 700; font-size: 1.05rem; }
.scard-actions { display: flex; gap: 8px; margin-top: 12px; }
.scard-done { border-left-color: var(--green-500); }
.scard-absent { border-left-color: var(--absent); }
.scard-cancelled { border-left-color: var(--cancel-mark); }
.scard .alert { margin: 10px 0 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: none;
  background: rgb(255 255 255 / 0.97); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 14px 4px; min-height: 52px;
  text-decoration: none; color: var(--muted); font-size: 0.92rem; font-weight: 600;
}
.tabbar a[aria-current="page"] { color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
@media (max-width: 900px) {
  .tabbar { display: flex; }
  body:has(.tabbar) .container { padding-bottom: 88px; }
}

/* ==========================================================================
   Login / bare pages
   ========================================================================== */
.bare { background: linear-gradient(180deg, var(--green-50) 0%, var(--bg) 60%); }
.bare-main { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--gutter); }
.login-card { width: 100%; max-width: 400px; padding: 32px 28px; box-shadow: var(--shadow-lg); }
.login-logo { display: block; width: 52px; height: 52px; margin-bottom: 14px; }
.login-brand { margin: 0; font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.login-card > .muted { margin: 4px 0 24px; }
.login-card .btn-primary { min-height: 50px; font-size: 1.05rem; margin-top: 4px; }

/* ==========================================================================
   Phase 2: badges, home, lists
   ========================================================================== */
.count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 2px;
  border-radius: 999px; background: var(--absent); color: #fff; font-size: 0.72rem; font-weight: 800; line-height: 1;
  vertical-align: 1px;
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--absent); margin-right: 6px; vertical-align: 2px; }

.greeting { font-size: 1.05rem; margin: -6px 0 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.stat:hover { border-color: var(--green-200); color: var(--text); }
.stat-label { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.85rem; color: var(--muted); }
.stat-warn .stat-value { color: var(--absent); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 12px; }
.home-grid .card + .card { margin-top: 0; }
.pin-item { padding: 10px 0; border-top: 1px solid var(--border); }
.pin-item:first-of-type { border-top: 0; padding-top: 0; }
.section-title a { font-weight: 600; margin-left: auto; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 10px; font-weight: 600; color: var(--text-2); }
.search { display: inline-flex; gap: 6px; flex: 1 1 260px; max-width: 420px; }
input[type="search"] {
  font: inherit; font-size: 1rem; min-height: 40px; padding: 8px 12px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
input[type="search"]:focus { outline: none; border-color: var(--green-500); box-shadow: var(--focus); }
.notice-bar {
  display: block; margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--absent-soft); color: var(--absent); font-weight: 600; text-decoration: none;
}
.notice-bar:hover { color: var(--absent); }

/* 수업일지 */
table.logs .col-check { width: 36px; text-align: center; }
table.logs .col-check input { width: 18px; height: 18px; accent-color: var(--primary); }
table.logs .col-log { min-width: 320px; width: 45%; }
table.logs textarea { min-height: 64px; font-size: 0.95rem; }
table.logs tr.row-missing td { background: #fffaf0; }
.save-state { display: block; margin-top: 6px; font-size: 0.8rem; }
.save-state.ok { color: var(--done); font-weight: 600; }
.save-state.err { color: var(--absent); font-weight: 600; white-space: normal; max-width: 180px; }
.log-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.log-title { font-size: 1rem; margin: 0 0 8px; }
.log-text { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }
.scard-log { margin-top: 12px; }
.scard-log > summary { font-size: 0.95rem; }

/* 알림 */
.compose .stack { margin-top: 14px; }
fieldset.recipients { border: 0; padding: 0; margin: 0; }
fieldset.recipients legend { font-size: 0.9rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  font-size: 0.92rem; font-weight: 500; background: var(--surface); user-select: none;
}
.chip small { color: var(--muted); }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--green-500); color: var(--primary); font-weight: 700; }
.chip input:focus-visible + span { box-shadow: var(--focus); }
.alert-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.alert-item { padding: 16px 18px; border-top: 1px solid var(--border); }
.alert-item:first-child { border-top: 0; }
.alert-item.unread { background: #fcfefc; box-shadow: inset 3px 0 0 var(--green-500); }
.alert-body { line-height: 1.7; }
.alert-session { margin-top: 8px; font-size: 0.9rem; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.alert-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.alert-actions form { display: inline; }
.btn.star { font-size: 1.05rem; min-width: 36px; padding: 2px 8px; color: var(--muted); }
.btn.star.on { color: #e0a100; border-color: #f0d29c; }
.btn.pinned { color: var(--primary); border-color: var(--green-200); background: var(--primary-soft); }
.push-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.push-card p { margin: 2px 0 0; }

/* 공지사항 */
.notice-list .card + .card { margin-top: 12px; }
.notice-title { font-size: 1.1rem; margin: 0 0 10px; }
.notice-body { line-height: 1.75; color: var(--text-2); }
.notice-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }

/* 개인일정 */
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .calendar-layout { grid-template-columns: minmax(0, 1fr); } }
table.pcal { width: 100%; min-width: 560px; border-collapse: collapse; table-layout: fixed; }
table.pcal th { padding: 10px 6px; background: var(--surface-2); font-size: 0.9rem; color: var(--text-2); }
table.pcal td { height: 92px; padding: 0; vertical-align: top; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
table.pcal td:last-child { border-right: 0; }
table.pcal tbody tr:last-child td { border-bottom: 0; }
table.pcal td.out { background: var(--bg); }
table.pcal td.holiday { background: var(--holiday-soft); }
table.pcal td.today { background: var(--today-soft); }
table.pcal td.selected { box-shadow: inset 0 0 0 2px var(--green-500); }
.pcal-day { display: flex; flex-direction: column; gap: 3px; height: 100%; min-height: 92px; padding: 6px; color: var(--text); text-decoration: none; }
.pcal-day:hover { background: rgb(31 160 85 / 0.06); color: var(--text); }
.pcal-day .cal-date { margin: 0; }
.cal-date.is-holiday { color: var(--holiday); }
.pcal-classes { font-size: 0.75rem; font-weight: 700; color: var(--primary); }
.pcal-ev {
  font-size: 0.8rem; padding: 1px 6px; border-radius: 4px; background: var(--makeup-soft); color: #1e4fbf;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-panel { position: sticky; top: calc(var(--topbar-h) + 16px); }
.ev-list { list-style: none; margin: 0 0 16px; padding: 0; }
.ev-list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.form-row input { min-width: 0; }
.form-row label, .stack > label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; font-weight: 600; color: var(--text-2); }

/* 서류 기한 (SPEC 5.6.1) */
.due-card { margin: 16px 0; }
.due-list { list-style: none; margin: 0; padding: 0; }
.due-list li + li { border-top: 1px solid var(--border); }
.due-list a {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 2px; min-height: 44px;
  color: var(--text); text-decoration: none;
}
.due-list a:hover .due-what strong { text-decoration: underline; }
.due-day {
  flex: none; min-width: 4.5em; padding: 2px 8px; border-radius: 999px; text-align: center;
  font-size: 0.82rem; font-weight: 700; background: var(--pending-soft); color: var(--pending);
}
.due-day.is-over { background: var(--absent-soft); color: var(--absent); }
.due-what { flex: 1 1 14em; min-width: 0; }
.due-more { display: inline-block; margin-top: 8px; font-size: 0.9rem; font-weight: 600; }
.guardian-msg textarea { margin-top: 8px; }
.due-form { align-items: flex-end; gap: 12px 20px; }
.due-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 600; color: var(--text-2); }
.input-unit { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text); }
.input-unit input { width: 6em; }

/* 바우처기록지 */
input[type="datetime-local"] {
  font: inherit; font-size: 0.95rem; font-weight: 400; min-height: 40px; padding: 7px 10px; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
input[type="datetime-local"]:focus { outline: none; border-color: var(--green-500); box-shadow: var(--focus); }
.page-tabs { margin: -4px 0 16px; }
.span-2 { grid-column: span 2; }
@media (max-width: 600px) { .span-2 { grid-column: 1 / -1; } }
.vgroup { padding: 0; overflow: hidden; }
.vgroup + .vgroup { margin-top: 14px; }
.vgroup-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.vrow { padding: 14px 18px 14px 15px; border-top: 1px solid var(--border); border-left: 3px solid transparent; }
.vrow:first-child { border-top: 0; }
.vrow-missing { border-left-color: var(--cancel-mark); }
.vrow-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.vrow-time { color: var(--text-2); font-variant-numeric: tabular-nums; }
/* content (wide) | payment fields; both columns share the row height */
.vrow-form { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: stretch; }
.vrow-meta { display: flex; flex-direction: column; gap: 10px; }
.vrow-meta label, .vrow-content > label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--text-2); }
.vrow-meta input { min-height: 40px; font-size: 0.92rem; }
.vrow-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vrow-content textarea { flex: 1; min-height: 112px; font-size: 0.95rem; }
.vrow-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; }
.vrow-state .save-state { display: inline; margin: 0; }
.vrow-link { display: flex; margin-top: 10px; justify-content: flex-end; flex-wrap: wrap; gap: 8px; align-items: center; }
.vrow-link form { margin: 0; }
.ref-box { margin-top: 6px; padding: 10px 12px; background: var(--makeup-soft); border-radius: var(--radius-sm); }
.ref-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.sheet-text { width: 100%; font-size: 0.9rem; line-height: 1.6; background: var(--surface-2); margin-bottom: 10px; }
.enroll-vouchers { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.vt-row { margin: 0; }
.vt-row input[type="text"] { max-width: 220px; }
.vt-row input[type="number"] { max-width: 160px; }
@media (max-width: 900px) {
  .vrow-form { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .vrow-meta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .vrow-content textarea { min-height: 96px; }
}
@media (max-width: 600px) {
  .vrow { padding: 12px 14px 12px 11px; }
  .vrow-meta { grid-template-columns: minmax(0, 1fr); }
  .vrow-actions .btn { min-height: 40px; }
}

/* 보고서 */
.report-form select { width: 100%; }
.report-fields { display: grid; gap: 14px; }
.report-fields.two-col { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.report-fields.two-col label:last-child { grid-column: 1 / -1; }
.report-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; font-weight: 600; color: var(--text-2); }
@media (max-width: 700px) { .report-fields.two-col { grid-template-columns: minmax(0, 1fr); } }
.report-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.report-actions form { margin: 0; }
.status-r-draft { background: var(--surface-2); color: var(--muted); }
.status-r-submitted { background: var(--makeup-soft); color: var(--makeup); }
.status-r-approved { background: var(--done-soft); color: var(--done); }
.status-r-rejected { background: var(--absent-soft); color: var(--absent); }
.report-doc + .report-doc { break-before: page; }
.print-kv { width: 100%; margin-bottom: 12px; }
.print-kv th, .print-kv td { border-bottom: 1px solid #e1e7e3; }
.print-h2 { font-size: 1rem; margin: 0 0 6px; }

/* 현황 대시보드 */
.dash-filters { margin-top: 8px; }
.inline-label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-2); font-size: 0.92rem; }
.dash-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.dash-head .section-title { margin: 0; }
.dash-head .ym-nav { margin: 0; }
.dash-month { margin-bottom: 20px; }
.dash-year { margin-bottom: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin: 12px 0; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.dash-month .tile { background: var(--surface-2); border-color: transparent; }
.tile-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.tile-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; color: var(--text); }
.tile-value small { font-size: 0.85rem; font-weight: 600; margin-left: 2px; color: var(--muted); }
.tile-sub { font-size: 0.82rem; color: var(--text-2); }
.tile-key .tile-value { color: var(--primary); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.key-done { background: var(--primary); }
.key-makeup { background: var(--makeup); }
.key-cancel { background: var(--cancel-mark); }
.key-absent { background: var(--absent); }
.absentees { margin: 4px 0 0; font-size: 0.92rem; color: var(--text-2); }
.absentees strong { margin-right: 6px; color: var(--text); }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.chart-card { margin: 0; padding: 16px 18px 12px; }
.chart-card figcaption { font-weight: 700; margin-bottom: 10px; }
.chart-wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 220px; }
.chart-box.chart-sm { height: 150px; }
.chart-box.chart-rank { height: 280px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.mini-title { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; margin: 0 0 4px; color: var(--text-2); }
.table-view { margin-top: 10px; }
.table-view > summary { font-size: 0.85rem; }
.table-view table { margin-top: 8px; }
.dash-error .chart-box::after { content: "차트를 불러오지 못했습니다. '표로 보기'를 이용하세요."; color: var(--muted); font-size: 0.9rem; }

/* 급여 */
.btn-block { width: 100%; margin-top: 10px; }
.inline-form { display: inline; margin: 0; }
.payroll-detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .payroll-detail { grid-template-columns: minmax(0, 1fr); } }
.payslip-card { max-width: 760px; }
.payslip-title { text-align: center; font-size: 1.35rem; margin: 4px 0 18px; }
.ps-sub { font-size: 0.98rem; margin: 18px 0 6px; }
.ps-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.ps-table th, .ps-table td { border: 1px solid #b9c3bd; padding: 8px 10px; }
.ps-table th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.ps-table td.c { text-align: center; }
.ps-table td.r, .ps-table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.ps-table .ps-head { width: 90px; }
.ps-total th { background: #eef3f0; }
.ps-net th { background: var(--primary-soft); color: var(--green-700); font-size: 1.05rem; }
.ps-ded th { width: 22%; }
tfoot th { background: var(--surface-2); padding: 10px 14px; text-align: left; }
tfoot th.num { text-align: right; }

/* 수업일지 문서보기 */
.print-page { background: var(--bg); }
.print-bar { position: sticky; top: 0; display: flex; gap: 12px; align-items: center; padding: 12px var(--gutter); background: var(--surface); border-bottom: 1px solid var(--border); }
.print-doc { max-width: 820px; margin: 24px auto; padding: 32px; background: #fff; border: 1px solid var(--border); }
.print-doc h1 { font-size: 1.4rem; margin: 0 0 20px; }
.print-entry { padding: 14px 0; border-top: 1px solid #d8dfdb; break-inside: avoid; }
.print-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; font-size: 0.92rem; }

/* ==========================================================================
   Print
   ========================================================================== */
/* ==========================================================================
   Phone (≤600px): compact month calendar, folded charts · ≤900px: list tables as cards
   ========================================================================== */
.dash-charts > summary { display: none; }
.table-view { overflow-x: auto; }
#day { scroll-margin-top: calc(var(--topbar-h) + 12px); }

@media (max-width: 900px) {
  .day-panel { position: static; }
}

@media (max-width: 600px) {
  /* 현황: charts start folded (app.js closes data-mobile-closed) */
  .dash-charts > summary {
    display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .dash-charts[open] > summary { margin-bottom: 14px; }

  /* 개인일정: the month fits the screen; titles become dots, the day panel shows details */
  table.pcal { min-width: 0; }
  table.pcal th { padding: 8px 0; font-size: 0.82rem; }
  table.pcal td { height: auto; }
  .pcal-day {
    min-height: 56px; padding: 6px 2px; flex-flow: row wrap; justify-content: center; align-content: flex-start; gap: 3px;
  }
  .pcal-day .cal-date { flex: 0 0 100%; justify-content: center; font-size: 0.9rem; }
  .pcal-day .hol-name { display: none; }
  .pcal-classes { font-size: 0.68rem; white-space: nowrap; }
  .pcal-ev { width: 7px; height: 7px; padding: 0; border-radius: 50%; background: var(--makeup); font-size: 0; }
}

@media (max-width: 900px) {
  /* list tables → one card per row; cells labelled with their column header */
  .table-cards { overflow: visible; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .table-cards table, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-cards tbody tr {
    position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; margin-bottom: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .table-cards tbody tr:hover td { background: none; }
  /* label column on the left; the value keeps its own block layout (several lines stay stacked) */
  .table-cards table td {
    display: block; position: relative; padding: 4px 0 4px 7rem; border: 0; text-align: left; white-space: normal;
  }
  /* unlabelled cells (actions): full width, buttons and save state on one line */
  .table-cards table td:not([data-label]) { padding-left: 0; }
  .table-cards table td:not([data-label]):has(.btn) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding-top: 8px; }
  .table-cards td:not([data-label]) .save-state { margin: 0; }
  .table-cards td[data-label]::before {
    content: attr(data-label); position: absolute; left: 0; top: 6px; width: 6.5rem;
    color: var(--muted); font-size: 0.85rem; font-weight: 600; line-height: 1.35;
  }
  .table-cards table td.card-title { order: -1; padding: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
  .table-cards td.card-title::before, .table-cards td.empty::before { content: none; }
  .table-cards table td.card-block { padding-left: 0; }
  .table-cards td.card-block::before { position: static; display: block; width: auto; margin-bottom: 4px; }
  .table-cards td.card-hide, .table-cards td.is-blank { display: none; }
  .table-cards table td.empty { padding: 8px 0; text-align: center; }
  .table-cards table td.col-check { position: absolute; top: 8px; right: 8px; width: auto; padding: 0; }
  .table-cards td.col-check input { width: 28px; height: 28px; }
  .table-cards tbody tr:has(.col-check) td.card-title { padding-right: 40px; }
  .table-cards .nowrap { white-space: normal; }
  /* card-inline cells share one line without labels (e.g. 수업일지: date · time · teacher · status) */
  .table-cards tbody tr:has(.card-inline) { flex-flow: row wrap; column-gap: 10px; }
  .table-cards tbody tr:has(.card-inline) > td { flex: 0 0 100%; }
  .table-cards tbody tr:has(.card-inline) > td.card-inline { flex: 0 0 auto; padding: 0 0 6px; }
  .table-cards td.card-inline::before { content: none; }
  .table-cards textarea, .table-cards .form-inline { width: 100%; }
  .table-cards details.inline { display: block; margin: 6px 0 0; }
  .table-cards input:not([type="checkbox"]) { min-width: 0; max-width: 100%; }
}
/* tablet: two cards per row */
@media (min-width: 601px) and (max-width: 900px) {
  .table-cards tbody { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .table-cards tbody tr { margin-bottom: 0; }
  .table-cards tbody tr:has(td.empty) { grid-column: 1 / -1; }
}

@media print {
  .topbar, .tabbar, .toolbar, .panel, .btn, form, .print-bar { display: none !important; }
  body, .bare, .print-page { background: #fff; }
  .card, .table-scroll { box-shadow: none; border-color: #ccc; }
  .print-doc { margin: 0; padding: 0; border: 0; max-width: none; }
}
