/* Cuadro de mando: tiles, inline SVG charts and the ask panel. Shared components live in demolab.css. */

.kpi .p { font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.kpi .s { line-height: 1.45; }
.kpi .d { font-weight: 700; white-space: nowrap; }
.kpi .d.up { color: var(--signal); }
.kpi .d.down { color: var(--err); }
.defs { font-size: 11px; color: var(--ink-3); margin: 10px 0 20px; max-width: none; }

.cm-charts { display: grid; gap: 20px; align-content: start; }
.panel > .hd .per { font-size: 11px; text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 11px; color: var(--ink-2); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.legend .k-bar { background: var(--ink-2); }
.legend .k-partial { background: var(--ink-2); opacity: 0.35; }
.legend .k-line { width: 16px; height: 2px; vertical-align: 3px; background: var(--gold); }
.legend .k-low { background: var(--warn); }
.legend .k-ok { background: var(--signal); }
.legend .k-target { width: 2px; height: 13px; vertical-align: -2px; background: var(--ink); }

.chart { position: relative; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--paper-3); stroke-width: 1; }
.chart .base { stroke: var(--ink-3); stroke-width: 1; }
.chart .tick { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .name { font-family: var(--font-mono); font-size: 11px; fill: var(--ink); }
.chart .val { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .val.strong { fill: var(--ink); font-weight: 700; }
.chart .colhd { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.12em; fill: var(--ink-3); }
.chart .bar { fill: var(--ink-2); }
.chart .bar.partial { fill-opacity: 0.35; }
.chart .line { fill: none; stroke: var(--gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--gold); stroke: var(--paper); stroke-width: 2; }
.chart .oee-low { fill: var(--warn); }
.chart .oee-ok { fill: var(--signal); }
.chart .track { fill: var(--paper-2); }
.chart .target { stroke: var(--ink); stroke-width: 2; }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:hover, .chart .hit:focus-visible { fill: rgba(10, 10, 10, 0.05); }
.tip { position: absolute; z-index: 6; pointer-events: none; display: none; background: var(--ink); color: var(--paper); font-size: 11px; line-height: 1.5; padding: 7px 10px; white-space: nowrap; }
.tip b { font-weight: 700; }
.note { font-size: 11px; color: var(--ink-3); margin: 10px 0 0; max-width: none; }
details.tview { margin-top: 10px; }
details.tview summary { cursor: pointer; font-size: 11px; color: var(--ink-2); }
details.tview .table { margin-top: 8px; }

/* Ask panel: sticky beside the charts on wide screens */
.ask { position: sticky; top: 66px; align-self: start; display: flex; flex-direction: column; max-height: calc(100vh - 84px); }
.ask .ai-notice { margin: 12px 16px 0; }
.ask .suggest-wrap { padding: 10px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.ask .suggest { gap: 6px; }
.ask .suggest button { font-size: 11.5px; padding: 6px 9px; }
.ask .chatlog { position: relative; max-height: none; flex: 1 1 auto; min-height: 240px; }
.ask .composer input { min-width: 0; }
.msg.answer { max-width: 100%; width: 100%; white-space: normal; }
.msg.answer .prose { white-space: pre-wrap; }
.msg .lbl { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin: 14px 0 5px; }
pre.sql { margin: 0; padding: 10px 12px; background: var(--ink); color: var(--paper); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg .table { background: var(--paper); font-size: 11.5px; }
.msg .table td, .msg .table th { padding: 6px 8px; }
.check { margin-top: 14px; padding: 9px 10px; border: 1px solid var(--line-soft); background: var(--paper); font-size: 12.5px; line-height: 1.5; display: flex; gap: 10px; align-items: flex-start; }
.check .chip { flex: none; margin-top: 2px; }
.msg details.more { margin-top: 10px; font-size: 11.5px; }
.msg details.more summary { cursor: pointer; color: var(--ink-2); }
.msg details.more pre.sql { margin-top: 8px; }
.msg .meta { margin-top: 10px; font-size: 10.5px; color: var(--ink-3); }
.msg.sys.notice { color: var(--warn); }

@media (max-width: 1000px) {
  .ask { position: static; max-height: none; order: -1; }
  .ask .chatlog { max-height: 75vh; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: span 2; }
  .ask .suggest { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .ask .suggest button { flex: none; white-space: nowrap; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 21px; }
  .panel > .hd { flex-wrap: wrap; }
  .ask .chatlog { padding: 12px; }
}
