/* EVENT MANAGEMENT PLATFORM - 공통 스타일 (반응형, 외부 CDN 미사용) */
:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f8fafc; --border: #dde3ea; --text: #1b2430; --muted: #64707d;
  --primary: #1f5fbf; --primary-strong: #174a96; --primary-soft: #e8f0fc;
  --success: #1a7f4b; --success-soft: #e6f5ec; --warning: #9a6700; --warning-soft: #fff5d6;
  --danger: #c0262d; --danger-soft: #fdecec; --info-soft: #eef2f7; --sidebar: #142033; --sidebar-text: #c9d3df;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --mono: Consolas, "D2Coding", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .mt-s { margin-top: .5rem; }

/* ---------- 관리자 레이아웃 */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { color: #fff; font-weight: 700; font-size: 1rem; padding: .25rem .5rem 1rem; letter-spacing: .02em; }
.brand small { display: block; font-weight: 400; color: #8fa1b5; font-size: .75rem; }
.nav a { display: block; color: var(--sidebar-text); padding: .55rem .75rem; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .sep { border-top: 1px solid rgba(255,255,255,.1); margin: .75rem 0; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--surface); border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; position: sticky; top: 0; z-index: 5; }
.topbar .user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .6rem; font-size: 1.1rem; cursor: pointer; }
.content { padding: 1.5rem; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .sub { color: var(--muted); font-size: .9rem; }
.screen-id { font-size: .72rem; color: var(--muted); font-family: var(--mono); }

/* ---------- 카드/그리드 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1rem; min-width: 0; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: .75rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .95rem; font-weight: 500; color: var(--muted); }
.stat .hint { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.stat.primary .value { color: var(--primary); } .stat.success .value { color: var(--success); } .stat.danger .value { color: var(--danger); }
.progress { height: 8px; background: var(--info-soft); border-radius: 99px; overflow: hidden; margin-top: .5rem; }
.progress > span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .4s; }
.chart-box { position: relative; height: 280px; }

/* ---------- 탭 */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 표 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: .6rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: var(--surface-2); font-weight: 600; color: #3a4654; white-space: nowrap; }
.table tbody tr:hover { background: #fafcff; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- 배지 */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--info-soft); color: #3a4654; white-space: nowrap; }
.badge.READY { background: var(--warning-soft); color: var(--warning); }
.badge.ACTIVE { background: var(--success-soft); color: var(--success); }
.badge.CLOSED { background: #e9ecef; color: #495057; }
.badge.CANCELLED, .badge.REVOKED { background: var(--danger-soft); color: var(--danger); }
.badge.UNUSED { background: var(--primary-soft); color: var(--primary); }
.badge.USED { background: var(--success-soft); color: var(--success); }
.badge.EXPIRED { background: #e9ecef; color: #6c757d; }
.live-dot { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--muted); }
.live-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #adb5bd; }
.live-dot.on::before { background: #22b35e; box-shadow: 0 0 0 3px rgba(34,179,94,.2); }
.live-dot.off::before { background: var(--danger); }

/* ---------- 폼 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
label.field { display: block; font-size: .87rem; font-weight: 600; color: #3a4654; }
label.field .req { color: var(--danger); }
.field-hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; margin-top: .3rem; padding: .55rem .7rem; border: 1px solid #c5cdd7; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,95,191,.25); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; margin-top: .3rem; font-weight: 400; }
.check input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label.field { min-width: 140px; }

/* ---------- 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid #c5cdd7; background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: #fff; border-color: #e3a5a8; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .3rem .6rem; font-size: .8rem; }
.btn.lg { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- 알림 */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert.info { background: var(--primary-soft); border-color: #c6d8f5; }
.alert.warn { background: var(--warning-soft); border-color: #f0dc9c; }
.alert.danger { background: var(--danger-soft); border-color: #f1c0c2; }
.alert.success { background: var(--success-soft); border-color: #b9e2c9; }
#toast-area { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: #1b2430; color: #fff; padding: .75rem 1rem; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: .9rem; }
.toast.error { background: var(--danger); } .toast.success { background: var(--success); }

/* ---------- 정보 목록 */
dl.info { display: grid; grid-template-columns: 140px 1fr; gap: .45rem 1rem; margin: 0; font-size: .92rem; }
dl.info dt { color: var(--muted); } dl.info dd { margin: 0; word-break: break-all; }

/* ---------- 인증번호 표시 */
.code-big { font-family: var(--mono); font-size: 2.6rem; font-weight: 700; letter-spacing: .08em; text-align: center; padding: 1.25rem; background: var(--surface-2); border: 2px dashed var(--primary); border-radius: 12px; color: var(--primary-strong); word-break: break-all; }
.code-list { font-family: var(--mono); max-height: 320px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .75rem; columns: 3 160px; font-size: .95rem; }
.qr-img { width: 100%; max-width: 320px; border: 1px solid var(--border); border-radius: 8px; background: #fff; padding: .5rem; display: block; }
.url-box { font-family: var(--mono); font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .5rem; word-break: break-all; }

/* ---------- 로그인 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, #142033, #1f5fbf); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 2rem 1.75rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card h1 { font-size: 1.2rem; }
.login-card .field { margin-bottom: .85rem; }

/* ---------- 참가자 화면 (모바일 우선) */
.p-body { background: #eef2f7; min-height: 100vh; }
.p-wrap { max-width: 480px; margin: 0 auto; padding: 1rem 1rem 2rem; }
.p-head { background: linear-gradient(150deg, #1f5fbf, #174a96); color: #fff; border-radius: 16px; padding: 1.4rem 1.25rem; margin-bottom: 1rem; }
.p-head .kicker { font-size: .8rem; opacity: .85; }
.p-head h1 { font-size: 1.5rem; margin: .25rem 0 .5rem; word-break: keep-all; }
.p-head .meta { font-size: .88rem; opacity: .92; }
.p-card { background: #fff; border-radius: 16px; padding: 1.4rem 1.25rem; box-shadow: var(--shadow); }
.p-card h2 { font-size: 1.15rem; }
.code-input { width: 100%; font-family: var(--mono); font-size: 1.9rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; padding: .9rem .5rem; border: 2px solid #b8c4d3; border-radius: 12px; margin: .75rem 0 1rem; }
.code-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(31,95,191,.15); }
.p-btn { width: 100%; padding: 1rem; font-size: 1.15rem; border-radius: 12px; border: none; background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; }
.p-btn:disabled { opacity: .6; }
.p-btn.secondary { background: #fff; color: var(--primary); border: 2px solid var(--primary); margin-top: .75rem; }
.result { text-align: center; padding: 1rem 0; }
.result .icon { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; font-size: 2.6rem; font-weight: 700; color: #fff; }
.result.ok .icon { background: var(--success); } .result.fail .icon { background: var(--danger); }
.result h2 { font-size: 1.4rem; } .result.ok h2 { color: var(--success); } .result.fail h2 { color: var(--danger); }
.result .time { font-size: 1.05rem; font-weight: 600; margin-top: .5rem; }
.p-notice { font-size: .82rem; color: var(--muted); margin-top: 1rem; line-height: 1.6; }

/* ---------- 안내문(인쇄) */
.poster { max-width: 800px; margin: 0 auto; padding: 2rem; text-align: center; background: #fff; }
.poster h1 { font-size: 2.2rem; margin-bottom: .5rem; }
.poster .poster-meta { font-size: 1.1rem; color: #333; margin-bottom: 1.5rem; }
.poster img { width: 70%; max-width: 480px; }
.poster ol { text-align: left; display: inline-block; font-size: 1.15rem; line-height: 2; margin-top: 1.25rem; }
.poster .no-print { margin-bottom: 1.5rem; }

/* ---------- 반응형 */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .menu-toggle { display: inline-block; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 1.5rem; }
  dl.info { grid-template-columns: 110px 1fr; }
  .code-big { font-size: 1.9rem; }
  .topbar .user .uname { display: none; }
}
@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  body { background: #fff; }
  .poster { padding: 0; }
}

/* ---------- Supabase 버전 추가: 모바일 목록 카드, 메뉴 서랍 */
.btn.block { width: 100%; }
.list { display: flex; flex-direction: column; gap: .5rem; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
a.list-item:hover { text-decoration: none; border-color: var(--primary); background: #fafcff; }
.list-item .li-main { min-width: 0; flex: 1 1 260px; }
.list-item .li-main b { word-break: keep-all; }
.li-stats { display: flex; gap: 1rem; }
.li-stats div { text-align: center; min-width: 52px; }
.li-stats b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.li-stats span { font-size: .75rem; color: var(--muted); }
.sidebar-backdrop { display: none; }
#toast-area { bottom: calc(1rem + env(safe-area-inset-bottom)); }
@media (max-width: 760px) {
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .topbar .crumb { display: none; }
  .page-head h1 { font-size: 1.2rem; }
  .btn { padding: .6rem .9rem; }
  .btn.sm { padding: .45rem .7rem; }
  .card { padding: 1rem; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .btn { width: 100%; }
  .list-item .btn-row { width: 100%; }
  .li-stats { width: 100%; justify-content: space-around; border-top: 1px dashed var(--border); padding-top: .5rem; }
  .table th, .table td { padding: .5rem .45rem; }
  .code-list { columns: 2 120px; }
  .chart-box { height: 240px; }
  input, select, textarea { font-size: 16px; } /* iOS 자동 확대 방지 */
}
