/* 콜비서 — 야간 도로 디자인
 * 어두운 아스팔트 바탕에 신호 앰버(행동)와 도로표지(판정: 녹색·청색·적색)를 씁니다.
 * 중앙선(점선)이 구분선이고, 금액은 간판 글꼴(Do Hyeon)로 크게 보여 줍니다. */

:root {
  --bg: #0e141b;
  --surface: #151d27;
  --raised: #1c2733;
  --line: #263341;
  --text: #e9eef4;
  --muted: #92a0b1;
  --faint: #5e6c7d;
  --amber: #ffb020;
  --amber-ink: #1b1200;
  --amber-text: #ffc24d;
  --money: #4ddba0;
  --danger: #ff7a6b;
  --warn-bg: #3a2c0b;
  --warn-text: #ffd27a;
  --sign-green: #0f7b55;
  --sign-blue: #1b5fbf;
  --sign-red: #c8362e;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 8px 24px rgb(0 0 0 / 0.28);
  --font: 'IBM Plex Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-num: 'Do Hyeon', 'IBM Plex Sans KR', system-ui, sans-serif;
  --num-w: 400;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #eef1f4;
    --surface: #ffffff;
    --raised: #f5f7f9;
    --line: #d9dfe6;
    --text: #131a22;
    --muted: #5a6776;
    --faint: #8a95a2;
    --amber: #f5a000;
    --amber-ink: #1b1200;
    --amber-text: #8a5a00;
    --money: #0c7a4d;
    --danger: #c0392b;
    --warn-bg: #fff1cf;
    --warn-text: #7a5600;
    --shadow: 0 1px 2px rgb(20 30 45 / 0.06), 0 6px 18px rgb(20 30 45 / 0.06);
    color-scheme: light;
  }
}
:root[data-theme='light'] {
  --bg: #eef1f4;
  --surface: #ffffff;
  --raised: #f5f7f9;
  --line: #d9dfe6;
  --text: #131a22;
  --muted: #5a6776;
  --faint: #8a95a2;
  --amber: #f5a000;
  --amber-ink: #1b1200;
  --amber-text: #8a5a00;
  --money: #0c7a4d;
  --danger: #c0392b;
  --warn-bg: #fff1cf;
  --warn-text: #7a5600;
  --shadow: 0 1px 2px rgb(20 30 45 / 0.06), 0 6px 18px rgb(20 30 45 / 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.55 var(--font);
  letter-spacing: -0.01em;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
b, strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }
.bad { color: var(--danger); font-weight: 600; }
.ok { color: var(--money); font-weight: 600; }
[hidden] { display: none !important; }

.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 16px; height: 16px; }

/* ---------- 헤더 ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 560px; margin: 0 auto; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { font: var(--num-w) 24px/1 var(--font-num); letter-spacing: 0; }
.mark { width: 20px; height: 24px; fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; }

.work {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text);
  font: 600 14px/1 var(--font); cursor: pointer;
}
.work::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.work.on { border-color: color-mix(in srgb, var(--money) 55%, var(--line)); }
.work.on::before { background: var(--money); box-shadow: 0 0 0 4px color-mix(in srgb, var(--money) 22%, transparent); }
.work .t { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.banner { max-width: 560px; margin: 0 auto 8px; padding: 8px 16px; background: var(--warn-bg); color: var(--warn-text); font-size: 13px; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 16px; }
.tab[hidden] { display: none; }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 28px 0 10px; }
.section-head.first { margin-top: 8px; }
.section-head h2 { font: 600 17px/1.3 var(--font); }
.note { margin: 8px 2px 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.list { display: grid; }

/* ---------- 버튼 ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: 600 15px/1 var(--font); cursor: pointer; text-decoration: none;
  transition: transform 0.08s ease, background-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-sm); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:focus-visible, .cta:focus-visible, .tabs a:focus-visible, .work:focus-visible, .call:focus-visible, .seg:focus-visible, .fab:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 2px;
}

/* ---------- 오늘 / 월 요약 (미터) ---------- */
.meter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 18px 16px; box-shadow: var(--shadow); }
.meter .cap { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 13px; }
.meter .big { font: var(--num-w) 60px/1.05 var(--font-num); letter-spacing: 0; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.meter .big .u { font-size: 22px; margin-left: 4px; color: var(--muted); }
.meter .big.neg { color: var(--danger); }
.centerline { height: 0; border-top: 2px dashed color-mix(in srgb, var(--amber) 70%, transparent); margin: 0 0 14px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi .k { font-size: 12px; color: var(--muted); }
.kpi .v { font: var(--num-w) 22px/1.25 var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.kpi .v small { font-size: 13px; color: var(--muted); margin-left: 1px; }
.minor { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.minor b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 콜카드 올리기 버튼 ---------- */
.cta {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 14px; padding: 16px 18px; min-height: 72px;
  border-radius: var(--r-lg); background: var(--amber); color: var(--amber-ink); cursor: pointer;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--amber) 28%, transparent);
  transition: transform 0.08s ease;
}
.cta:active { transform: scale(0.99); }
.cta .ico { width: 30px; height: 30px; stroke-width: 1.7; }
.cta-text { display: grid; gap: 1px; }
.cta strong { font: 600 19px/1.2 var(--font); }
.cta .hint-desktop { font-size: 13px; opacity: 0.75; }
.cta.over { outline: 3px dashed var(--amber-ink); outline-offset: -8px; }
@media (hover: none) { .hint-desktop { display: none; } }

/* ---------- 콜 카드 ---------- */
.call {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; padding: 14px 16px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.call .meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.call .meta .plat { margin-left: auto; }
.route { position: relative; display: grid; gap: 8px; padding-left: 20px; min-width: 0; }
.route::before { content: ''; position: absolute; left: 5px; top: 12px; bottom: 12px; border-left: 2px dotted var(--faint); }
.stop { position: relative; font-weight: 600; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.stop::before { content: ''; position: absolute; left: -20px; top: 5px; width: 12px; height: 12px; box-sizing: border-box; }
.stop.s::before { border: 2.5px solid var(--text); border-radius: 50%; background: var(--surface); }
.stop.e::before { background: var(--amber); border-radius: 3px; transform: rotate(45deg) scale(0.82); }
.stop.none { color: var(--muted); font-weight: 400; }
.amount { align-self: end; text-align: right; }
.amount .net { font: var(--num-w) 26px/1.1 var(--font-num); letter-spacing: 0; color: var(--money); font-variant-numeric: tabular-nums; }
.amount .net small { font-size: 14px; color: var(--muted); }
.amount .calc { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.call .foot { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  background: color-mix(in srgb, var(--money) 16%, transparent); color: var(--money); }
.tag.wait, .tag.review { background: var(--warn-bg); color: var(--warn-text); }
.est { color: var(--muted); }

.empty { padding: 22px 16px; border: 1px dashed var(--line); border-radius: var(--r-md); text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--text); margin-bottom: 2px; font-size: 15px; }

/* ---------- 일지 (날짜별 묶음) ---------- */
.daygroup { margin-bottom: 8px; }
.daytitle { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 8px; }
.daytitle h3 { font: 600 15px/1.3 var(--font); }
.daytitle span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.daytitle span b { color: var(--money); font-family: var(--font-num); font-weight: var(--num-w); font-size: 17px; letter-spacing: 0; }

/* ---------- 통계 ---------- */
.monthnav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; text-align: center; margin: 4px 0 12px; }
.monthnav h2 { font: var(--num-w) 24px/1.2 var(--font-num); letter-spacing: 0; }
.monthnav .btn { min-height: 44px; padding: 0; font-size: 22px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 12px 8px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.bars .col { flex: 1; min-width: 0; display: grid; align-content: end; justify-items: center; height: 100%; gap: 4px; }
.bars .col i { display: block; width: 100%; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--amber); }
.bars .col span { font-size: 10px; color: var(--muted); height: 16px; line-height: 16px; font-variant-numeric: tabular-nums; }
.bars .empty-bars { width: 100%; align-self: center; text-align: center; color: var(--muted); font-size: 14px; padding-bottom: 16px; }
.dayrow { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: baseline; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.dayrow .d { font-weight: 600; font-variant-numeric: tabular-nums; }
.dayrow .c { color: var(--muted); font-size: 14px; }
.dayrow .p { font: var(--num-w) 20px/1.2 var(--font-num); letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* ---------- 카드·폼 ---------- */
.panel { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.sheetcard { padding: 14px 16px; margin-bottom: 14px; display: grid; gap: 8px; background: var(--raised); border: 1px solid var(--amber); border-radius: var(--r-md); }
.form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--amber) 70%, transparent); outline-offset: 0; border-color: var(--amber); }
textarea { font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; min-height: 0; }
.switch, .chip-check { display: flex; flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 15px; cursor: pointer; }
.switch input, .chip-check input { width: 20px; min-height: 0; height: 20px; accent-color: var(--amber); flex: none; }
.chip-check { font-size: 13px; color: var(--muted); }
.chip-check input { width: 16px; height: 16px; }
details > summary { cursor: pointer; padding: 4px 0; color: var(--amber-text); }
details[open] > summary { margin-bottom: 8px; }

/* ---------- 작업 결과(올린 이미지) ---------- */
.job { display: grid; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.job .head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.job .head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job pre { margin: 0; white-space: pre-wrap; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; max-height: 220px; overflow: auto; background: var(--bg); padding: 10px; border-radius: var(--r-sm); }
.job .call { margin: 0; background: var(--raised); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.2s; }

/* ---------- 공유 영역 ---------- */
.sharebox { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--amber); border-radius: var(--r-md); background: color-mix(in srgb, var(--amber) 9%, var(--surface)); }
.sharebox.done { border-color: var(--line); background: var(--raised); color: var(--money); }
.warn-text { color: var(--warn-text); background: var(--warn-bg); padding: 8px 10px; border-radius: var(--r-sm); }

/* ---------- 지도 ---------- */
.mapwrap { position: relative; margin: 0 -16px; }
.map { height: min(58vh, 460px); background: var(--raised); z-index: 0; }
.map-top { position: absolute; z-index: 400; top: 12px; left: 12px; right: 12px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 3px; gap: 2px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.seg { appearance: none; border: 0; background: transparent; color: var(--muted); min-height: 38px; border-radius: 999px; font: 600 13px/1 var(--font); cursor: pointer; }
.seg.on { background: var(--amber); color: var(--amber-ink); }
.fab { position: absolute; z-index: 400; right: 14px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--amber); color: var(--amber-ink); box-shadow: 0 6px 18px rgb(0 0 0 / 0.35); cursor: pointer; }
.fab:active { transform: scale(0.95); }
.map-under { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom { display: none; } /* 손가락 확대를 쓰므로 + − 버튼은 숨김 */
.rank-pin span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--amber); color: var(--amber-ink);
  font: var(--num-w) 16px/1 var(--font-num); border: 2px solid #fff; box-shadow: 0 2px 6px rgb(0 0 0 / 0.45); }

.rec { display: grid; grid-template-columns: 40px 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.rec .rank { grid-row: 1 / 3; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--raised); font: var(--num-w) 22px/1 var(--font-num); color: var(--amber-text); }
.rec:first-child .rank { background: var(--amber); color: var(--amber-ink); }
.rec .name { font-weight: 600; line-height: 1.3; }
.rec .dist { grid-row: 1; grid-column: 3; text-align: right; font: var(--num-w) 22px/1 var(--font-num); letter-spacing: 0; }
.rec .dist small { font-size: 12px; color: var(--muted); margin-left: 1px; }
.rec .sub { grid-column: 2 / 4; font-size: 13px; color: var(--muted); }
.rec .heat { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 8px; }
.rec .heat i { display: block; height: 100%; background: linear-gradient(90deg, #ffd84d, #ff6b3d); border-radius: 2px; }
.rec .acts { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 8px; }

/* 판정: 도로표지판 (녹색=콜밭, 청색=보통, 적색=오지) */
.analysis { margin-top: 12px; display: grid; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.analysis .where { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; }
.sign { position: relative; display: grid; place-items: center; min-height: 84px; padding: 10px 18px; border-radius: 14px; color: #fff; background: var(--sign-blue); }
.sign::before { content: ''; position: absolute; inset: 5px; border: 2px solid rgb(255 255 255 / 0.9); border-radius: 10px; pointer-events: none; }
.sign b { font: var(--num-w) 38px/1.1 var(--font-num); letter-spacing: 0; }
.sign small { font-size: 13px; opacity: 0.9; }
.sign.hot { background: var(--sign-green); }
.sign.remote { background: var(--sign-red); }
.sign.unknown { background: var(--faint); }
.analysis .facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact { padding: 3px 10px; border-radius: 999px; background: var(--raised); font-size: 12px; color: var(--muted); }
.analysis .acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 하단 탭 ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabs a { display: grid; justify-items: center; gap: 3px; padding: 10px 0 9px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; position: relative; }
.tabs a[aria-current='page'] { color: var(--amber-text); }
.tabs a[aria-current='page']::before { content: ''; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--amber); }

/* ---------- 대화상자 (아래에서 올라오는 시트) ---------- */
dialog { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; overflow: auto;
  background: var(--surface); color: var(--text); border-radius: var(--r-lg) var(--r-lg) 0 0; border-top: 1px solid var(--line); }
dialog[open] { animation: sheet-up 0.22s ease-out; }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.dlg { display: grid; gap: 14px; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); }
.dlg h3 { font: 600 18px/1.3 var(--font); }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); font: 600 14px/1 var(--font); cursor: pointer; }
.chip[aria-pressed='true'] { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; max-width: min(92vw, 520px);
  padding: 12px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgb(0 0 0 / 0.4); }

@media (min-width: 640px) {
  .mapwrap { margin: 0; border-radius: var(--r-lg); overflow: hidden; }
  dialog { border-radius: var(--r-lg); margin: auto; border: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
