/* Components: tables, status squares, KPI strip, 3D scene, board, timeline, empty states.
   Hairline borders only. Status is always a 6px square + text label, never colour alone. */

.view-head { margin-bottom: 20px; }
.view-head h2 { margin-bottom: 4px; }
.view-head p { color: var(--text-muted); max-width: 68ch; margin-bottom: 0; }

.meta { font-size: 13px; color: var(--text-muted); }
.meta-line { display: block; font-size: 13px; color: var(--text-muted); }

/* ---- Status: plain text + 6px square ---- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.status-sq { width: 6px; height: 6px; flex: none; background: var(--c-grey); }
.status.ok .status-sq { background: var(--c-green); }
.status.warn .status-sq { background: var(--c-amber); }
.status.bad .status-sq { background: var(--c-red); }

/* ---- KPI strip: plain numbers + labels, hairline-separated, 12-col grid ---- */
.kpi-strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.kpi { padding: 16px 16px 16px 0; border-left: 1px solid var(--border); }
.kpi:first-child { border-left: 0; }
.kpi + .kpi { padding-left: 16px; }
.kpi-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1;
}
.kpi-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Tables ---- */
.tbl-wrap { overflow-x: auto; margin-bottom: 24px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; font-weight: 500;
  color: var(--text-muted); text-align: left;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:hover td { background: var(--c-hover); }
.tbl tr[data-goto] { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.mono, .tbl th.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.tbl a { text-decoration: none; font-weight: 600; }
.tbl a:hover { text-decoration: underline; }

/* ---- Progress: 2px bar + mono percent ---- */
.progress-inline { display: inline-flex; align-items: center; gap: 8px; }
.progress { width: 80px; height: 2px; background: var(--border); }
.progress > span { display: block; height: 100%; background: var(--text); }
.progress-pct {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---- 3D company scene: canvas + HTML label overlay. Canvas draws flat
   faces only (see scene3d.js); labels are plain HTML so text stays crisp. ---- */
.scene-wrap {
  position: relative; border: 1px solid var(--border);
  background: var(--surface); overflow: hidden; margin-bottom: 8px;
}
.scene-canvas {
  display: block; width: 100%; height: clamp(440px, 64vh, 680px);
  touch-action: none; cursor: grab;
}
.scene-progress {
  position: absolute; left: 12px; bottom: 12px; z-index: 3;
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 10px; min-width: 190px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; color: var(--text-muted);
}
.scene-progress-bar { height: 3px; background: var(--border); margin-top: 6px; }
.scene-progress-bar i {
  display: block; height: 100%; width: 0; background: #da291c;
  transition: width 0.3s ease;
}
.scene-canvas:active { cursor: grabbing; }
.scene-labels { position: absolute; inset: 0; pointer-events: none; }
.scene-label {
  position: absolute; transform: translate(-50%, 0); text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  padding: 4px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; line-height: 1.45; max-width: 210px; overflow-wrap: break-word;
}
.scene-label strong { display: block; font-family: -apple-system, "Helvetica Neue", Helvetica, Inter, Arial, sans-serif; font-size: 13px; }
.scene-label span { color: var(--text-muted); }
.scene-tooltip {
  position: absolute; z-index: 2; background: var(--surface);
  border: 1px solid var(--border); padding: 8px 10px; font-size: 13px; line-height: 1.45;
  max-width: 220px; pointer-events: none;
}
.scene-hint { color: var(--text-muted); font-size: 13px; margin: 10px 0 6px; }
.scene-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 16px; }
.scene-legend-text { font-size: 13px; color: var(--text-muted); }

/* ---- X-ray panel: flat, hairline top rule. Worker rows reuse .tbl ---- */
.xray-panel { border-top: 1px solid var(--border); padding: 12px 0 16px; margin-bottom: 16px; }
.xray-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; justify-content: space-between; }
.xray-head h4 { margin: 0; }
.xray-empty { color: var(--text-muted); font-size: 13px; margin: 8px 0 0; }
.xray-panel .tbl-wrap { margin-bottom: 0; }
.xray-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 12px; font-size: 13px; color: var(--text-muted); }
.xray-controls button.is-active, .scene-legend button.is-active { background: #111111; color: #ffffff; border-color: #111111; }
.xray-plan { overflow-x: auto; }

/* ---- BIM floor plan (SVG): ink linework, flat, no decoration ---- */
.bim-plan { display: block; width: 100%; max-width: 640px; height: auto; background: #ffffff; }
.bim-plan .plan-wall { fill: #ffffff; stroke: #111111; stroke-width: 2.5; }
.bim-plan .plan-room:hover .plan-wall { stroke: #da291c; }
.bim-plan .plan-grid { stroke: #999999; stroke-width: 0.75; stroke-dasharray: 4 3; }
.bim-plan .plan-bubble { fill: #ffffff; stroke: #111111; stroke-width: 1; }
.bim-plan .plan-bubble-text { fill: #111111; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-anchor: middle; }
.bim-plan .plan-dim { stroke: #111111; stroke-width: 0.75; }
.bim-plan .plan-dim-ext { stroke: #666666; stroke-width: 0.5; }
.bim-plan .plan-dim-text { fill: #111111; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-anchor: middle; }
.bim-plan .plan-north circle { fill: #ffffff; stroke: #111111; stroke-width: 1; }
.bim-plan .plan-north path { fill: #111111; }
.bim-plan .plan-north text { fill: #111111; font: bold 11px ui-monospace, SFMono-Regular, Menlo, monospace; text-anchor: middle; }
.bim-plan .plan-window { stroke: #111111; stroke-width: 1; }
.bim-plan .plan-door-gap { stroke: #ffffff; stroke-width: 3; }
.bim-plan .plan-door-arc { fill: none; stroke: #666666; stroke-width: 0.75; }
.bim-plan .plan-door-leaf { stroke: #111111; stroke-width: 1.25; }
.bim-plan .plan-room-name { fill: #111111; font: bold 12px ui-monospace, SFMono-Regular, Menlo, monospace; text-anchor: middle; }
.bim-plan .plan-room-area { fill: #666666; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; text-anchor: middle; }
.bim-plan .plan-desk { fill: none; stroke: #111111; stroke-width: 1; }
.bim-plan .plan-worker { fill: #111111; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.bim-plan .plan-title rect { fill: #ffffff; stroke: #111111; stroke-width: 1.25; }
.bim-plan .plan-title text { fill: #111111; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; }
.bim-plan .plan-title .plan-title-name { font: bold 11px ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- Connect-your-machines panel: honest, never fake buildings ---- */
.connect-panel { border-top: 1px solid var(--border); padding-top: 20px; margin: 24px 0; }
.connect-panel h3 { margin-bottom: 8px; }
.connect-panel > p { color: var(--text-muted); font-size: 14px; }
.connect-list { list-style: none; margin: 0; padding: 0; }
.connect-list li { padding: 12px 0; border-top: 1px solid var(--border); }
.connect-list li:first-child { border-top: 0; }
.connect-list code {
  display: block; margin-top: 6px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12px; overflow-x: auto; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---- Filters ---- */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; align-items: end;
  border-bottom: 1px solid var(--border); padding-bottom: 16px;
}
.filters label { font-size: 13px; font-weight: 600; }
.filters select {
  display: block; margin-top: 4px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); max-width: 220px;
}

/* ---- Board: 5 hairline columns, task rows with a 1px left status tick ---- */
.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--border); align-items: start; }
.board-note { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; }
.col-empty { font-size: 13px; color: var(--text-muted); margin: 0; padding: 6px 12px 12px; }
.board-col { min-width: 0; border-left: 1px solid var(--border); }
.board-col:first-child { border-left: 0; }
.board-col h3 {
  display: flex; align-items: baseline; gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; font-weight: 500; color: var(--text-muted);
  padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--border);
}
.col-count { font-size: 13px; color: var(--text); font-weight: 700; }
.task-card {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  border-left: 2px solid var(--c-grey); background: var(--surface); overflow-wrap: break-word;
}
.task-card:last-child { border-bottom: 0; }
.task-card.todo { border-left-color: var(--c-grey); }
.task-card.in_progress { border-left-color: var(--text); }
.task-card.in_review { border-left-color: var(--c-amber); }
.task-card.done { border-left-color: var(--c-green); }
.task-card.blocked { border-left-color: var(--c-red); }
.task-card .task-title { font-weight: 600; font-size: 14px; overflow-wrap: break-word; }
.task-card .task-meta { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.task-card .move-row { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; }
.task-card .move-row button {
  padding: 4px 6px; font-size: 12px; min-height: 28px;
  background: transparent; border-color: transparent; color: var(--text-muted); font-weight: 500;
}
.task-card .move-row button:hover { color: var(--text); border-color: transparent; }

/* ---- Activity timeline: mono timestamp column + text, hairline left rule ---- */
.event-list { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid var(--border); }
.event-item {
  display: grid; grid-template-columns: 150px 1fr; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--border); overflow-wrap: break-word;
}
.event-item:last-child { border-bottom: 0; }
.event-item .event-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; letter-spacing: 0.04em; color: var(--text-muted);
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.event-item .event-title { font-weight: 600; }
.event-item p { margin: 4px 0 0; }

/* ---- Empty state: plain, left-aligned. One line + concrete next action. ---- */
.empty { padding: 16px 0; border-top: 1px solid var(--border); margin: 8px 0 24px; text-align: left; }
.empty strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }
.empty p { max-width: 60ch; margin: 0 0 12px; font-size: 14px; color: var(--text-muted); }

/* ---- Search results ---- */
.result-list { list-style: none; margin: 0 0 24px; padding: 0; }
.result-list li { padding: 10px 0; border-bottom: 1px solid var(--border); overflow-wrap: break-word; }
.result-list li:last-child { border-bottom: 0; }
.result-list .meta { display: block; }

/* ---- Detail rows ---- */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: break-word; }
.section-head { margin-top: 28px; }

@media (max-width: 1000px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
  .event-item { grid-template-columns: 110px 1fr; }
}
/* 390px phones: scene labels (max 210px, centred on the building) could
   clip at the canvas edges (overflow hidden on .scene-wrap), and the
   legend's 16px gaps wasted a narrow row. Narrower labels + tighter
   legend keep both readable without hiding anything. */
@media (max-width: 480px) {
  .scene-label { max-width: 140px; font-size: 10px; padding: 3px 6px; }
  .scene-label strong { font-size: 12px; }
  .scene-legend { gap: 8px; }
  .scene-tooltip { max-width: 160px; }
}
/* Backend badge: honest connection indicator — text + square, never colour alone. */
.backend-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; padding: 6px 10px; border: 1px solid var(--border); background: var(--surface); }
.backend-badge::before { content: ""; width: 8px; height: 8px; flex: none; background: var(--c-grey); }
.backend-badge.connected::before { background: var(--c-green); }
.backend-badge.disconnected::before, .backend-badge.auth-failed::before { background: var(--c-red); }
.backend-badge.needs-key::before, .backend-badge.checking::before { background: var(--c-amber); }

@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; }
  .board-col { border-left: 0; border-top: 1px solid var(--border); }
  .board-col:first-child { border-top: 0; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); }
  .kpi:first-child { border-top: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .scene-canvas { height: 360px; }
  .filters select { max-width: 100%; }
  .event-item { grid-template-columns: 1fr; gap: 4px; }
}
