/* 거주자 앱 — 폰 화면 먼저. 큰 글씨, 누르기 쉬운 버튼. */
:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #5d6a65;
  --line: #dde3e0;
  --brand: #1f5f4a;
  --brand-soft: #e3efe9;
  --danger: #b3261e;
  --danger-soft: #fbeae9;
  --warn-soft: #fff4d6;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.container { max-width: 560px; margin: 0 auto; padding: 16px 16px 96px; }
.container.wide { max-width: 960px; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; }

h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; color: var(--muted); }
p { margin: 0 0 8px; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 0.85rem; }
.big { font-size: 1.15rem; font-weight: 700; }
.strike { text-decoration: line-through; color: var(--muted); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.guide { white-space: pre-wrap; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 12px;
}
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.section-head h2 { margin: 0; }

/* ─── 폼 ─── */
label { display: block; font-weight: 600; margin: 12px 0 6px; }
label.check { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 8px 0; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=time], input[type=datetime-local],
input:not([type]), select, textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.row > input { flex: 1 1 200px; width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; margin: 12px 0; }
legend { font-weight: 600; padding: 0 4px; }
.form-error { color: var(--danger); min-height: 1.4em; margin-top: 8px; }
.entry { margin-top: 24px; }
.entry .btn-block { margin-top: 8px; }
.grid-2, .grid-3 { display: grid; gap: 0 12px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1.4fr 1fr 1fr; }
.time-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.time-row input { flex: 1; }
.day-check { margin: 4px 8px 4px 0; }

/* ─── 버튼 ─── */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 16px;
  min-height: 44px;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-outline { color: var(--danger); border-color: #e7b9b5; }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 6px 10px; min-height: 34px; font-size: 0.9rem; }
.btn-link { background: none; border: none; color: var(--brand); text-decoration: underline; font: inherit; padding: 4px; cursor: pointer; }

/* ─── 상단 ─── */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.topbar .title { font-size: 1.25rem; font-weight: 800; }
.topbar .sub { color: var(--muted); font-size: 0.9rem; }
.chip { display: inline-block; background: var(--brand-soft); color: var(--brand); font-weight: 700; border-radius: 999px; padding: 4px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { font-weight: 600; font-size: 0.9rem; }

/* ─── 거주자: 내 예약 · 타임 ─── */
.mine-card { border-color: var(--brand); background: linear-gradient(0deg, #fff, var(--brand-soft)); }
.mine-card .row { margin-top: 12px; }
.day h3 { margin-top: 18px; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 84px;
  cursor: pointer;
}
.slot:disabled { cursor: default; }
.slot-part { font-size: 0.85rem; color: var(--muted); }
.slot-time { font-weight: 700; font-size: 1.05rem; }
.slot-state { font-size: 0.85rem; font-weight: 600; }
.slot-open { border-color: var(--brand); }
.slot-open .slot-state { color: var(--brand); }
.slot-open:not(:disabled):active { background: var(--brand-soft); }
.slot-mine { background: var(--brand); border-color: var(--brand); color: #fff; }
.slot-mine .slot-part, .slot-mine .slot-state { color: #fff; }
.slot-taken, .slot-closed { background: #f0f2f1; color: #8b9692; }
.slot-taken .slot-time, .slot-closed .slot-time { text-decoration: line-through; }
.foot { text-align: center; margin-top: 24px; color: var(--muted); }

/* ─── 관리자 ─── */
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--brand); border-color: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.booking-line { background: var(--warn-soft); border-color: #f0dfa8; }
.slot-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.slot-row-time { font-weight: 600; }
.slot-row-status { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.slot-row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.slot-row.is-closed .slot-row-time { color: var(--muted); }
.badge { font-size: 0.75rem; border-radius: 6px; padding: 1px 6px; background: var(--brand-soft); color: var(--brand); font-weight: 700; margin-left: 4px; }
.badge-lock { background: var(--warn-soft); color: #7a5b00; }
.log { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.log li { padding: 6px 0; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
.row-end { flex-wrap: nowrap; justify-content: flex-end; }

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .slot-row { grid-template-columns: 1fr auto; }
  .slot-row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :first-child { grid-column: 1 / -1; }
}

/* ─── 알림 · 창 ─── */
#toasts { position: fixed; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; z-index: 20; }
body:has(.demo-bar) #toasts { bottom: 72px; }
.toast { background: #1c2421; color: #fff; padding: 12px 16px; border-radius: 12px; max-width: 520px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast-error { background: var(--danger); }
.toast-success { background: var(--brand); }
.dialog { border: none; border-radius: var(--radius); padding: 20px; width: min(92vw, 440px); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(0,0,0,.4); }
.dialog h2 { margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.demo-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--warn-soft); border-top: 1px solid #f0dfa8; padding: 8px 16px; font-size: 0.85rem; text-align: center; z-index: 10; }

/* ─── 인쇄: 세대별 안내문만 ─── */
#print-area { display: none; }
@media print {
  body { background: #fff; }
  body > :not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .print-card { border: 1px dashed #999; padding: 16px; margin: 0 0 12px; break-inside: avoid; font-size: 12pt; }
  .print-title { font-weight: 700; margin-bottom: 4px; }
  .print-unit { font-size: 20pt; font-weight: 800; margin-bottom: 8px; }
  .print-code { font-size: 16pt; }
}

/* ─── 문의·접수 ─── */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.back { display: inline-block; margin: 0 0 12px; text-decoration: none; font-weight: 600; }
.emergency { border-color: #f0c2bf; background: var(--danger-soft); }
.emergency h2 { color: var(--danger); }
.kind-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kind-btn {
  display: flex; flex-direction: column; gap: 4px; padding: 14px; min-height: 92px;
  border: 1.5px solid var(--brand); border-radius: 12px; text-decoration: none; color: var(--text); background: #fff;
}
.kind-btn strong { color: var(--brand); font-size: 1.05rem; }
.kind-btn span { color: var(--muted); font-size: 0.85rem; }
.kind-btn:active { background: var(--brand-soft); }

.status { display: inline-block; font-size: 0.78rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.status-new { background: #e4ecfb; color: #1d4ea8; }
.status-mid { background: var(--warn-soft); color: #7a5b00; }
.status-done { background: var(--brand-soft); color: var(--brand); }
.status-off { background: #eceeed; color: var(--muted); }
.badge-urgent { background: var(--danger-soft); color: var(--danger); }

.req { border-top: 1px solid var(--line); }
.req-head {
  font: inherit; color: inherit; background: none; border: none; width: 100%; text-align: left; cursor: pointer;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 0 4px;
}
.req-title { font-weight: 700; }
.req-date { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.req-preview { color: var(--muted); margin: 0 0 12px; }
.req-body { padding: 4px 0 14px; }
.note { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.note p { margin: 4px 0 0; }

.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: #f0f2f1; cursor: pointer; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-ph { width: 84px; height: 84px; border-radius: 10px; background: #eceeed; }
.photo-remove { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.photo-full { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; }
.photo-add { display: inline-flex; align-items: center; margin-top: 12px; }

.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { display: inline-flex; margin: 0; font-weight: 500; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; background: #fff; }
.choice input:checked + span { border-color: var(--brand); background: var(--brand); color: #fff; }
.choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.callout { border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; }
.callout p { margin: 4px 0 0; }
.callout-urgent { background: var(--danger-soft); border: 1px solid #f0c2bf; }

/* 관리자 › 접수 */
.tab-count { display: inline-block; margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.75rem; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn { font: inherit; font-size: 0.9rem; border: none; background: #fff; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.seg-btn.active { background: var(--brand); color: #fff; }
.section-head select { width: auto; padding: 6px 10px; }
.req-row {
  font: inherit; color: inherit; text-align: left; width: 100%; background: none; border: none; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 4px; cursor: pointer;
}
.req-row:hover { background: #f7f9f8; }
.req-row.is-new { background: #f5f8ff; }
.req-row-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.req-row-body { grid-column: 1 / 2; color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-row-date { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 0.85rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.req-detail .guide { background: #f7f9f8; border-radius: 10px; padding: 10px 12px; }
