/* Electro Ins — estilos de la herramienta (se suma a /css/site.css). */
:root {
  --ink: #1a1a2e;
  --ink-soft: #16213e;
  --accent: #dc2626;
  --accent-dark: #b91c1c;
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --input-bg: #ffffff;
  --input-line: #d1d5db;
  --calc-bg: #f3f4f6;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --warn: #92400e;
  --warn-bg: #fef3c7;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(26, 26, 46, 0.05), 0 6px 18px rgba(26, 26, 46, 0.05);
}

* { box-sizing: border-box; }

body.tool { background: var(--bg); }
.page { font-size: 14px; line-height: 1.45; }

h1, h2, h3, p { margin: 0; }

/* ---------- encabezado de la herramienta ---------- */
.tool-hero { background: radial-gradient(700px 260px at 90% -20%, rgba(255,77,61,.3), transparent 65%), linear-gradient(135deg, var(--ink), var(--ink-soft)); color: #fff; }
.tool-hero__inner { max-width: 1360px; margin: 0 auto; padding: 28px 24px 30px; }
.tool-hero h1 { font-size: clamp(24px, 3.4vw, 34px); font-weight: 800; letter-spacing: -.5px; margin-bottom: 6px; }
.tool-hero p { color: rgba(255,255,255,.8); font-size: 15px; max-width: 760px; }
.tool-hero .breadcrumb { margin-bottom: 12px; }
body.tool[data-tab="simple"] .tool-hero__inner { max-width: 868px; }
body.tool[data-tab="simple"] .tool-hero__sub--analysis,
body.tool[data-tab="analysis"] .tool-hero__sub--simple { display: none; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; }
.toolbar__note { color: var(--text); font-size: 13.5px; max-width: 820px; }
.toolbar__note strong { color: var(--ink); }
.toolbar__actions { display: flex; gap: 10px; }

/* ---------- layout ---------- */
.page { max-width: 1360px; margin: 0 auto; padding: 22px 24px 56px; display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.page > *, .split > * { min-width: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card__head { display: grid; gap: 4px; margin-bottom: 14px; }
.card__head h2 { font-size: 16px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.card__hint { color: var(--muted); font-size: 13px; max-width: 110ch; }
.card__foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.card h3 { font-size: 14px; color: var(--ink); margin: 18px 0 8px; }
.card h3:first-of-type { margin-top: 0; }
.card h3 small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 600; flex: none;
}
.legend, .note { color: var(--muted); font-size: 12.5px; }
.legend { margin-top: 10px; }
.split { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  .page { padding: 14px 12px 40px; }
  .card { padding: 14px 12px; }
}

.page-foot { color: var(--muted); font-size: 12.5px; display: grid; gap: 4px; padding: 0 4px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; border-top: 3px solid var(--ink-soft); min-height: 92px;
}
.kpi__label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.kpi__value { font-size: 22px; font-weight: 650; color: var(--ink); margin: 2px 0; font-variant-numeric: tabular-nums; }
.kpi__sub { font-size: 12px; color: var(--muted); }
.kpi[data-tone="ok"] { border-top-color: var(--ok); }
.kpi[data-tone="ok"] .kpi__value { color: var(--ok); }
.kpi[data-tone="warn"] { border-top-color: #f59e0b; }
.kpi[data-tone="warn"] .kpi__value { color: var(--warn); }
.kpis[data-stale="true"] { opacity: 0.55; }

/* ---------- fields ---------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 18px; }
.field-grid--narrow { grid-template-columns: 1fr; }
.field { display: grid; gap: 4px; align-content: start; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field small { font-size: 11.5px; color: var(--muted); }
.field input[type="number"] { text-align: left; }
.readout { background: var(--calc-bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-weight: 600; color: var(--ink); }

input, select, button { font: inherit; color: inherit; }
input[type="text"], input[type="number"], select {
  width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--input-line); border-radius: 7px;
  background: var(--input-bg); min-width: 0;
}
input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(220,38,38,.12); outline: none; }
input:disabled, select:disabled { background: var(--calc-bg); border-color: var(--line); color: var(--muted); }
input.is-invalid { border-color: var(--bad); background: var(--bad-bg); }

.btn {
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-family: inherit;
  cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn:hover { border-color: #c5ccd6; background: #f8f9fb; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(220,38,38,.25); }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.5); }
.btn-icon {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.btn-icon:hover { background: var(--bad-bg); color: var(--bad); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
.grid thead th {
  background: #f7f8fa; color: #4b5565; font-size: 12px; font-weight: 600;
  white-space: normal; line-height: 1.25;
}
.grid thead th small { display: block; font-weight: 400; color: var(--muted); }
.grid tbody tr:last-child td, .grid tfoot tr:last-child td { border-bottom: 0; }
.grid td.num, .grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.center, .grid th.center { text-align: center; }
.grid td.calc { background: var(--calc-bg); }
.grid td.idx { color: var(--muted); width: 1%; font-variant-numeric: tabular-nums; }
.grid td.wrap { white-space: normal; }
.grid tfoot td { background: #f7f8fa; font-weight: 600; }
.grid tr.is-sectional td { background: #f7f8fa; }
.grid tr.is-sectional td.calc { background: #eceff3; }
.grid .empty { text-align: center; color: var(--muted); padding: 18px 8px; white-space: normal; }
.grid .w-name { min-width: 150px; }
.grid .w-type { min-width: 210px; }
.grid .w-cov { min-width: 130px; }
.grid .w-num { min-width: 84px; width: 96px; }
.grid .w-sm { min-width: 70px; width: 78px; }
.grid .w-phase { min-width: 136px; }
.grid .w-opt { min-width: 104px; }
.grid--results td { padding: 8px; }
.grid .sub { display: block; font-size: 11.5px; color: var(--muted); }
.grid .tag { font-size: 10.5px; color: var(--accent-dark); font-weight: 600; margin-left: 4px; text-transform: uppercase; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--calc-bg); color: var(--muted); white-space: nowrap;
}
.chip[data-tone="ok"] { background: var(--ok-bg); color: var(--ok); }
.chip[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }
.chip[data-tone="bad"] { background: var(--bad-bg); color: var(--bad); }
.ratio[data-tone="ok"] { color: var(--ok); font-weight: 600; }
.ratio[data-tone="warn"] { color: var(--warn); font-weight: 600; }
.ratio[data-tone="bad"] { color: var(--bad); font-weight: 600; }

/* ---------- banner ---------- */
.banner { border-radius: var(--radius); padding: 12px 16px; border: 1px solid; font-size: 13px; }
.banner[data-tone="bad"] { background: var(--bad-bg); border-color: #f3b8b1; color: #7a1a12; }
.banner[data-tone="warn"] { background: var(--warn-bg); border-color: #f1d48c; color: #6b4600; }
.banner strong { display: block; margin-bottom: 4px; }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner code { background: rgba(0, 0, 0, 0.06); padding: 1px 5px; border-radius: 4px; }
.banner .btn { margin-top: 8px; }

[hidden] { display: none !important; }

/* ========== Tab bar ========== */
.tab-bar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 64px; z-index: 90; }
.tab-bar__inner { max-width: 1360px; margin: 0 auto; padding: 0 24px; display: flex; gap: 0; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 12px 20px; border: none; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--ink); background: rgba(0,0,0,0.02); }
body.tool[data-tab="simple"] .tab-bar__inner { max-width: 868px; }
.tab-btn--active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-btn svg { flex: none; }
@media (max-width: 640px) {
  .tab-bar__inner { padding: 0 12px; }
  .tab-btn { padding: 10px 14px; font-size: 13px; }
}

/* Mostrar u ocultar según la pestaña activa */
body[data-tab="analysis"] .whatsapp-float { display: none; }

/* ========== Simple view ========== */
.page--simple { max-width: 868px; padding-bottom: 100px; }

.card--welcome { background: #fff; border: 1px solid #fecaca; border-left: 4px solid var(--accent); }
.card--welcome h2 { font-size: 18px; margin-bottom: 6px; color: var(--ink); }
.card--welcome p { color: var(--text); font-size: 14px; line-height: 1.55; }

/* Info toggle button */
.info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer; vertical-align: middle; margin-left: 6px;
  transition: background 0.15s, color 0.15s;
}
.info-btn:hover { background: var(--accent); color: #fff; }

/* Info box */
.info-box {
  background: #fff7f7; border: 1px solid #fecaca; border-radius: 8px; padding: 12px 16px;
  margin-bottom: 14px; font-size: 13px; line-height: 1.55; color: var(--text);
}
.info-box p { margin: 0 0 6px; }
.info-box p:last-child { margin-bottom: 0; }
.info-box ul { margin: 4px 0 8px; padding-left: 20px; }
.info-box li { margin-bottom: 4px; }

/* Simple room cards */
.simple-room {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  margin-bottom: 10px; position: relative;
}
.simple-room__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.simple-room__num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; flex: none;
}
.simple-room__fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.simple-room__fields--wide { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .simple-room__fields { grid-template-columns: 1fr; }
  .simple-room__fields--wide { grid-template-columns: 1fr 1fr; }
}
.simple-room__remove {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.simple-room__remove:hover { background: var(--bad-bg); color: var(--bad); }

/* Simple circuit cards */
.simple-circuit {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  margin-bottom: 10px; position: relative;
}
.simple-circuit__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.simple-circuit__icon {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  font-size: 16px; flex: none;
}
.simple-circuit__icon--iug { background: #fef3c7; }
.simple-circuit__icon--tug { background: #dbeafe; }
.simple-circuit__icon--tue { background: #fce7f3; }
.simple-circuit__icon--other { background: #e0e7ff; }
.simple-circuit__fields { display: grid; grid-template-columns: 1fr; gap: 10px; max-width: 320px; }
.simple-circuit__remove {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%;
  border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.simple-circuit__remove:hover { background: var(--bad-bg); color: var(--bad); }

/* Results simple */
.card--results-simple { border-top: 3px solid var(--accent); }
.result-item {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.result-item:last-child { border-bottom: none; }
.result-icon {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; flex: none;
  font-size: 15px; font-weight: 700;
}
.result-icon--ok { background: var(--ok-bg); color: var(--ok); }
.result-icon--warn { background: var(--warn-bg); color: var(--warn); }
.result-icon--bad { background: var(--bad-bg); color: var(--bad); }
.result-icon--info { background: #e0e7ff; color: #3730a3; }
.result-text { flex: 1; }
.result-text strong { display: block; margin-bottom: 2px; }
.result-text small { color: var(--muted); }

.result-summary {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 8px;
  margin-bottom: 14px; font-size: 16px; font-weight: 600;
}
.result-summary--ok { background: var(--ok-bg); color: var(--ok); }
.result-summary--warn { background: var(--warn-bg); color: var(--warn); }
.result-summary--bad { background: var(--bad-bg); color: var(--bad); }
.result-summary svg { flex: none; }

/* WhatsApp floating button */
.whatsapp-float { position: fixed; bottom: 24px; right: 24px; z-index: 200; }
.whatsapp-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 999px;
  background: #25d366; color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4); transition: transform 0.15s, box-shadow 0.15s;
}
.whatsapp-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5); }
.whatsapp-btn svg { flex: none; }
@media (max-width: 640px) {
  .whatsapp-btn span { display: none; }
  .whatsapp-btn { padding: 14px; border-radius: 50%; }
}

/* Simple outlets table */
.grid--simple th, .grid--simple td { padding: 8px 10px; font-size: 13px; }
.grid--simple .w-sm { min-width: 60px; width: 70px; }
.grid--simple .room-status { font-size: 12px; white-space: normal; }
