/* Agroamb · Sequentur — blanco, liso, minimalista */
:root {
  --ink: #1f1f1f;
  --ink-2: #5f6368;
  --muted: #898781;
  --hairline: #e8e8e6;
  --grid: #eeeeec;
  --page: #ffffff;
  --card: #ffffff;
  --wash: #f7f8f7;
  --accent: #eb6834;        /* naranja Sequentur (validado) */
  --accent-ink: #b34617;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }

/* ---------------- Header ---------------- */
header {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; background: rgba(255,255,255,.95);
  backdrop-filter: blur(6px); z-index: 1200;
}
header img.logo { height: 42px; display: block; }
header .title { font-size: 15px; color: var(--ink-2); font-weight: 400; }
header .spacer { flex: 1; }
.lastdata { text-align: right; }
.lastdata .k { font-size: 11px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; }
.lastdata .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- Chips resumen ---------------- */
.chips {
  display: flex; gap: 28px; flex-wrap: wrap;
  padding: 18px 28px 6px;
}
.chip .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip .k { font-size: 12px; color: var(--ink-2); margin-top: 1px; }

/* ---------------- Layout ---------------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  padding: 18px 28px 40px;
  align-items: start;
}

/* ---------------- Lista de sensores ---------------- */
.panel-title {
  font-size: 12px; color: var(--ink-2); text-transform: uppercase;
  letter-spacing: .6px; margin: 4px 2px 10px; font-weight: 600;
}
.search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  margin-bottom: 12px;
  background: var(--wash);
}
.search:focus { border-color: var(--accent); background: #fff; }
.sensor-list {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: calc(100vh - 260px);
  overflow-y: auto;
}
.s-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--grid);
  cursor: pointer;
}
.s-item:last-child { border-bottom: none; }
.s-item:hover { background: var(--wash); }
.s-item.sel { background: #fdf0e9; box-shadow: inset 3px 0 0 var(--accent); }
.s-item .r1 { display: flex; align-items: baseline; gap: 8px; }
.s-item .imei { font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; flex: 1; }
.s-item .when { font-size: 11px; color: var(--muted); white-space: nowrap; }
.s-item .r2 { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.s-item.nodata { opacity: .55; }
.s-item.nodata .r2 { font-style: italic; }
.bar { flex: 1; height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; }
.pct { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.mm { min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Columna derecha ---------------- */
.right { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.card > h2 {
  margin: 0; padding: 14px 20px 12px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: .6px;
  display: flex; align-items: center; gap: 10px;
}
.card > h2 .sub { font-weight: 400; text-transform: none; color: var(--muted); letter-spacing: 0; }
#map { height: 380px; }

/* Detalle */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail-body { padding: 4px 20px 20px; }
.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 18px; }
.kv .k { font-size: 11px; color: var(--muted); }
.kv .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.kv .v small { font-weight: 400; color: var(--ink-2); font-size: 11px; }

.states { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 4px 10px; border-radius: 14px;
  background: var(--wash); color: var(--ink-2);
  border: 1px solid var(--grid);
}
.state.alert { background: #fbe9e7; color: #99231f; border-color: #f3cfcb; font-weight: 600; }

.depth-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding: 12px 14px;
  background: var(--wash); border-radius: 10px;
}
.depth-row label { font-size: 12.5px; color: var(--ink-2); }
.depth-row input {
  width: 90px; padding: 7px 10px; border: 1px solid var(--hairline);
  border-radius: 8px; font-size: 14px; outline: none; text-align: right;
}
.depth-row input:focus { border-color: var(--accent); }
.depth-row .hint { font-size: 11px; color: var(--muted); width: 100%; }
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  background: var(--ink); color: #fff; font-size: 13px;
  padding: 8px 16px; border-radius: 20px; margin-top: 16px;
}
.btn:hover { background: #000; }
.btn.line { background: #fff; color: var(--ink); border: 1px solid var(--hairline); }
.btn.line:hover { background: var(--wash); }

/* Gráfico */
.chart-wrap { padding: 4px 16px 16px; height: 300px; position: relative; }
.controls { display: flex; gap: 8px; margin-left: auto; }
.controls select {
  border: 1px solid var(--hairline); background: #fff; color: var(--ink-2);
  border-radius: 8px; font-size: 12px; padding: 4px 8px; outline: none;
}

/* Tabla últimas lecturas */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: right; font-weight: 500; color: var(--muted);
  padding: 8px 14px; border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
td {
  padding: 7px 14px; border-bottom: 1px solid var(--grid);
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
.tbl-wrap { overflow-x: auto; }

/* Marcadores */
.pin {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--accent);
  color: var(--ink); font-size: 10px; font-weight: 700;
  box-shadow: 0 1px 5px rgba(0,0,0,.25);
}
.pin.filled { color: #fff; border-color: #fff; }
.leaflet-container { font: inherit; }

footer {
  padding: 20px 28px 30px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--grid);
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .sensor-list { max-height: 340px; }
  header { flex-wrap: wrap; }
}
