/* Tecnoden Postventa — estilos de la aplicación web.
   Identidad tomada del logo de Tecnoden Plus: verde lima (#71B01B), azul
   marino (#0A3F84) y títulos en Barlow Semi Condensed cursiva. El modo oscuro
   ("nocturno solar") usa los mismos dos colores sobre azul noche.
   Sin frameworks ni CDN: una sola hoja y las fuentes servidas por la app. */

@font-face {
  font-family: "Barlow Semi Condensed";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-style: italic; font-weight: 600; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-600-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-style: italic; font-weight: 700; font-display: swap;
  src: url("../fonts/barlow-semi-condensed-700-italic.woff2") format("woff2");
}

:root {
  /* Marca */
  --green: #71b01b;         /* verde del logo: acentos, barras, indicadores */
  --green-strong: #4f8a10;  /* verde legible como texto sobre blanco */
  --green-soft: #eef6e2;
  --navy: #0a3f84;          /* azul del logo: títulos, botones principales */
  --navy-hover: #08336b;
  --navy-soft: #e7eef8;
  --sidebar: #0a2f66;
  --sidebar-active: #13438c;
  --sidebar-text: #c8d5ec;
  --sidebar-muted: #8ea3c6;

  /* Superficies y texto */
  --bg: #f3f5f0;
  --surface: #ffffff;
  --surface-2: #f8faf6;
  --border: #e1e6dc;
  --text: #17233a;
  --text-2: #46546b;
  --muted: #6b7686;
  --heading: var(--navy);
  --link: var(--navy);
  --primary: var(--navy);
  --primary-hover: var(--navy-hover);
  --on-primary: #ffffff;
  --selected: #0a3f84;      /* fondo de pestaña o filtro seleccionado (texto blanco) */
  --focus: rgba(113, 176, 27, .35);

  /* Semáforo */
  --ok: #3f7d12;      --ok-soft: #eaf5dc;
  --info: #0a3f84;    --info-soft: #e7eef8;
  --warn: #9a5b06;    --warn-soft: #fcf0d9;
  --bad: #b3261e;     --bad-soft: #fde8e6;
  --neutral: #5b6677; --neutral-soft: #edf0f3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(10, 47, 102, .05), 0 1px 3px rgba(10, 47, 102, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Barlow Semi Condensed", "Arial Narrow", var(--font);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  /* Calendario de calor: de casi blanco a verde fuerte (como Hoymiles). */
  --heat-0: #f0faf4; --heat-1: #daf4e6; --heat-2: #c4edd8; --heat-3: #afe7cb; --heat-4: #99e1bd;
  --heat-5: #83daaf; --heat-6: #6dd4a1; --heat-7: #58ce94; --heat-8: #42c786; --heat-9: #2cc178;
  --tip-bg: #1f2933; --tip-text: #ffffff;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --green: #8fd14a;
    --green-strong: #9bd65a;
    --green-soft: #1b3319;
    --navy: #7fa8e8;
    --navy-hover: #9dbdf0;
    --navy-soft: #16294a;
    --sidebar: #07122a;
    --sidebar-active: #13284c;

    --bg: #0b1830;
    --surface: #10223f;
    --surface-2: #0d1d37;
    --border: #1f365c;
    --text: #e3eaf5;
    --text-2: #b6c3d9;
    --muted: #8a9bb8;
    --heading: #ffffff;
    --link: #9dbdf0;
    --primary: #8fd14a;
    --primary-hover: #a6de6b;
    --on-primary: #0a1a33;
    --selected: #1d4f99;
    --focus: rgba(143, 209, 74, .35);

    --ok: #9bd65a;      --ok-soft: #1b3319;
    --info: #9dbdf0;    --info-soft: #16294a;
    --warn: #f3c15a;    --warn-soft: #3a2c0e;
    --bad: #ff8a80;     --bad-soft: #3d1a1a;
    --neutral: #a3afc2; --neutral-soft: #1a2b47;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --heat-0: #1c3a3a; --heat-1: #204c43; --heat-2: #245e4c; --heat-3: #287055; --heat-4: #2c825e;
    --heat-5: #2f9468; --heat-6: #33a671; --heat-7: #37b87a; --heat-8: #3bca83; --heat-9: #3fdc8c;
    --tip-bg: #e3eaf5; --tip-text: #0a1a33;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.2; margin: 0; color: var(--heading); font-family: var(--display); font-style: italic; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: .2px; }
h2 { font-size: 1.2rem; font-weight: 600; }
p { margin: .5rem 0; }
code { font-family: var(--mono); font-size: .92em; }
small { font-size: .82rem; }
.block { display: block; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; }
.tone-warn { color: var(--warn); font-weight: 600; }
.tone-bad { color: var(--bad); font-weight: 600; }
.tag { background: var(--warn-soft); color: var(--warn); padding: 1px 8px; border-radius: 99px; font-size: .78rem; }

/* ---------- Estructura ---------- */

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 3px solid var(--green);
}

/* El nombre de la marca, compuesto con la tipografía del logo. */
.wordmark {
  display: block; padding: 2px 10px 18px;
  font-family: var(--display); font-style: italic; font-weight: 700;
  font-size: 1.7rem; line-height: 1; letter-spacing: .3px;
  color: #ffffff;
}
.wordmark:hover { text-decoration: none; }
.wordmark .wm-green { color: #7cc242; }
.wordmark small {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  font-family: var(--font); font-style: normal; font-weight: 600;
  font-size: .68rem; letter-spacing: 1.6px; text-transform: uppercase; color: var(--sidebar-muted);
}
.wordmark small::before { content: ""; width: 16px; height: 2px; background: #7cc242; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav-item.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #7cc242; }
.nav-item.is-active .icon { color: #9bd65a; }
.nav-item.is-soon { color: var(--sidebar-muted); cursor: default; }
.nav-item.is-soon:hover { background: transparent; color: var(--sidebar-muted); }
.nav-item em { margin-left: auto; font-style: normal; font-size: .7rem; white-space: nowrap; border: 1px solid #25497f; border-radius: 99px; padding: 0 7px; }
.nav-button { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.sidebar-foot { margin-top: auto; border-top: 1px solid #1d4078; padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--sidebar-text); }
.me:hover, .me.is-active { background: var(--sidebar-active); text-decoration: none; }
.me-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.me-text strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--sidebar-muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .8rem; font-weight: 700;
  background: #7cc242; color: #0a2f66;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 32px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-search {
  flex: 1; max-width: 560px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 99px;
  padding: 6px 14px; color: var(--muted);
}
.topbar-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
.topbar-search input[type="search"] { flex: 1; border: 0; outline: 0; box-shadow: none; background: transparent; padding: 2px 0; font: inherit; color: var(--text); min-width: 0; }
.icon-button { background: none; border: 0; color: var(--text); padding: 6px; border-radius: var(--radius-sm); cursor: pointer; }
.icon-button:hover { background: var(--surface); }
.menu-button { display: none; }
.topbar-brand { display: none; font-family: var(--display); font-style: italic; font-weight: 700; font-size: 1.35rem; line-height: 1; }
.topbar-brand:hover { text-decoration: none; }
.topbar-brand .wm-green { color: var(--green-strong); }
.topbar-brand .wm-navy { color: var(--heading); margin-left: 1px; }

.content { padding: 28px 32px 40px; width: 100%; max-width: 1280px; }
.footer { margin-top: auto; padding: 16px 32px; color: var(--muted); font-size: .8rem; }
.scrim { display: none; }

/* Título de página con la línea verde del logo. */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1::after { content: ""; display: block; width: 44px; height: 4px; margin-top: 8px; background: var(--green); transform: skewX(-20deg); }
.page-head .muted { margin: 8px 0 0; }
.crumb { margin: 0 0 4px; font-size: .85rem; }

/* ---------- Tarjetas y paneles ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 16px; margin-bottom: 20px; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat { padding: 18px; display: flex; flex-direction: column; gap: 2px; position: relative; border-top: 4px solid var(--navy); }
.stat-green { border-top-color: var(--green); }
.stat-navy { border-top-color: var(--navy); }
.stat-alert { border-top-color: var(--bad); }
.stat-icon {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--green-soft); color: var(--green-strong);
}
.stat-label { color: var(--text-2); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font-family: var(--display); font-weight: 600; font-size: 2.4rem; line-height: 1.05; color: var(--heading); margin-top: 6px; }
.stat-value small { font-family: var(--font); font-size: .9rem; font-weight: 600; color: var(--muted); }
.stat-value.stat-empty { font-size: 1.5rem; color: var(--muted); margin: 10px 0 4px; }
.stat-foot { color: var(--muted); font-size: .84rem; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel { padding: 18px 20px; margin-bottom: 16px; }
.grid-2 .panel { margin-bottom: 0; }
.panel-narrow { max-width: 620px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.count { background: var(--navy-soft); color: var(--navy); border-radius: 99px; padding: 0 9px; font-size: .8rem; font-weight: 700; font-style: normal; font-family: var(--font); }
.panel-hint { background: var(--surface-2); box-shadow: none; border-left: 4px solid var(--green); border-radius: 0 var(--radius) var(--radius) 0; }
.empty { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 6px 0; }
.empty .icon { color: var(--green-strong); }
ul.plain { margin: 6px 0 0; padding-left: 18px; }
ul.plain li { margin: 4px 0; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: 10px 20px; text-align: left; vertical-align: top; border-top: 1px solid var(--border); }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 700; border-top: 0; padding-top: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.is-muted td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.table-note { margin: 12px 0 0; font-size: .85rem; }

/* ---------- Insignias (semáforo de pólizas) ---------- */

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 99px;
  font-size: .76rem; font-weight: 700; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.badge + .badge { margin-left: 4px; }
.badge-ok, .badge-vigente, .badge-renovada { background: var(--ok-soft); color: var(--ok); }
.badge-info, .badge-en_aviso { background: var(--info-soft); color: var(--info); }
.badge-por_vencer, .badge-proxima { background: var(--warn-soft); color: var(--warn); }
.badge-urgente, .badge-vence_hoy, .badge-vencida { background: var(--bad-soft); color: var(--bad); }

/* ---------- Formularios ---------- */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; border: 0; padding: 0; margin: 0; }
.field > span, .field legend { font-weight: 600; font-size: .9rem; color: var(--text-2); }
.field legend { margin-bottom: 6px; }
.hint { color: var(--muted); font-size: .82rem; }
input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%;
}
input:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
.choice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; margin-bottom: 6px;
}
.choice:has(input:checked) { border-color: var(--green); background: var(--green-soft); }
.choice input { margin-top: 4px; accent-color: var(--green-strong); }
.code-input { font-family: var(--mono); font-size: 1.35rem !important; letter-spacing: 6px; text-align: center; max-width: 220px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: center; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.button:hover { background: var(--surface-2); text-decoration: none; }
.button:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--focus); }
.button .icon { width: 18px; height: 18px; }
/* Botón principal: azul del logo con el filo verde, como la cinta «Servicio que genera valor». */
.button-primary {
  background: var(--primary); border-color: var(--primary); color: var(--on-primary);
  box-shadow: inset 0 -3px 0 var(--green);
}
.button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.button-block { width: 100%; padding: 12px 16px; font-size: 1rem; }

.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.danger-row:first-of-type { border-top: 0; }
.danger-row p { margin: 2px 0 0; }

/* ---------- Avisos ---------- */

.notice {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  background: var(--ok-soft); color: var(--ok); font-weight: 500;
}
.notice .icon { margin-top: 1px; }
.notice-error { background: var(--bad-soft); color: var(--bad); }
.notice-aviso { background: var(--warn-soft); color: var(--warn); }
.notice-info { background: var(--info-soft); color: var(--info); }

/* ---------- Búsqueda ---------- */

.search-big {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 8px 8px 16px; margin-bottom: 18px; color: var(--muted); box-shadow: var(--shadow);
}
.search-big:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
.search-big input[type="search"] { flex: 1; min-width: 0; border: 0; box-shadow: none; background: transparent; padding: 6px 0; font-size: 1.05rem; }

/* ---------- Verificación en dos pasos y credenciales ---------- */

.steps { list-style: none; counter-reset: paso; margin: 0; padding: 0; display: grid; gap: 22px; }
.steps > li { counter-increment: paso; position: relative; padding-left: 50px; }
.steps > li::before {
  content: counter(paso);
  position: absolute; left: 0; top: -4px;
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--display); font-style: italic; font-weight: 700; font-size: 1.2rem;
  background: var(--navy); color: #fff; box-shadow: inset 0 -3px 0 var(--green);
}
.qr { display: inline-block; padding: 8px; background: #fff; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 8px 0; line-height: 0; }
.manual summary { cursor: pointer; color: var(--link); font-weight: 600; }
.secret { display: inline-block; font-size: 1.05rem; letter-spacing: 1px; padding: 6px 10px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); word-break: break-all; }
.credentials { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; margin: 14px 0; }
.credentials dt { color: var(--muted); font-weight: 600; }
.credentials dd { margin: 0; }

/* ---------- Pantallas de entrada ---------- */

.auth {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px; background: var(--bg);
  border-top: 6px solid var(--navy);
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px;
  border-bottom: 4px solid var(--green);
}
/* El logo tiene fondo blanco: en modo oscuro va sobre una placa blanca. */
.auth-logo { display: block; background: #fff; border-radius: 10px; padding: 6px; margin: -6px -6px 6px; }
.auth-logo img { display: block; width: 100%; height: auto; }
.auth-card h1 { font-size: 1.6rem; margin-top: 14px; }
.auth-card .form { margin-top: 18px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: .9rem; }
.auth-foot { color: var(--muted); font-size: .8rem; margin-top: 16px; }

.error-panel { text-align: center; margin: 40px auto; }
.error-panel h1::after { margin-left: auto; margin-right: auto; }
.error-code { font-family: var(--display); font-style: italic; font-weight: 700; font-size: 3.5rem; color: var(--green-strong); margin: 0; }

/* ---------- Expediente: listas, fichas y formularios (fase 4) ---------- */

select, textarea, input[type="date"], input[type="tel"] {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; width: 100%;
}
select:focus, textarea:focus { outline: 0; border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
.req { color: var(--bad); font-style: normal; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field-wide { grid-column: 1 / -1; }
.form-record { gap: 0; }
.form-record .panel { margin-bottom: 16px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 4; margin: 0 -4px; padding: 12px 4px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px);
}
.choice-inline { align-self: end; margin-bottom: 0; }
.choice-wide { flex-basis: 100%; }
.button-sm { padding: 6px 12px; font-size: .85rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-bar { margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: .88rem;
}
.chip:hover { text-decoration: none; border-color: var(--green); }
.chip span { color: var(--muted); font-weight: 700; font-size: .8rem; }
.chip.is-active { background: var(--selected); border-color: var(--selected); color: #fff; box-shadow: inset 0 -2px 0 var(--green); }
.chip.is-active span { color: #cfe0f7; }
.chip-warn:not(.is-active) span { color: var(--warn); }
.filter-search {
  display: flex; align-items: center; gap: 8px; min-width: min(320px, 100%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 5px 14px; color: var(--muted);
}
.filter-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--focus); }
.filter-search input[type="search"] { border: 0; box-shadow: none; padding: 3px 0; background: transparent; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 14px; font-size: .85rem; }
.legend .badge + .badge { margin-left: 0; }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-capture td { vertical-align: middle; }
.table-capture input, .table-capture select { padding: 6px 8px; min-width: 140px; }
.table-capture .is-missing { border-color: var(--warn); background: var(--warn-soft); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }

.head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.head-link { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: .9rem; }
.head-link .icon { width: 16px; height: 16px; }
.archived-banner { align-items: center; }
.archived-banner > div { flex: 1; }
.archived-banner form { flex: none; }

/* Pestañas del expediente: franja azul con el filo verde en la activa. */
.tabs {
  display: flex; gap: 2px; overflow-x: auto; margin: 0 0 18px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; white-space: nowrap; font-size: .92rem; flex: none;
}
.tab .icon { width: 17px; height: 17px; }
.tab:hover { background: var(--surface-2); text-decoration: none; }
.tab.is-active { background: var(--selected); color: #fff; box-shadow: inset 0 -3px 0 var(--green); }
.tab-actions { margin: 0 0 14px; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0 0 10px; }
.facts dt { color: var(--muted); font-weight: 600; font-size: .88rem; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts-grid { grid-template-columns: max-content 1fr max-content 1fr; }
.subhead { font-family: var(--display); font-style: italic; font-weight: 600; color: var(--heading); font-size: 1.05rem; margin: 18px 0 8px; }
.tag-plain { background: var(--navy-soft); color: var(--navy); display: inline-block; margin: 1px 0; }
.note-text { white-space: pre-wrap; background: var(--surface-2); border-left: 3px solid var(--green); padding: 8px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.icon-xs { width: 13px; height: 13px; vertical-align: -2px; }

.policy-card { padding: 4px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.policy-card:last-child { border-bottom: 0; margin-bottom: 0; }
.policy-card p { margin: 6px 0; }
.policy-level { margin-left: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); }
.timeline li:first-child { border-top: 0; }
.timeline-date { color: var(--muted); font-size: .84rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline-compact li { padding: 5px 0; }
.timeline-compact { margin-bottom: 10px; }

.panel-danger { border-left: 4px solid var(--bad); }
.panel-danger .form-inline input[type="text"] { flex: 1; min-width: 220px; width: auto; }

meter { width: 90px; height: 10px; vertical-align: middle; }

.dup-group .table-wrap { margin-bottom: 8px; }
.radio-cell { display: inline-flex; padding: 4px; cursor: pointer; }
.radio-cell input { width: 18px; height: 18px; accent-color: var(--green-strong); }
.dup-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.dup-dismiss { display: flex; justify-content: flex-end; margin-top: 6px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; margin: 0; gap: 2px; }
.segmented label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: .88rem; color: var(--text-2); }
.segmented label:has(input:checked) { background: var(--green-soft); color: var(--green-strong); }
.segmented input { accent-color: var(--green-strong); }

/* ---------- Generación (fase 5) ---------- */

input[type="month"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.stat-link { margin-top: 6px; font-weight: 600; font-size: .85rem; }
.inline-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-filter select, .inline-filter input[type="date"] { width: auto; padding: 6px 10px; }
.day-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.subhead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.subhead-row .subhead { margin-bottom: 0; }
.basis { margin: -4px 0 4px; }

.table-capture .kwh-input { width: 120px; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.table-capture tr.has-error td { background: var(--bad-soft); }
.table-capture tr.has-error .kwh-input { border-color: var(--bad); }
.table-capture tr.has-warning td { background: var(--warn-soft); }

.chart { margin: 6px 0 12px; }
.chart svg { display: block; width: 100%; height: auto; max-height: 280px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart-bar { fill: var(--navy); }
.chart-bar.is-low { fill: #e0a526; }
.chart-bar:hover { fill: var(--green-strong); }
.chart-estimate { stroke: var(--green); stroke-width: 3; stroke-linecap: round; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 12px; height: 10px; border-radius: 2px; }
.key-bar { background: var(--navy); }
.key-low { background: #e0a526; }
.key-estimate { height: 3px; width: 14px; background: var(--green); }
.chart-bar.is-selected { fill: var(--green-strong); }

/* Ficha del cliente: sistema y portal. */
.mono { font-family: var(--mono); font-size: .92rem; word-break: break-all; }
.system-total { margin: 0 0 8px; font-family: var(--display); font-size: 1.6rem; color: var(--heading); }
.facts.portal { margin-bottom: 6px; }
.facts.portal + .small-link { display: inline-block; margin-bottom: 12px; }
.small-link { font-size: .85rem; }
.input-sm { max-width: 120px; }
.brand-cell select, .brand-cell input { width: 100%; }
.brand-cell input:not([hidden]) { margin-top: 6px; }
.brand-list { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--border); }
.brand-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 0; border-bottom: 1px solid var(--border); }
.brand-list form { margin: 0; }
.add-row { margin-top: 8px; }
[data-type-detail]:not([hidden]) { margin-top: 6px; }

/* Ajustar estimado: barra de HSP como la del cotizador. */
.hsp-panel { background: var(--surface-2); }
.hsp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.hsp-head h2 { margin: 0; font-size: 1.05rem; }
.hsp-value { font-family: var(--display); font-size: 1.8rem; font-weight: 700; color: #ca8a04; }
.hsp-city select { width: auto; min-width: 240px; }
.hsp-slider { position: relative; margin: 10px 0 6px; }
.hsp-slider input[type="range"] { width: 100%; accent-color: #eab308; padding: 0; border: 0; box-shadow: none; background: none; }
.hsp-ticks { position: relative; height: 42px; }
.hsp-tick:nth-child(even) { padding-top: 20px; }  /* ciudades con promedio parecido no se enciman */
.hsp-tick:nth-child(even)::before { height: 20px; }
.hsp-tick {
  position: absolute; top: 0; transform: translateX(-50%); padding: 6px 0 0; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .75rem; font-weight: 600; color: var(--muted);
}
.hsp-tick::before { content: ""; position: absolute; top: 0; left: 50%; width: 2px; height: 6px; background: var(--muted); }
.hsp-tick:hover, .hsp-tick.is-active { color: #ca8a04; }
.hsp-range { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.hsp-factor { max-width: 320px; margin-top: 10px; }
.bar-cell { width: 45%; }
.bar-cell meter { width: 100%; height: 12px; }

/* Calendario de calor («Producción diaria», como Hoymiles). */
.heat { position: relative; margin: 6px 0 16px; }
.heat-scroll svg { display: block; width: 100%; height: auto; }
.heat-cell { stroke: var(--surface); stroke-width: 1; cursor: pointer; }
.heat-link:hover .heat-cell, .heat-link:focus .heat-cell, .heat-cell.is-selected { stroke: var(--text); stroke-width: 1.5; }
.heat-link:focus { outline: none; }
.heat-0 { fill: var(--heat-0); } .heat-1 { fill: var(--heat-1); } .heat-2 { fill: var(--heat-2); }
.heat-3 { fill: var(--heat-3); } .heat-4 { fill: var(--heat-4); } .heat-5 { fill: var(--heat-5); }
.heat-6 { fill: var(--heat-6); } .heat-7 { fill: var(--heat-7); } .heat-8 { fill: var(--heat-8); }
.heat-9 { fill: var(--heat-9); }
.heat-controls { display: flex; align-items: center; gap: 14px; margin: 4px 0 10px; }
.heat-range { position: relative; width: 240px; height: 26px; }
.heat-gradient {
  position: absolute; left: 6px; right: 6px; bottom: 2px; height: 10px; border-radius: 2px;
  background: linear-gradient(90deg, var(--heat-0), var(--heat-4), var(--heat-9));
}
.heat-range input[type="range"] {
  position: absolute; inset: 0; width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none;
  background: none; -webkit-appearance: none; appearance: none; pointer-events: none;
}
.heat-range input[type="range"]::-webkit-slider-runnable-track { background: none; border: 0; }
.heat-range input[type="range"]::-moz-range-track { background: none; border: 0; }
.heat-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto; cursor: pointer;
  width: 12px; height: 11px; margin-top: -2px; border: 0; background: var(--text-2);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.heat-range input[type="range"]::-moz-range-thumb {
  pointer-events: auto; cursor: pointer; width: 12px; height: 11px; border: 0; border-radius: 0;
  background: var(--text-2); clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.heat-range input[type="range"]:focus-visible::-webkit-slider-thumb { background: var(--green-strong); }
.heat-tip {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  background: var(--tip-bg); color: var(--tip-text); border-radius: 6px; padding: 5px 9px;
  font-size: .8rem; font-weight: 600; line-height: 1.35; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  transform: translate(-50%, calc(-100% - 10px));
}
.heat-tip small { display: block; font-weight: 400; opacity: .85; }
.heat-detail {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin: 0 0 10px;
  padding: 12px 16px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--heat-9);
}
.heat-detail[hidden], .heat-tip[hidden] { display: none; }
.heat-detail strong { font-size: 1.05rem; }
.heat-detail .heat-kwh { font-family: var(--display); font-size: 1.6rem; font-weight: 700; color: var(--heading); }

/* Captura de varios días: nombre fijo a la izquierda, un día por columna. */
.range-picker { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.range-picker .field { width: auto; min-width: 150px; }
.range-picker input[type="date"], .range-picker select { width: auto; }
.range-hint { flex-basis: 100%; margin: 0; }
.capture-grid { max-height: 70vh; overflow: auto; }
.capture-grid thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); padding-top: 8px; }
.capture-grid .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 190px; box-shadow: 1px 0 0 var(--border); }
.capture-grid thead .sticky-col { z-index: 3; }
.capture-grid .day-col { text-align: center; white-space: nowrap; }
.capture-grid .day-col span { font-weight: 600; text-transform: none; letter-spacing: 0; }
.capture-grid .day-cell { padding: 6px 8px; }
.capture-grid .kwh-input { width: 84px; }
.table-capture td.has-error { background: var(--bad-soft); }
.table-capture td.has-error .kwh-input { border-color: var(--bad); }
.table-capture td.has-warning { background: var(--warn-soft); }

/* ---------- Celular y tableta ---------- */

@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .panel { margin-bottom: 0; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(5, 12, 28, .5); z-index: 15; }
  .menu-button { display: inline-flex; }
  .topbar-brand { display: inline-block; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-search { padding: 6px 12px; }
  .content { padding: 20px 16px 32px; }
  .footer { padding: 12px 16px; }
  h1 { font-size: 1.6rem; }
  .table-wrap { margin: 0 -20px; }
  .table th, .table td { padding: 9px 14px; }
  .danger-row { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .facts-grid { grid-template-columns: max-content 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-search { min-width: 0; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .archived-banner { flex-wrap: wrap; }
  .head-link { margin-left: 0; }
  .panel-head { flex-wrap: wrap; }
  .chart { overflow-x: auto; }
  .chart svg { min-width: 560px; }
  .heat-scroll { overflow-x: auto; }
  .heat-scroll svg { min-width: 620px; }
}

/* Tipo de cobertura (póliza, año gratis, sin vigencia) */
.coverage-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.coverage-option { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.coverage-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--navy-soft); }
.coverage-option input { margin-top: 3px; }
.field[hidden] { display: none; }
