/* 현장 담당자가 한 손으로 쓰는 모바일 화면. 차분한 녹회색 바탕에 상태색만 강하게. */
:root {
  --bg: #f3f5f4;
  --panel: #ffffff;
  --panel-2: #eef1f0;
  --line: #dde2e0;
  --fg: #17201d;
  --muted: #5e6b66;
  --accent: #1d6b57;
  --accent-fg: #ffffff;
  --bad: #c43a2f;
  --bad-bg: #fbe9e7;
  --warn: #a8640a;
  --warn-bg: #fdf1dc;
  --hold: #6b4fa8;
  --hold-bg: #efeaf8;
  --ok: #1d6b57;
  --ok-bg: #e2f1ec;
  --done: #7b8682;
  --done-bg: #eceeed;
  --shadow: 0 1px 2px rgba(20, 30, 26, .06), 0 4px 16px rgba(20, 30, 26, .06);
  --radius: 14px;
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --tab-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --panel: #1b201f; --panel-2: #232a28; --line: #2e3633; --fg: #e8eeeb; --muted: #95a39d;
    --accent: #4fb596; --accent-fg: #0d1513; --bad: #f07067; --bad-bg: #3a1f1c; --warn: #e8a948; --warn-bg: #36290f;
    --hold: #b39ae8; --hold-bg: #2a2340; --ok: #4fb596; --ok-bg: #18302a; --done: #8a9590; --done-bg: #252b29;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px);
}
.topbar-in {
  display: flex; align-items: center; gap: 6px; min-height: 56px; max-width: 720px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.topbar-title { min-width: 0; }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { flex: none; width: 40px; height: 40px; margin-left: -8px; border: 0; background: none; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }

.view {
  max-width: 720px; margin: 0 auto; padding-block: 12px 24px; outline: none;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.view.wide { max-width: 1100px; }

/* 하단 탭 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
}
.tabbar a {
  height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
}
.tabbar svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }

/* 필터 */
.search {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 0 14px; font-size: 15px;
}
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel-2); border-radius: 12px; padding: 3px; }
.seg button { height: 38px; border: 0; border-radius: 9px; background: none; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--fg); box-shadow: var(--shadow); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip .n { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .75; }
.filters { display: flex; flex-direction: column; gap: 10px; }
.result-meta { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.linkish { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 0; cursor: pointer; }

/* 공사 카드 */
.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: inherit; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--st, transparent); }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-top .dday { margin-left: auto; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.card h3 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; }
.card .latest { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px dashed var(--line); padding-top: 8px; }
.card .latest b { color: var(--fg); font-weight: 600; }
.pill { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--c); background: var(--cb); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--panel-2); white-space: nowrap; }
.tag.edited { color: var(--accent); background: var(--ok-bg); }
.st-bad { --c: var(--bad); --cb: var(--bad-bg); --st: var(--bad); }
.st-warn { --c: var(--warn); --cb: var(--warn-bg); --st: var(--warn); }
.st-hold { --c: var(--hold); --cb: var(--hold-bg); --st: var(--hold); }
.st-ok { --c: var(--ok); --cb: var(--ok-bg); --st: transparent; }
.st-done { --c: var(--done); --cb: var(--done-bg); --st: transparent; }
.dday.neg { color: var(--bad); }
.progress { display: flex; align-items: center; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.progress .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--panel-2); overflow: hidden; }
.progress .bar i { display: block; height: 100%; border-radius: 4px; background: var(--c, var(--accent)); }
.progress .pct { width: 3.2em; text-align: right; font-weight: 700; }
.progress .none { color: var(--muted); font-weight: 500; width: auto; }

/* 상세 */
.hero { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.hero h2 { margin: 0; font-size: 20px; line-height: 1.35; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hero .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.facts div { background: var(--panel); padding: 10px 12px; min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.facts .full { grid-column: 1 / -1; }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.action {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.action.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.action svg { width: 18px; height: 18px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section > h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; justify-content: space-between; align-items: baseline; }
.section > h3 small { font-weight: 500; color: var(--muted); font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.timeline li { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; white-space: pre-wrap; }
.timeline li:first-child { border-top: 0; }
.timeline li.app { background: color-mix(in srgb, var(--ok-bg) 60%, var(--panel)); }
.timeline .who { display: block; font-size: 12px; color: var(--muted); white-space: normal; }
.timeline .when { font-weight: 700; margin-right: 6px; font-variant-numeric: tabular-nums; }
.timeline.collapsed li:nth-child(n+7) { display: none; }
details.box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
details.box summary { padding: 12px 14px; font-weight: 700; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.box summary::-webkit-details-marker { display: none; }
details.box summary::after { content: "펼치기"; font-size: 12px; color: var(--accent); font-weight: 600; }
details.box[open] summary::after { content: "접기"; }
details.box summary small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: auto; }
.mat { list-style: none; margin: 0; padding: 0 14px 10px; }
.mat li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.mat .p { font-weight: 600; overflow-wrap: anywhere; }
.mat .s { font-weight: 700; font-size: 12px; }
.mat .d { grid-column: 1 / -1; color: var(--muted); font-variant-numeric: tabular-nums; }
.plain { white-space: pre-wrap; padding: 0 14px 12px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; margin: 0; }

/* 시트 (하단에서 올라오는 수정 창) */
.sheet {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92dvh; border: 0; padding: 0; background: transparent; color: var(--fg);
}
@media (min-width: 640px) { .sheet { margin: auto; max-width: 480px; } .sheet-body { border-radius: 18px !important; } }
.sheet::backdrop { background: rgba(10, 16, 14, .45); }
.sheet-body {
  background: var(--panel); border-radius: 18px 18px 0 0; display: flex; flex-direction: column; gap: 14px;
  padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  max-height: 92dvh; overflow-y: auto;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 2px; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet-sub { margin: -8px 0 0; font-size: 13px; color: var(--muted); }
.fields { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 13px; font-weight: 700; }
.field .hint { font-size: 12px; color: var(--muted); }
.field input[type="date"], .field input[type="text"], .field input[type="number"], .field textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 10px 12px; font-size: 16px;
}
.field textarea { min-height: 96px; resize: vertical; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 32px; }
.range-row output { width: 3.5em; text-align: right; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-weight: 700; }
.switch input { width: 22px; height: 22px; accent-color: var(--hold); }
.form-error { margin: 0; color: var(--bad); font-size: 14px; font-weight: 600; }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.btn { min-height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; font-size: 16px; cursor: pointer; padding: 0 16px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 12px);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px);
}
.toast.err { background: var(--bad); color: #fff; }

/* 공통 패널 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel h2 { margin: 0; font-size: 16px; }
.panel .note { margin: 0; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: 14px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.loading { color: var(--muted); padding: 24px 0; text-align: center; }
.skel { height: 112px; border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skel { animation: shimmer 1.2s infinite linear; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* 대시보드 */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; color: inherit; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi.bad .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }
.kpi.hold .v { color: var(--hold); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 12px; }
.chart { position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--fg); font-weight: 700; }
.chart .grid line { stroke: var(--line); }
.chart .dot { cursor: pointer; stroke: var(--panel); stroke-width: 1.5; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; }
.tip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; max-width: 240px; }
.tip b { display: block; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; }
.mini-list a { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: center; padding: 10px 0; text-decoration: none; color: inherit; }
.mini-list .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.mini-list .d { font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-list .m { grid-column: 2 / 4; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 업로드·변경 */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel); text-align: center; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--ok-bg); }
.drop strong { font-size: 16px; }
.drop span { font-size: 13px; color: var(--muted); }
.report { display: flex; flex-direction: column; gap: 10px; }
.report .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.report .stats div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; }
.report .stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.report .stats span { font-size: 12px; color: var(--muted); }
.warns { list-style: none; margin: 0; padding: 0 14px 10px; font-size: 13px; }
.warns li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.warns .lv { flex: none; font-weight: 700; font-size: 11px; padding: 1px 6px; border-radius: 4px; height: fit-content; }
.warns .lv.error { color: var(--bad); background: var(--bad-bg); }
.warns .lv.warn { color: var(--warn); background: var(--warn-bg); }
.warns .lv.info { color: var(--muted); background: var(--panel-2); }
.callout { padding: 10px 12px; border-radius: 10px; font-size: 13px; background: var(--warn-bg); color: var(--fg); }
.callout.ok { background: var(--ok-bg); }
.changes { list-style: none; margin: 0; padding: 0; }
.changes li { padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.changes li:first-child { border-top: 0; }
.changes .h { font-weight: 700; font-size: 14px; }
.changes .x { color: var(--muted); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
