/* ===========================================================================
   Monitoreo de Dumpers — Constructora Independencia
   Estilo minimalista, colores corporativos sólo en detalles (sin fondos).
   Sin dependencias externas (funciona offline / en modo hotspot).
   =========================================================================== */
:root {
  --brand:      #00795C;   /* verde teal corporativo */
  --brand-dark: #005C46;
  --accent:     #8DC63F;   /* lima */
  --ink:        #1f2a28;
  --muted:      #6b7775;
  --line:       #e6eae9;
  --bg:         #f6f8f7;
  --card:       #ffffff;
  --ok:         #2e9e5b;
  --warn:       #e8a13a;
  --danger:     #d2453d;
  --radius:     12px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }

/* ---- Top bar ---- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px; position: sticky; top: 0; z-index: 50;
}
.topbar .brand img { height: 34px; display: block; }
.topbar .right { display: flex; align-items: center; gap: 16px; }
.status-pill { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--danger); } .dot.warn { background: var(--warn); }
.user { font-size: 13px; color: var(--muted); }

/* ---- Layout ---- */
.wrap { max-width: 1080px; margin: 22px auto; padding: 0 18px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  background: none; border: none; cursor: pointer; padding: 11px 16px;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  display: flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; } }

/* ---- Cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .accent-bar { width: 3px; height: 16px; background: var(--accent); border-radius: 2px; margin-right: 10px; }
.card-head .title { display: flex; align-items: center; }
.card-body { padding: 18px; }

/* ---- KPI grid ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--brand);
       border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi.accent { border-left-color: var(--accent); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.danger { border-left-color: var(--danger); }
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 8px 15px; border-radius: 9px; font-size: 13.5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: .12s;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.outline { background: #fff; color: var(--brand); }
.btn.outline:hover { background: #f0f7f4; }
.btn.ghost { background: #fff; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: #fdf1f0; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; }

/* ---- Lista de redes WiFi seleccionables (escaneo remoto) ---- */
.wifi-net-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.wifi-net {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 9px; border: 1.5px solid var(--line); background: #fff;
  cursor: pointer; transition: .12s; font-size: 13.5px; color: var(--ink);
}
.wifi-net:hover { border-color: var(--brand); background: #f0f7f4; }
.wifi-net .wifi-bars { flex: none; display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.wifi-net .wifi-bars i { display: block; width: 3px; background: var(--line); border-radius: 1px; }
.wifi-net .wifi-bars i:nth-child(1) { height: 4px; }
.wifi-net .wifi-bars i:nth-child(2) { height: 7px; }
.wifi-net .wifi-bars i:nth-child(3) { height: 10px; }
.wifi-net .wifi-bars i:nth-child(4) { height: 14px; }
.wifi-net.sig-4 .wifi-bars i { background: var(--brand); }
.wifi-net.sig-3 .wifi-bars i:nth-child(-n+3) { background: var(--brand); }
.wifi-net.sig-2 .wifi-bars i:nth-child(-n+2) { background: var(--warn); }
.wifi-net.sig-1 .wifi-bars i:nth-child(1) { background: var(--danger); }
.wifi-net .ssid { flex: 1; font-weight: 600; }
.wifi-net .dbm { flex: none; font-size: 12px; color: var(--muted); }
.wifi-net .pick-hint {
  flex: none; font-size: 11.5px; color: var(--brand); opacity: 0; transition: .12s;
}
.wifi-net:hover .pick-hint { opacity: 1; }
.wifi-net.selected { border-color: var(--brand); background: #f0f7f4; }
.wifi-net.selected .ssid::after { content: " ✓ elegida"; font-weight: 400; color: var(--brand); }

/* ---- Forms ---- */
label.fl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input.in, select.in {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--ink);
}
input.in:focus, select.in:focus { outline: none; border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
     text-transform: uppercase; letter-spacing: .3px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: #e7f4ee; color: var(--brand); }
.badge.lime  { background: #eef7df; color: #5a7d1e; }
.badge.warn  { background: #fcf2e2; color: #9a6612; }
.badge.danger{ background: #fae9e8; color: var(--danger); }
.badge.gray  { background: #eef1f0; color: var(--muted); }

/* ---- Efficiency bar ---- */
.effbar { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; min-width: 90px; }
.effbar > span { display: block; height: 100%; background: var(--brand); }

/* ---- Hourly chart (24h) ---- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 6px; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart .bar { width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 1px; transition: height .2s; }
.chart .bar.off { background: var(--warn); }
.chart .bar.idle { background: var(--line); }
.chart .hr { font-size: 9px; color: var(--muted); }
.chart-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.worklabel { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

/* ---- Modal ---- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,30,28,.45); display: none;
            align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal .m-head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 600; border-top: 3px solid var(--accent); border-radius: var(--radius) var(--radius) 0 0; }
.modal .m-body { padding: 18px; }
.modal .m-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Toast ---- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
         background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 9px;
         font-size: 13.5px; opacity: 0; transition: .25s; pointer-events: none; z-index: 200; }
#toast.show { opacity: 1; }
#toast.ok { background: var(--brand); } #toast.bad { background: var(--danger); }

/* ---- Auth / setup pages ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); width: 100%; max-width: 380px;
             border-top: 4px solid var(--accent); overflow: hidden; }
.auth-card .head { padding: 26px 26px 8px; text-align: center; }
.auth-card .head img { height: 42px; }
.auth-card .head p { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.auth-card .body { padding: 18px 26px 26px; }
.auth-card .body .fl { margin-top: 12px; }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 18px; }
.flash { background: #fae9e8; color: var(--danger); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-top: 10px; }
.net-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px;
            border: 1px solid var(--line); border-radius: 9px; margin-bottom: 8px; cursor: pointer; }
.net-item:hover { border-color: var(--brand); }
.net-item .sig { font-size: 12px; color: var(--muted); }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.5);
        border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ---- Línea de tiempo de actividad (Reportes) — Gantt por máquina ---- */
.tl-legend { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: var(--ink); margin: 10px 0 16px; }
.tl-legend span { display: flex; align-items: center; gap: 8px; }
.tl-legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.tl-scroll { overflow-x: auto; }
#tl-chart { display: block; width: 100%; min-width: 680px; height: auto; }
#tl-chart .row-label { font-size: 12.5px; fill: var(--ink); font-weight: 520; }
#tl-chart .tick { font-size: 10.5px; fill: var(--muted); font-family: ui-monospace, monospace; }
#tl-chart .gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; }
#tl-chart .axis-title { font-size: 11px; fill: var(--muted); letter-spacing: .08em; }
#tl-chart .seg { cursor: pointer; }
#tl-chart .seg:hover { opacity: .82; }
#tl-tip {
  position: fixed; pointer-events: none; opacity: 0; transition: opacity .08s;
  background: #fff; border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow);
  font-size: 12px; padding: 7px 10px; border-radius: 8px; z-index: 50; white-space: nowrap;
}
#tl-tip .t-state { font-weight: 600; }
#tl-tip .t-meta { color: var(--muted); font-size: 11px; margin-top: 2px; font-family: ui-monospace, monospace; }
.tl-summary { margin-top: 22px; }
.tl-summary h3 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.tl-summary td.num { font-family: ui-monospace, monospace; text-align: right; }
.tl-summary th.num { text-align: right; }
.dist { display: flex; height: 9px; border-radius: 5px; overflow: hidden; min-width: 120px; }
.dist > span { display: block; height: 100%; }

/* ---- Pase de lista matinal ---- */
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rc-chip { font-size: 12px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); }
.rc-chip.ok { color: var(--ok); border-color: var(--ok); }
.rc-chip.miss { color: var(--danger); border-color: var(--danger); }

/* ---- Calibración ---- */
.cal-fb { margin: 14px 0; padding: 10px 12px; border-radius: 8px; font-size: 13px;
          border: 1px solid var(--line); background: #fafbfb; color: var(--ink); }
.cal-fb.ok-fb { border-color: var(--ok); color: var(--ok); background: #f3fbf6; }
.cal-fb.warn-fb { border-color: var(--warn); color: var(--warn); background: #fdf7ec; }
.cal-fb.bad-fb { border-color: var(--danger); color: var(--danger); background: #fdf2f1; }

/* ---- Advertencia de dumpers que no reportan ---- */
.req-warn { margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; font-size: 13px;
            border: 1px solid var(--warn); color: var(--warn); background: #fdf7ec; }
.req-warn b { color: var(--danger); }

/* ---- Gestión de obras ---- */
.obra-item { display: flex; align-items: center; justify-content: space-between;
             padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
             margin-bottom: 6px; font-size: 13px; gap: 12px; }
.obra-item span { flex: 1; }

/* ---- Icono ⓘ + tooltip flotante (posición fixed, nunca queda detrás de cards) ---- */
.has-tip { position: relative; }
.info-icon {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 15px;
  height: 15px;
  background: #97a5a2;
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 800;
  font-style: normal;
  font-family: "Segoe UI", Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  z-index: 10;
  line-height: 1;
  user-select: none;
  transition: background .12s;
}
.info-icon:hover { background: #5e6e6b; }

#info-tip {
  position: fixed;
  background: rgba(20, 32, 30, 0.93);
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  max-width: 280px;
  line-height: 1.45;
  text-align: center;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity .14s;
  white-space: normal;
}
#info-tip.show { opacity: 1; }

/* ---- Anomalías fuera de horario ---- */
.anomaly-row { font-size: 13px; }
.anomaly-row td { padding: 6px 10px; }
.anomaly-badge { display: inline-block; padding: 2px 8px; border-radius: 12px;
                 font-size: 11px; font-weight: 600; background: #fdf2f1;
                 color: var(--danger); border: 1px solid var(--danger); }

/* ---- Botón PDF / exportar ---- */
.btn.pdf { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.pdf:hover { background: var(--brand); color: #fff; }

/* ---- Alerta de anomalías en pestaña Reportes ---- */
#anomaly-section { margin-top: 10px; }
.anomaly-alert-banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-radius: 8px; font-size: 13px; border: 1px solid #f0b8b4;
  background: #fef5f4; color: var(--danger); margin-bottom: 12px;
}
.anomaly-alert-banner .count-badge {
  background: var(--danger); color: #fff; border-radius: 12px;
  padding: 1px 8px; font-weight: 700; font-size: 12px;
}
.anomaly-card { border-left: 3px solid var(--danger) !important; }
.count-badge { display: inline-block; background: var(--danger); color: #fff;
               border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700;
               margin-left: 6px; vertical-align: middle; }

/* ---- Impresión / PDF ---- */
@media print {
  .topbar, .tabs, .btn, .row-actions, #rep-req-wrap, #anomaly-section .btn,
  #tl-tip, .toast, .tooltip-wrap { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { max-width: 100%; margin: 0; padding: 0 10mm; }
  .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .panel { display: block !important; }
  #reportes { display: block !important; }
  .panel:not(#reportes) { display: none !important; }
  svg#tl-chart { max-width: 100%; height: auto; }
}

/* ===================== Mapa / geocercas ===================== */
#toast.warn { background: var(--warn); }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.map-card { margin-bottom: 0; }
.map-box { height: 560px; width: 100%; background: #dfe5e3; }
.map-note { font-size: 11.5px; margin: 0; padding: 8px 18px; }
.map-side .card { margin-bottom: 18px; }
.map-pos { font-size: 13px; margin-top: 10px; line-height: 1.55; }
.map-pos .bad, #map-fence-info .bad { color: var(--danger); }
.map-chk { display: block; font-size: 13px; padding: 3px 0; cursor: pointer; }
.map-label { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 6px;
             font-weight: 600; font-size: 12px; color: var(--ink); box-shadow: none; padding: 1px 6px; }
.map-label::before { display: none; }
@media (max-width: 980px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-box { height: 420px; }
}

/* ===================== Desglose de tramos (línea de tiempo) ===================== */
#tl-tip .t-break { font-size: 12px; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
#tl-tip .t-break.muted { color: var(--muted); font-size: 11px; }
#tl-tip .t-dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
#tl-tip .t-close { font-size: 10.5px; color: var(--muted); margin-top: 6px; text-align: right; }
#tl-tip.pinned { box-shadow: 0 6px 22px rgba(0,0,0,.18); border: 1px solid var(--line); }
.seg-g { cursor: pointer; }
td.sub, th.sub { color: var(--muted); font-size: 12px; }
#tl-tip .t-break.muted { white-space: normal; max-width: 280px; }
