/* =====================================================================
   BuildTrack — app.css
   โครง shell + คอมโพเนนต์เฉพาะระบบ (โหลดหลัง bootstrap-reskin.css)
   ---------------------------------------------------------------------
   กฎ layout ที่ห้ามผิด:
     - sidebar / topbar = position: fixed
     - .app-content ใช้ margin-left + padding-top + box-sizing: border-box
     - ห้ามใส่ display:flex ที่ wrapper และห้าม width:100% ที่ .app-content
   ===================================================================== */

/* ---------------------------------------------------------------------
   1) APP SHELL
   --------------------------------------------------------------------- */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--bt-sidebar-w);
  height: 100vh;
  background: var(--bt-navy);
  color: var(--bt-ink-invert);
  z-index: 1040;
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: transform .22s ease;
}

.app-topbar {
  position: fixed;
  top: 0;
  left: var(--bt-sidebar-w);
  right: 0;
  height: var(--bt-topbar-h);
  background: var(--bt-surface);
  border-bottom: 1px solid var(--bt-line);
  z-index: 1030;
  padding: 0 1.25rem;
}

.app-content {
  margin-left: var(--bt-sidebar-w);
  padding-top: calc(var(--bt-topbar-h) + 1.25rem);
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  padding-bottom: 2.5rem;
  box-sizing: border-box;
  min-height: 100vh;
}

/* ---------------------------------------------------------------------
   2) SIDEBAR
   --------------------------------------------------------------------- */
.sidebar-brand {
  display: block;
  padding: 1.15rem 1.15rem 1rem;
  border-bottom: 1px solid var(--bt-navy-line);
  text-decoration: none;
  color: inherit;
}
.sidebar-brand .brand-name {
  font-family: var(--bt-font-display);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: -0.015em;
  color: #fff;
  line-height: 1.1;
}
.sidebar-brand .brand-sub {
  font-size: 0.7rem;
  color: oklch(0.72 0.02 258);
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.sidebar-brand .brand-mark {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bt-accent);
  color: var(--bt-navy);
  font-family: var(--bt-font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  line-height: 26px;
  margin-right: 0.5rem;
  vertical-align: -5px;
}

.sidebar-section {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: oklch(0.62 0.02 258);
  padding: 1rem 1.15rem 0.35rem;
}

.sidebar-nav { list-style: none; margin: 0; padding: 0.35rem 0.6rem 1.5rem; }

.sidebar-nav a {
  display: block;
  position: relative;
  padding: 0.55rem 0.7rem;
  margin-bottom: 2px;
  border-radius: var(--bt-radius-sm);
  color: oklch(0.85 0.012 258);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: background-color .14s ease, color .14s ease;
}
.sidebar-nav a i { width: 20px; margin-right: 0.5rem; font-size: 1rem; vertical-align: -1px; }
.sidebar-nav a:hover { background: var(--bt-navy-2); color: #fff; }

.sidebar-nav a.active {
  background: var(--bt-primary);
  color: #fff;
  font-weight: 500;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--bt-accent);
}

.sidebar-nav a .phase-tag {
  float: right;
  font-family: var(--bt-font-mono);
  font-size: 0.66rem;
  color: oklch(0.60 0.02 258);
  border: 1px solid var(--bt-navy-line);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 1.5;
  margin-top: 2px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.245 0.022 255 / 0.45);
  z-index: 1035;
  display: none;
}
.sidebar-backdrop.show { display: block; }

/* ---------------------------------------------------------------------
   3) TOPBAR
   --------------------------------------------------------------------- */
.topbar-row {
  height: var(--bt-topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-title {
  font-family: var(--bt-font-display);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0;
}
.topbar-spacer { margin-left: auto; }

.topbar-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius-sm);
  background: var(--bt-surface);
  color: var(--bt-ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-btn:hover { background: var(--bt-surface-alt); color: var(--bt-ink); }
.topbar-btn .dot {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--bt-bad);
  color: #fff;
  font-size: 0.63rem;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  border: 2px solid var(--bt-surface);
  z-index: 2;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bt-primary-soft);
  color: var(--bt-primary-ink);
  font-weight: 600;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  flex: none;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }

.menu-toggle { display: none; }

/* ---------------------------------------------------------------------
   4) PAGE HEADER / EMPTY STATE
   --------------------------------------------------------------------- */
.page-head { margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.42rem; margin: 0 0 0.15rem; }
.page-head .lead-sub { color: var(--bt-ink-muted); font-size: 0.875rem; margin: 0; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bt-ink-muted);
}
.empty-state i { font-size: 2.4rem; color: var(--bt-line-strong); display: block; margin-bottom: 0.6rem; }
.empty-state h3 { font-size: 1.05rem; color: var(--bt-ink-soft); margin-bottom: 0.3rem; }

/* ---------------------------------------------------------------------
   5) KPI CARD
   --------------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.kpi {
  background: var(--bt-surface);
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius);
  padding: 0.95rem 1.05rem;
  box-shadow: var(--bt-shadow-sm);
}
.kpi .kpi-label {
  font-size: 0.8125rem;
  color: var(--bt-ink-soft);
  margin-bottom: 0.35rem;
  display: block;
}
.kpi .kpi-value {
  font-family: var(--bt-font-display);
  font-weight: 700;
  font-size: 1.95rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .kpi-unit { font-size: 0.82rem; font-weight: 500; color: var(--bt-ink-muted); margin-left: 0.3rem; }
.kpi .kpi-foot { font-size: 0.78rem; color: var(--bt-ink-muted); margin-top: 0.3rem; }

.kpi-ok   .kpi-value { color: var(--bt-ok-ink); }
.kpi-warn .kpi-value { color: var(--bt-warn-ink); }
.kpi-bad  .kpi-value { color: var(--bt-bad-ink); }
.kpi-info .kpi-value { color: var(--bt-primary-ink); }

/* ---------------------------------------------------------------------
   6) SIGNATURE — S-CURVE STRIP
   แถบเทียบแผน (เส้นประ) กับจริง (ทึบ) ฝังในแถวตาราง/การ์ดโครงการ
   --------------------------------------------------------------------- */
.scurve-strip {
  position: relative;
  width: 108px;
  height: 26px;
  display: inline-block;
  vertical-align: middle;
  background:
    repeating-linear-gradient(to right,
      var(--bt-line) 0 1px, transparent 1px 12px);
  border-bottom: 1px solid var(--bt-line-strong);
}
.scurve-strip svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scurve-plan {
  fill: none;
  stroke: var(--bt-ink-muted);
  stroke-width: 1.4;
  stroke-dasharray: 3 3;
}
.scurve-actual { fill: none; stroke-width: 2; stroke-linecap: round; }
.scurve-actual.is-ok   { stroke: var(--bt-ok); }
.scurve-actual.is-warn { stroke: var(--bt-warn); }
.scurve-actual.is-bad  { stroke: var(--bt-bad); }

.scurve-legend {
  font-size: 0.75rem;
  color: var(--bt-ink-muted);
}
.scurve-legend .k-plan,
.scurve-legend .k-actual {
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 2px solid var(--bt-ink-muted);
  vertical-align: 4px;
  margin-right: 4px;
}
.scurve-legend .k-plan { border-top-style: dashed; }
.scurve-legend .k-actual { border-top-color: var(--bt-ok); }

/* พื้นหลังกริดกระดาษเขียนแบบ ใช้เฉพาะหน้า Schedule/WBS */
.blueprint-grid {
  background-color: var(--bt-surface);
  background-image:
    linear-gradient(to right, oklch(0.905 0.008 250 / 0.55) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(0.905 0.008 250 / 0.55) 1px, transparent 1px);
  background-size: 8px 8px;
}

/* ---------------------------------------------------------------------
   7) UTILITIES
   --------------------------------------------------------------------- */
.card-tight .card-body { padding: 0.9rem 1rem; }
.table-card { overflow: hidden; }
.table-card .table { border-collapse: separate; }

/* Bootstrap dropdowns inside responsive tables must be able to escape the
   card/table clipping area while they are open. Keep the clipping for the
   rounded card corners when no menu is active. */
.table-card:has(.dropdown-menu.show),
.table-card .table-responsive:has(.dropdown-menu.show) {
  overflow: visible;
}
.table-card:has(.dropdown-menu.show) {
  position: relative;
  z-index: 2;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--bt-line);
  border-radius: 999px;
  background: var(--bt-surface);
  font-size: 0.8125rem;
  color: var(--bt-ink-soft);
  text-decoration: none;
}
.chip:hover { border-color: var(--bt-line-strong); color: var(--bt-ink); }
.chip.active { background: var(--bt-primary-soft); border-color: var(--bt-primary); color: var(--bt-primary-ink); font-weight: 500; }
.chip .n { font-family: var(--bt-font-mono); font-size: 0.75rem; }

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1090;
  display: grid;
  gap: 0.5rem;
}

.divider-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bt-ink-muted);
  border-bottom: 1px solid var(--bt-line);
  padding-bottom: 0.35rem;
  margin: 1.35rem 0 0.85rem;
}

/* ---------------------------------------------------------------------
   8) RESPONSIVE
   --------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); box-shadow: var(--bt-shadow-lg); }

  .app-topbar { left: 0; padding: 0 0.9rem; }

  .app-content {
    margin-left: 0;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .menu-toggle { display: inline-flex; }
}

@media (max-width: 575.98px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 0.7rem; }
  .kpi .kpi-value { font-size: 1.7rem; }
  .page-head h1 { font-size: 1.25rem; }
  .topbar-title { display: none; }
}

@media print {
  .app-sidebar, .app-topbar, .toolbar, .btn { display: none !important; }
  .app-content { margin-left: 0; padding: 0; }
}

/* ---------------------------------------------------------------------
   9) SEARCH SELECT (dropdown ค้นหาได้ แสดงรายการทันทีที่คลิก)
   --------------------------------------------------------------------- */
.search-select { position: relative; }

.search-select .ss-toggle {
  width: 100%;
  text-align: left;
  background-color: var(--bt-surface);
  cursor: pointer;
}
.search-select .ss-toggle .ss-placeholder { color: var(--bt-ink-muted); }

.search-select .ss-panel {
  display: none;
  position: absolute;
  z-index: 1060;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bt-surface);
  border: 1px solid var(--bt-line-strong);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow);
  padding: 0.4rem;
}
.search-select.open .ss-panel { display: block; }

.search-select .ss-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}
.search-select .ss-list li {
  padding: 0.45rem 0.6rem;
  border-radius: var(--bt-radius-sm);
  cursor: pointer;
  line-height: 1.35;
}
.search-select .ss-list li:hover,
.search-select .ss-list li.active { background: var(--bt-primary-soft); }
.search-select .ss-list .ss-name { font-size: 0.9rem; }
.search-select .ss-list .ss-meta { font-size: 0.78rem; color: var(--bt-ink-muted); }
.search-select .ss-empty { padding: 0.85rem; text-align: center; color: var(--bt-ink-muted); font-size: 0.85rem; }

/* ---------------------------------------------------------------------
   10) PROJECT DETAIL
   --------------------------------------------------------------------- */
.project-hero {
  background: var(--bt-surface);
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--bt-shadow-sm);
  margin-bottom: 1rem;
}
.project-hero .code { font-family: var(--bt-font-mono); font-size: 0.82rem; color: var(--bt-ink-muted); }
.project-hero h1 { font-size: 1.45rem; margin: 0.15rem 0 0.35rem; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--bt-line);
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius);
  overflow: hidden;
  margin-top: 1rem;
}
.stat-row > div { background: var(--bt-surface); padding: 0.8rem 0.95rem; }
.stat-row .stat-label { font-size: 0.78rem; color: var(--bt-ink-muted); display: block; }
.stat-row .stat-value {
  font-family: var(--bt-font-display);
  font-weight: 600;
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
}

.doc-row .doc-icon {
  width: 34px; height: 34px;
  border-radius: var(--bt-radius-sm);
  background: var(--bt-primary-soft);
  color: var(--bt-primary-ink);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}

@media (max-width: 767.98px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------------
   11) WBS TREE TABLE
   --------------------------------------------------------------------- */
.wbs-table td { padding: 0.5rem 0.7rem; }
.wbs-table .wbs-name { display: flex; align-items: center; gap: 0.4rem; }
.wbs-table .wbs-indent { display: inline-block; }
.wbs-table .wbs-code {
  font-family: var(--bt-font-mono);
  font-size: 0.78rem;
  color: var(--bt-ink-muted);
  min-width: 46px;
}
.wbs-table tr.is-parent { background: var(--bt-surface-alt); }
.wbs-table tr.is-parent .wbs-title { font-weight: 600; }
.wbs-table tr.is-milestone .wbs-title::after {
  content: '◆';
  color: var(--bt-accent);
  margin-left: 0.35rem;
  font-size: 0.7rem;
}
.wbs-table .num-cell { font-family: var(--bt-font-mono); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.wbs-progress {
  position: relative;
  height: 18px;
  min-width: 84px;
  background: var(--bt-bg-sunken);
  border-radius: 4px;
  overflow: hidden;
}
.wbs-progress > span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
}
.wbs-progress.is-ok   > span { background: var(--bt-ok); }
.wbs-progress.is-warn > span { background: var(--bt-warn); }
.wbs-progress.is-bad  > span { background: var(--bt-bad); }
.wbs-progress b {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
  font-family: var(--bt-font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 18px;
  color: var(--bt-ink);
  mix-blend-mode: luminosity;
}

/* ---------------------------------------------------------------------
   12) GANTT
   --------------------------------------------------------------------- */
.gantt { border: 1px solid var(--bt-line); border-radius: var(--bt-radius); overflow: hidden; }

.gantt-head, .gantt-row { display: flex; align-items: stretch; }

.gantt-name {
  flex: 0 0 300px;
  min-width: 300px;
  padding: 0.4rem 0.7rem;
  border-right: 1px solid var(--bt-line);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.gantt-track {
  position: relative;
  flex: 1 1 auto;
  min-height: 30px;
  background-image: linear-gradient(to right, var(--bt-line) 1px, transparent 1px);
  background-size: 8.334% 100%;
}

.gantt-head {
  background: var(--bt-surface-alt);
  border-bottom: 1px solid var(--bt-line);
  font-size: 0.78rem;
  color: var(--bt-ink-muted);
}
.gantt-head .gantt-track { display: flex; min-height: 30px; }
.gantt-head .gantt-month {
  border-right: 1px solid var(--bt-line);
  padding: 0.4rem 0.4rem;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.gantt-row { border-bottom: 1px solid var(--bt-line); background: var(--bt-surface); }
.gantt-row:last-child { border-bottom: 0; }
.gantt-row:hover { background: var(--bt-primary-soft); }
.gantt-row.is-parent { background: var(--bt-surface-alt); font-weight: 600; }

.gantt-bar {
  position: absolute;
  top: 7px;
  height: 16px;
  border-radius: 4px;
  background: var(--bt-primary-soft);
  border: 1px solid var(--bt-primary);
  overflow: hidden;
}
.gantt-bar > i {
  display: block;
  height: 100%;
  background: var(--bt-primary);
}
.gantt-bar.is-ok   > i { background: var(--bt-ok); }
.gantt-bar.is-warn > i { background: var(--bt-warn); }
.gantt-bar.is-bad  > i { background: var(--bt-bad); }
.gantt-bar.is-parent { background: var(--bt-ink-muted); border-color: var(--bt-ink-soft); height: 9px; top: 11px; border-radius: 2px; }

.gantt-milestone {
  position: absolute;
  top: 8px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: var(--bt-accent);
  border: 1px solid var(--bt-accent-ink);
  transform: rotate(45deg);
}

.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--bt-bad);
  z-index: 2;
  pointer-events: none;
}
.gantt-today::after {
  content: 'วันนี้';
  position: absolute;
  top: -1px;
  left: 3px;
  font-size: 0.65rem;
  color: var(--bt-bad-ink);
  font-family: var(--bt-font-mono);
}

.gantt-scroll { overflow-x: auto; }
.gantt-scroll .gantt { min-width: 900px; }

/* ---------------------------------------------------------------------
   13) S-CURVE CHART
   --------------------------------------------------------------------- */
.scurve-chart { width: 100%; height: 300px; }
.scurve-chart svg { width: 100%; height: 100%; overflow: visible; }
.scurve-chart .axis        { stroke: var(--bt-line-strong); stroke-width: 1; }
.scurve-chart .grid        { stroke: var(--bt-line); stroke-width: 1; stroke-dasharray: 2 4; }
.scurve-chart .tick-text   { fill: var(--bt-ink-muted); font-size: 10px; font-family: var(--bt-font-mono); }
.scurve-chart .line-plan   { fill: none; stroke: var(--bt-ink-muted); stroke-width: 2; stroke-dasharray: 5 4; }
.scurve-chart .line-actual { fill: none; stroke: var(--bt-ok); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.scurve-chart .line-actual.is-warn { stroke: var(--bt-warn); }
.scurve-chart .line-actual.is-bad  { stroke: var(--bt-bad); }
.scurve-chart .dot-actual  { fill: var(--bt-surface); stroke-width: 2; }
.scurve-chart .today-line  { stroke: var(--bt-bad); stroke-width: 1.5; stroke-dasharray: 3 3; }

/* ---------------------------------------------------------------------
   14) DAILY REPORT — ปฏิทิน / ฟอร์มมือถือ / รูป
   --------------------------------------------------------------------- */
.dr-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.dr-calendar .dow {
  text-align: center;
  font-size: 0.72rem;
  color: var(--bt-ink-muted);
  padding-bottom: 0.2rem;
}
.dr-day {
  position: relative;
  min-height: 62px;
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius-sm);
  padding: 0.3rem 0.4rem;
  background: var(--bt-surface);
  text-decoration: none;
  color: inherit;
  display: block;
}
.dr-day .d { font-family: var(--bt-font-mono); font-size: 0.78rem; color: var(--bt-ink-muted); }
.dr-day .mark { display: block; margin-top: 0.35rem; font-size: 0.7rem; line-height: 1.3; }
.dr-day.is-empty { border: 0; background: transparent; }
.dr-day.is-future { background: var(--bt-bg-sunken); opacity: 0.55; }
.dr-day.has-report { border-color: var(--bt-ok); background: var(--bt-ok-soft); }
.dr-day.has-report.is-draft { border-color: var(--bt-line-strong); background: var(--bt-surface-alt); }
.dr-day.has-report.is-submitted { border-color: var(--bt-info); background: var(--bt-info-soft); }
.dr-day.has-report.is-rejected { border-color: var(--bt-bad); background: var(--bt-bad-soft); }
.dr-day.is-missing { border-style: dashed; border-color: var(--bt-warn); background: var(--bt-warn-soft); }
.dr-day.is-today { box-shadow: 0 0 0 2px var(--bt-primary); }
.dr-day:hover { border-color: var(--bt-primary); }

.repeat-row {
  display: grid;
  gap: 0.5rem;
  align-items: start;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--bt-line);
}
.repeat-row:last-of-type { border-bottom: 0; }
.repeat-row .row-drop { padding-top: 0.15rem; }
.repeat-manpower { grid-template-columns: 1fr 90px 1fr 40px; }
.repeat-equipment { grid-template-columns: 1fr 70px 90px 90px 40px; }
.repeat-material { grid-template-columns: 1fr 80px 90px 90px 40px; }
.repeat-work { grid-template-columns: 210px 1fr 90px 120px 40px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.6rem;
}
.photo-card {
  position: relative;
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius-sm);
  overflow: hidden;
  background: var(--bt-surface);
}
.photo-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-card .cap {
  padding: 0.3rem 0.45rem;
  font-size: 0.75rem;
  color: var(--bt-ink-soft);
  line-height: 1.3;
}
.photo-card .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: oklch(0.245 0.022 255 / 0.6);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1;
}

.weather-pick { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.weather-pick input { position: absolute; opacity: 0; pointer-events: none; }
.weather-pick label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--bt-line-strong);
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--bt-surface);
}
.weather-pick input:checked + label {
  background: var(--bt-primary-soft);
  border-color: var(--bt-primary);
  color: var(--bt-primary-ink);
  font-weight: 500;
}
.weather-pick input:focus-visible + label { outline: 2px solid var(--bt-primary); outline-offset: 2px; }

.form-section { margin-bottom: 1rem; }
.form-section > .card-header { display: flex; align-items: center; justify-content: space-between; }

@media (max-width: 767.98px) {
  .repeat-manpower  { grid-template-columns: 1fr 70px 40px; }
  .repeat-equipment { grid-template-columns: 1fr 70px 40px; }
  .repeat-material  { grid-template-columns: 1fr 80px 40px; }
  .repeat-work      { grid-template-columns: 1fr 40px; }
  .repeat-row .hide-sm { display: none; }
  .dr-day { min-height: 50px; }
}

/* ---------------------------------------------------------------------
   15) APPROVAL TIMELINE + INBOX
   --------------------------------------------------------------------- */
.approval-timeline { list-style: none; margin: 0; padding: 0; }
.approval-timeline li {
  position: relative;
  display: flex;
  gap: 0.7rem;
  padding-bottom: 0.9rem;
}
.approval-timeline li:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: 0;
  width: 2px;
  background: var(--bt-line);
}
.approval-timeline .at-dot {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  background: var(--bt-bg-sunken);
  color: var(--bt-ink-muted);
  border: 2px solid var(--bt-surface);
  box-shadow: 0 0 0 1px var(--bt-line);
}
.approval-timeline li.is-ok   .at-dot { background: var(--bt-ok-soft);   color: var(--bt-ok-ink);   box-shadow: 0 0 0 1px var(--bt-ok); }
.approval-timeline li.is-bad  .at-dot { background: var(--bt-bad-soft);  color: var(--bt-bad-ink);  box-shadow: 0 0 0 1px var(--bt-bad); }
.approval-timeline li.is-info .at-dot { background: var(--bt-info-soft); color: var(--bt-primary-ink); box-shadow: 0 0 0 1px var(--bt-info); }
.approval-timeline li.is-current .at-dot { animation: at-pulse 1.8s ease-in-out infinite; }

@keyframes at-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--bt-info); }
  50%      { box-shadow: 0 0 0 4px var(--bt-info-soft); }
}

.approval-timeline .at-title { font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.approval-timeline .at-title .mono { color: var(--bt-ink-muted); font-size: 0.75rem; font-weight: 400; }
.approval-timeline .at-meta { font-size: 0.8rem; color: var(--bt-ink-muted); }
.approval-timeline .at-comment {
  margin-top: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: var(--bt-surface-alt);
  border-left: 2px solid var(--bt-line-strong);
  border-radius: 0 var(--bt-radius-sm) var(--bt-radius-sm) 0;
  font-size: 0.82rem;
}

.inbox-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 0; border-bottom: 1px solid var(--bt-line); }
.inbox-row:last-child { border-bottom: 0; }
.inbox-row .ib-main { flex: 1 1 auto; min-width: 0; }
.inbox-row .ib-title { font-size: 0.92rem; font-weight: 500; }
.inbox-row .ib-meta { font-size: 0.8rem; color: var(--bt-ink-muted); }
.inbox-row .ib-delta {
  font-family: var(--bt-font-mono);
  font-size: 0.82rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bt-ok-soft);
  color: var(--bt-ok-ink);
  white-space: nowrap;
}

.step-chain { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.step-chain .sc-step {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--bt-line-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  background: var(--bt-surface);
}
.step-chain .sc-step .n {
  font-family: var(--bt-font-mono);
  font-size: 0.72rem;
  color: var(--bt-ink-muted);
}
.step-chain .sc-arrow { color: var(--bt-ink-muted); }

/* ---------------------------------------------------------------------
   16) PHOTO GALLERY + LIGHTBOX
   --------------------------------------------------------------------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.75rem;
}
.gallery-item {
  position: relative;
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius);
  overflow: hidden;
  background: var(--bt-surface);
  cursor: zoom-in;
}
.gallery-item img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.gallery-item .gi-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: oklch(1 0 0 / 0.92);
  color: var(--bt-ink-soft);
}
.gallery-item .gi-tag.t-before { color: var(--bt-primary-ink); }
.gallery-item .gi-tag.t-after  { color: var(--bt-ok-ink); }
.gallery-item .gi-tag.t-issue  { color: var(--bt-bad-ink); }
.gallery-item .gi-tag.t-safety { color: var(--bt-accent-ink); }
.gallery-item .gi-body { padding: 0.4rem 0.55rem; }
.gallery-item .gi-cap  { font-size: 0.78rem; line-height: 1.35; }
.gallery-item .gi-meta { font-size: 0.7rem; color: var(--bt-ink-muted); font-family: var(--bt-font-mono); }
.gallery-item:hover { border-color: var(--bt-primary); }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1080;
  background: oklch(0.18 0.02 255 / 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 78vh; border-radius: var(--bt-radius); }
.lightbox .lb-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.9rem 1.2rem;
  color: oklch(0.95 0.01 255);
  font-size: 0.85rem;
  background: linear-gradient(to top, oklch(0.18 0.02 255 / 0.9), transparent);
}
.lightbox .lb-close,
.lightbox .lb-prev,
.lightbox .lb-next {
  position: absolute;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: oklch(1 0 0 / 0.14);
  color: #fff;
  font-size: 1.1rem;
}
.lightbox .lb-close { top: 1rem; right: 1rem; }
.lightbox .lb-prev  { left: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next  { right: 1rem; top: 50%; transform: translateY(-50%); }
.lightbox button:hover { background: oklch(1 0 0 / 0.26); }

.compare-col h3 {
  font-size: 0.85rem;
  color: var(--bt-ink-muted);
  text-transform: none;
  margin-bottom: 0.5rem;
}
.compare-col { border-right: 1px solid var(--bt-line); padding-right: 0.9rem; }
.compare-col:last-child { border-right: 0; padding-right: 0; }

/* ---------------------------------------------------------------------
   17) ISSUE KANBAN
   --------------------------------------------------------------------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 0.75rem;
  align-items: start;
}
.kanban-col {
  background: var(--bt-bg-sunken);
  border: 1px solid var(--bt-line);
  border-radius: var(--bt-radius);
  min-height: 140px;
}
.kanban-col.drag-over { border-color: var(--bt-primary); background: var(--bt-primary-soft); }
.kanban-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--bt-line);
  font-size: 0.85rem;
  font-weight: 600;
}
.kanban-head .n { font-family: var(--bt-font-mono); font-weight: 400; color: var(--bt-ink-muted); }
.kanban-head::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.45rem;
  flex: none;
}
.kanban-col[data-status="open"] .kanban-head::before        { background: var(--bt-bad); }
.kanban-col[data-status="in_progress"] .kanban-head::before { background: var(--bt-info); }
.kanban-col[data-status="resolved"] .kanban-head::before    { background: var(--bt-ok); }
.kanban-col[data-status="closed"] .kanban-head::before      { background: var(--bt-ink-muted); }

.kanban-body { padding: 0.55rem; display: grid; gap: 0.5rem; }

.issue-card {
  background: var(--bt-surface);
  border: 1px solid var(--bt-line);
  border-left: 3px solid var(--bt-line-strong);
  border-radius: var(--bt-radius-sm);
  padding: 0.6rem 0.7rem;
  cursor: grab;
  text-decoration: none;
  color: inherit;
  display: block;
  box-shadow: var(--bt-shadow-sm);
}
.issue-card:active { cursor: grabbing; }
.issue-card.dragging { opacity: 0.45; }
.issue-card.sev-critical { border-left-color: var(--bt-bad); }
.issue-card.sev-high     { border-left-color: var(--bt-warn); }
.issue-card.sev-medium   { border-left-color: var(--bt-info); }
.issue-card.sev-low      { border-left-color: var(--bt-line-strong); }
.issue-card:hover { border-color: var(--bt-primary); }

.issue-card .ic-no { font-family: var(--bt-font-mono); font-size: 0.7rem; color: var(--bt-ink-muted); }
.issue-card .ic-title { font-size: 0.88rem; font-weight: 500; line-height: 1.4; margin: 0.15rem 0 0.35rem; }
.issue-card .ic-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; font-size: 0.72rem; color: var(--bt-ink-muted); }
.issue-card .ic-impact { color: var(--bt-bad-ink); font-family: var(--bt-font-mono); }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { display: flex; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--bt-line); }
.comment-list li:last-child { border-bottom: 0; }
.comment-list .cm-body { font-size: 0.87rem; }
.comment-list .cm-meta { font-size: 0.75rem; color: var(--bt-ink-muted); }
.comment-list li.is-system .cm-body { color: var(--bt-ink-muted); font-size: 0.8rem; font-style: normal; }

@media (max-width: 991.98px) {
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare-col { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--bt-line); padding-bottom: 0.9rem; margin-bottom: 0.9rem; }
}
@media (max-width: 575.98px) {
  .kanban { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------
   18) WBS DEPENDENCY
   --------------------------------------------------------------------- */
.dep-badge {
  border: 1px solid var(--bt-line-strong);
  background: var(--bt-surface);
  color: var(--bt-ink-muted);
  border-radius: 999px;
  font-family: var(--bt-font-mono);
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  margin-left: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.dep-badge:hover { border-color: var(--bt-primary); color: var(--bt-primary-ink); }

.dep-list { list-style: none; margin: 0; padding: 0; }
.dep-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--bt-line);
}
.dep-list li:last-child { border-bottom: 0; }
.dep-list .dep-type {
  font-family: var(--bt-font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: var(--bt-radius-sm);
  background: var(--bt-primary-soft);
  color: var(--bt-primary-ink);
  flex: none;
}
.dep-list .dep-main { flex: 1 1 auto; min-width: 0; }
.dep-list .dep-name { font-size: 0.88rem; }
.dep-list .dep-meta { font-size: 0.75rem; color: var(--bt-ink-muted); }

.dep-hint {
  background: var(--bt-surface-alt);
  border-left: 3px solid var(--bt-primary);
  border-radius: 0 var(--bt-radius-sm) var(--bt-radius-sm) 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------------
   19) OFFLINE / PWA
   --------------------------------------------------------------------- */
.offline-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--bt-warn-soft);
  color: var(--bt-warn-ink);
  border: 1px solid var(--bt-warn);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

body.is-offline .app-topbar { border-bottom-color: var(--bt-warn); }

.queue-card {
  border: 1px solid var(--bt-line);
  border-left: 3px solid var(--bt-warn);
  border-radius: var(--bt-radius);
  background: var(--bt-surface);
  padding: 0.8rem 0.95rem;
  margin-bottom: 0.6rem;
}
.queue-card .qc-title { font-size: 0.92rem; font-weight: 500; }
.queue-card .qc-meta { font-size: 0.78rem; color: var(--bt-ink-muted); }
.queue-card .qc-error { font-size: 0.78rem; color: var(--bt-bad-ink); margin-top: 0.3rem; }
.queue-card .qc-files { font-size: 0.75rem; color: var(--bt-ink-muted); font-family: var(--bt-font-mono); }
