/* Semáforo de herramientas · tablero claro (pedido de Damián, 28/10: "fondo blanco, gráficos, todo en una página").
   Colores de estado fijos (bien / atención / urgente) y siempre con ícono y texto, nunca el color solo. */
:root {
  color-scheme: light;
  --plano: #f6f6f3; --superficie: #ffffff; --superficie-2: #f9f9f7; --hundido: #f0efec;
  --tinta: #0b0b0b; --tinta-2: #52514e; --apagado: #898781;
  --grilla: #e1e0d9; --base: #c3c2b7; --aro: rgba(11, 11, 11, .08);
  --bien: #0ca30c; --atencion: #fab219; --urgente: #d03b3b; --sin: #c3c2b7;
  --bien-suave: #e7f6e7; --atencion-suave: #fff4dc; --urgente-suave: #fbe9e9; --sin-suave: #f0efec;
  --bien-texto: #006300; --atencion-texto: #7a5300; --urgente-texto: #a12626; --sin-texto: #52514e;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #6250d6;
  --acento: #2a78d6; --acento-hover: #1c5cab;
  --letra: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--plano); color: var(--tinta); font-family: var(--letra); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

.sem { max-width: 1180px; margin: 0 auto; padding: 24px 16px calc(48px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.cargando { color: var(--tinta-2); text-align: center; margin-top: 30vh; }

/* cabecera */
.cab { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.cab-tit { flex: 1; min-width: 240px; }
.cab h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.cab p { margin: 4px 0 0; color: var(--tinta-2); font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { white-space: nowrap; min-height: 40px; border-radius: 10px; border: 1px solid var(--grilla); background: var(--superficie); padding: 0 14px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--superficie-2); }
.btn-prim { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn-prim:hover { background: var(--acento-hover); }
.btn-prim:disabled { opacity: .6; }
.btn-chico { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-peligro { color: var(--urgente-texto); border-color: #f0c4c4; }

/* estado: píldora con ícono + texto */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 14px; height: 14px; flex: none; }
.pill.verde { background: var(--bien-suave); color: var(--bien-texto); }
.pill.amarillo { background: var(--atencion-suave); color: var(--atencion-texto); }
.pill.rojo { background: var(--urgente-suave); color: var(--urgente-texto); }
.pill.gris { background: var(--sin-suave); color: var(--sin-texto); }

/* tarjetas */
.card { background: var(--superficie); border-radius: 14px; box-shadow: 0 0 0 1px var(--aro), 0 1px 2px rgba(0,0,0,.04); padding: 18px; min-width: 0; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.card .sub { margin: 2px 0 0; font-size: 13px; color: var(--tinta-2); }
.card-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* indicadores */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .et { font-size: 13px; color: var(--tinta-2); font-weight: 500; }
.kpi .val { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.kpi .val small { font-size: 16px; font-weight: 600; color: var(--tinta-2); }
.kpi .det { font-size: 13px; color: var(--tinta-2); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.cuenta { display: inline-flex; align-items: center; gap: 4px; }
.punto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.punto.verde { background: var(--bien); } .punto.amarillo { background: var(--atencion); } .punto.rojo { background: var(--urgente); } .punto.gris { background: var(--sin); }
.segbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--superficie); }
.segbar i { display: block; height: 100%; }
.segbar i.verde { background: var(--bien); } .segbar i.amarillo { background: var(--atencion); } .segbar i.rojo { background: var(--urgente); } .segbar i.gris { background: var(--sin); }

.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; }

/* gráfico: uso de cada límite (barras horizontales) */
.barras { display: flex; flex-direction: column; gap: 10px; }
.fila-b { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr); gap: 12px; align-items: center; border-radius: 6px; }
.fila-b .nom { font-size: 13px; line-height: 1.25; min-width: 0; }
.fila-b .nom b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-b .nom span { color: var(--tinta-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pista { position: relative; height: 22px; }
.pista .eje { position: absolute; left: 0; right: 44px; top: 0; bottom: 0; }
.pista .umbral { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--grilla); }
.pista .barra { position: absolute; left: 0; top: 4px; height: 14px; border-radius: 0 4px 4px 0; min-width: 3px; }
.pista .barra.verde { background: var(--bien); } .pista .barra.amarillo { background: var(--atencion); } .pista .barra.rojo { background: var(--urgente); }
.pista .pct { position: absolute; top: 2px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 6px; }
.fila-b:hover .barra, .fila-b:focus .barra { filter: brightness(1.08); }
.fila-b:focus { outline: 2px solid var(--acento); outline-offset: 2px; }
.eje-x { display: grid; grid-template-columns: minmax(0, 210px) minmax(0, 1fr); gap: 12px; margin-top: 4px; }
.eje-x .marcas { position: relative; height: 16px; margin-right: 44px; }
.eje-x .marcas span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--apagado); font-variant-numeric: tabular-nums; }
.vacio { font-size: 14px; color: var(--tinta-2); margin: 0; padding: 12px 0; }

/* gráfico: renovaciones (línea de tiempo) */
.tl-eje { position: relative; height: 18px; margin: 0 6px 6px 120px; }
.tl-eje span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--apagado); white-space: nowrap; }
.tl-fila { display: grid; grid-template-columns: 114px minmax(0, 1fr); gap: 6px; align-items: center; min-height: 34px; border-radius: 6px; }
.tl-fila .nom { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-pista { position: relative; height: 30px; margin-right: 6px; }
.tl-pista::before { content: ""; position: absolute; left: 0; right: 0; top: 15px; height: 1px; background: var(--grilla); }
.tl-pista .zona { position: absolute; top: 9px; height: 13px; border-radius: 4px; }
.tl-pista .zona.amarillo { background: var(--atencion-suave); } .tl-pista .zona.rojo { background: var(--urgente-suave); }
.tl-pista .hito { position: absolute; top: 9px; width: 13px; height: 13px; border-radius: 50%; transform: translateX(-50%); box-shadow: 0 0 0 2px var(--superficie); }
.tl-pista .hito.verde { background: var(--bien); } .tl-pista .hito.amarillo { background: var(--atencion); } .tl-pista .hito.rojo { background: var(--urgente); } .tl-pista .hito.gris { background: var(--sin); }
.tl-pista .cuando { position: absolute; top: 0; font-size: 12px; color: var(--tinta-2); white-space: nowrap; }
.tl-fila:focus { outline: 2px solid var(--acento); outline-offset: 2px; }
.tl-hoy { position: absolute; top: -4px; bottom: -4px; width: 1px; background: var(--base); }

/* gráfico: evolución (líneas) */
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--tinta-2); margin-bottom: 8px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.linea-svg { width: 100%; display: block; overflow: visible; }
.linea-svg text { font-size: 11px; fill: var(--apagado); font-family: var(--letra); }
.linea-svg .et-fin { font-size: 12px; fill: var(--tinta-2); font-weight: 600; }

/* gasto */
.gasto { display: flex; flex-direction: column; gap: 14px; }
.gasto h3 { margin: 0 0 6px; font-size: 13px; color: var(--tinta-2); font-weight: 600; }
.g-fila { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 12px; align-items: center; min-height: 26px; }
.g-fila .nom { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-pista { position: relative; height: 22px; }
.g-eje { position: absolute; left: 0; right: 120px; top: 0; bottom: 0; }
.g-pista .barra { position: absolute; left: 0; top: 4px; height: 14px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 3px; }
.g-pista .val { position: absolute; top: 2px; padding-left: 6px; font-size: 13px; font-weight: 600; white-space: nowrap; }

/* herramientas */
.sec-tit { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.sec-tit h2 { margin: 0; font-size: 18px; font-weight: 700; }
.herrs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.herr { display: flex; flex-direction: column; gap: 12px; }
.herr-cab { display: flex; align-items: flex-start; gap: 10px; }
.herr-cab h3 { margin: 0; font-size: 17px; font-weight: 700; }
.herr-cab .sub { margin-top: 2px; }
.herr-cab .der { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.dato { background: var(--superficie-2); border-radius: 10px; padding: 8px 10px; }
.dato span { display: block; font-size: 12px; color: var(--tinta-2); }
.dato b { display: block; font-size: 15px; margin-top: 2px; }
.dato small { color: var(--tinta-2); font-size: 12px; }
.medidor { display: flex; flex-direction: column; gap: 4px; }
.medidor .fila { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.medidor .fila span:first-child { color: var(--tinta-2); }
.medidor .fila b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.medidor .pista-m { height: 6px; border-radius: 999px; background: var(--hundido); overflow: hidden; }
.medidor .pista-m i { display: block; height: 100%; border-radius: 999px; }
.medidor .pista-m i.verde { background: var(--bien); } .medidor .pista-m i.amarillo { background: var(--atencion); } .medidor .pista-m i.rojo { background: var(--urgente); }
.medidor small { font-size: 12px; color: var(--apagado); }
.medidor.sin .fila b { color: var(--apagado); font-weight: 500; }
.nota { font-size: 13px; color: var(--tinta-2); margin: 0; }
.alerta { font-size: 13px; margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--atencion-suave); color: var(--atencion-texto); line-height: 1.45; }
.alerta.mal { background: var(--urgente-suave); color: var(--urgente-texto); }
.alerta b { color: inherit; }
.agregar { border: 1.5px dashed var(--base); background: transparent; border-radius: 14px; min-height: 120px; color: var(--tinta-2); font-weight: 600; font-size: 15px; box-shadow: none; }
.agregar:hover { background: var(--superficie); color: var(--tinta); }

/* pendientes de configuración */
.pend { background: var(--superficie); border-radius: 14px; box-shadow: 0 0 0 1px var(--aro); padding: 16px 18px; border-left: 4px solid var(--atencion); }
.pend h2 { margin: 0 0 8px; font-size: 16px; }
.pend ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.5; color: var(--tinta-2); }
.pend b { color: var(--tinta); }
.pend code, .card code { background: var(--hundido); padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* avisos */
.avisos { display: flex; flex-direction: column; }
.aviso { padding: 10px 0; border-top: 1px solid var(--grilla); font-size: 14px; line-height: 1.5; }
.aviso:first-child { border-top: none; padding-top: 0; }
.aviso time { display: block; font-size: 12px; color: var(--apagado); }
.pie { font-size: 12px; color: var(--apagado); text-align: center; line-height: 1.6; }

/* tabla */
details.tabla { margin-top: 12px; }
details.tabla summary { font-size: 13px; color: var(--acento); cursor: pointer; font-weight: 600; }
details.tabla table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
details.tabla th, details.tabla td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grilla); }
details.tabla td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* tooltip */
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--superficie); border-radius: 10px; box-shadow: 0 0 0 1px var(--aro), 0 8px 24px rgba(0,0,0,.12); padding: 8px 10px; font-size: 13px; max-width: 280px; }
.tip b { display: block; font-size: 15px; }
.tip span { color: var(--tinta-2); display: block; }
.tip .tl { display: flex; align-items: center; gap: 6px; }
.tip .tl i { width: 12px; height: 2px; display: inline-block; }

/* diálogo */
.dlg { border: none; border-radius: 16px; background: var(--superficie); color: var(--tinta); padding: 20px; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.dlg::backdrop { background: rgba(20, 20, 18, .35); }
.dlg h2 { margin: 0 0 14px; font-size: 20px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--tinta-2); font-weight: 600; }
.form input, .form select, .form textarea { min-height: 40px; border-radius: 8px; border: 1px solid var(--base); background: var(--superficie); padding: 8px 10px; font-size: 15px; font-weight: 400; width: 100%; color: var(--tinta); }
.form textarea { min-height: 60px; resize: vertical; }
.form .tres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.form .check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--tinta); font-weight: 500; }
.form .check input { width: 18px; min-height: 18px; height: 18px; }
.form details { background: var(--superficie-2); border-radius: 10px; padding: 10px 12px; }
.form details summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.form details[open] summary { margin-bottom: 10px; }
.form-acc { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1f1f1d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 30; max-width: calc(100vw - 32px); }

@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .sem { padding-top: 16px; }
  .cab h1 { font-size: 22px; }
  .kpi .val { font-size: 24px; }
  .fila-b { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .fila-b .nom { display: flex; gap: 6px; align-items: baseline; }
  .fila-b .nom b { flex: none; max-width: 62%; }
  .eje-x { grid-template-columns: minmax(0, 1fr); }
  .eje-x > span:first-child { display: none; }
  .cab-tit { min-width: 100%; }
  .g-fila { grid-template-columns: minmax(0, 110px) minmax(0, 1fr); }
  .tl-fila { grid-template-columns: 84px minmax(0, 1fr); }
  .tl-eje { margin-left: 90px; }
  .herrs { grid-template-columns: minmax(0, 1fr); }
  .form .tres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.kpi .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tl-eje span:last-child { transform: translateX(-100%); }
.tl-eje span:first-child { transform: none; }
