/* ==========================================================
   QR 라벨 인쇄
   색: 바탕 #F4F3EF / 글자 #17191C / 보조 #5B6068 / 선 #E2E0DA / 강조 #1E5B4B
   ========================================================== */

:root {
    --ground: #F4F3EF;
    --surface: #FFFFFF;
    --ink: #17191C;
    --muted: #5B6068;
    --line: #E2E0DA;
    --line-soft: #ECEAE4;
    --control: #D6D3CB;
    --accent: #1E5B4B;
    --accent-deep: #123B30;
    --accent-soft: #E6F0EC;
    --font: 'IBM Plex Sans KR', 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.55; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-weight: 600; text-align: center; }
.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 상단 바 ---------- */

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }

.topbar-inner {
    max-width: 1440px; margin: 0 auto; padding: 14px 32px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px;
    min-height: 72px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }

.steps {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap; gap: 6px 18px;
    font-size: 14px; color: var(--muted);
}
.step { display: flex; align-items: center; gap: 6px; }
.step-dot {
    width: 20px; height: 20px; border-radius: 10px;
    border: 1.5px solid #9AA0A6; font-size: 12px;
    display: inline-flex; align-items: center; justify-content: center;
}
.step--done .step-dot, .step--active .step-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.step--active { color: var(--ink); font-weight: 600; }

.topbar-file { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.file-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: var(--ground); border-radius: 8px;
}

.notice {
    max-width: 1376px; margin: 16px auto 0; padding: 12px 16px;
    background: #FFF6E5; border: 1px solid #F0D9A8; border-radius: 10px;
    color: #6B4A00; font-size: 14px;
}

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

.btn-primary {
    display: inline-flex; align-items: center; gap: 10px;
    min-height: 52px; padding: 0 26px; border: 0; border-radius: 12px;
    background: var(--accent); color: #fff;
    font-size: 17px; font-weight: 700; cursor: pointer;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); }

.btn-outline {
    min-height: 44px; padding: 0 14px; border-radius: 8px;
    border: 1px solid var(--control); background: var(--surface);
    font-weight: 500; cursor: pointer;
}
.btn-outline:hover { background: #F7F6F2; }
.btn-outline--accent { border-color: var(--accent); color: var(--accent); font-weight: 600; border-radius: 10px; width: 100%; }

.link-btn {
    border: 0; background: transparent; padding: 0 4px; min-height: 32px;
    color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer;
    align-self: flex-start;
}
.link-btn:hover { text-decoration: underline; }

.icon-btn {
    width: 40px; height: 40px; border-radius: 10px;
    border: 1px solid var(--control); background: var(--surface);
    font-size: 18px; cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: #F7F6F2; }
.icon-btn--lg { width: 44px; height: 44px; font-size: 20px; }

/* ---------- 1. 시작 화면 ---------- */

.start {
    max-width: 760px; margin: 0 auto; padding: 72px 24px;
    display: flex; flex-direction: column; gap: 28px;
}
.start-head h1 { margin: 0 0 10px; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.start-head p { margin: 0; font-size: 17px; line-height: 1.6; color: #4A4F57; }

.drop {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    min-height: 280px; padding: 32px; text-align: center;
    border: 2px dashed #B9B5AB; border-radius: 18px; background: var(--surface);
    cursor: pointer;
}
.drop:hover, .drop--over { border-color: var(--accent); background: #F3F8F6; }
.drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-title { font-size: 20px; font-weight: 700; }
.drop-sub { font-size: 15px; color: var(--muted); }
.drop-sub u { color: var(--accent); font-weight: 600; }

.error {
    margin: 0; padding: 12px 16px; border-radius: 10px;
    background: #FDECEC; border: 1px solid #F3C2C2; color: #8A1C1C; font-size: 15px;
}

.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.col-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 16px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted);
}
.col-card b { font-size: 15px; color: var(--ink); }
.col-key { font-family: var(--mono); color: var(--accent); font-weight: 500; }

/* ---------- 2. 작업 화면 ---------- */

.work {
    max-width: 1440px; margin: 0 auto; padding: 24px 32px 48px;
    display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start;
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.row-between { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

h2 { margin: 0; font-size: 18px; font-weight: 700; }
h3 { margin: 0; font-size: 15px; font-weight: 700; }

/* 성도 목록 */

.members { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.members-head {
    padding: 20px 20px 14px; display: flex; flex-direction: column; gap: 14px;
    border-bottom: 1px solid var(--line-soft);
}
.sel-count { color: var(--accent); font-size: 16px; }

.search {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--control); border-radius: 10px; padding: 0 12px; min-height: 44px;
}
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; font: inherit; font-size: 15px; background: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--small { gap: 6px; }

.chip {
    min-height: 40px; padding: 0 14px; border-radius: 20px;
    border: 1px solid var(--control); background: var(--surface);
    font-size: 14px; font-weight: 500; cursor: pointer;
}
.chip-count { color: var(--muted); font-weight: 400; }
.chip:hover { background: #F7F6F2; }
.chip--on, .chip--on:hover { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip--on .chip-count { color: #fff; opacity: 0.8; }

.chip-sm {
    min-height: 34px; padding: 0 12px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--surface);
    font-size: 13px; color: #3D4148; cursor: pointer;
}
.chip-sm--on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

.members-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; background: #FAFAF7; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.check-all { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; font-weight: 600; }
.members-bar .link-btn { margin-left: auto; align-self: center; }

input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.member-list { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.member-row {
    display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 14px;
    padding: 0 20px; min-height: 52px; border-bottom: 1px solid #F0EEE9; cursor: pointer;
}
.member-row:hover { background: #F7F6F2; }
.member-main { display: flex; flex-direction: column; min-width: 0; }
.member-name { font-size: 16px; font-weight: 600; }
.member-place { font-size: 13px; color: var(--muted); }
.member-code { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--muted); font-size: 15px; }

/* 미리보기 영역 */

.sheet-area { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.print-bar { padding: 18px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.print-bar-text { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.print-bar .btn-primary { margin-left: auto; }

.sheet-row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }

.preview { flex: 0 0 auto; max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.preview .small { max-width: 504px; margin: 0; }
.preview-scroll { max-width: 100%; overflow-x: auto; }

.pager { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.pager-text { font-weight: 600; min-width: 72px; text-align: center; }

.side { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.side-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.side-card p { margin: 0; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper-value { flex: 1; text-align: center; font-size: 22px; font-weight: 700; }
.stepper-value small { font-size: 14px; font-weight: 500; color: var(--muted); }

.disclosure {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border: 0; background: transparent; padding: 0; min-height: 32px;
    font-size: 15px; font-weight: 700; cursor: pointer; text-align: left;
}
.disclosure .small { font-weight: 500; }

.cal-grid {
    display: grid; grid-template-columns: 56px 40px minmax(0, 1fr) 40px;
    align-items: center; gap: 8px; font-size: 14px;
}

.tip {
    background: var(--accent-soft); border-radius: 14px; padding: 16px 18px;
    display: flex; flex-direction: column; gap: 8px;
    font-size: 13px; line-height: 1.5; color: var(--accent-deep);
}
.tip > b { font-size: 14px; }

/* ==========================================================
   라벨지 (미리보기 · 인쇄 공통)
   --mm 하나로 크기를 정한다: 미리보기 2.4px, 인쇄 1mm
   규격: A4, 70 × 42.3mm, 3열 × 7행, 위 여백 0.45mm, 왼쪽 여백 0
   ========================================================== */

.sheet {
    position: relative;
    width: calc(var(--mm) * 210);
    height: calc(var(--mm) * 297);
    overflow: hidden;
    background: #fff;
}

.sheet-grid {
    display: grid;
    grid-template-columns: repeat(3, calc(var(--mm) * 70));
    grid-auto-rows: calc(var(--mm) * 42.3);
    padding-top: calc(var(--mm) * 0.45);
    padding-left: 0;
}

.cell { position: relative; overflow: hidden; }

/* 라벨 내용 */
.lbl {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--mm) * 1); /* QR 자체 여백(4모듈 ≈ 5mm)이 있어 1mm 면 충분 */
    padding: 0 calc(var(--mm) * 2);
    color: #000;
    text-align: left;
}
.lbl-qr {
    flex: none;
    width: calc(var(--mm) * 38);
    height: calc(var(--mm) * 38);
}
.lbl-text { display: flex; flex-direction: column; gap: calc(var(--mm) * 1.5); min-width: 0; }
.lbl-name {
    font-size: calc(var(--mm) * 6.35);       /* 18pt */
    font-weight: 700; line-height: 1.15;
    white-space: nowrap; overflow: hidden;
}
.lbl-name--long { font-size: calc(var(--mm) * 4.939); } /* 14pt, 5글자 이상 */
.lbl-place, .lbl-code { font-size: calc(var(--mm) * 3.881); line-height: 1.2; } /* 11pt */
.lbl-code { font-family: var(--mono); letter-spacing: 0.04em; }

/* 미리보기 전용 */
.sheet--preview {
    --mm: 2.4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.08);
}
.sheet--preview .cell {
    border: 0;
    border-right: 1px dashed #E4E2DC;
    border-bottom: 1px dashed #E4E2DC;
    background: #fff;
    padding: 0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
}
.sheet--preview .cell:hover { box-shadow: inset 0 0 0 2px var(--accent); }
.cell--used { background: repeating-linear-gradient(135deg, #EEECE6 0 6px, #F7F6F2 6px 12px) !important; }
.cell-note { font-size: 12px; font-weight: 500; color: #6B7078; }
.cell-note--faint { color: #A3A7AD; font-weight: 400; }
.start-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
}

/* 보정용 테두리 */
.cell--cal {
    outline: calc(var(--mm) * 0.2) solid #000;
    outline-offset: calc(var(--mm) * -0.1);
    display: flex; align-items: center; justify-content: center;
}
.cal-no { font-size: calc(var(--mm) * 6); font-weight: 700; color: #000; }
.cal-caption {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    background: #fff; padding: calc(var(--mm) * 2) calc(var(--mm) * 4);
    border: calc(var(--mm) * 0.3) solid #000;
    font-size: calc(var(--mm) * 4); font-weight: 700; color: #000; white-space: nowrap;
}

/* ---------- 인쇄 ---------- */

.print-root { display: none; --mm: 1mm; }

@page { size: A4; margin: 0; }

@media print {
    html, body { background: #fff; }
    .app, #blazor-error-ui { display: none !important; }
    .print-root { display: block; }
    .sheet--print { break-after: page; page-break-after: always; }
    .sheet--print:last-child { break-after: auto; page-break-after: auto; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- 로딩 · 오류 ---------- */

.boot {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; color: var(--muted); font-size: 15px;
}
.boot-spinner {
    width: 32px; height: 32px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    padding: 12px 20px; background: #FDECEC; color: #8A1C1C; font-size: 14px;
}
#blazor-error-ui .reload { margin-left: 8px; color: inherit; font-weight: 600; }

/* ---------- 좁은 화면 ---------- */

@media (max-width: 720px) {
    .topbar-inner, .work { padding-left: 16px; padding-right: 16px; }
    .topbar-file { margin-left: 0; }
    .cols { grid-template-columns: minmax(0, 1fr); }
    .print-bar .btn-primary { margin-left: 0; width: 100%; justify-content: center; }
}
