/* 정도 스펙표 자동생성기 - 스타일시트 */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
               "맑은 고딕", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  font-feature-settings: "ss06" on;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--color-surface-default);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.site-header nav a {
  margin-left: 24px;
  color: var(--fg-mute);
  text-decoration: none;
  font-size: 14px;
}
.site-header nav a:hover { color: var(--fg); }
.user-info {
  margin-left: 24px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
  color: var(--fg-mute);
  font-size: 13px;
}
.logout-link { color: var(--fg-mute); font-size: 13px; }
.company-switcher {
  position: relative;
  display: inline-block;
  margin-left: 10px;
  font-size: 12px;
}
.company-switcher summary {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--color-surface-default);
  color: var(--fg);
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.company-switcher summary::-webkit-details-marker { display: none; }
.company-switcher summary:hover,
.company-switcher[open] summary {
  border-color: var(--color-border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}
.company-switcher strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.company-switch-chevron { color: var(--fg-mute); font-size: 15px; line-height: 1; transition: transform .15s ease; }
.company-switcher[open] .company-switch-chevron { transform: rotate(180deg); }
.company-switch-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 7px);
  right: 0;
  width: min(280px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--color-surface-default);
  box-shadow: 0 14px 35px rgba(0, 0, 0, .13);
}
.company-switch-menu p {
  margin: 3px 6px 7px;
  color: var(--fg-mute);
  font-size: 11px;
  font-weight: 600;
}
.company-switch-menu form { margin: 0; }
.site-header nav .company-switch-option,
.company-switch-option {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 7px;
  background: var(--color-surface-default);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.site-header nav .company-switch-option:hover,
.site-header nav .company-switch-option:focus-visible {
  border-color: var(--color-border-default);
  background: var(--color-surface-subtle);
}
.company-switch-option.active { background: var(--color-surface-subtle); font-weight: 650; }
.company-switch-option em {
  color: var(--fg-mute);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
}
.company-switch-option.active em { color: var(--ok); font-weight: 650; }

/* 관리자 뱃지 */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  background: var(--color-surface-subtle);
  color: var(--fg-mute);
}
.badge.admin { background: var(--accent); color: var(--color-surface-default); }

/* 공정표 - 달력 뷰 */
.cal-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  margin-top: 12px;
}
.cal-sidebar {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 18px;
  position: sticky;
  top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.cal-sidebar h3 {
  margin: 0 0 10px; font-size: 14px;
  color: var(--fg); font-weight: 700;
  letter-spacing: -0.2px;
}
.sidebar-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.sidebar-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.sec-sub { font-size: 12px !important; color: var(--fg-mute) !important; font-weight: 600 !important; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list:empty::before {
  content: '아직 없음. 아래에서 추가하세요.';
  color: var(--fg-mute); font-size: 12px; font-style: italic;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}
.task-item:hover { background: var(--color-surface-canvas); }
.task-color {
  width: 16px; height: 16px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.task-name-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 13px;
  min-width: 0;
}
.task-name-input:focus { outline: 1px solid var(--line); border-radius: 4px; }
.task-del {
  border: none; background: none;
  color: var(--fg-mute); cursor: pointer;
  font-size: 16px; padding: 2px 6px;
}
.task-del:hover { color: var(--danger); }

.legend {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--fg-mute);
}
.legend .lv {
  display: inline-block;
  width: 22px; height: 12px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.legend .lv.lv-3 { background: var(--color-intensity-high); }  /* 강 = 빨강 */
.legend .lv.lv-2 { background: var(--color-intensity-medium); }  /* 중 = 초록 */
.legend .lv.lv-1 { background: var(--color-intensity-low); }  /* 약 = 하늘 */

.cal-main {}
.cal-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; margin-bottom: 16px;
}
.cal-title {
  font-size: 22px; font-weight: 700; margin: 0 20px;
  min-width: 180px; text-align: center;
}

.calendar {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  table-layout: fixed;
}
.calendar th {
  padding: 10px 0;
  background: var(--color-surface-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--line);
}
.calendar th.sat { color: var(--color-info); }
.calendar th.sun { color: var(--color-danger); }

.cal-cell {
  height: 90px;
  padding: 6px 8px;
  vertical-align: top;
  border: 1px solid var(--color-surface-subtle);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}
.cal-cell:hover { background: var(--color-surface-canvas); }
.cal-cell.other { color: var(--color-border-default); background: var(--color-surface-canvas); cursor: default; }
.cal-cell.other:hover { background: var(--color-surface-canvas); }
.cal-cell.today { background: var(--color-warning-subtle); }
.cal-cell.today .cal-day {
  background: var(--fg); color: var(--color-surface-default);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.cal-cell.sun .cal-day { color: var(--color-danger); }
.cal-cell.sat .cal-day { color: var(--color-info); }
.cal-cell.today.sun .cal-day,
.cal-cell.today.sat .cal-day { color: var(--color-surface-default); }
.cal-day { font-size: 13px; font-weight: 500; }

/* 공휴일 */
.cal-cell.holiday .cal-day { color: var(--color-danger); }
.cal-cell.holiday.today .cal-day { color: var(--color-surface-default); }
.holiday-name {
  font-size: 10px; color: var(--color-danger);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}

/* 년·월 셀렉트 */
.year-select, .month-select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--color-surface-default);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cal-title { display: none; }

.cal-bars {
  margin-top: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.bar {
  height: 6px;
  border-radius: 2px;
}
.bar.lv-1 { opacity: 0.3; }
.bar.lv-2 { opacity: 0.6; }
.bar.lv-3 { opacity: 1; }

/* 셀 안의 공정 뱃지: [공정색상 배경 이름 | 강중약색상 배지] */
.cal-badges {
  margin-top: 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.task-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  overflow: hidden;
  white-space: nowrap;
  padding: 1px 2px;
}
.task-badge.lv-1, .task-badge.lv-2, .task-badge.lv-3 { opacity: 1; }
.tb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  color: var(--color-text-primary);
  font-weight: 400;
  padding: 1px 2px;
  background: transparent !important;
}
/* 좌측 색상 점 (검정) */
.tb-name::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-text-primary);
  margin-right: 4px;
  vertical-align: middle;
}
.tb-lv {
  font-weight: 800;
  padding: 2px 6px;
  font-size: 10px;
  flex-shrink: 0;
  color: var(--color-surface-default);
  min-width: 22px; text-align: center;
}
/* 강중약 색상 구분 */
.tb-lv.lv-3 { background: var(--color-intensity-high); }  /* 강 = 빨강 */
.tb-lv.lv-2 { background: var(--color-intensity-medium); }  /* 중 = 초록 */
.tb-lv.lv-1 { background: var(--color-intensity-low); color: var(--color-text-primary); }  /* 약 = 하늘색 (진한 글자) */

/* 셀 크기 좀 키움 (공정 뱃지 잘 보이게) */
.cal-cell { height: 110px; }

/* 팝오버 */
.pop-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 900;
}
.day-popover {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--color-surface-default);
  border-radius: 12px;
  padding: 18px 22px;
  min-width: 360px;
  max-width: 500px;
  max-height: 80vh; overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
.pop-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.pop-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--fg-mute);
}
.pop-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--color-border-subtle);
}
.pop-row:last-child { border-bottom: none; }
.pop-task-name { flex: 1; font-size: 14px; }
.lv-btns { display: flex; gap: 4px; }
.lv-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: var(--color-surface-default);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.lv-btn.active {
  background: var(--fg); color: var(--color-surface-default); border-color: var(--fg);
}

@media print {
  .site-header, .btn, .cal-nav .btn, .floating-status, .page-head > div:last-child, .quick-add { display: none !important; }
  .cal-layout { display: block; }
  .cal-sidebar { max-height: none; break-inside: avoid; margin-bottom: 20px; }
}

/* 모바일: 달력 뷰 최적화 */
@media (max-width: 768px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-sidebar {
    position: static;
    max-height: none;
    order: 2;
  }
  .cal-main { order: 1; }
  .cal-cell { height: auto; min-height: 84px; padding: 3px; }
  .cal-day { font-size: 12px; }
  /* 뱃지를 2줄로 스택 (공정명 위, 강중약 아래) */
  .task-badge {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
    padding: 0;
    border: 1px solid var(--color-border-default);
    border-radius: 3px;
    background: var(--color-surface-default);
    overflow: hidden;
    line-height: 1.2;
  }
  .tb-name {
    font-size: 10px;
    padding: 2px 3px;
    color: var(--color-text-primary);
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }
  .tb-name::before { display: none; }
  .tb-lv {
    padding: 2px 3px;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
    color: var(--color-surface-default);
  }
  .cal-nav { flex-wrap: wrap; gap: 6px; }
  .year-select, .month-select { padding: 4px 6px; font-size: 12px; }
  .holiday-name { font-size: 9px; }
}
@media (max-width: 480px) {
  .cal-cell { min-height: 76px; padding: 2px 2px; }
  .tb-name { font-size: 9px; padding: 1px 2px; }
  .tb-lv { padding: 1px 2px; font-size: 9px; }
  .cal-badges { gap: 1px; }
}

/* 계약서 */
.contract-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  margin-top: 12px;
}
.contract-form {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  position: sticky; top: 20px;
  align-self: start;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.contract-form h3 { margin: 0 0 12px; font-size: 15px; }
.contract-form h4 {
  margin: 18px 0 8px;
  font-size: 12px;
  color: var(--fg-mute);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.contract-form .row {
  display: block;
  margin-bottom: 10px;
}
.contract-form label {
  display: block;
  font-size: 11px;
  color: var(--fg-mute);
  font-weight: 600;
  margin-bottom: 4px;
  width: auto;
}
.contract-form input, .contract-form select, .contract-form textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
.contract-form input:focus, .contract-form select:focus, .contract-form textarea:focus {
  outline: none; border-color: var(--fg);
}
.pay-row {
  display: grid;
  grid-template-columns: 80px 45px 8px 120px 1fr;
  gap: 4px;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
}
.pay-amount { color: var(--fg); font-weight: 600; text-align: right; }
.pay-date, .pay-desc, .pay-pct { padding: 4px 6px !important; font-size: 12px !important; }
.pay-pct { text-align: right; }
.pay-pct-unit { color: var(--fg-mute); font-size: 11px; }

/* 계약서 문서 자체 */
.contract-preview {}
.contract-doc {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 40px 50px;
  font-family: "맑은 고딕", sans-serif;
  font-size: 12px;
  line-height: 1.7;
  color: var(--color-text-primary);
  max-width: 210mm;
  margin: 0 auto;
}
.doc-header {
  text-align: center;
  border-bottom: 2px solid var(--color-text-primary);
  padding-bottom: 20px;
  margin-bottom: 24px;
}
.doc-logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.doc-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 1px;
}
.doc-title small { display: block; font-size: 13px; font-weight: 400; color: var(--fg-mute); margin-top: 4px; }
.doc-company {
  font-size: 11px;
  color: var(--fg-mute);
  line-height: 1.5;
}
.clause {
  margin-bottom: 18px;
  page-break-inside: avoid;
}
.clause h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border-default);
}
.clause p { margin: 4px 0; }
.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px;
  font-size: 12px;
}
.pay-table {
  width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 12px;
}
.pay-table th, .pay-table td {
  border: 1px solid var(--color-border-default); padding: 6px 10px; text-align: center;
}
.pay-table th { background: var(--color-surface-subtle); font-weight: 600; }
.pay-table td.right { text-align: right; }
.small { font-size: 11px; color: var(--fg-mute); font-style: italic; }
.pre-line { white-space: pre-line; margin-top: 8px; }
.signature {
  margin-top: 40px;
  page-break-inside: avoid;
}
.contract-date { text-align: center; margin-bottom: 20px; font-weight: 600; }
.sig-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 30px;
  margin-top: 20px;
}
.sig-block {
  border: 1px solid var(--color-border-default);
  padding: 16px 20px;
  border-radius: 4px;
}
.sig-label {
  font-weight: 700; margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border-default);
}
.sig-block > div { margin: 4px 0; }
.sig-line { margin-top: 20px; color: var(--fg-mute); }

@media print {
  /* margin:0 이어야 브라우저가 헤더(날짜·제목)/푸터(URL·페이지번호) 공간을 안 그림 */
  @page { size: A4; margin: 0; }
  body { background: var(--color-surface-default); margin: 0; }
  .site-header, .storage-banner, .no-print, .floating-status { display: none !important; }
  /* 시각적 여백은 container padding으로 대체 */
  .container { max-width: none; padding: 12mm; }
  .contract-layout { display: block; }
  .contract-preview { padding: 0; }
  .contract-doc { border: none; padding: 0; margin: 0; box-shadow: none; }
}

/* 프로젝트 대시보드 */
.dash-cover {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.dash-cover-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
  font-size: 14px;
}
.dash-lbl {
  display: inline-block;
  min-width: 70px;
  color: var(--fg-mute);
  font-weight: 600;
  font-size: 12px;
  margin-right: 8px;
}
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
}
.dash-card h3 { margin: 0 0 12px; font-size: 16px; }
.dash-icon { font-size: 36px; margin-bottom: 4px; }
.dash-metric {
  font-size: 32px;
  font-weight: 700;
  color: var(--fg);
  margin: 10px 0 4px;
}
.metric-num { font-size: 36px; }
.metric-slash { color: var(--fg-mute); margin: 0 4px; font-weight: 400; }
.metric-total { color: var(--fg-mute); font-size: 24px; font-weight: 500; }
.metric-unit { font-size: 14px; color: var(--fg-mute); font-weight: 500; margin-left: 4px; }
.dash-sub { color: var(--fg-mute); font-size: 12px; }
.dash-progress {
  height: 6px;
  background: var(--color-surface-subtle);
  border-radius: 3px;
  margin: 14px 0;
  overflow: hidden;
}
.dash-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}
.dash-actions {
  display: flex; gap: 8px; justify-content: center;
  margin-top: 12px;
}

.dash-quick {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
}
.dash-quick h2 { font-size: 16px; margin: 0 0 12px; }
.quick-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-meta {
  color: var(--fg-mute);
  font-size: 12px;
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.action-cell { white-space: nowrap; }
.action-cell .btn, .action-cell form { margin-right: 4px; }

/* 저장 공간 배너 · 관리자 위젯 */
.storage-banner {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--color-surface-default);
  text-align: center;
}
.storage-banner.warn { background: var(--color-warning); }
.storage-banner.danger { background: var(--danger); }
.storage-banner a { color: var(--color-surface-default); text-decoration: underline; margin-left: 8px; }

.storage-box {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
  margin-top: 12px;
}
.storage-box.warn { border-color: var(--color-warning); }
.storage-box.danger { border-color: var(--danger); }
.storage-numbers {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 10px;
}
.storage-percent {
  font-size: 32px; font-weight: 700;
}
.storage-box.warn .storage-percent { color: var(--color-warning); }
.storage-box.danger .storage-percent { color: var(--danger); }
.storage-detail { color: var(--fg-mute); font-size: 13px; }
.storage-bar {
  height: 12px;
  background: var(--color-surface-subtle);
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
}
.storage-fill {
  height: 100%;
  background: var(--ok);
  transition: width 0.3s;
}
.storage-box.warn .storage-fill { background: var(--color-warning); }
.storage-box.danger .storage-fill { background: var(--danger); }
.storage-msg { margin: 8px 0 0; font-size: 13px; }
.storage-msg.warn { color: var(--color-warning); font-weight: 600; }
.storage-msg.danger { color: var(--danger); font-weight: 600; }

/* 시공 사진 아카이브 */
.upload-queue {
  background: var(--color-surface-subtle);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.upload-queue h3 { margin: 0 0 12px; font-size: 15px; }
.queue-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.queue-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.queue-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.q-del {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.6);
  color: var(--color-surface-default);
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.photo-date-group { margin-bottom: 28px; }
.date-label {
  font-size: 15px;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin: 0 0 12px;
}
.date-label small { color: var(--fg-mute); font-weight: 400; margin-left: 6px; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--color-surface-subtle);
}
.photo-item img {
  width: 100%; height: 100%; object-fit: cover;
  cursor: zoom-in;
}
.photo-delete {
  position: absolute;
  top: 6px; right: 6px;
  background: rgba(0,0,0,0.55);
  color: var(--color-surface-default);
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.85;
  transition: background 0.15s;
  z-index: 2;
}
.photo-delete:hover { background: var(--danger); opacity: 1; }
.photo-item:hover .photo-delete { opacity: 1; }

@media (max-width: 640px) {
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-head > div:last-child { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 800px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* 공유 랜딩 페이지 */
.share-wrap {
  max-width: 720px; margin: 0 auto;
  padding: 40px 24px;
}
.share-header {
  text-align: center;
  padding: 30px 0 40px;
  border-bottom: 1px solid var(--line);
}
.share-brand {
  font-size: 28px; font-weight: 700; letter-spacing: 3px;
}
.share-tagline { color: var(--fg-mute); font-size: 13px; margin-top: 8px; }

.share-project {
  padding: 30px 0;
  text-align: center;
}
.share-project h1 { font-size: 28px; margin: 0 0 20px; }
.share-meta {
  color: var(--fg-mute);
  font-size: 14px;
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
}

.share-docs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px;
  margin: 30px 0;
}
.share-card {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.15s, box-shadow 0.15s;
}
.share-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.share-icon { font-size: 44px; margin-bottom: 8px; }
.share-name { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.share-desc { color: var(--fg-mute); font-size: 13px; }

.share-footer {
  text-align: center;
  padding: 30px 0;
  border-top: 1px solid var(--line);
  color: var(--fg-mute);
  font-size: 12px;
  line-height: 1.8;
}
.share-footer a { color: var(--fg-mute); }

/* 공유 뷰에서 편집 UI 숨김 (베이스 CSS 안전장치) */
.read-only-view .btn.danger, .read-only-view #btn-delete { display: none !important; }
.read-only-view .contract-layout.ro,
.read-only-view .cal-layout.ro { grid-template-columns: 1fr; }
.contract-layout.ro .contract-form { display: none; }
.cal-layout.ro .cal-sidebar { display: none; }

@media (max-width: 600px) {
  .share-docs { grid-template-columns: 1fr; }
}

/* 옛 그리드 스타일 (남아있으면 삭제) */
.sched-range { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.sched-range label { font-size: 13px; color: var(--fg-mute); }
.sched-range input[type=date] { padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; font-family: inherit; margin-left: 6px; }
.quick-add { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; align-items: center; }
.qa-label { font-size: 12px; color: var(--fg-mute); font-weight: 600; margin-right: 4px; }
.quick-add-btn { background: var(--color-surface-subtle); color: var(--fg-mute); font-size: 12px; padding: 5px 10px; border-radius: 14px; }
.quick-add-btn.custom { background: var(--color-info-subtle); color: var(--color-info); padding-right: 8px; }
.quick-add-btn:hover { border-color: var(--fg); color: var(--fg); }
.quick-add-btn.custom:hover { border-color: var(--color-info); }
.tag-del { margin-left: 4px; font-size: 14px; padding: 0 4px; color: rgba(43,108,176,0.5); }
.tag-del:hover { color: var(--color-danger); }
.add-custom-btn { display: block; margin-top: 10px; width: 100%; }

.legend {
  margin: 12px 0;
  font-size: 12px;
  color: var(--fg-mute);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cell-demo {
  display: inline-block;
  width: 24px; height: 20px;
  border: 1px solid var(--line);
  text-align: center; line-height: 20px;
  font-size: 11px; color: var(--color-surface-default);
}
.cell-demo.lvl-3 { background: var(--color-text-primary); }
.cell-demo.lvl-2 { background: var(--color-text-secondary); }
.cell-demo.lvl-1 { background: var(--color-border-strong); color: var(--color-text-primary); }

.sched-wrap {
  overflow-x: auto;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}
.sched-grid {
  border-collapse: collapse;
  font-size: 12px;
}
.sched-grid th, .sched-grid td {
  border: 1px solid var(--line);
  text-align: center;
  padding: 0;
}
.sched-grid .corner {
  background: var(--color-surface-subtle);
  min-width: 140px;
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  position: sticky; left: 0; z-index: 3;
}
.sched-grid .corner-del { min-width: 32px; background: var(--color-surface-subtle); }
.sched-grid .day-header {
  background: var(--color-surface-subtle);
  min-width: 26px; max-width: 30px;
  padding: 4px 2px;
  font-weight: 500;
}
.sched-grid .day-header.sat { background: var(--color-info-subtle); color: var(--color-info); }
.sched-grid .day-header.sun { background: var(--color-danger-subtle); color: var(--color-danger); }
.sched-grid .d-md { font-size: 10px; color: var(--fg-mute); }
.sched-grid .d-day { font-size: 13px; font-weight: 700; }
.sched-grid .d-wk { font-size: 10px; color: var(--fg-mute); }
.sched-grid .task-name-cell {
  background: var(--color-surface-default); position: sticky; left: 0; z-index: 2;
  padding: 0;
}
.sched-grid .task-name-input {
  width: 100%; padding: 6px 10px;
  border: none; background: transparent;
  font-family: inherit; font-size: 13px;
}
.sched-grid .task-name-input:focus { outline: 2px solid var(--fg); }
.sched-grid .day-cell {
  min-width: 26px; height: 30px;
  cursor: pointer;
  background: var(--color-surface-default);
  transition: background 0.05s;
}
.sched-grid .day-cell.sat { background: var(--color-info-subtle); }
.sched-grid .day-cell.sun { background: var(--color-danger-subtle); }
.sched-grid .day-cell:hover { outline: 1px solid var(--fg); }
.sched-grid .day-cell.lvl-1 { background: var(--color-border-default); }
.sched-grid .day-cell.lvl-2 { background: var(--color-text-secondary); }
.sched-grid .day-cell.lvl-3 { background: var(--color-text-primary); }
.sched-grid .day-cell.lvl-1.sat, .sched-grid .day-cell.lvl-1.sun { background: var(--color-border-default); }
.sched-grid .day-cell.lvl-2.sat, .sched-grid .day-cell.lvl-2.sun { background: var(--color-text-secondary); }
.sched-grid .day-cell.lvl-3.sat, .sched-grid .day-cell.lvl-3.sun { background: var(--color-text-primary); }

@media print {
  .site-header, .quick-add, .btn, .floating-status, .page-head > div:last-child,
  .sched-range input, .corner-del button { display: none !important; }
  .sched-wrap { overflow: visible; }
  .sched-grid .day-cell { height: 22px; min-width: 20px; }
}
.inline-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 0;
}
.inline-form label { font-size: 12px; color: var(--fg-mute); font-weight: 600; }
.inline-form input[type=password] {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px;
}

h1 { font-size: 28px; margin: 0 0 8px; font-weight: 700; }
h2 { font-size: 20px; margin: 24px 0 12px; font-weight: 600; }
.hint { color: var(--fg-mute); font-size: 14px; }

.hero {
  text-align: center;
  padding: 40px 0 24px;
}
.hero-sub { color: var(--fg-mute); font-size: 15px; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}
.big-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.15s, box-shadow 0.15s;
}
.big-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.big-card.primary {
  background: var(--accent);
  color: var(--color-surface-default);
}
.big-card-num {
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 2px;
}
.big-card.primary .big-card-num { color: rgba(255,255,255,0.6); }
.big-card-title {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0;
}
.big-card-desc {
  font-size: 14px;
  color: var(--fg-mute);
}
.big-card.primary .big-card-desc { color: rgba(255,255,255,0.85); }

.section { margin-top: 40px; }

.project-list { list-style: none; padding: 0; }
.project-list li a {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--fg);
}
.project-list li a:hover { border-color: var(--fg); }
.proj-name { font-weight: 600; }
.proj-date { color: var(--fg-mute); font-size: 13px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.tab {
  padding: 12px 20px;
  text-decoration: none;
  color: var(--fg-mute);
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.tab.active {
  color: var(--fg);
  border-bottom-color: var(--fg);
  font-weight: 700;
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.material-card {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  transition: box-shadow 0.15s;
}
.material-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.material-img {
  width: 100%;
  aspect-ratio: 1;
  background: var(--color-surface-subtle);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.material-img img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.material-img .no-img { color: var(--color-text-disabled); font-size: 12px; }
.material-info { padding: 12px; }
.material-name { font-weight: 600; margin-bottom: 4px; }
.material-brand, .material-spec {
  font-size: 12px; color: var(--fg-mute);
}

.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--fg-mute);
}

.form { max-width: 640px; margin-top: 16px; }
.row {
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}
.row label {
  width: 120px;
  font-size: 14px;
  color: var(--fg-mute);
  font-weight: 500;
}
.row input[type=text],
.row input[type=file],
.row select {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface-default);
}
.row input[type=text]:focus, .row select:focus {
  outline: none;
  border-color: var(--fg);
}
.row.actions { margin-top: 24px; }
.req { color: var(--danger); }

.preview {
  margin-top: 12px;
  display: flex; align-items: center; gap: 12px;
}
.preview img {
  width: 80px; height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.preview small { color: var(--fg-mute); }

/* 사진 업로드 (드래그·붙여넣기 지원) */
.image-upload-row {
  align-items: flex-start;
}
.uploader {
  flex: 1;
}
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  background: var(--color-surface-canvas);
  transition: all 0.15s;
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}
.dropzone:hover, .dropzone:focus {
  border-color: var(--fg);
  background: var(--color-surface-default);
}
.dropzone.dragover {
  border-color: var(--fg);
  background: var(--color-warning-subtle);
}
.drop-hint {
  color: var(--fg-mute);
}
.hint-icon {
  font-size: 44px;
  margin-bottom: 10px;
}
.hint-main {
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 6px;
}
.hint-sub {
  font-size: 12px;
}
.preview-area img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.uploader-note {
  display: block;
  margin-top: 8px;
  color: var(--fg-mute);
  font-size: 12px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--color-surface-default);
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  margin-right: 8px;
}
.btn:hover { border-color: var(--fg); }
.btn.primary {
  background: var(--accent);
  color: var(--color-surface-default);
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}
.btn.danger:hover { background: var(--danger); color: var(--color-surface-default); }

/* 프로젝트 편집 화면 */
.slide-block {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 16px;
}
.slide-block summary {
  cursor: pointer;
  padding: 4px 0;
  font-size: 15px;
}
.slot-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}
.slot-table th {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-mute);
  font-weight: 600;
  font-size: 12px;
}
.slot-table td {
  padding: 6px;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}
.slot-table input[type=text],
.slot-table select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-surface-default);
}
.thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}
.preview-cell { width: 60px; }
.reset-cell { width: 40px; text-align: center; }
.reset-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-mute);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
  transition: all 0.15s;
}
.reset-btn:hover {
  background: var(--color-danger-subtle);
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.reset-btn:active { transform: scale(0.92); }

/* ── 자재 검색 선택기 (mat-select 대체) ── */
.matpick { position: relative; display: block; }
.matpick > input,
.slot-table .matpick > input {
  width: 100%;
  padding: 6px 24px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: var(--color-surface-default);
  color: var(--fg);
}
.matpick > input::placeholder { color: var(--color-text-disabled); font-weight: 400; }
.matpick > input.picked { font-weight: 600; }
.matpick-caret {
  position: absolute; right: 2px; top: 0; bottom: 0; width: 20px;
  border: none; background: none; cursor: pointer;
  color: var(--fg-mute); font-size: 11px; line-height: 1; padding: 0;
}
.matpick-menu {
  position: fixed;
  z-index: 900;
  background: var(--color-surface-default);
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px;
}
.matpick-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  border: none; background: none; cursor: pointer;
  padding: 6px 8px; border-radius: 6px;
  font-family: inherit; font-size: 13px; color: var(--fg);
}
.matpick-menu button:hover,
.matpick-menu button.active { background: var(--color-surface-hover); }
.matpick-menu button.on { background: var(--color-info-subtle); font-weight: 700; }
.matpick-menu img.mp-thumb {
  width: 34px; height: 34px; object-fit: cover; flex: none;
  border-radius: 4px; border: 1px solid var(--line); background: var(--color-surface-subtle);
}
.matpick-menu .mp-noimg {
  width: 34px; height: 34px; flex: none;
  border-radius: 4px; border: 1px dashed var(--line); background: var(--color-surface-canvas);
}
.matpick-menu .mp-text { min-width: 0; flex: 1; }
.matpick-menu .mp-name {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.matpick-menu .mp-sub {
  display: block; font-size: 11px; color: var(--fg-mute); font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.matpick-menu .mp-empty,
.matpick-menu .mp-more {
  padding: 8px 10px; font-size: 12px; color: var(--fg-mute);
}
.matpick-menu .mp-group {
  padding: 8px 10px 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--fg-mute); text-transform: none;
  border-top: 1px solid var(--line); margin-top: 4px;
}
.matpick-menu .mp-group:first-child { border-top: none; margin-top: 0; }
.matpick-menu .mp-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 10px; font-weight: 600; vertical-align: 1px;
  color: var(--color-warning); background: var(--color-warning-subtle); border: 1px solid var(--color-warning-border); border-radius: 10px;
}
.matpick-menu mark { background: var(--color-warning-subtle); color: inherit; border-radius: 2px; }

.floating-status {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--color-surface-default);
  background: var(--ok);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transition: opacity 0.2s;
}
.floating-status.saving { background: var(--warn); }
.floating-status.error { background: var(--danger); }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }

/* 카테고리 관리 */
.cat-list { list-style: none; padding: 0; margin: 12px 0; }
.cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.cat-row.builtin { background: var(--color-surface-subtle); }
.cat-row strong { font-size: 15px; }
.cat-type {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: var(--color-surface-subtle);
  color: var(--fg-mute);
  font-size: 11px;
  border-radius: 10px;
}
.cat-meta { color: var(--fg-mute); font-size: 13px; }
.btn.sm { padding: 6px 12px; font-size: 12px; margin: 0; }
.add-tab { color: var(--fg-mute); font-weight: 500; }
.add-tab:hover { color: var(--fg); }

/* 프로젝트 카테고리 토글 */
.cat-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.cat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.cat-toggle:has(input:checked) {
  background: var(--accent);
  color: var(--color-surface-default);
  border-color: var(--accent);
}
.cat-toggle input { margin: 0; cursor: pointer; }
.cat-toggle input:checked { accent-color: var(--color-surface-default); }

/* 카테고리 설정 테이블 */
.cat-toggle-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.cat-toggle-table th {
  background: var(--color-surface-subtle);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.cat-toggle-table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}
.cat-toggle-table tr:last-child td { border-bottom: none; }
.cat-toggle-table td strong { font-size: 14px; }
.cat-toggle-table input[type=number] {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
}
.cat-toggle-table input[type=checkbox] {
  width: 20px; height: 20px; cursor: pointer;
}

.add-cat-block {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.add-cat-block summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--fg);
  font-size: 14px;
}
.add-cat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.add-cat-form input[type=text] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
}
.add-cat-form select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
}
.add-cat-form small { width: 100%; margin-top: 4px; }

/* 프로젝트 목록 테이블 */
.project-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.project-table th {
  background: var(--color-surface-subtle);
  padding: 12px;
  text-align: left;
  font-size: 12px;
  color: var(--fg-mute);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.project-table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.project-table tr:last-child td { border-bottom: none; }
.project-table td.mute { color: var(--fg-mute); font-size: 13px; }
.project-table a { color: var(--fg); text-decoration: none; }
.project-table a:hover { text-decoration: underline; }

/* 자재 검색 바 */
.mat-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.mat-search-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface-default);
}
.mat-search-bar input:focus { outline: none; border-color: var(--fg); }
#mat-count { color: var(--fg-mute); font-size: 13px; }

/* 카드 클릭 커서 */
.material-card {
  cursor: pointer;
  position: relative;
  /* 화면 밖 카드는 브라우저가 레이아웃·페인트를 미룬다. 대용량 자재 목록 스크롤 비용을 줄인다. */
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
}

/* 자재 카드 삭제 버튼 (사진 위 우측 상단 X) */
.card-delete-form {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  margin: 0;
}
.card-delete-btn {
  width: 26px; height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: var(--color-surface-default);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.card-delete-btn:hover { background: var(--danger); }

/* 자재 큰 미리보기 모달 */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-content {
  background: var(--color-surface-default);
  border-radius: 12px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  position: relative;
  display: flex; gap: 24px;
}
.modal-content img {
  width: 320px; height: 320px;
  object-fit: contain;
  background: var(--color-surface-canvas);
  border-radius: 8px;
}
.modal-info { flex: 1; min-width: 0; }
.modal-info h2 { margin: 0 0 10px; }
.modal-info div { margin-bottom: 8px; color: var(--fg-mute); }
.modal-actions { margin-top: 20px; display: flex; gap: 8px; }
.modal-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: none;
  font-size: 28px; cursor: pointer; color: var(--fg-mute);
}

/* 로그인 페이지 */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.login-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 0.5px;
}
.login-sub {
  color: var(--fg-mute);
  font-size: 13px;
  margin: 0 0 28px;
}
.login-form .row { margin-bottom: 16px; display: block; }
.login-form label {
  display: block;
  font-size: 12px;
  color: var(--fg-mute);
  margin-bottom: 6px;
  font-weight: 600;
  width: auto;
}
.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface-default);
}
.login-form input:focus { outline: none; border-color: var(--fg); }
.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-mute);
}
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}
.flash.error { background: var(--color-danger-subtle); color: var(--danger); }
.flash.ok { background: var(--color-success-subtle); color: var(--ok); }

/* 프로젝트 NOTE */
.note-block {
  margin-top: 8px;
  padding: 12px 6px 4px;
  border-top: 1px dashed var(--line);
}
.note-block label {
  display: block;
  font-size: 12px;
  color: var(--fg-mute);
  margin-bottom: 6px;
  font-weight: 600;
}
.note-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.note-input:focus { outline: none; border-color: var(--fg); }

/* 블록 좌측 라벨 입력 행 */
.block-label-row td {
  background: var(--color-surface-subtle);
  padding: 8px 12px !important;
  border-top: 2px solid var(--line);
}
.block-label-label {
  display: inline-block;
  min-width: 110px;
  font-size: 12px;
  color: var(--fg-mute);
  font-weight: 600;
  margin-right: 8px;
}
.block-label-input {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  min-width: 300px;
}
.block-label-input:focus { outline: none; border-color: var(--fg); }

/* ============================================================
   지출 관리 (프로젝트 지출 · 회사 지출)
   ============================================================ */

/* 상단 요약 카드 (프로젝트 지출) */
.exp-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.exp-metric {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.exp-lbl { font-size: 12px; color: var(--fg-mute); font-weight: 600; }
.exp-val { font-size: 20px; font-weight: 700; color: var(--fg); }

/* 지출 추가 폼 */
.exp-add {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.exp-add h3 { margin: 0 0 12px; font-size: 15px; }
.exp-add-form {
  display: grid;
  grid-template-columns: 140px 130px 1fr 130px 1fr auto;
  gap: 8px;
  align-items: center;
}
.exp-add-form input, .exp-add-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--color-surface-default);
}
.exp-add-form input:focus, .exp-add-form select:focus {
  outline: none; border-color: var(--fg);
}

/* 지출 리스트 테이블 */
.exp-list-wrap {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
}
.exp-list-wrap h3 { margin: 0 0 12px; font-size: 15px; }
.exp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.exp-table th {
  background: var(--color-surface-subtle);
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
  color: var(--fg-mute);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.exp-table th.right, .exp-table td.right { text-align: right; }
.exp-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-surface-subtle);
  vertical-align: middle;
}
.exp-table tfoot td {
  border-top: 2px solid var(--line);
  padding: 12px 10px;
  font-size: 14px;
}
.cell-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
}
.cell-input:hover, .cell-input:focus {
  border-color: var(--line);
  background: var(--color-surface-default);
  outline: none;
}
.amount-input { min-width: 100px; }
.cat-select { min-width: 100px; }

/* ============================================================
   회사 지출 화면
   ============================================================ */
.ce-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin: 16px 0 20px;
  flex-wrap: wrap;
}
.ce-jump {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.ce-jump input, .ce-jump select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.ce-jump input { width: 80px; }

.ce-empty {
  background: var(--color-warning-subtle);
  border: 1px dashed var(--color-warning-border);
  border-radius: 10px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
}
.ce-empty p { margin: 0 0 12px; }

.ce-add {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.ce-add h3 { margin: 0 0 12px; font-size: 15px; }
.ce-add-form {
  display: grid;
  grid-template-columns: 130px 1fr 140px 1fr auto;
  gap: 8px;
  align-items: center;
}
.ce-add-form input, .ce-add-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--color-surface-default);
}
.ce-add-form input:focus, .ce-add-form select:focus {
  outline: none; border-color: var(--fg);
}

.ce-list-wrap {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
}
.ce-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ce-table th {
  background: var(--color-surface-subtle);
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
  color: var(--fg-mute);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.ce-table th.right, .ce-table td.right { text-align: right; }
.ce-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-surface-subtle);
  vertical-align: middle;
}
.ce-table tfoot td {
  border-top: 2px solid var(--line);
  padding: 12px 10px;
  font-size: 14px;
}
.ce-cell {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
}
.ce-cell:hover, .ce-cell:focus {
  border-color: var(--line);
  background: var(--color-surface-default);
  outline: none;
}

/* 연간 요약 */
.ce-year-summary {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px;
}
.ce-year-summary h2 { margin: 0 0 8px; font-size: 18px; }
.ce-year-total {
  font-size: 14px;
  color: var(--fg-mute);
  margin-bottom: 20px;
}
.ce-year-total strong { color: var(--fg); font-size: 16px; }
.ce-year-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.ce-year-block h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--fg-mute);
  font-weight: 600;
}
.ce-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ce-summary-table th, .ce-summary-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-surface-subtle);
}
.ce-summary-table th.right, .ce-summary-table td.right { text-align: right; }
.ce-summary-table th {
  font-size: 11px;
  color: var(--fg-mute);
  font-weight: 600;
  background: var(--color-surface-subtle);
}
.ce-summary-table tr.highlight { background: var(--color-warning-subtle); }
.ce-summary-table tr.highlight td { font-weight: 700; }
.ce-summary-table a { color: var(--fg); text-decoration: none; }
.ce-summary-table a:hover { text-decoration: underline; }

/* 지출 관리 모바일 */
@media (max-width: 900px) {
  .exp-add-form, .ce-add-form {
    grid-template-columns: 1fr 1fr;
  }
  .exp-add-form input:first-of-type,
  .exp-add-form select,
  .exp-add-form button {
    grid-column: span 1;
  }
  .exp-add-form input[type=text]:not(:last-of-type) { grid-column: 1 / -1; }
  .ce-year-grid { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 640px) {
  .exp-add-form, .ce-add-form { grid-template-columns: 1fr; }
  .exp-add-form > *, .ce-add-form > * { grid-column: 1; }

  /* 지출 테이블 → 카드 뷰 */
  .exp-table, .exp-table tbody, .exp-table tr, .exp-table td { display: block; width: 100%; }
  .exp-table thead, .exp-table tfoot { display: none; }
  .exp-table tr {
    background: var(--color-surface-default);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .exp-table td {
    padding: 4px 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .exp-table .cell-input { font-size: 15px; padding: 8px 10px; border-color: var(--line); background: var(--color-surface-default); }
  .exp-table td .cell-input { flex: 1; }
  .exp-table td.right { justify-content: flex-end; }

  /* 회사 지출 테이블 → 카드 */
  .ce-table, .ce-table tbody, .ce-table tr, .ce-table td { display: block; width: 100%; }
  .ce-table thead, .ce-table tfoot { display: none; }
  .ce-table tr {
    background: var(--color-surface-default);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  .ce-table td {
    padding: 4px 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .ce-table .ce-cell { font-size: 15px; padding: 8px 10px; border-color: var(--line); background: var(--color-surface-default); }
  .ce-table td .ce-cell { flex: 1; }

  .ce-nav { justify-content: stretch; }
  .ce-nav .btn { flex: 1; text-align: center; padding: 8px 10px; }
  .ce-jump { flex: 1 1 100%; justify-content: center; }
}

/* ============================================================
   모바일 대응 통합 (전체 화면)
   태블릿: 900px 이하 / 폰: 640px 이하 / 소형폰: 400px 이하
   ============================================================ */

/* 태블릿·중형 (900px 이하) */
@media (max-width: 900px) {
  .container { padding: 20px 16px; }

  /* 헤더: 좌우 여백 축소 */
  .site-header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .site-header nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .site-header nav a { margin-left: 0; font-size: 13px; }
  .user-info { margin-left: 12px; padding-left: 10px; font-size: 12px; }

  /* 계약서 레이아웃 → 1컬럼 */
  .contract-layout { grid-template-columns: 1fr; gap: 16px; }
  .contract-form {
    position: static;
    max-height: none;
    padding: 16px;
  }

  /* 대시보드 카드 그리드 축소 */
  .dash-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .dash-card { padding: 18px 14px; }
  .dash-icon { font-size: 30px; }
  .metric-num { font-size: 28px; }

  /* 스펙표 편집 - 카테고리 토글 테이블 스크롤 처리 */
  .cat-toggle-table { display: block; overflow-x: auto; }
  .block-label-input { min-width: 0; width: 100%; }
}

/* 폰 (640px 이하) */
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }

  .container { padding: 16px 12px; }

  /* 헤더 - 브랜드+로그아웃 축소 */
  .site-header { padding: 10px 12px; gap: 6px; }
  .brand { font-size: 16px; }
  .company-switcher { margin-left: 0; }

  /* 페이지 헤더 - 타이틀+버튼 세로 정렬 */
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-head > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .btn { padding: 10px 14px; margin-right: 0; }
  .btn.sm { padding: 8px 12px; }

  /* 홈 카드 그리드 */
  .card-grid { grid-template-columns: 1fr; gap: 12px; }
  .big-card { padding: 20px; }
  .big-card-title { font-size: 18px; }

  /* 대시보드 → 1컬럼 */
  .dash-grid { grid-template-columns: 1fr; }
  .dash-cover { padding: 14px 16px; }
  .dash-cover-grid { grid-template-columns: 1fr; gap: 6px; font-size: 13px; }

  /* 자재 관리 - 카드 그리드 (최소 140px로 → 모바일도 2열 보장) */
  .material-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .material-info { padding: 10px; }
  .material-name { font-size: 13px; }
  .material-brand, .material-spec { font-size: 11px; }
  .card-delete-btn { width: 30px; height: 30px; font-size: 20px; }

  /* 자재 모달 - 세로 스택 */
  .modal-backdrop { padding: 16px; }
  .modal-content {
    flex-direction: column;
    padding: 16px;
    gap: 14px;
    max-height: 92vh;
  }
  .modal-content img {
    width: 100%; height: auto; max-height: 40vh;
  }

  /* 자재 검색바 */
  .mat-search-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .mat-search-bar input { font-size: 15px; }

  /* 사진 그리드 - 모바일 3열 */
  .photo-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .photo-delete {
    width: 32px; height: 32px; font-size: 20px;
    opacity: 1;
  }

  /* 프로젝트 목록 테이블 → 카드 형태 */
  .project-table { border: none; background: transparent; }
  .project-table thead { display: none; }
  .project-table, .project-table tbody, .project-table tr, .project-table td {
    display: block;
    width: 100%;
  }
  .project-table tr {
    background: var(--color-surface-default);
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px 14px;
  }
  .project-table td {
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
  }
  .project-table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 70px;
    font-size: 11px;
    color: var(--fg-mute);
    font-weight: 600;
    margin-right: 8px;
  }
  .project-table td:first-child {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border-subtle);
  }
  .project-table td:first-child::before { display: none; }
  .project-table .action-cell {
    white-space: normal;
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-subtle);
  }
  .project-table .action-cell::before { display: none; }
  .project-table .action-cell .btn { margin: 0; padding: 6px 10px; font-size: 12px; }
  .project-table .action-cell form { margin: 0; }

  /* 계약서 - 지급 방식 행: 3줄 flex 레이아웃 */
  .pay-row {
    display: flex;
    flex-wrap: wrap;
    grid-template-columns: none;
    gap: 6px;
    padding: 10px;
    background: var(--color-surface-subtle);
    border-radius: 6px;
    margin-bottom: 8px;
    align-items: center;
  }
  .pay-desc { flex: 1 1 100%; }
  .pay-pct { flex: 0 0 68px; }
  .pay-pct-unit { flex: 0 0 auto; }
  .pay-date { flex: 1 1 130px; }
  .pay-amount {
    flex: 1 1 100%;
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    padding-top: 4px;
    border-top: 1px dashed var(--line);
    margin-top: 4px;
  }

  /* 계약서 문서 여백 축소 */
  .contract-doc { padding: 20px 16px; font-size: 13px; }
  .doc-title { font-size: 20px; }
  .doc-logo { font-size: 16px; }
  .grid-2 { grid-template-columns: 1fr; gap: 4px; }
  .sig-grid { grid-template-columns: 1fr; gap: 14px; }
  .sig-block { padding: 12px 14px; }
  .pay-table { font-size: 11px; }
  .pay-table th, .pay-table td { padding: 4px 6px; }

  /* 스펙표 편집 - 자재 슬롯 테이블 */
  .slot-table { font-size: 12px; }
  .slot-table th, .slot-table td { padding: 4px 3px; }
  .slot-table input[type=text], .slot-table select {
    padding: 6px 6px; font-size: 12px;
  }
  .matpick > input,
  .slot-table .matpick > input { padding: 6px 22px 6px 6px; font-size: 12px; }
  .matpick-menu { max-height: 52vh; }
  .matpick-menu img.mp-thumb, .matpick-menu .mp-noimg { width: 30px; height: 30px; }
  .thumb { width: 40px; height: 40px; }
  .preview-cell { width: 46px; }
  .reset-cell { width: 34px; }
  .reset-btn { width: 26px; height: 26px; font-size: 13px; }

  /* 프로젝트 편집 - 표지 폼 */
  .row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 10px;
  }
  .row label {
    width: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-mute);
  }
  .row input[type=text], .row input[type=file], .row select {
    font-size: 15px;
    padding: 10px 12px;
  }

  /* 카테고리 토글 - 터치 타겟 확대 */
  .cat-toggle { padding: 10px 14px; font-size: 13px; }
  .cat-toggle input { width: 18px; height: 18px; }

  /* 카테고리 설정 테이블 - 카드 형태로 변환 */
  .cat-toggle-table, .cat-toggle-table tbody, .cat-toggle-table tr, .cat-toggle-table td {
    display: block; width: 100%;
  }
  .cat-toggle-table thead { display: none; }
  .cat-toggle-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .cat-toggle-table tr:last-child { border-bottom: none; }
  .cat-toggle-table td {
    padding: 4px 0;
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .cat-toggle-table td::before {
    content: attr(data-label);
    min-width: 80px;
    font-size: 11px;
    color: var(--fg-mute);
    font-weight: 600;
  }
  .cat-toggle-table td:first-child::before { display: none; }
  .cat-toggle-table input[type=checkbox] { width: 22px; height: 22px; }
  .cat-toggle-table input[type=number] { width: 80px; }

  /* 카테고리 추가 폼 */
  .add-cat-form { flex-direction: column; align-items: stretch; }
  .add-cat-form input[type=text], .add-cat-form select {
    min-width: 0; width: 100%;
  }

  /* 사진 업로드 큐 썸네일 */
  .queue-thumbs { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .dropzone { min-height: 180px; padding: 18px; }
  .hint-icon { font-size: 36px; }

  /* 공유 랜딩 - 여백 축소 */
  .share-wrap { padding: 24px 16px; }
  .share-brand { font-size: 22px; letter-spacing: 2px; }
  .share-project h1 { font-size: 22px; }
  .share-card { padding: 24px 18px; }
  .share-icon { font-size: 36px; }
  .share-name { font-size: 17px; }

  /* 플로팅 상태 배지 위치 조정 (하단 홈바 회피) */
  .floating-status {
    right: 12px;
    bottom: 12px;
    font-size: 12px;
    padding: 6px 12px;
  }

  /* 저장 공간 배너 */
  .storage-banner { padding: 8px 12px; font-size: 12px; }
  .storage-box { padding: 14px 16px; }
  .storage-percent { font-size: 24px; }

  /* 자재 관리 탭 - 가로 스크롤 */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab { padding: 10px 14px; white-space: nowrap; font-size: 13px; }
}

/* 소형폰 (400px 이하) */
@media (max-width: 400px) {
  .material-grid { gap: 8px; }
  .photo-grid { grid-template-columns: repeat(2, 1fr); }
  .site-header nav a { font-size: 12px; }
  .brand { font-size: 15px; }
  .contract-doc { padding: 16px 12px; }
}

/* iOS 폼 확대 방지 - 입력 폰트 16px 이상 유지 */
@media (max-width: 640px) {
  input[type=text], input[type=password], input[type=number],
  input[type=date], input[type=email], input[type=tel],
  select, textarea {
    font-size: 16px !important;
  }
  /* 예외: 작은 표 내부 입력은 15px 유지 (레이아웃 안깨지게) */
  .slot-table input, .slot-table select,
  .pay-row input, .cat-toggle-table input[type=number] {
    font-size: 15px !important;
  }
}

/* ============================================================
   계약서 - 입금 확인 UI
   ============================================================ */
.pay-row-wrap {
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px solid var(--line);
  background: var(--color-surface-default);
}
.pay-row-wrap.paid {
  background: var(--color-success-subtle);
  border-color: var(--color-success-border);
}
.pay-paid-line {
  display: grid;
  grid-template-columns: auto 1fr 80px 1fr;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
}
.pay-paid-check {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; color: var(--fg-mute); font-weight: 600;
  white-space: nowrap;
}
.pay-row-wrap.paid .pay-paid-check { color: var(--ok); }
.pay-paid-line input[type=date],
.pay-paid-line select,
.pay-paid-line input[type=text] {
  padding: 4px 6px !important;
  font-size: 12px !important;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--color-surface-default);
  min-width: 0;
}

/* 문서 미리보기 안 */
.pay-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.pay-status.pay-done {
  background: var(--color-success-subtle);
  color: var(--color-success);
}
.pay-status.pay-pending {
  background: var(--color-surface-subtle);
  color: var(--color-text-secondary);
}
.pay-paid-cell small {
  color: var(--fg-mute);
  font-size: 10px;
  margin-left: 4px;
}
.pay-table tr.paid td { background: var(--color-surface-canvas); }
.pay-summary {
  margin: 8px 0 4px;
  padding: 8px 12px;
  background: var(--color-surface-subtle);
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg-mute);
  text-align: right;
}
.pay-summary b { color: var(--fg); }

/* ============================================================
   회사 대시보드
   ============================================================ */
.cd-jump {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--color-surface-default);
}
.cd-jump input, .cd-jump select {
  padding: 6px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 4px;
}
.cd-jump input { width: 80px; }

.cd-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.cd-card {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 6px;
}
.cd-card.cd-revenue { border-top: 3px solid var(--color-chart-revenue); }
.cd-card.cd-exp { border-top: 3px solid var(--color-chart-expense); }
.cd-card.cd-net { border-top: 3px solid var(--color-info); }
.cd-card.cd-net.danger { border-top-color: var(--danger); }
.cd-card.cd-unpaid { border-top: 3px solid var(--color-warning); }
.cd-lbl {
  font-size: 12px; color: var(--fg-mute); font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px;
}
.cd-lbl small { color: var(--color-text-disabled); font-weight: 400; font-size: 10px; }
.cd-val {
  font-size: 26px; font-weight: 800; color: var(--fg);
}
.cd-val span { font-size: 14px; font-weight: 500; color: var(--fg-mute); margin-left: 4px; }
.cd-net.danger .cd-val { color: var(--danger); }
.cd-sub {
  font-size: 12px; color: var(--fg-mute);
}
.cd-sub b.up { color: var(--ok); margin-left: 6px; }
.cd-sub b.down { color: var(--danger); margin-left: 6px; }

.cd-section {
  background: var(--color-surface-default);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.cd-section h2 {
  font-size: 17px;
  margin: 0 0 16px;
  display: flex; align-items: baseline; gap: 10px;
}

/* 12개월 트렌드 차트 */
.cd-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
}
.cd-bar-group {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
}
.cd-bars {
  flex: 1;
  width: 100%;
  display: flex; gap: 3px;
  align-items: flex-end;
  justify-content: center;
}
.cd-bar {
  width: 45%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: opacity 0.15s;
}
.cd-bar:hover { opacity: 0.8; }
.cd-bar.rev { background: var(--color-chart-revenue); }
.cd-bar.exp { background: var(--color-chart-expense); }
.cd-bar-label {
  font-size: 11px; color: var(--fg-mute);
  text-align: center; line-height: 1.2;
}
.cd-bar-label small { font-size: 9px; color: var(--color-text-disabled); }
.cd-bar-group.current .cd-bar-label { color: var(--fg); font-weight: 700; }
.cd-bar-group.current .cd-bar-label small { color: var(--fg-mute); }
.cd-chart-legend {
  display: flex; gap: 16px;
  margin-top: 10px; padding: 0 4px;
  font-size: 12px; color: var(--fg-mute);
}
.cd-chart-legend .dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 2px; margin-right: 4px;
  vertical-align: middle;
}
.cd-chart-legend .dot.rev { background: var(--color-chart-revenue); }
.cd-chart-legend .dot.exp { background: var(--color-chart-expense); }

/* 연간 요약 */
.cd-year {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.cd-year > div {
  padding: 14px 18px;
  background: var(--color-surface-canvas);
  border-radius: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.cd-year .lbl { font-size: 11px; color: var(--fg-mute); font-weight: 600; }
.cd-year b { font-size: 18px; font-weight: 800; }
.cd-year-net { background: var(--color-success-subtle) !important; }
.cd-year-net.danger { background: var(--color-danger-subtle) !important; }
.cd-year-net.danger b { color: var(--danger); }

/* 프로젝트 현황 테이블 */
.cd-proj-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cd-proj-table th {
  background: var(--color-surface-subtle);
  padding: 10px;
  text-align: left;
  font-size: 11px;
  color: var(--fg-mute);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.cd-proj-table th.right, .cd-proj-table td.right { text-align: right; }
.cd-proj-table td {
  padding: 10px;
  border-bottom: 1px solid var(--color-surface-subtle);
}
.cd-proj-table a { color: var(--fg); text-decoration: none; font-weight: 600; }
.cd-proj-table a:hover { text-decoration: underline; }
.cd-proj-table td.paid { color: var(--ok); font-weight: 600; }
.cd-proj-table td.unpaid { color: var(--color-warning); font-weight: 600; }
.cd-proj-table .ratio.warn { color: var(--color-warning); font-weight: 700; }
.cd-proj-table .ratio.danger { color: var(--danger); font-weight: 700; }
.cd-proj-table .status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.cd-proj-table .status-진행중 { background: var(--color-info-subtle); color: var(--color-info); }
.cd-proj-table .status-완료 { background: var(--color-success-subtle); color: var(--color-success); }
.cd-proj-table .status-준비 { background: var(--color-surface-subtle); color: var(--color-text-secondary); }

/* 모바일 */
@media (max-width: 900px) {
  .cd-metrics { grid-template-columns: 1fr 1fr; }
  .cd-year { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .cd-metrics { grid-template-columns: 1fr; }
  .cd-year { grid-template-columns: 1fr; }
  .cd-val { font-size: 22px; }
  .cd-chart { height: 140px; gap: 4px; }
  .cd-bar-label { font-size: 10px; }
  .cd-section { padding: 14px 16px; }

  /* 프로젝트 테이블 → 카드 */
  .cd-proj-table, .cd-proj-table tbody, .cd-proj-table tr, .cd-proj-table td { display: block; width: 100%; }
  .cd-proj-table thead { display: none; }
  .cd-proj-table tr {
    background: var(--color-surface-default); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px 14px; margin-bottom: 10px;
  }
  .cd-proj-table td {
    padding: 4px 0; border: none;
    display: flex; justify-content: space-between; align-items: center;
    font-size: 13px;
  }
  .cd-proj-table td::before {
    content: attr(data-label);
    color: var(--fg-mute); font-size: 11px; font-weight: 600;
  }
  .cd-proj-table td.right { text-align: right; }
  .cd-proj-table td:first-child { font-size: 15px; padding-bottom: 8px; border-bottom: 1px solid var(--color-surface-subtle); margin-bottom: 4px; }
  .cd-proj-table td:first-child::before { display: none; }
  .cd-proj-table td:first-child a { flex: 1; }

  /* 계약서 입금 라인 - 세로 스택 */
  .pay-paid-line {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }
  .pay-paid-check { grid-column: 1 / -1; }
  .pay-paid-memo { grid-column: 1 / -1; }
}
