/* §13 Pure Minimal */
:root {
  --bg: #FAFAFA;
  --text: #333333;
  --accent: #2563EB;
  --c-wait: #6B7280;
  --c-progress: #F59E0B;
  --c-done: #10B981;
  --c-defer: #DC2626;
  --border: #E5E7EB;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── 상단 바 ───────────────────────── */
#topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.topbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#app-title { font-weight: 700; font-size: 15px; white-space: nowrap; }
select, input[type="search"], textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  min-height: 44px;
}
#round-select { flex: 1; min-width: 0; }
#type-filter { max-width: 140px; }
#branch-search { flex: 1; min-width: 100px; }
.chip-group { display: flex; gap: 4px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0 12px;
  min-height: 34px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;
  font-size: 18px;
  cursor: pointer;
}

/* ── 지도 ───────────────────────── */
#map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; background: #E5E7EB; }
#map-notice {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1.7;
  z-index: 5;
}

/* 마커 (커스텀 오버레이) */
.marker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--c-wait);
  color: #fff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
  cursor: pointer;
  transform: translateY(-50%);
  border: 2px solid transparent;
}
.marker.st-progress { background: var(--c-progress); }
.marker.st-done { background: var(--c-done); }
.marker.warn-ring { border-color: var(--c-defer); box-shadow: 0 0 0 2px rgba(220,38,38,.35), 0 1px 4px rgba(0,0,0,.3); }
.marker.compact {
  padding: 4px 7px;
  font-size: 11px;
  min-width: 30px;
  justify-content: center;
}
.marker .badge {
  background: rgba(255,255,255,.9);
  color: var(--text);
  border-radius: 999px;
  font-size: 10px;
  padding: 1px 5px;
  font-weight: 700;
}

/* ── 지점 패널 ───────────────────────── */
#panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 380px;
  background: #fff;
  border-left: 1px solid var(--border);
  z-index: 30;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 8px rgba(0,0,0,.06);
}
#panel-handle { display: none; }
#panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 8px;
}
#panel-branch-name { font-size: 17px; }
#panel-branch-sub { font-size: 12px; color: var(--c-wait); margin-top: 3px; }
#panel-actions { display: flex; gap: 8px; padding: 0 16px 10px; }
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 0 14px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }

#device-list { flex: 1; overflow-y: auto; list-style: none; padding: 0 12px 20px; }
.device-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.device-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.device-loc { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; }
.device-meta { font-size: 12px; color: var(--c-wait); margin-top: 3px; line-height: 1.5; }
.device-key { font-size: 12px; color: var(--c-wait); margin-top: 4px; }
.device-key b { font-size: 17px; color: var(--text); letter-spacing: 1px; }
.type-badge {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  padding: 1px 6px;
  color: var(--c-wait);
  margin-left: 6px;
  vertical-align: 1px;
}
.status-badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  color: #fff;
  white-space: nowrap;
}
.status-badge.s-X { background: var(--c-wait); }
.status-badge.s-O { background: var(--c-done); }
.status-badge.s-취소 { background: #9CA3AF; }
.status-badge.s-연기 { background: var(--c-defer); }
.device-note { font-size: 12px; color: var(--c-defer); margin-top: 4px; }
.device-done-info { font-size: 12px; color: var(--c-done); margin-top: 4px; }
.device-btns { display: flex; gap: 6px; margin-top: 8px; }
.device-btns .btn { flex: 1; min-height: 40px; font-size: 13px; }

/* ── 모달 ───────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
}
.modal-box h3 { font-size: 16px; }
.modal-sub { font-size: 13px; color: var(--c-wait); margin-top: 5px; line-height: 1.5; }
.modal-btns { display: flex; gap: 8px; margin-top: 16px; }
.modal-btns .btn { flex: 1; }
.warn-text { color: var(--c-defer); font-size: 13px; margin-top: 8px; }
textarea { width: 100%; margin-top: 12px; resize: vertical; font-family: inherit; }

/* 바코드 키패드 */
#barcode-display {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#barcode-value { font-size: 26px; font-weight: 700; letter-spacing: 2px; word-break: break-all; }
#keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}
#keypad button {
  min-height: 52px;
  font-size: 22px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
#keypad button:active { background: var(--border); }
#keypad .key-fn { font-size: 15px; color: var(--c-wait); }

/* 토스트 */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  z-index: 200;
  max-width: 90vw;
}

/* 바코드 없이 완료(패스) */
.btn-pass {
  width: 100%;
  margin-top: 10px;
  color: var(--c-wait);
  border-style: dashed;
}

/* ── 목록(표) 보기 ───────────────────────── */
#list-view {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.table-wrap { flex: 1; overflow: auto; }
#list-table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}
#list-table th, #list-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
}
#list-table th {
  position: sticky;
  top: 0;
  background: #fff;
  box-shadow: 0 1px 0 var(--border);
  font-weight: 700;
}
#list-table tbody tr:hover { background: #F3F4F6; }
.row-actions { white-space: nowrap; }
.btn.mini {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  margin-right: 4px;
}

/* ── 매핑 마법사 / 지오코딩 ───────────────────────── */
.wizard-box { max-width: 680px; max-height: 88vh; display: flex; flex-direction: column; }
.wizard-head { display: flex; justify-content: space-between; align-items: flex-start; }
#wizard-body, #geocode-body { flex: 1; overflow-y: auto; margin-top: 12px; min-height: 120px; }
.radio-row { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 14px; cursor: pointer; }
.radio-row input { width: 18px; height: 18px; }
.sub-form { margin: 4px 0 8px 26px; display: flex; flex-direction: column; gap: 6px; }
.sub-form input, .sub-form select { width: 100%; }
.date-row { display: flex; gap: 10px; font-size: 13px; color: var(--c-wait); }
.date-row label { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.wizard-note { font-size: 13px; color: var(--c-wait); margin: 6px 0; line-height: 1.5; }
.badge-rec { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 8px; }
.wizard-preview { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.wizard-preview table { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.wizard-preview td, .wizard-preview th { border-bottom: 1px solid var(--border); padding: 4px 8px; }
.wizard-preview tr { cursor: pointer; }
.wizard-preview tr.header-row { background: #DBEAFE; font-weight: 700; }
.wizard-preview .row-no { color: var(--c-wait); background: #F3F4F6; }
.filter-row { display: flex; gap: 8px; margin: 6px 0; }
.filter-row select, .filter-row input { flex: 1; min-width: 0; }
.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.map-row { display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 40px; }
.map-row span { width: 90px; flex-shrink: 0; }
.map-row select { flex: 1; min-width: 0; min-height: 36px; padding: 4px 8px; }
.map-row.required span { font-weight: 700; }
.preview-summary { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
.geo-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 6px 0;
  font-size: 13px;
}
.geo-item small { color: var(--c-wait); }
.geo-section { border-top: 1px solid var(--border); padding: 8px 0; margin-top: 8px; }
.geo-tools { margin: 8px 0; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
#map-click-banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; z-index: 40;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
@media (max-width: 768px) {
  .map-grid { grid-template-columns: 1fr; }
}

/* ── 페이스 대시보드 ───────────────────────── */
#pace-bar { border-top: 1px solid var(--border); padding-top: 6px; }
#pace-summary-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
#pace-bar.collapsed #pace-cards { display: none; }
.icon-btn.mini { min-width: 32px; min-height: 32px; font-size: 13px; }
#pace-cards { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; align-items: stretch; }
.pace-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
  min-width: 86px; flex-shrink: 0; background: #fff;
  display: flex; flex-direction: column; gap: 2px;
}
.pace-card b { font-size: 20px; }
.pace-card span { font-size: 11px; color: var(--c-wait); }
.pace-card.warn b { color: var(--c-progress); }
.pace-card.v-good b { color: var(--c-done); }
.pace-card.v-tight b { color: var(--c-progress); }
.pace-card.v-late b { color: var(--c-defer); }
.v-chip { border-radius: 999px; color: #fff; padding: 2px 10px; font-size: 12px; background: var(--c-wait); }
.v-chip.v-good { background: var(--c-done); }
.v-chip.v-tight { background: var(--c-progress); }
.v-chip.v-late { background: var(--c-defer); }

/* ── 일정 배정 ───────────────────────── */
#schedule-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); z-index: 40;
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  max-width: 94vw; flex-wrap: wrap;
}
#schedule-info { font-size: 13px; font-weight: 600; white-space: nowrap; }
#schedule-date { min-height: 40px; }
#schedule-bar .btn { min-height: 40px; font-size: 13px; }
.marker.sel { outline: 3px solid var(--accent); outline-offset: 1px; }

/* 동기화 상태 점 */
.sync-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--c-wait); flex-shrink: 0; }
.sync-dot.s-ok { background: var(--c-done); }
.sync-dot.s-err { background: var(--c-defer); }
.sync-dot.s-sync { background: var(--c-progress); }

.date-inline { min-height: 32px; padding: 2px 6px; font-size: 12px; }
.date-chip { min-height: 34px; border-radius: 999px; padding: 0 10px; font-size: 13px; max-width: 150px; }

/* 작업자 선택 (완료·연기·취소 모달 안) */
.worker-seg { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.ws-label { font-size: 13px; color: var(--c-wait); }
.worker-seg .ws { min-width: 48px; min-height: 44px; font-size: 16px; font-weight: 700; }
.worker-seg.big .ws { flex: 1; min-height: 56px; font-size: 22px; }

.hidden { display: none !important; }

/* ── 모바일: 바텀시트 ───────────────────────── */
@media (max-width: 768px) {
  #panel {
    top: auto;
    left: 0;
    width: 100%;
    height: 62vh;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
  }
  #panel-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 2px;
  }
  #panel-handle span {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
  }
  #status-filter { overflow-x: auto; }
}
