/* ──────────────────────────────────────────────────────────
   KELVIN (PDL6) — product extension stylesheet
   KELVIN is the laboratorio de inferencia termodinámica and the
   ORIGIN of the lab language. It consumes the base design system
   (styles.css) and layers on the thermal-diagnostic patterns that
   are specific to it: the asset catalogue table, machine-type
   chips, the Deep-Dive hero, the Target/Actual/Gap operational
   grid, the thermal profile chart frame, advisories, the
   diagnostic narrative, confidence meter, the "señales
   insuficientes" broken-state hero, signal maps and defrost
   episode cards.

   Load it ON TOP of the base:
     <link rel="stylesheet" href="styles.css" />
     <link rel="stylesheet" href="styles/kelvin.css" />

   Ported verbatim (de-duplicated against lab.css) from the live
   KELVIN frontend globals.css.
   ────────────────────────────────────────────────────────── */

/* ── Kelvin thermal band accents ───────────────────────────── */
:root {
  --k-demand-cold:  #dbeafe;
  --k-demand-heat:  #fef3c7;
  --k-discrepancy:  #fee2e2;
}

/* ── Asset catalogue table ─────────────────────────────────── */
.catalog-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.catalog-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.catalog-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate-500);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--slate-50);
}
.catalog-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  cursor: pointer;
}
.catalog-table tbody tr:last-child { border-bottom: 0; }
.catalog-table tbody tr:hover { background: var(--slate-50); }
.catalog-table td { padding: 12px 16px; vertical-align: middle; }

/* Tiny DEMO / ERROR flag next to an asset name */
.asset-flag {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  padding: 2px 5px; border-radius: 2px; border: 1px solid;
}
.asset-flag.demo  { color: var(--orange-500); background: var(--orange-50); border-color: #fde4b4; }
.asset-flag.error { color: #d97706; background: #fffbeb; border-color: #fde68a; }

/* Inferred machine-type chip (italic = computed, not confirmed) */
.type-chip {
  display: inline-block;
  font-size: 11px; font-weight: 600; font-style: italic;
  padding: 2px 8px; border-radius: 10px; border: 1px solid;
  white-space: nowrap;
}
.type-chip.hvac  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.type-chip.ir    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.type-chip.pm    { background: #faf5ff; color: #6d28d9; border-color: #ddd6fe; }
.type-chip.cwb   { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.type-chip.wts   { background: #fefce8; color: #854d0e; border-color: #fef08a; }

.instance-chip {
  font-family: var(--font-mono); font-size: 10.5px;
  background: #f1f5f9; color: var(--slate-600);
  border: 1px solid var(--border); border-radius: 3px;
  padding: 2px 6px; white-space: nowrap;
}
.var-count { font-family: var(--font-mono); font-size: 12px; }
.var-count .mapped { color: var(--green-600); font-weight: 500; }
.var-count .total  { color: var(--slate-400); }

/* ── KELVIN status pills (additive states over lab.css base) ── */
.status-pill.operational { color: var(--green-600); background: var(--green-50); border-color: #bbf7d0; }
.status-pill.warning     { color: #d97706; background: #fffbeb; border-color: #fde68a; }
.status-pill.attention   { color: var(--red-600); background: var(--red-50); border-color: #fecaca; }
.status-pill.calculating { color: var(--blue-600); background: var(--blue-100); border-color: #bfdbfe; }
.status-pill.calculating .dot { animation: pdl-blink 1.4s infinite; }

/* Cache freshness dot */
.cache-dot {
  color: var(--green-600); font-size: 10px; font-weight: 500;
  font-family: var(--font-mono);
}

/* ── Deep Dive hero ────────────────────────────────────────── */
.dd-hero {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg,#fff 0%,#fafbfd 100%);
}
.dd-breadcrumb {
  font-size: 12px; color: var(--slate-500);
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.dd-back {
  color: var(--blue-600); cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.dd-back:hover { text-decoration: underline; }
.dd-title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.dd-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dd-title-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dd-eyebrow {
  font-size: 10px; letter-spacing: 0.16em; color: var(--slate-500);
  font-weight: 600; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.dd-title {
  font-size: 24px; font-weight: 600; color: var(--slate-900);
  letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px;
}
.dd-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; color: var(--slate-600); margin-top: 2px; flex-wrap: wrap;
}
.dd-meta .chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 11px; color: var(--slate-700);
  background: var(--slate-100); padding: 2px 7px; border-radius: 3px;
}
/* Inferred chip — computed by Kelvin, not confirmed source data */
.dd-meta .chip.inferred {
  background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; font-style: italic;
}

/* ── Diagnostic summary bar (icon + status row) ────────────── */
.diag-summary-bar { display: flex; align-items: stretch; border-top: 1px solid var(--border); background: #fff; }
.diag-summary-bar > * + * { border-left: 1px solid var(--border); }
.diag-summary-bar .cell {
  padding: 10px 16px; flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0;
}
.diag-summary-bar .cell.compact { flex: 0 0 auto; }
.diag-summary-bar .label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--slate-500); font-weight: 600;
}
.diag-summary-bar .icon-wrap {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--navy-50); color: var(--navy-800);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.diag-summary-bar .icon-wrap.blue { background: #dbeafe; color: #1d4fd7; }

/* ── Operational state grid (Target / Actual / Gap) ────────── */
.op-state-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.op-state-grid .col {
  padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.op-state-grid .col:nth-child(2n) { border-right: 0; }
.op-state-grid .col:nth-last-child(-n+2) { border-bottom: 0; }
.op-state-grid .col.highlight { background: var(--navy-50); }
.col-label {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--slate-500); font-weight: 600;
}
.op-state-grid .col.highlight .col-label { color: var(--navy-800); }
.col-value {
  font-size: 20px; font-weight: 600; color: var(--slate-900);
  letter-spacing: -0.01em; line-height: 1.15;
}
.col-value.small { font-size: 16px; }
.col-sub { font-family: var(--font-mono); font-size: 11px; color: var(--slate-500); }
.col-note { font-size: 12px; color: var(--slate-600); line-height: 1.45; }

/* ── Chart frame ───────────────────────────────────────────── */
.chart-wrap { padding: 16px 20px 20px; }
.chart-toolbar {
  display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px;
}
.chart-toolbar .zoom {
  display: flex; align-items: center; gap: 2px;
  background: var(--slate-100); border-radius: var(--radius); padding: 2px;
}
.chart-toolbar .zoom span {
  font-size: 11px; font-weight: 500; color: var(--slate-600);
  padding: 3px 9px; border-radius: 3px; cursor: pointer;
}
.chart-toolbar .zoom span.active {
  background: #fff; color: var(--navy-800); box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--slate-600); }
.chart-legend .lg .swatch { width: 14px; height: 3px; border-radius: 2px; }
.chart-legend .lg .swatch.dash { background-image: linear-gradient(90deg,currentColor 60%,transparent 0); background-size: 5px 3px; height: 3px; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-band-legend {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px;
  font-size: 10.5px; color: var(--slate-500);
}
.chart-band-legend .b { display: inline-flex; align-items: center; gap: 5px; }
.chart-band-legend .b .sw { width: 10px; height: 10px; border-radius: 2px; }

/* ── Advisory (warnings — honest limitations live here) ────── */
.advisory {
  margin: 4px 20px 12px;
  background: #fffbeb; border: 1px solid #fde68a; border-left: 3px solid var(--orange-500);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; gap: 10px; font-size: 13px; color: #78350f; line-height: 1.5;
}
.advisory .adv-title { font-weight: 600; color: #92400e; margin-bottom: 2px; font-size: 12px; letter-spacing: 0.02em; }
.advisory p { margin: 0; }
.advisory p + p { margin-top: 4px; color: #92651f; }

/* ── Diagnostic narrative + confidence ─────────────────────── */
.diag-narrative { padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.diag-narrative p { margin: 0 0 10px 0; font-size: 13.5px; line-height: 1.65; color: var(--slate-700); max-width: 78ch; }
.diag-narrative p:last-child { margin-bottom: 0; }
.diag-narrative strong { color: var(--slate-900); font-weight: 600; }
.diag-narrative .lead { font-size: 14.5px; color: var(--slate-800); line-height: 1.6; }
.diag-footer { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.confidence { font-size: 11px; color: var(--slate-500); display: flex; align-items: center; gap: 6px; }
.confidence-bar { width: 80px; height: 4px; background: var(--slate-200); border-radius: 2px; overflow: hidden; }
.confidence-bar .fill { height: 100%; background: var(--green-500); }

/* ── Mode bars (segment time-in-mode) ──────────────────────── */
.mode-bars { margin-top: 6px; display: grid; grid-template-columns: 56px 1fr; gap: 8px 10px; align-items: center; }
.mode-bar-label { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--slate-500); font-weight: 600; text-align: right; }
.mode-bar-track { position: relative; height: 8px; background: var(--slate-100); border-radius: 2px; overflow: hidden; }
.mode-seg { position: absolute; top: 0; bottom: 0; }
.mode-seg.cold { background: var(--blue-500); }
.mode-seg.heat { background: var(--orange-500); }
.mode-seg.disc { background: #fca5a5; }

/* ── KELVIN mono tags ──────────────────────────────────────── */
.kelvin-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 3px; white-space: nowrap; border: 1px solid transparent;
}
.kelvin-tag.ready      { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.kelvin-tag.wip        { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.kelvin-tag.broken     { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.kelvin-tag.new        { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.kelvin-tag.hypothesis { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }

/* ── Broken-state hero (señales insuficientes) ─────────────── */
.broken-hero {
  background: repeating-linear-gradient(-45deg, #fee2e2 0 8px, #fecaca 8px 16px);
  border: 1px solid #fca5a5; border-radius: var(--radius-lg); padding: 20px 24px; position: relative;
}
.broken-hero-title {
  margin: 0; font-family: var(--font-mono); font-size: 14px; letter-spacing: 0.06em;
  text-transform: uppercase; color: #991b1b; font-weight: 800;
  display: flex; align-items: center; gap: 8px;
}
.broken-hero-body { margin-top: 8px; font-size: 13px; color: #7f1d1d; line-height: 1.55; }
.broken-trace {
  margin-top: 10px; display: inline-block; font-family: var(--font-mono); font-size: 11px;
  color: #991b1b; background: rgba(255,255,255,0.65); padding: 5px 10px; border-radius: 3px;
  border: 1px dashed #fca5a5;
}

/* ── Signal map ────────────────────────────────────────────── */
.signal-row {
  display: grid; grid-template-columns: 18px 1fr auto; gap: 10px;
  padding: 7px 0; border-bottom: 1px dashed var(--border); align-items: center; font-size: 12.5px;
}
.signal-row:last-child { border-bottom: 0; }
.signal-row .ico { font-family: var(--font-mono); font-size: 12px; text-align: center; }
.signal-row .sig-name { font-family: var(--font-mono); font-size: 11.5px; color: var(--slate-900); }
.signal-row .sig-name.miss   { color: #991b1b; text-decoration: line-through; opacity: 0.75; }
.signal-row .sig-name.partial { color: #92400e; }

/* ── Diff block (declared vs observed) ─────────────────────── */
.diff-block {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.75;
  background: #fafaf9; border-radius: var(--radius); padding: 10px 14px; border: 1px solid var(--border);
}
.diff-block .diff-note { color: var(--slate-500); display: block; }
.diff-block .diff-add  { color: #166534; background: #dcfce7; display: block; padding: 0 4px; }
.diff-block .diff-del  { color: #991b1b; background: #fee2e2; display: block; padding: 0 4px; text-decoration: line-through; }

/* ── Defrost episode cards (IR) ────────────────────────────── */
.defrost-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.defrost-card {
  border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 12px;
  background: #fff; display: flex; flex-direction: column; gap: 2px;
}
.defrost-card .dc-idx { font-family: var(--font-mono); font-size: 9.5px; color: var(--slate-500); letter-spacing: 0.08em; }
.defrost-card .dc-val { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--slate-900); margin-top: 2px; }
.defrost-card .dc-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--slate-600); }

/* "inferido" micro-badge for computed sections */
.inferred-badge {
  font-size: 9px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: #6B9FD4; background: #EEF4FF; border-radius: 4px; padding: 1px 5px; font-style: italic;
}
