/* =====================================================================
 * 웹 방명록 — style.css
 * 섹션: Tokens / Base / Layout(Admin) / Components / Visitor / Auth / Utilities / Print
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * Tokens (색상·간격·모양) — 프로그램 theme_color는 --brand로 덮어씀
 * ------------------------------------------------------------------- */
:root {
  --brand: #2563eb;
  --brand-contrast: #ffffff;
  --brand-hover: color-mix(in srgb, var(--brand) 86%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 35%, var(--border));

  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f5;
  --text: #111827;
  --text-muted: #4b5563;
  --text-faint: #6b7280;
  --border: #dde2ea;
  --border-strong: #c3cad6;

  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #c62828;
  --danger-soft: #fde8e8;
  --warn: #a15c00;
  --warn-soft: #fff3d6;
  --info: #1d4ed8;
  --info-soft: #e0eaff;

  --focus: #2563eb;
  --overlay: rgba(15, 23, 42, 0.5);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, 0.18);

  --sidebar-w: 248px;
  --topbar-h: 60px;
  --tap: 48px;

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "맑은 고딕", Roboto,
    "Helvetica Neue", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171d26;
    --surface-2: #1c232e;
    --surface-3: #242c38;
    --text: #eef2f7;
    --text-muted: #b4bdca;
    --text-faint: #8d97a6;
    --border: #2c3542;
    --border-strong: #3c4757;

    --success: #4ade80;
    --success-soft: #11321f;
    --danger: #ff8a80;
    --danger-soft: #3a1717;
    --warn: #fbbf24;
    --warn-soft: #35290b;
    --info: #93b4ff;
    --info-soft: #18264a;

    --focus: #8ab4ff;
    --overlay: rgba(0, 0, 0, 0.62);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.55);
  }
}

/* ---------------------------------------------------------------------
 * Base
 * ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
body.modal-open { overflow: hidden; }

h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.08rem; }
p { margin: 0; }

a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-hover); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000;
  padding: 10px 16px; border: 0; border-radius: var(--radius-sm);
  background: var(--brand); color: var(--brand-contrast); font-weight: 600;
  transition: top .15s;
}
.skip-link:focus { top: 12px; }

.boot, .noscript {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--text-muted); font-size: 1.05rem; padding: 24px; text-align: center;
}

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------------
 * Layout — 관리자 (사이드바 + 콘텐츠)
 * ------------------------------------------------------------------- */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; min-height: 100dvh;
}

.sidebar {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 20px;
  font-weight: 800; font-size: 1.08rem;
  border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.sidebar-brand .logo-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-contrast);
}
.sidebar-brand .logo-mark svg { width: 18px; height: 18px; }

.side-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.side-nav .nav-label {
  margin: 14px 10px 6px; font-size: .78rem; font-weight: 700;
  color: var(--text-faint); letter-spacing: .02em;
}
.side-nav .nav-label:first-child { margin-top: 2px; }
.side-nav .nav-program {
  margin: 0 10px 6px; font-weight: 700; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.nav-link svg { width: 18px; height: 18px; flex: none; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link[aria-current="page"] {
  background: var(--brand-soft); color: var(--brand); font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .nav-link[aria-current="page"] { color: var(--text); }
}
.nav-link .ext { margin-left: auto; width: 14px; height: 14px; opacity: .6; }

.sidebar-foot {
  margin-top: auto; padding: 14px 12px 18px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-foot .mode-line { font-size: .82rem; color: var(--text-faint); padding: 0 10px; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar .crumbs {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: .95rem; color: var(--text-muted);
}
.topbar .crumbs a { color: var(--text-muted); text-decoration: none; }
.topbar .crumbs a:hover { color: var(--text); text-decoration: underline; }
.topbar .crumbs .sep { opacity: .5; }
@media (max-width: 600px) { .topbar .crumbs > a, .topbar .crumbs > .sep { display: none; } }
.topbar .crumbs .current {
  color: var(--text); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; }

.content {
  width: 100%; max-width: 1180px;
  padding: 28px 24px 64px; margin: 0 auto;
}
.content:focus, [tabindex="-1"]:focus { outline: none; }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 12px 16px; margin-bottom: 22px;
}
.page-header .sub { color: var(--text-muted); margin-top: 4px; }
.page-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .admin-shell.nav-open .sidebar { transform: none; }
  .admin-shell.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35; background: var(--overlay);
  }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; }
  .content { padding: 20px 16px 56px; }
}

/* ---------------------------------------------------------------------
 * Components
 * ------------------------------------------------------------------- */

/* Buttons */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--btn-bd); border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
  user-select: none;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--surface-3); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--brand-contrast); --btn-bd: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
@media (prefers-color-scheme: dark) {
  .btn-danger { --btn-bg: #b3261e; --btn-bd: #b3261e; }
}
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-muted); }
.btn-ghost:hover { --btn-fg: var(--text); }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .9rem; }
.btn-lg { min-height: 56px; padding: 12px 24px; font-size: 1.12rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 42px; }
.btn-icon.btn-sm { width: 34px; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2.5px solid var(--btn-fg); border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head .desc { color: var(--text-muted); font-size: .92rem; margin-top: 2px; }
.card-body { padding: 20px; }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Program card (목록) */
.program-card { display: flex; flex-direction: column; padding: 18px 18px 14px; gap: 10px; }
.program-card .title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.program-card h3 a { color: var(--text); text-decoration: none; }
.program-card h3 a:hover { text-decoration: underline; }
.program-card .meta { color: var(--text-muted); font-size: .92rem; }
.program-card .counts { display: flex; gap: 18px; }
.program-card .counts b { font-size: 1.2rem; }
.program-card .counts span { display: block; color: var(--text-faint); font-size: .82rem; }
.program-card .foot { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 2px; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--text-muted);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-local {
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.mode-badge-top { margin: -16px 0 12px; }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row + .form-row { margin-top: 16px; }
.form-label { font-weight: 600; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-help { color: var(--text-faint); font-size: .88rem; }
.form-error { color: var(--danger); font-size: .9rem; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.form-error:empty { display: none; }
.form-error svg { width: 16px; height: 16px; margin-top: 3px; flex: none; }

.input, .select, .textarea {
  width: 100%; min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}
.input-pin { font-size: 1.5rem; letter-spacing: .5em; text-align: center; font-family: var(--mono); }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }

/* Tabs */
.tabs {
  display: flex; gap: 4px; overflow-x: auto;
  border-bottom: 1px solid var(--border); margin-bottom: 20px;
  scrollbar-width: thin;
}
.tab {
  flex: none; min-height: 46px; padding: 10px 16px;
  border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--text-muted); font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
@media (prefers-color-scheme: dark) { .tab[aria-selected="true"] { color: var(--text); } }

/* Key-value list */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 20px; margin: 0; }
.kv dt { color: var(--text-faint); font-weight: 600; }
.kv dd { margin: 0; }
@media (max-width: 520px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } .kv dd { margin-bottom: 10px; } }

/* Empty / placeholder states */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 48px 24px; text-align: center; color: var(--text-muted);
}
.empty .empty-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h2, .empty h3 { color: var(--text); }
.empty .btn { margin-top: 8px; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--info-soft); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--info) 25%, transparent);
}
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--info); }
.notice-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice-warn svg { color: var(--warn); }
.notice-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice-danger svg { color: var(--danger); }

/* Self-test list */
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.check-list li svg { width: 18px; height: 18px; flex: none; margin-top: 3px; }
.check-list li.ok svg { color: var(--success); }
.check-list li.fail { background: var(--danger-soft); }
.check-list li.fail svg { color: var(--danger); }
.check-list li .ms { margin-left: auto; color: var(--text-faint); font-size: .82rem; font-family: var(--mono); }
.check-list li .err { display: block; color: var(--danger); font-size: .88rem; }

/* Spinner & loading bar */
.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 3px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 900;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  background-size: 50% 100%; background-repeat: no-repeat;
  animation: loading-slide 1s ease-in-out infinite;
}
@keyframes loading-slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

.view-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px 0; color: var(--text-muted); }

/* Toasts */
.toast-root {
  position: fixed; z-index: 1100;
  right: 16px; bottom: 16px; left: auto;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  width: 360px; max-width: 100%;
  padding: 13px 12px 13px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 5px solid var(--info);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out;
}
.toast.leaving { animation: toast-out .18s ease-in forwards; }
.toast > svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--info); }
.toast .msg { flex: 1; min-width: 0; font-weight: 500; }
.toast .close { border: 0; background: none; color: var(--text-faint); padding: 2px; border-radius: 6px; }
.toast .close svg { width: 18px; height: 18px; }
.toast-success { border-left-color: var(--success); } .toast-success > svg { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error > svg { color: var(--danger); }
.toast-warn { border-left-color: var(--warn); } .toast-warn > svg { color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
@media (max-width: 600px) {
  .toast-root { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .toast { width: auto; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: var(--overlay);
  animation: fade-in .15s ease-out;
}
.modal {
  width: 100%; max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease-out;
}
.modal-sm { max-width: 400px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 6px; }
.modal-head h2 { flex: 1; font-size: 1.15rem; }
.modal-body { padding: 10px 20px 4px; overflow-y: auto; }
.modal-body p + p { margin-top: 8px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 16px 20px 20px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (max-width: 480px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92dvh; }
  .modal-foot .btn { flex: 1; }
}

/* Danger zone */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.danger-zone .card-head h2 { color: var(--danger); }

/* ---------------------------------------------------------------------
 * Visitor (방문자) — 여백 넉넉한 카드형, 큰 글씨/큰 터치 영역
 * ------------------------------------------------------------------- */
.visitor {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  padding: 32px 16px 48px;
  font-size: 18px;
  background:
    radial-gradient(1200px 400px at 50% -120px, var(--brand-soft), transparent 70%),
    var(--bg);
}
.visitor-card {
  width: 100%; max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.visitor-card h1 { font-size: 1.75rem; }
.visitor-card .lead { color: var(--text-muted); margin-top: 10px; font-size: 1.08rem; white-space: pre-line; }
.visitor .btn { min-height: var(--tap); font-size: 1.05rem; }
.visitor-status { text-align: center; padding: 40px 28px; }
.visitor-status .empty-icon {
  margin: 0 auto 16px; width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand);
}
.visitor-status .empty-icon svg { width: 36px; height: 36px; }
@media (max-width: 480px) {
  .visitor { padding: 20px 12px 36px; }
  .visitor-card { padding: 24px 18px; }
}

/* ---------------------------------------------------------------------
 * Auth (로그인 / PIN) · 전체 화면 안내
 * ------------------------------------------------------------------- */
.center-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 420px; padding: 32px 28px; }
.auth-card .brand-mark {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--brand-contrast);
}
.auth-card .brand-mark svg { width: 28px; height: 28px; }
.auth-card h1 { text-align: center; font-size: 1.45rem; }
.auth-card .sub { text-align: center; color: var(--text-muted); margin: 8px 0 22px; }
.auth-card .foot-links { margin-top: 18px; text-align: center; font-size: .92rem; }
.auth-card .foot-links button { border: 0; background: none; color: var(--text-muted); text-decoration: underline; padding: 6px; }
.auth-card .local-tag { display: flex; justify-content: center; margin-bottom: 18px; }

.error-screen { width: 100%; max-width: 620px; padding: 32px 28px; }
.error-screen > .empty-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; }
.error-screen > .empty-icon svg { width: 28px; height: 28px; }
.error-screen .empty-icon { background: var(--danger-soft); color: var(--danger); margin-bottom: 16px; }
.error-screen ol { padding-left: 1.3em; margin: 12px 0 0; }
.error-screen ol li + li { margin-top: 6px; }
.error-screen code, .mono {
  font-family: var(--mono); font-size: .88em;
  background: var(--surface-3); padding: 1px 6px; border-radius: 5px;
}
.error-screen details { margin-top: 16px; color: var(--text-muted); font-size: .9rem; }
.error-screen pre { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); }

/* ---------------------------------------------------------------------
 * Components — 스위치 · 메뉴 · 툴바 · 폼 섹션 · 템플릿 선택
 * ------------------------------------------------------------------- */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* 프로그램 색상을 일부 영역에만 적용할 때 파생 색을 다시 계산 */
.themed {
  --brand-hover: color-mix(in srgb, var(--brand) 86%, #000);
  --brand-soft: color-mix(in srgb, var(--brand) 12%, var(--surface));
  --brand-line: color-mix(in srgb, var(--brand) 35%, var(--border));
}

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px;
  background: var(--border-strong); transition: background .15s;
}
.switch-ui::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 3px solid var(--focus); outline-offset: 2px; }

.menu {
  position: absolute; z-index: 1050; min-width: 190px; padding: 6px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  animation: fade-in .1s ease-out;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px;
  border: 0; border-radius: 6px; background: none; color: var(--text); text-align: left; white-space: nowrap;
}
.menu-item svg { width: 17px; height: 17px; color: var(--text-muted); }
.menu-item:hover, .menu-item:focus { background: var(--surface-3); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.menu-sep { height: 1px; margin: 4px 2px; background: var(--border); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.search-box { position: relative; flex: 1 1 260px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-faint); pointer-events: none; }
.search-box .input { padding-left: 38px; }
.toolbar-select { width: auto; min-width: 140px; }

.program-card .mono-soft { font-family: var(--mono); font-size: .82rem; color: var(--text-faint); margin-top: -6px; }
.push-right { margin-left: auto; }
.btn-ghost.danger-text { --btn-fg: var(--danger); }

.input-prefix { display: flex; align-items: stretch; }
.input-prefix > span {
  display: flex; align-items: center; padding: 0 10px; white-space: nowrap;
  border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface-3); color: var(--text-muted); font-family: var(--mono); font-size: .9rem;
}
.input-prefix .input { min-width: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-section + .form-section { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.section-title { font-size: 1.05rem; margin-bottom: 14px; }
.form-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-2col .form-row + .form-row { margin-top: 0; }
@media (max-width: 600px) { .form-2col { grid-template-columns: minmax(0, 1fr); } }
.form-footer {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  border-radius: 0 0 var(--radius) var(--radius);
}
.dirty-note { margin-right: auto; color: var(--warn); font-weight: 600; font-size: .92rem; }

.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.template-option { position: relative; cursor: pointer; }
.template-option input { position: absolute; opacity: 0; }
.template-option > span {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 12px 14px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
}
.template-option small { color: var(--text-faint); }
.template-option input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.template-option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.check-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check-row input { flex: none; width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brand); }

/* ---------------------------------------------------------------------
 * Builder (항목 설계)
 * ------------------------------------------------------------------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.builder-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.save-status { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text-faint); }
.save-status svg { width: 16px; height: 16px; }
.save-status.is-saved svg { color: var(--success); }
.save-status.is-error, .save-status.is-invalid { color: var(--danger); font-weight: 600; }

.fb-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fb-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.fb-item.is-open { border-color: var(--brand-line); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.fb-item.is-hidden .fb-title { opacity: .55; }
.fb-row { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 2px; }
.fb-handle { flex: none; display: grid; place-items: center; width: 28px; height: 44px; color: var(--text-faint); cursor: grab; }
.fb-handle svg { width: 18px; height: 18px; }
.no-drag .fb-handle { visibility: hidden; width: 8px; }
.fb-summary {
  flex: 1; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border: 0; border-radius: var(--radius-sm); background: none; text-align: left;
}
.fb-summary:hover { background: var(--surface-2); }
.fb-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-muted); font-size: .82rem; font-weight: 700;
}
.fb-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.fb-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-meta { font-size: .85rem; color: var(--text-faint); }
.req-text { color: var(--danger); }
.fb-chevron { flex: none; width: 18px; height: 18px; color: var(--text-faint); transition: transform .15s; }
.fb-item.is-open .fb-chevron { transform: rotate(180deg); }
.fb-actions { flex: none; display: flex; gap: 2px; }
.fb-editor { padding: 16px; border-top: 1px solid var(--border); }
.fe-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fe-grid .form-row + .form-row { margin-top: 0; }
.fe-wide { grid-column: 1 / -1; }
.fe-switches { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.fe-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); }
.fb-ghost { opacity: .35; }
.fb-empty { padding: 28px 16px; text-align: center; color: var(--text-muted); border: 2px dashed var(--border); border-radius: var(--radius); }

.fb-palette { margin-top: 22px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.palette-btn {
  display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 10px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted); font-weight: 600; text-align: left;
}
.palette-btn svg { width: 16px; height: 16px; flex: none; }
.palette-btn:hover { border-color: var(--brand); border-style: solid; color: var(--brand); background: var(--brand-soft); }

.builder-preview, .design-preview { position: sticky; top: calc(var(--topbar-h) + 16px); }
.preview-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 700; }
.preview-frame {
  max-height: calc(100vh - var(--topbar-h) - 70px); max-height: calc(100dvh - var(--topbar-h) - 70px);
  overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg);
}
.preview-toggle { display: none; }
@media (max-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder-preview { display: none; position: static; }
  .builder.show-preview .builder-preview { display: block; }
  .preview-toggle { display: inline-flex; }
}
@media (max-width: 600px) {
  .fe-grid { grid-template-columns: minmax(0, 1fr); }
  .fb-actions .btn-icon.btn-sm { width: 32px; }
  .fb-num { display: none; }
}

/* 디자인 탭 */
.design-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
@media (max-width: 1100px) {
  .design-layout { grid-template-columns: minmax(0, 1fr); }
  .design-preview { position: static; }
}
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.swatch {
  width: 38px; height: 38px; border-radius: 50%; padding: 0;
  border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--border-strong);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--text); }
.color-input { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.logo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo-preview {
  width: 170px; height: 84px; display: grid; place-items: center; overflow: hidden; padding: 6px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-faint);
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* 공유 탭 */
.url-row { display: flex; gap: 8px; flex-wrap: wrap; }
.url-row .input { flex: 1 1 220px; font-family: var(--mono); font-size: .86rem; }
.qr-body { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-box {
  width: 266px; height: 266px; display: grid; place-items: center; padding: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
}
.qr-box img, .qr-box canvas { width: 240px; height: 240px; }
.qr-box .view-loading { padding: 0; color: #4b5563; }

/* ---------------------------------------------------------------------
 * Visitor form (방문자 작성 화면)
 * ------------------------------------------------------------------- */
.visitor.is-preview { min-height: 0; padding: 16px 12px 24px; }
.visitor.is-preview .visitor-card { padding: 24px 18px; }
.vh { text-align: center; }
.vh-logo { max-height: 72px; max-width: 70%; margin: 0 auto 16px; object-fit: contain; }
.vh .lead { margin-top: 10px; }

.vf-progress {
  position: sticky; top: 0; z-index: 5;
  margin: 22px -28px 0; padding: 12px 28px;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(6px);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.vf-progress-text { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: .9rem; color: var(--text-muted); }
.vf-progress-text b { color: var(--text); }
.vf-progress-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.vf-progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .25s; }

.vf-form { display: flex; flex-direction: column; gap: 28px; margin-top: 24px; }
.vf-field { display: flex; flex-direction: column; gap: 10px; transition: padding .15s; }
.vf-field.has-error, .vf-consent.has-error { padding-left: 14px; border-left: 4px solid var(--danger); }
.vf-label { font-size: 1.1rem; font-weight: 700; line-height: 1.4; }
legend.vf-label { margin-bottom: 10px; }
.vf-label .req, .vf-consent .req { color: var(--danger); margin-left: 4px; }
.vf-help { margin-top: -4px; color: var(--text-muted); font-size: .95rem; }
fieldset.vf-field .vf-help { margin: -4px 0 10px; }
fieldset.vf-field .vf-error { margin-top: 10px; }
.vf-error { display: flex; align-items: flex-start; gap: 6px; color: var(--danger); font-size: .98rem; font-weight: 600; }
.vf-error:empty { display: none; }
.vf-error svg { flex: none; width: 18px; height: 18px; margin-top: 3px; }

.visitor .input, .visitor .select, .visitor .textarea {
  min-height: 56px; padding: 12px 16px; border-radius: var(--radius); font-size: 1.05rem;
}
.visitor .textarea { min-height: 120px; }
.visitor .vf-date { max-width: 260px; }

.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.chips-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chips-compact { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip > span {
  display: flex; align-items: center; justify-content: center; height: 100%; min-height: 56px; padding: 10px 12px;
  border: 2px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  font-weight: 600; line-height: 1.3; text-align: center; transition: background .12s, border-color .12s, color .12s;
}
.chip:hover > span { border-color: var(--brand); }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.chip input[type="checkbox"]:checked + span::before { content: "✓"; margin-right: 6px; font-weight: 800; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:disabled + span { opacity: .4; cursor: not-allowed; }

.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.star { position: relative; padding: 4px; border-radius: 10px; cursor: pointer; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star svg { width: 46px; height: 46px; color: var(--border-strong); transition: transform .1s, color .1s; }
.star:hover svg { transform: scale(1.08); }
.star.on svg { color: #f5a400; fill: #f5a400; }
.star:has(input:focus-visible) { outline: 3px solid var(--focus); }
.rating-text { margin-left: 10px; font-weight: 700; color: var(--text-muted); }

.vf-number { display: flex; align-items: center; gap: 8px; }
.visitor .vf-number .input { width: 120px; text-align: center; font-size: 1.2rem; }
.vf-step { width: 56px; min-height: 56px; padding: 0; border-radius: var(--radius); }
.vf-step svg { width: 22px; height: 22px; }
.vf-unit { font-weight: 600; color: var(--text-muted); }

.sig { position: relative; }
.sig-canvas {
  display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair;
  background: #fff; border: 2px dashed var(--border-strong); border-radius: var(--radius);
}
.sig-hint {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  padding: 0 16px; text-align: center; color: #8a94a3; pointer-events: none;
}
.sig.has-ink .sig-hint { display: none; }
.sig-clear { position: absolute; right: 8px; bottom: 8px; }

.vf-consent { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.check-big { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-weight: 600; }
.check-big input { flex: none; width: 26px; height: 26px; margin-top: 1px; accent-color: var(--brand); }
.consent-details { margin-top: 8px; }
.consent-details summary { padding: 10px 0; color: var(--brand); font-weight: 600; cursor: pointer; }
.consent-text {
  max-height: 240px; overflow: auto; padding: 12px; white-space: pre-line;
  font-size: .95rem; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.vf-consent .vf-error { margin-top: 8px; }

.vf-submit { min-height: 64px; font-size: 1.2rem; }
.vf-submit-error .btn { min-height: 48px; }

.complete { text-align: center; padding: 20px 0 4px; }
.check-anim { width: 96px; height: 96px; margin: 0 auto 20px; }
.check-anim circle {
  fill: none; stroke: var(--success); stroke-width: 3;
  stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .6s ease-out forwards;
}
.check-anim path {
  fill: none; stroke: var(--success); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 36; stroke-dashoffset: 36; animation: draw .35s .5s ease-out forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
.complete-title { font-size: 1.5rem; white-space: pre-line; }
.complete-sub { margin-top: 8px; color: var(--text-muted); }
.complete-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 28px; }
.countdown { color: var(--text-muted); }
.countdown b { color: var(--brand); font-size: 1.25em; }

.visitor.is-kiosk { font-size: 20px; }
.visitor.is-kiosk .visitor-card { max-width: 760px; }
.kiosk-fs { position: fixed; right: 12px; bottom: 12px; z-index: 20; opacity: .75; }
.kiosk-fs:hover, .kiosk-fs:focus-visible { opacity: 1; }

@media (max-width: 480px) {
  .vf-progress { margin: 18px -18px 0; padding: 10px 18px; }
  .star svg { width: 40px; height: 40px; }
  .rating-text { flex-basis: 100%; margin: 4px 0 0 4px; }
}
.visitor.is-preview .vf-progress { margin: 18px -18px 0; padding: 10px 18px; }

/* ---------------------------------------------------------------------
 * Data (방명록 데이터 테이블 · 필터 · 페이지)
 * ------------------------------------------------------------------- */
.filter-card { padding: 14px; }
.filter-grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-grid .search-box { flex: 1 1 240px; }
.filter-dates { display: flex; align-items: center; gap: 6px; }
.filter-dates .input { width: 150px; }
.quick-range { display: flex; gap: 4px; }
.quick-range .btn[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.filter-field { display: flex; gap: 6px; flex: 1 1 300px; }
.filter-field .select { flex: 1; min-width: 0; }
@media (max-width: 600px) {
  .filter-dates { flex: 1 1 100%; min-width: 0; }
  .filter-dates .input { padding-left: 8px; padding-right: 6px; }
  .filter-dates .input { flex: 1; width: auto; min-width: 0; }
  .filter-field { flex-basis: 100%; }
}

.data-summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; min-height: 48px; margin: 12px 0 8px; }
.bulk-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 8px 6px 14px; border-radius: var(--radius-sm);
  background: var(--brand-soft); border: 1px solid var(--brand-line);
}

.table-wrap { overflow: auto; max-height: calc(100vh - 220px); max-height: calc(100dvh - 220px); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table thead th {
  position: sticky; top: 0; z-index: 2; padding: 0;
  background: var(--surface-2); color: var(--text-muted); font-weight: 700; white-space: nowrap;
}
.data-table thead th.col-check, .data-table thead th:not(:has(.sort-btn)) { padding: 10px 12px; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tbody tr.is-selected td { background: var(--brand-soft); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.col-check { width: 44px; }
.col-check input { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
.col-actions { width: 84px; position: sticky; right: 0; background: var(--surface); }
.data-table thead .col-actions { background: var(--surface-2); z-index: 3; }
.row-actions { display: flex; gap: 2px; }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sort-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 42px; padding: 10px 12px;
  border: 0; background: none; color: inherit; font-weight: inherit; text-align: left; white-space: nowrap;
}
.sort-btn:hover { color: var(--text); }
.sort-icon { width: 14px; height: 14px; opacity: .3; flex: none; }
.sort-btn.is-active { color: var(--text); }
.sort-btn.is-active .sort-icon { opacity: 1; color: var(--brand); }
.cell-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-width: 140px; max-width: 280px; white-space: pre-line;
}
.cell-btn {
  padding: 3px 8px; border: 1px dashed var(--border-strong); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: .88rem; white-space: nowrap;
}
.cell-btn:hover { border-style: solid; border-color: var(--brand); }
.cell-rating { white-space: nowrap; font-weight: 600; }
.cell-rating span { color: #f5a400; }
.sig-thumb { padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.sig-thumb img { height: 32px; width: auto; max-width: 110px; }
.sig-large { width: 100%; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sig-preview { max-width: 260px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.page-now { min-width: 64px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.select-sm { width: auto; min-height: 34px; padding: 4px 10px; font-size: .9rem; }

.radio-list { display: flex; flex-direction: column; gap: 8px; }
.check-list-inline { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.entry-editor .form-row + .form-row { margin-top: 14px; }

/* 태그 입력 (방문자 화면) */
.tag-box { display: flex; flex-direction: column; gap: 10px; }
.tag-selected { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tag-selected:empty { display: none; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 4px 4px 4px 14px;
  border-radius: 999px; background: var(--brand); color: var(--brand-contrast); font-weight: 700;
}
.tag-remove {
  display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: 50%; color: inherit;
  background: color-mix(in srgb, var(--brand-contrast) 20%, transparent);
}
.tag-remove svg { width: 16px; height: 16px; }
.tag-entry { display: flex; gap: 8px; }
.tag-entry .input { flex: 1; min-width: 0; }
.visitor .tag-add { flex: none; min-height: 56px; border-radius: var(--radius); }
.tag-hint { margin-bottom: 6px; font-size: .9rem; color: var(--text-muted); }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px;
  border: 2px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font-weight: 600;
}
.tag-chip:hover { border-color: var(--brand); }
.tag-chip small { font-size: .78rem; font-weight: 700; color: var(--text-faint); }
.tag-chip[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.tag-chip[aria-pressed="true"]::before { content: "✓"; font-weight: 800; color: var(--brand); }
.tag-chip:focus-visible, .tag-remove:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* 완료 화면: 채널·SNS 안내 */
.promo { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); text-align: center; }
.promo-msg { margin-bottom: 14px; font-size: 1.05rem; font-weight: 600; white-space: pre-line; }
.promo-links { display: flex; flex-direction: column; gap: 10px; }
.promo-btn {
  --pb: var(--brand); --pf: var(--brand-contrast);
  --btn-bg: var(--pb); --btn-fg: var(--pf); --btn-bd: var(--pb);
  min-height: 56px; font-weight: 800;
}
.promo-btn:hover { background: color-mix(in srgb, var(--pb) 88%, #000); color: var(--pf); }
.promo-btn svg { width: 22px; height: 22px; }
.promo-links.is-qr { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 16px; }
.promo-qr-card { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.promo-qr { width: 170px; height: 170px; padding: 10px; display: grid; place-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.promo-qr img, .promo-qr canvas { width: 150px; height: 150px; }
.promo-qr-card figcaption { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.promo-qr-card figcaption svg { width: 18px; height: 18px; }
.promo-qr-hint { margin-top: 10px; color: var(--text-muted); font-size: .95rem; }
.promo-qr-fallback { font-size: .75rem; color: #374151; word-break: break-all; }

/* 디자인 탭: 링크 편집 줄 */
.promo-editor { display: flex; flex-direction: column; gap: 10px; }
.promo-editor:empty { display: none; }
.promo-row { display: grid; grid-template-columns: 150px minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.promo-row .promo-err { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .promo-row { grid-template-columns: minmax(0, 1fr) auto; }
  .promo-row .select { grid-column: 1; }
  .promo-row [data-promo="url"], .promo-row [data-promo="label"] { grid-column: 1 / -1; }
  .promo-row [data-action="promo-remove"] { grid-column: 2; grid-row: 1; }
}

/* 설정: 새 방명록 알림 상태 */
.nt-status { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: .92rem; }
.nt-status li { display: flex; gap: 8px; align-items: flex-start; color: var(--text-muted); }
.nt-status svg { flex: none; width: 17px; height: 17px; margin-top: 3px; }
.nt-status .nt-ok svg { color: var(--success); }
.nt-status .nt-warn { color: var(--text); }
.nt-status .nt-warn svg { color: var(--warn); }
.nt-status .nt-info svg { color: var(--info); }

/* 설정: 휴대폰 알림(텔레그램) */
.pn-h { margin: 4px 0 8px; font-size: 1rem; }
.pn-me { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.pn-steps { margin: 0 0 12px; padding-left: 1.3em; color: var(--text-muted); }
.pn-steps li + li { margin-top: 4px; }
.pn-bot svg.pn-ok { width: 18px; height: 18px; color: var(--success); }
.pn-chats { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pn-chats li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }

/* 로그인: 구글 버튼 */
.btn-google { --btn-bg: #ffffff; --btn-fg: #1f1f1f; --btn-bd: #747775; font-weight: 600; }
.btn-google:hover { background: #f2f2f2; color: #1f1f1f; }
.btn-google svg { width: 20px; height: 20px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 6px; color: var(--text-faint); font-size: .88rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------------------------------------------------------------------
 * Utilities
 * ------------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: .9rem; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.w-full { width: 100%; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------------------------------------------------------------------
 * Stats (통계)
 * ------------------------------------------------------------------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-sm); background: var(--surface-3); flex-wrap: wrap; }
.seg-btn { min-height: 36px; padding: 6px 12px; border: 0; border-radius: 6px; background: none; color: var(--text-muted); font-weight: 600; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-sm .seg-btn { min-height: 30px; padding: 4px 10px; font-size: .88rem; }
.input-sm { min-height: 34px; padding: 4px 8px; font-size: .9rem; width: auto; }

.section-heading { font-size: 1.15rem; margin: 32px 0 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: .88rem; color: var(--text-muted); font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .95rem; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.kpi-value-sm { font-size: 1.25rem; padding: 6px 0 3px; }
.kpi-sub { font-size: .84rem; color: var(--text-faint); }
.kpi-delta { font-size: .88rem; font-weight: 700; color: var(--text-muted); }
.kpi-delta.is-up, .compare-table .is-up { color: var(--success); }
.kpi-delta.is-down, .compare-table .is-down { color: var(--danger); }

.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; }
.chart-fallback { display: grid; place-items: center; height: 100%; padding: 16px; text-align: center; color: var(--text-muted); background: var(--surface-2); border-radius: var(--radius-sm); }
.chart-print-img { display: none; }
.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.card-body.analysis-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 800px) { .analysis-grid, .card-body.analysis-grid { grid-template-columns: minmax(0, 1fr); } }
.sub-title { font-size: .98rem; margin-bottom: 8px; }

.mini-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.mini-table th, .mini-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.mini-table thead th { color: var(--text-muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.mini-table tbody th { font-weight: 600; }
.mini-table tfoot th, .mini-table tfoot td { border-top: 2px solid var(--border-strong); font-weight: 700; }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-table .bar-col { width: 32%; }
.inline-bar { display: block; height: 10px; min-width: 2px; border-radius: 0 4px 4px 0; background: #2a78d6; }
@media (prefers-color-scheme: dark) { .inline-bar { background: #3987e5; } }
.table-scroll { overflow-x: auto; }
.cross-table td, .cross-table th { white-space: nowrap; }
.table-details { margin-top: 10px; }
.table-details summary { cursor: pointer; color: var(--text-muted); font-size: .9rem; padding: 6px 0; }
.table-details .mini-table { margin-top: 6px; }
.mini-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 14px; }
.mini-kpis div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.mini-kpis span { font-size: .82rem; color: var(--text-muted); }
.mini-kpis b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.response-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.response-list li { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.response-list li:last-child { border-bottom: 0; }
.response-list p { white-space: pre-line; }

.heatmap-wrap { overflow-x: auto; }
.heatmap { display: grid; grid-template-columns: 26px repeat(24, minmax(11px, 1fr)); gap: 2px; min-width: 300px; }
.hm-hour { font-size: .72rem; color: var(--text-faint); }
.hm-day { display: flex; align-items: center; font-size: .8rem; font-weight: 600; color: var(--text-muted); }
.hm-cell { height: 22px; border-radius: 3px; background: var(--surface-3); }
.hm-legend { display: flex; align-items: center; gap: 3px; margin-top: 10px; font-size: .8rem; color: var(--text-muted); }
.hm-legend i { width: 22px; height: 12px; border-radius: 2px; }
.hm-legend span:first-child { margin-right: 4px; }
.hm-legend span:last-child { margin-left: 4px; }

.cross-controls, .compare-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.cmp-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cmp-range legend { float: left; margin-right: 6px; font-weight: 700; color: var(--text-muted); }
.compare-table td { white-space: nowrap; }
.report-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 16px; }

.compare-card > summary { cursor: pointer; list-style: none; }
.compare-card > summary::-webkit-details-marker { display: none; }
.compare-card > summary::after { content: "펼치기 ▾"; font-size: .88rem; color: var(--text-muted); white-space: nowrap; }
.compare-card[open] > summary::after { content: "접기 ▴"; }
.compare-card:not([open]) > summary { border-bottom: 0; }

.print-only { display: none; }
#print-root { display: none; }
.print-inline { display: none; }

/* ---------------------------------------------------------------------
 * 인쇄 문서(명단 · QR 안내문) — 인쇄 시에만 보임
 * ------------------------------------------------------------------- */
.roster-head { margin-bottom: 10px; }
.roster-head h1 { font-size: 16pt; }
.roster-head p { margin-top: 2px; font-size: 9.5pt; color: #444; }
.roster-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; }
.roster-table th, .roster-table td { padding: 4px 6px; border: 1px solid #999; text-align: left; vertical-align: top; }
.roster-table thead { display: table-header-group; }
.roster-table thead th { background: #eef1f5; }
.roster-table tr { break-inside: avoid; }
.roster-table .num { width: 36px; text-align: right; }
.roster-table .sig-cell { width: 34mm; padding: 2px 4px; vertical-align: middle; }
.roster-sig { display: block; max-width: 32mm; max-height: 12mm; width: auto; height: auto; object-fit: contain; }

.qr-sheet { display: flex; flex-direction: column; align-items: center; height: 265mm; padding-top: 8mm; text-align: center; color: #111; }
.qs-logo { max-height: 22mm; max-width: 80mm; margin-bottom: 6mm; object-fit: contain; }
.qs-kicker { font-size: 16pt; font-weight: 700; color: var(--qs-brand); }
.qs-title { margin: 3mm 0 0; font-size: 30pt; font-weight: 800; line-height: 1.25; }
.qs-welcome { margin-top: 4mm; font-size: 13pt; color: #444; white-space: pre-line; }
.qs-qr { width: 105mm; height: 105mm; margin: 10mm 0 8mm; padding: 4mm; border: 2.5mm solid var(--qs-brand); border-radius: 6mm; }
.qs-steps { display: flex; gap: 8mm; margin: 0; padding: 0; list-style: none; font-size: 12.5pt; }
.qs-steps li { display: flex; align-items: center; gap: 2.5mm; }
.qs-steps b { display: inline-grid; place-items: center; width: 8mm; height: 8mm; border-radius: 50%; background: var(--qs-brand); color: #fff; font-size: 11pt; }
.qs-url { margin-top: auto; font-size: 9pt; color: #666; word-break: break-all; }

/* ---------------------------------------------------------------------
 * Print — A4 · 흰 배경 · 메뉴/버튼 숨김 · 차트가 페이지 사이에서 잘리지 않게
 * ------------------------------------------------------------------- */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #f6f7f9; --surface-3: #eef1f5;
    --text: #111; --text-muted: #374151; --text-faint: #6b7280;
    --border: #d1d5db; --border-strong: #9ca3af;
    --success: #15803d; --danger: #b91c1c; --shadow-sm: none; --shadow: none;
  }
  html, body { background: #fff !important; color: #111; font-size: 10.5pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sidebar, .topbar, .sidebar-backdrop, .toast-root, .loading-bar, .skip-link, .mode-badge-top,
  .no-print, .page-header .actions, .filter-card, .modal-backdrop, .menu, .kiosk-fs { display: none !important; }
  .admin-shell { display: block; }
  .content { max-width: none; margin: 0; padding: 0 2px; }
  .page-header { display: none !important; }
  .card { box-shadow: none; border-color: #d1d5db; }
  .print-only { display: block; }
  .print-inline { display: inline; }
  .print-section, .kpi, .mini-table tr, .card { break-inside: avoid; page-break-inside: avoid; }
  .section-heading { margin-top: 18px; break-after: avoid; page-break-after: avoid; }
  .print-exclude { display: none !important; }

  /* 차트: 캔버스 대신 인쇄 직전에 만든 고해상도 이미지 */
  canvas { display: none !important; }
  .chart-print-img { display: block !important; width: 100%; height: auto; }
  .chart-box { height: auto !important; }
  .response-list { max-height: none; overflow: visible; }
  .response-list li:nth-child(n+11), .response-list li.is-extra { display: none; }
  .table-scroll, .heatmap-wrap { overflow: visible; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-grid, .card-body.analysis-grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .kpi-value { font-size: 16pt; }
  .kpi-value-sm { font-size: 12pt; }

  /* 표지 */
  .print-cover { display: flex !important; flex-direction: column; justify-content: center; min-height: 240mm; break-after: page; page-break-after: always; }
  .print-cover.print-exclude { display: none !important; }
  .cover-logo { max-height: 24mm; max-width: 80mm; margin-bottom: 10mm; object-fit: contain; }
  .cover-kicker { font-size: 13pt; font-weight: 600; color: #555; }
  .cover-title { margin: 4mm 0 12mm; font-size: 28pt; }
  .cover-meta { display: grid; grid-template-columns: 30mm 1fr; gap: 3mm 6mm; font-size: 12pt; }
  .cover-meta dt { color: #555; }
  .cover-meta dd { margin: 0; font-weight: 600; }
  .print-filter { margin-bottom: 4mm; font-size: 9pt; color: #555; }

  /* 별도 인쇄 문서(명단·QR)만 인쇄할 때 */
  body.printing-custom #app, body.printing-custom .modal-backdrop { display: none !important; }
  body.printing-custom #print-root { display: block !important; padding: 0 2px; }
}
