:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1c2126;
  --muted: #6b7480;
  --accent: #2f6f4f;
  --accent-soft: #e8f2ec;
  --warn: #b7791f;
  --danger: #c0392b;
  --ok: #2f6f4f;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 25, 30, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.55 'Malgun Gothic',
    -apple-system,
    'Segoe UI',
    sans-serif;
}

/* ---------- 사이드바 ---------- */
#sidebar {
  width: 264px;
  flex: 0 0 264px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 12px;
}
.brand-mark {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 13px;
}
.brand-name {
  font-weight: 600;
  letter-spacing: -0.2px;
}

.side-search {
  padding: 0 12px 10px;
}
.side-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  background: #fafbfc;
}
.side-search input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
  background: #fff;
}

.nav {
  display: flex;
  gap: 4px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
.nav-btn {
  flex: 1;
  padding: 7px 2px;
  font-size: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.nav-btn:hover {
  background: #f0f2f4;
}
.nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.mini {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.mini:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
  overflow-y: auto;
  flex: 1;
}
.project-list li {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.project-list li:hover {
  background: #f3f5f7;
}
.project-list li.active {
  background: var(--accent-soft);
  border-color: #cfe3d8;
}
.pl-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pl-sub {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
}

.side-foot {
  padding: 8px 16px 12px;
  font-size: 10.5px;
  color: #99a1aa;
  border-top: 1px solid var(--line);
  word-break: break-all;
}

/* ---------- 메인 ---------- */
#main {
  flex: 1;
  height: 100vh;
  overflow-y: auto;
}
.view {
  padding: 22px 26px 60px;
  max-width: 1120px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 21px;
  letter-spacing: -0.3px;
}
.page-head .sub {
  color: var(--muted);
  font-size: 12.5px;
}
.head-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
}
.btn:hover {
  border-color: #c3c9d0;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover {
  background: #285e43;
}
.btn.ghost {
  background: transparent;
}
.btn.danger {
  color: var(--danger);
  border-color: #eccfcb;
}
.btn.danger:hover {
  background: #fdf3f2;
}
.btn.sm {
  padding: 4px 9px;
  font-size: 12px;
}

/* ---------- 카드 / 통계 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  box-shadow: var(--shadow);
}
.card.clickable {
  cursor: pointer;
}
.card.clickable:hover {
  border-color: #c3c9d0;
}
.card h3 {
  margin: 0 0 3px;
  font-size: 15px;
}
.card .meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.stat .label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}
.stat .value {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.4px;
}
.stat .value.pos {
  color: var(--ok);
}
.stat .value.warn {
  color: var(--warn);
}
.stat .value.neg {
  color: var(--danger);
}
.stat .note {
  font-size: 10.5px;
  color: #99a1aa;
  margin-top: 2px;
}

.bar {
  height: 5px;
  background: #eceff1;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 7px;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fafbfc;
  vertical-align: middle;
}
.badge.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #cfe3d8;
}
.badge.completed {
  background: #eef1f4;
  color: #566;
}
.badge.on_hold,
.badge.planning {
  background: #fdf6e8;
  color: var(--warn);
  border-color: #f0e2c4;
}
.badge.type-new_build {
  background: #eef2f7;
  color: #46617f;
  border-color: #d4dfea;
}
.badge.type-interior {
  background: #fdf1ea;
  color: #a55b28;
  border-color: #f0dccd;
}
.badge.cancelled {
  background: #f8eceb;
  color: var(--danger);
  border-color: #eccfcb;
}

/* ---------- 섹션 / 테이블 ---------- */
.section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 15px;
  border-bottom: 1px solid var(--line);
}
.section > header h2 {
  margin: 0;
  font-size: 14px;
}
.section-body {
  padding: 13px 15px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 11.5px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f2f4;
  vertical-align: middle;
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr:hover {
  background: #fafbfc;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 7px 14px;
  font-size: 13px;
}
.dl dt {
  color: var(--muted);
  font-size: 12px;
}
.dl dd {
  margin: 0;
}

/* ---------- 체크리스트 ---------- */
.cl-cat {
  border-bottom: 1px solid var(--line);
}
.cl-cat:last-child {
  border-bottom: none;
}
.cl-cat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  cursor: pointer;
  user-select: none;
}
.cl-cat-head:hover {
  background: #fafbfc;
}
.cl-cat-head .caret {
  color: var(--muted);
  font-size: 10px;
  width: 10px;
}
.cl-cat-head .name {
  font-weight: 600;
  font-size: 13.5px;
}
.cl-cat-head .count {
  color: var(--muted);
  font-size: 12px;
}
.cl-cat-head .spacer {
  flex: 1;
}
.cl-items {
  list-style: none;
  margin: 0;
  padding: 0 0 6px;
}
.cl-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 15px 5px 34px;
  font-size: 13px;
}
.cl-item:hover {
  background: #fafbfc;
}
.cl-item input[type='checkbox'] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.cl-item .title {
  flex: 1;
}
.cl-item.done .title {
  color: #a3aab2;
  text-decoration: line-through;
}
.cl-item .due {
  font-size: 11.5px;
  color: var(--muted);
}
.cl-item .due.overdue {
  color: var(--danger);
  font-weight: 600;
}
.cl-item .row-actions {
  opacity: 0;
  display: flex;
  gap: 4px;
}
.cl-item:hover .row-actions {
  opacity: 1;
}

/* ---------- 폼 / 모달 ---------- */
dialog {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: min(620px, 92vw);
  box-shadow: 0 12px 40px rgba(15, 20, 25, 0.22);
}
dialog::backdrop {
  background: rgba(20, 25, 32, 0.4);
}
#modal-form {
  padding: 20px 22px 16px;
}
#modal-form h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 11px 14px;
  max-height: 62vh;
  overflow-y: auto;
  padding-right: 2px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.field.wide {
  grid-column: 1 / -1;
}
.field label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}
.field input,
.field select,
.field textarea {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.field textarea {
  resize: vertical;
  min-height: 62px;
}
.field .hint {
  font-size: 10.5px;
  color: #99a1aa;
}
.field input:disabled {
  background: #f2f4f6;
  color: #99a1aa;
  cursor: not-allowed;
}

/* 체크박스 필드 (부가세 별도 등) */
.check-label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  padding: 5px 0;
}
.check-label input[type='checkbox'] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin: 16px 0 0;
  padding: 0;
}
.modal-error {
  background: #fdf3f2;
  border: 1px solid #eccfcb;
  color: var(--danger);
  padding: 8px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  margin: 12px 0 0;
  white-space: pre-line;
}

/* ---------- 기타 ---------- */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted);
}
.empty p {
  margin: 0 0 14px;
}

.toast-area {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 100;
}
.toast {
  background: #22282f;
  color: #fff;
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  max-width: 380px;
  white-space: pre-line;
  animation: slide-in 0.16s ease-out;
}
/* 버튼이 달린 알림. 확인창 대신 쓰므로 손이 멈추지 않는다 */
.toast.with-action {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 440px;
}
.toast-action {
  flex-shrink: 0;
  padding: 5px 11px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.toast-action:hover {
  background: rgba(255, 255, 255, 0.14);
}
.toast.error {
  background: #a5342a;
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- 탭 (Phase 2) ---------- */
.tabbar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.tab {
  padding: 8px 15px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--accent);
  font-weight: 650;
  border-bottom-color: var(--accent);
}
.tab-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 5px;
  min-width: 16px;
  text-align: center;
  line-height: 15px;
}

/* 세그먼트 토글 (간트/목록, 일/주/월) */
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.segmented button {
  border: none;
  background: #fff;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  border-right: 1px solid var(--line);
}
.segmented button:last-child {
  border-right: none;
}
.segmented button.on {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 경고 배너 */
.alert {
  background: #fdf6e8;
  border: 1px solid #f0e2c4;
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert strong {
  color: var(--warn);
}
.alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.alert li {
  margin-bottom: 2px;
}

/* 위험 수준 경고 (준공서류 누락 등) */
.alert.danger {
  background: #fdf3f2;
  border-color: #f2d5d1;
  border-left-color: var(--danger);
}
.alert.danger strong {
  color: var(--danger);
}

/* ---------- 표준공정 미리보기 ---------- */
dialog.preview-dialog {
  width: min(860px, 94vw);
  padding: 20px 22px 16px;
}
dialog.preview-dialog h3 {
  margin: 0;
  font-size: 16px;
}
/* 공정이 30개를 넘으므로 표만 스크롤시키고 버튼은 항상 보이게 둔다 */
.preview-scroll {
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.preview-scroll table {
  margin: 0;
}
.preview-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* 미리보기: 착공일 + 요약 머리말 */
.preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 10px 0 12px;
  font-size: 13px;
}
.preview-head label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.preview-head input[type='date'] {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

/* 미리보기 표: 체크 + 일수 직접 수정 */
.preview-table th.pv-check,
.preview-table td.pv-check {
  width: 34px;
  text-align: center;
  padding-left: 8px;
  padding-right: 0;
}
.preview-table input[type='number'] {
  width: 58px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  text-align: right;
}
.preview-table input[type='checkbox'] {
  width: 15px;
  height: 15px;
  cursor: pointer;
}
/* 체크를 푼 줄은 눈에서 물러나되, 되돌릴 수 있게 남겨둔다 */
.preview-table tr.pv-off td {
  opacity: 0.42;
}
.preview-table tr.pv-off td.pv-check {
  opacity: 1;
}
.pv-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
}
.preview-actions {
  align-items: center;
}
.preview-actions #pv-busy {
  margin-right: auto;
  font-size: 12px;
}

/* 아직 확보하지 못한 준공서류 */
tr.doc-missing td:first-child {
  border-left: 3px solid var(--warn);
}

/* 지연 / 임박 강조 */
tr.row-delayed td,
tr.sev-overdue td {
  background: #fdf3f2;
}
tr.sev-urgent td {
  background: #fdf6e8;
}
tr.sev-soon td {
  background: #fcfbf5;
}
.due-soon {
  color: var(--warn);
  font-weight: 600;
}

/* ---------- Frappe Gantt ---------- */
.gantt-host {
  padding: 10px 6px 4px;
  /* 가로 스크롤은 라이브러리가 만드는 .gantt-container 가 갖는다.
     여기에 또 걸면 스크롤 영역이 이중이 되어, 막대를 끌 때 두 축이 따로 움직인다. */
}
.gantt-host .gantt-container {
  max-height: 62vh;
  /* 빈 곳을 잡아끌어 화면을 옮길 수 있다는 걸 커서로 알린다 */
  cursor: grab;
}
.gantt-host.panning .gantt-container,
.gantt-host.panning .gantt-container * {
  cursor: grabbing;
}
.gantt-host {
  user-select: none;
  -webkit-user-select: none;
}
/* 드래그 중에는 막대에 전환 효과를 주지 않는다. 커서보다 늦게 따라와 미끄러져 보인다. */
.gantt .bar-wrapper .bar,
.gantt .bar-wrapper:hover .bar {
  transition: none;
}
.gantt .bar-wrapper {
  cursor: pointer;
}
.gantt .bar {
  fill: #b9c6cf;
}
.gantt .bar-progress {
  fill: var(--accent);
}
.gantt .bar-label {
  fill: #1c2126;
  font-size: 12px;
}
.gantt .bar-label.big {
  fill: #1c2126;
}
/* 지연 공정 */
.gantt .bar-delayed .bar {
  fill: #f0cdc8;
}
.gantt .bar-delayed .bar-progress {
  fill: var(--danger);
}
/* 완료 공정 */
.gantt .bar-done .bar-progress {
  fill: #7f9d8c;
}
/* 지연 구간(계획 종료일 초과분) - 점선 테두리로 구분 */
.gantt .bar-overrun .bar {
  fill: #fadbd6;
  stroke: var(--danger);
  stroke-width: 1;
  stroke-dasharray: 3 2;
}
.gantt .bar-overrun .bar-progress {
  fill: none;
}
.gantt .bar-overrun .bar-label,
.gantt .bar-overrun .bar-label.big {
  fill: var(--danger);
  font-size: 11px;
}
.gantt .bar-overrun .handle-group {
  display: none; /* 드래그 불가 */
}

/* ---------- 공종별 색상 ----------
   50가지 원가분류를 눈이 찾는 단위(구조/설비/마감…)로 묶어 14색으로 줄였다.
   지연·완료 상태 색이 이보다 우선한다 (아래에서 덮어쓴다). */
.gantt .cat-demo   .bar { fill: #c9a0a0; }
.gantt .cat-temp   .bar { fill: #c3c8cd; }
.gantt .cat-earth  .bar { fill: #c2ae94; }
.gantt .cat-frame  .bar { fill: #a9b4bf; }
.gantt .cat-proof  .bar { fill: #9dbfbd; }
.gantt .cat-window .bar { fill: #a3bcd6; }
.gantt .cat-plumb  .bar { fill: #a6c4d9; }
.gantt .cat-elec   .bar { fill: #dcc490; }
.gantt .cat-carp   .bar { fill: #c4a882; }
.gantt .cat-tile   .bar { fill: #cbb9a4; }
.gantt .cat-paint  .bar { fill: #bfb0cd; }
.gantt .cat-finish .bar { fill: #d5b3bd; }
.gantt .cat-furn   .bar { fill: #a9c3a6; }
.gantt .cat-ext    .bar { fill: #9fb891; }
.gantt .cat-etc    .bar { fill: #b9c6cf; }

/* 상태가 공종보다 우선한다 — 지연은 무엇보다 먼저 눈에 띄어야 한다 */
.gantt .bar-delayed .bar { fill: #f0cdc8; }
.gantt .bar-done .bar { fill: #d5dcd8; }

/* 목록·미리보기의 공종 표시 점 */
.cat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: baseline;
  background: #b9c6cf;
}
.cat-dot.cat-demo   { background: #c9a0a0; }
.cat-dot.cat-temp   { background: #c3c8cd; }
.cat-dot.cat-earth  { background: #c2ae94; }
.cat-dot.cat-frame  { background: #a9b4bf; }
.cat-dot.cat-proof  { background: #9dbfbd; }
.cat-dot.cat-window { background: #a3bcd6; }
.cat-dot.cat-plumb  { background: #a6c4d9; }
.cat-dot.cat-elec   { background: #dcc490; }
.cat-dot.cat-carp   { background: #c4a882; }
.cat-dot.cat-tile   { background: #cbb9a4; }
.cat-dot.cat-paint  { background: #bfb0cd; }
.cat-dot.cat-finish { background: #d5b3bd; }
.cat-dot.cat-furn   { background: #a9c3a6; }
.cat-dot.cat-ext    { background: #9fb891; }

.cat-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.cat-legend span {
  display: inline-flex;
  align-items: center;
}

/* 뒷공정 일괄 밀기 바 */
.shift-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
  font-size: 12.5px;
}
.shift-bar select,
.shift-bar input[type='number'] {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  background: #fff;
  color: var(--text);
}
.shift-bar select {
  max-width: 240px;
}

/* ---------- 회계 / 자금 / 계약 (Phase 3) ---------- */
.neg-text {
  color: var(--danger);
}
.pos-text {
  color: var(--ok);
}

tr.group-row td {
  background: #f2f4f6;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 5px 10px;
}

.stars {
  color: #d9a43b;
  letter-spacing: 1px;
}

/* 변경계약 타임라인 */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--line);
}
.tl-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 10px 0 10px 14px;
  position: relative;
  font-size: 13px;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: -21px;
  top: 15px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--line);
}
.tl-item.tl-original::before {
  border-color: var(--accent);
  background: var(--accent);
}
.tl-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.tl-amount {
  text-align: right;
  font-weight: 650;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- 사진 갤러리 (Phase 4) ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
  transition: 0.12s;
}
.dropzone.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.photo {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.photo-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: #eceff1;
  overflow: hidden;
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}
.photo figcaption {
  padding: 8px 10px 10px;
  font-size: 12px;
}
.photo-date {
  font-weight: 650;
  margin-bottom: 3px;
}
.photo-meta {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11.5px;
}
.photo-memo {
  color: var(--muted);
  margin-top: 4px;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.photo-actions {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

/* ---------- 대시보드 (Phase 4) ---------- */
.project-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  padding: 14px;
}
.project-home-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.project-home-card:hover {
  border-color: var(--accent);
  box-shadow: 0 5px 18px rgba(25, 45, 35, .1);
  transform: translateY(-1px);
}
.project-card-open {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 15px;
  width: 100%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-home-top, .project-home-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.project-home-top strong { font-size: 15px; }
.project-home-address, .project-home-schedule { color: var(--muted); font-size: 12px; }
.project-home-progress { height: 6px; border-radius: 99px; background: #edf0f2; overflow: hidden; }
.project-home-progress i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.project-home-bottom { font-size: 11.5px; color: var(--muted); }
.project-card-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: #fafbfb;
}
.project-card-actions button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 8px 3px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.project-card-actions button:last-child { border-right: 0; }
.project-card-actions button:hover { color: var(--accent); background: var(--accent-soft); }
.operations-panel input[type='month'] {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  font: inherit;
}
.dashboard-partial-error { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dashboard-partial-error span { flex: 1; min-width: 220px; }
.dashboard-partial-error small { width: 100%; color: var(--muted); overflow-wrap: anywhere; }
.operation-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}
.operation-stats > div { padding: 14px 15px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.operation-stats > div:last-child { border-right: 0; }
.operation-stats small, .operation-stats span { color: var(--muted); font-size: 11px; }
.operation-stats strong { font-size: 19px; }
.operation-projects { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); padding: 8px; gap: 6px; }
.operation-projects button {
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fafbfb;
  color: inherit;
  font: inherit;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}
.operation-projects button:hover { border-color: var(--accent); background: var(--accent-soft); }
.operation-projects span { display: flex; flex-direction: column; gap: 2px; }
.operation-projects small { color: var(--muted); font-size: 10.5px; }
.operation-projects b { white-space: nowrap; font-size: 12px; }
.week-task-list { display: flex; flex-direction: column; }
.week-task {
  display: grid;
  grid-template-columns: 65px minmax(160px, 1fr) minmax(180px, auto) 45px;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.week-task:last-child { border-bottom: 0; }
.week-task:hover { background: var(--accent-soft); }
.week-task > span:nth-child(2) { display: flex; flex-direction: column; }
.week-task small, .week-task-date { color: var(--muted); font-size: 11px; }
.week-task.delayed .badge { color: var(--danger); }
@media (max-width: 700px) {
  .operation-stats { grid-template-columns: repeat(2, 1fr); }
  .operation-stats > div:nth-child(2) { border-right: 0; }
  .operation-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .week-task { grid-template-columns: 58px 1fr 38px; }
  .week-task-date { grid-column: 2 / -1; }
}
tr.row-link {
  cursor: pointer;
}
tr.row-link:hover td {
  background: var(--accent-soft);
}

.notes {
  list-style: none;
  margin: 0;
  padding: 0;
}
.note-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px;
  border-bottom: 1px solid #f0f2f4;
  font-size: 13px;
}
.note-item:last-child {
  border-bottom: none;
}
.note-item:hover {
  background: #fafbfc;
}
.note-item input[type='checkbox'] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: 0 0 auto;
}
.note-body {
  flex: 1;
  white-space: pre-line;
}
.note-item.done .note-body {
  color: #a3aab2;
  text-decoration: line-through;
}
.note-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
}
.note-item:hover .note-actions {
  opacity: 1;
}

/* ---------- 도면 면적계산 (Phase 5) ---------- */
.quantity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 10px;
  padding: 13px;
}
.quantity-card {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 12px;
  cursor: pointer;
}
.quantity-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.quantity-card-title { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.quantity-card-title small { color: var(--muted); }
.quantity-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 5px; }
.quantity-flow span { display: flex; flex-direction: column; gap: 2px; }
.quantity-flow b { font-size: 13px; }
.quantity-flow small, .quantity-flow i { color: var(--muted); font-size: 10.5px; font-style: normal; }
.quantity-card-total { display: block; text-align: right; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; font-weight: 650; }
.fp-toolbar {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 11px;
  margin-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.fp-hint {
  font-size: 12px;
  color: var(--muted);
}
.fp-canvas-wrap {
  background: #eceff1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 70vh;
  text-align: center;
}
#fp-canvas {
  display: block;
  margin: 0 auto;
  cursor: crosshair;
  max-width: 100%;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- 작업일보 (Phase 8) ---------- */
.logs {
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.log {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.log.stopped {
  border-color: #eccfcb;
  background: #fdfaf9;
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.log.stopped .log-head {
  background: #fdf3f2;
}
.log-date {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
}
.log-actions {
  display: flex;
  gap: 4px;
}
.log-body {
  padding: 11px 13px;
  font-size: 13px;
}
.log-body p {
  margin: 0 0 7px;
}
.log-work {
  white-space: pre-line;
}
.log-stop {
  color: var(--danger);
  font-weight: 600;
}
.log-issue {
  background: #fdf6e8;
  border-left: 3px solid var(--warn);
  padding: 6px 10px;
  border-radius: 4px;
  white-space: pre-line;
}
.crew-table {
  margin-top: 9px;
  border-top: 1px solid var(--line);
}
.crew-table th {
  font-size: 11px;
  padding: 5px 8px;
}
.crew-table td {
  padding: 5px 8px;
  font-size: 12.5px;
}

/* ---------- 견적서 (Phase 8) ---------- */
.quote-sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 34px 40px;
  box-shadow: var(--shadow);
  color: #14181c;
}
.quote-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-bottom: 2px solid #14181c;
  padding-bottom: 12px;
  margin-bottom: 18px;
}
.quote-head h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: 9px;
  font-weight: 700;
}
.quote-meta {
  font-size: 12px;
  text-align: right;
  color: var(--muted);
  line-height: 1.7;
}
.quote-info {
  margin-bottom: 16px;
  font-size: 13px;
}
.quote-info th {
  background: #f4f6f8;
  width: 88px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  font-size: 12px;
  color: #46505a;
}
.quote-info td {
  padding: 7px 10px;
  border: 1px solid var(--line);
}
.quote-total-box {
  border: 2px solid #14181c;
  border-radius: 6px;
  padding: 13px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}
.quote-grand {
  font-size: 19px;
  font-weight: 700;
}
.quote-items {
  margin-bottom: 14px;
  font-size: 12.5px;
}
.quote-items th.group {
  background: #14181c;
  color: #fff;
  text-align: left;
  font-size: 13px;
  padding: 7px 10px;
  letter-spacing: 0.5px;
}
.quote-items th {
  border: 1px solid var(--line);
  padding: 6px 9px;
  background: #f4f6f8;
  color: #46505a;
}
.quote-items td {
  border: 1px solid var(--line);
  padding: 6px 9px;
}
.quote-items tr.subtotal td {
  background: #f4f6f8;
  font-weight: 700;
  text-align: right;
}
.quote-note {
  margin-top: 22px;
  font-size: 12px;
}
.quote-note h3 {
  font-size: 13px;
  margin: 0 0 7px;
}
.quote-note ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.8;
  color: #3c464f;
}
.quote-sign {
  margin-top: 30px;
  text-align: right;
  font-size: 13px;
  line-height: 2;
}

/* 인쇄: 견적서만 남기고 전부 숨긴다 */
@media print {
  @page {
    size: A4;
    margin: 12mm;
  }
  body {
    display: block;
    background: #fff;
  }
  #sidebar,
  .page-head,
  .stat-row,
  .tabbar,
  .no-print,
  .toast-area {
    display: none !important;
  }
  #main {
    height: auto;
    overflow: visible;
  }
  .view {
    padding: 0;
    max-width: none;
  }
  .quote-sheet {
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .quote-items {
    page-break-inside: avoid;
  }
  .quote-note,
  .quote-sign {
    page-break-inside: avoid;
  }
}

code {
  background: #f0f2f4;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

.muted {
  color: var(--muted);
}
.right {
  text-align: right;
}
.nowrap {
  white-space: nowrap;
}

/* =====================================================================
   모바일 반응형
   현장에서 폰으로 보는 게 실제 사용 시나리오다.
   사이드바는 드로어로, 표는 가로 스크롤로 처리한다.
   ===================================================================== */

/* 모바일 상단바 — 기본은 숨김 */
#mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 60;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
}
#menu-toggle {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
}
#mobile-title {
  font-weight: 600;
  font-size: 15px;
}
#drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.45);
  z-index: 70;
}
#drawer-backdrop.on {
  display: block;
}

@media (max-width: 860px) {
  body {
    display: block;
  }

  #mobile-bar {
    display: flex;
  }

  /* 사이드바 = 슬라이드 드로어 */
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    width: 84vw;
    max-width: 320px;
    flex: none;
    transform: translateX(-100%);
    transition: transform 0.18s ease-out;
    box-shadow: 2px 0 16px rgba(15, 20, 25, 0.18);
  }
  #sidebar.open {
    transform: translateX(0);
  }

  #main {
    height: auto;
    overflow: visible;
  }
  .view {
    padding: 14px 12px 60px;
    max-width: none;
  }

  .page-head {
    flex-direction: column;
    gap: 10px;
  }
  .page-head h1 {
    font-size: 18px;
  }
  .head-actions {
    width: 100%;
  }
  .head-actions .btn {
    flex: 1;
  }

  /* 탭이 13개다. 가로 스크롤로 넘긴다. */
  .tabbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabbar::-webkit-scrollbar {
    display: none;
  }
  .tab {
    white-space: nowrap;
    padding: 9px 12px;
  }

  /* 표는 가로 스크롤. 세로로 접으면 열 대응이 무너져 오히려 못 읽는다. */
  .section > table,
  .quote-items,
  .quote-info {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .section > table td,
  .section > table th {
    padding: 9px 10px;
  }

  /* 통계 카드: 2열 */
  .stat-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .stat .value {
    font-size: 15px;
  }

  /* 폼: 1열 */
  .form-grid {
    grid-template-columns: 1fr;
    max-height: 68vh;
  }
  dialog {
    width: 94vw;
  }
  dialog.preview-dialog {
    width: 96vw;
    padding: 16px 14px 12px;
  }
  .preview-scroll {
    max-height: 60vh;
  }
  #modal-form {
    padding: 16px 16px 12px;
  }

  /* 터치 목표를 키운다 */
  .btn.sm {
    padding: 7px 11px;
    font-size: 12.5px;
  }
  .cl-item {
    padding: 9px 12px 9px 30px;
  }
  .cl-item input[type='checkbox'] {
    width: 19px;
    height: 19px;
  }
  .cl-item .row-actions {
    opacity: 1; /* 폰에는 hover 가 없다 */
  }
  .note-actions,
  .photo-actions {
    opacity: 1;
  }

  /* 섹션 헤더가 버튼과 겹치지 않게 */
  .section > header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  .shift-bar select {
    max-width: 100%;
  }
  .timeline {
    padding-left: 10px;
  }
  .tl-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .tl-amount {
    text-align: left;
  }
  .dl {
    grid-template-columns: 92px 1fr;
  }
  .toast-area {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    max-width: none;
  }
  .quote-sheet {
    padding: 18px 14px 24px;
  }
  .quote-head h1 {
    font-size: 21px;
    letter-spacing: 5px;
  }
}

/* 아주 좁은 화면 */
@media (max-width: 420px) {
  .stat-row {
    grid-template-columns: 1fr;
  }
  .log-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* 폼: 문제가 있는 칸을 그 자리에서 짚어준다 */
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  background: #fdf7f6;
}
.field.has-error label {
  color: var(--danger);
}
.field-error {
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
}
.field.has-error .hint {
  display: none; /* 오류 문구와 겹치지 않게 */
}

/* 금액 입력: 콤마 + 원 단위 표시 */
.field input.money {
  text-align: right;
  padding-right: 30px;
  font-variant-numeric: tabular-nums;
}
.field .unit-suffix {
  position: absolute;
  right: 10px;
  top: 27px;
  font-size: 12px;
  color: var(--muted);
  pointer-events: none;
}
.field {
  position: relative;
}

/* 탭 그룹 구분선 (공사진행 / 관리 / 준공후 / 준비) */
.tab-divider {
  width: 1px;
  align-self: center;
  height: 16px;
  background: var(--line);
  margin: 0 6px;
  flex: 0 0 auto;
}
.fp-file-help {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  background: #f7f9f8;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.fp-file-help strong { color: var(--text); }

.gantt .overrun-overlay .bar {
  stroke-dasharray: 5 4;
  stroke-width: 1px;
  opacity: 0.75;
}

/* 관리자 로그인 ------------------------------------------------------ */
.logout-btn {
  width: 100%;
  margin-top: 12px;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.24);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #f5f1e9, #e9efe9);
}

.login-card {
  width: min(100%, 420px);
  padding: 36px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(35, 49, 42, 0.14);
}

.login-brand {
  margin-bottom: 28px;
  color: var(--muted);
  font-weight: 700;
}

.login-brand span {
  display: inline-block;
  margin-right: 8px;
  padding: 5px 9px;
  border-radius: 7px;
  color: #fff;
  background: var(--accent);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.login-card form {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.login-card label {
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.login-card .login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  cursor: pointer;
}

.login-card .login-remember input {
  width: auto;
  margin: 0;
}

.login-card .btn {
  min-height: 46px;
  margin-top: 4px;
}

@media (max-width: 480px) {
  .login-card {
    padding: 28px 22px;
  }
}
