/* ==========================================================================
   ALERTA MESH — app.css
   Paleta Meshtastic (verde sobre grafito), modo oscuro y claro. 100% offline.
   ========================================================================== */
@font-face { font-family: "Plex Sans"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Plex Sans"; font-weight: 700; font-display: swap; src: url(../fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-mono-latin-500-normal.woff2) format("woff2"); }

:root, :root[data-theme="dark"] {
  --bg: #22232E; --rail: #1B1C25; --surface: #2C2D3C; --hover: #2C2D3C; --selected: #383A4D;
  --line: #34354A; --line-2: #3D3F52; --text: #F4F4F6; --text-2: #E4E5EC; --muted: #B4B6C6; --faint: #8E90A3;
  --btn: #67EA94; --btn-text: #13261A;
  --green: #67EA94; --red: #FF6B6B; --amber: #F7B955; --blue: #79B8FF; --grey: #9C9EB0;
  --tile-filter: brightness(.55) saturate(.45) invert(1) hue-rotate(180deg) brightness(.9) contrast(.9);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F4F5F7; --rail: #FFFFFF; --surface: #FFFFFF; --hover: #EEF0F4; --selected: #E7F6EC;
  --line: #E3E5EA; --line-2: #D3D6DD; --text: #1B1C25; --text-2: #3A3C4A; --muted: #5E6172; --faint: #8A8FA0;
  --green: #157A3C; --red: #C93434; --amber: #A15C00; --blue: #1F5FBF; --grey: #6B6E80;
  --tile-filter: none;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Plex Sans", "Segoe UI", system-ui, sans-serif; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.mono { font-family: "Plex Mono", ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; color: var(--text); font-weight: 500; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--faint); color: var(--text); }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--primary { background: var(--btn); border-color: var(--btn); color: var(--btn-text); font-weight: 600; }
.btn--primary:hover:not(:disabled) { color: var(--btn-text); filter: brightness(1.06); }
.btn--invert { background: var(--text); border-color: var(--text); color: var(--rail); font-weight: 600; }
.btn--invert:hover:not(:disabled) { color: var(--rail); }
.btn--danger { background: var(--red); border-color: var(--red); color: var(--rail); font-weight: 600; }
.btn--danger:hover:not(:disabled) { color: var(--rail); }
.btn--outline { border-color: var(--green); color: var(--green); background: transparent; font-weight: 600; }
.btn--outline:hover { color: var(--green); }
.btn[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }
.link { background: none; border: 0; padding: 4px; color: var(--green); font-size: 13px; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; color: var(--text); }
textarea { resize: none; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea { font-size: 14px; }

.segmented { display: flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.segmented button { flex: 1; min-height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 34px; padding: 0 10px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 6px; font-size: 12.5px; color: var(--text-2); }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.grow { flex: 1 1 180px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack--end { margin-top: auto; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--grey); flex: none; }
.dot--square { border-radius: 2px; }
.dot--green { background: var(--green); } .dot--red { background: var(--red); }
.dot--amber { background: var(--amber); } .dot--blue { background: var(--blue); }
.c-green { color: var(--green); } .c-red { color: var(--red); } .c-amber { color: var(--amber); } .c-blue { color: var(--blue); } .c-grey { color: var(--grey); }
.state { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.state .dot { background: currentColor; }

/* ---------- Estructura ---------- */
.shell { display: flex; min-height: 100vh; }
.rail { flex: 0 0 236px; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--rail); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand__name { font-weight: 700; font-size: 16px; }
.brand__site { color: var(--muted); font-size: 12.5px; }
.logo-a { fill: none; stroke: var(--text); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.logo-net { fill: none; stroke: var(--green); stroke-width: 2; }
.logo-node { fill: var(--rail); stroke: var(--green); stroke-width: 2; }
.logo-dot { fill: var(--green); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--hover); color: var(--text); }
.nav__label { flex: 1; }
.badge { min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: var(--red); color: var(--rail); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.sys { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.sys__row { display: flex; gap: 10px; align-items: flex-start; }
.sys__row .dot { margin-top: 6px; }
.sys__row b { font-weight: 500; }
.sys__meter { display: flex; justify-content: space-between; font-size: 12.5px; }
.bar { height: 4px; margin-top: 6px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar span { display: block; height: 4px; width: 0; background: var(--btn); }
.rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.university { display: flex; align-items: center; gap: 10px; padding: 10px; background: #F5F5F5; border: 1px solid var(--line-2); border-radius: 8px; color: #3D3D3D; font-size: 11.5px; line-height: 1.3; }
.university img { height: 40px; width: auto; max-width: 90px; object-fit: contain; }

.content { flex: 1; min-width: 0; }
.view { display: flex; flex-direction: column; gap: 16px; padding: 18px 24px 24px; }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.head .muted { font-size: 13px; }
.head__right { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.clocks { display: flex; gap: 16px; font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.card__head { padding: 14px 16px 8px; }
.card .muted { font-size: 13px; }
.card.pad { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }

.alert { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; border-radius: 10px; border: 1px solid var(--red);
  background: color-mix(in srgb, var(--red) 12%, transparent); }
.alert > .ic { width: 22px; height: 22px; color: var(--red); }
.alert__text { flex: 1 1 320px; }

.stats { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stat { flex: 1 1 170px; padding: 12px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat__label { color: var(--muted); font-size: 12.5px; }
.stat__value { font-size: 24px; font-weight: 500; margin-right: 8px; }
.stat__note { color: var(--muted); font-size: 12.5px; }

/* ---------- Operación ---------- */
.ops { display: grid; grid-template-columns: minmax(270px, 1fr) minmax(380px, 2fr) minmax(330px, 1.2fr); gap: 16px; align-items: stretch; }
.ops > .card { height: max(820px, calc(100vh - 220px)); display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 8px; border-bottom: 1px solid var(--line-2); }
.tabs button { min-height: 38px; padding: 0 2px; background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; color: var(--muted); }
.tabs button[aria-selected="true"] { border-bottom-color: var(--green); color: var(--text); font-weight: 600; }
.queue__list { flex: 1; overflow: auto; padding: 6px 8px 10px; }
.item { width: 100%; text-align: left; display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 12px; align-items: start; padding: 12px 10px; border: 0; border-radius: 8px; background: transparent; }
.item:hover { background: var(--bg); }
.item[aria-current="true"] { background: var(--selected); }
.item .dot { width: 10px; height: 10px; margin-top: 5px; }
.item__title { display: block; font-weight: 600; }
.item__sub { display: block; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.item__side { text-align: right; font-size: 12.5px; font-weight: 500; }
.item__side .mono { display: block; color: var(--text-2); font-weight: 400; font-size: 13px; }
.empty { padding: 20px 12px; color: var(--muted); font-size: 13px; }

.maptools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.maptools__right { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.maptools select { width: auto; min-height: 36px; font-size: 13px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; }
.checks input { width: 16px; height: 16px; accent-color: var(--btn); }
.mapwrap { position: relative; flex: 1; min-height: 320px; }
#map { position: absolute; inset: 0; background: var(--bg); }
.maphint { position: absolute; z-index: 600; left: 50%; top: 10px; transform: translateX(-50%); padding: 6px 12px; background: var(--rail); border: 1px solid var(--amber); border-radius: 6px; color: var(--amber); font-size: 13px; white-space: nowrap; pointer-events: none; }
.is-planning #map { cursor: crosshair; }
.legend { position: absolute; z-index: 500; left: 10px; bottom: 10px; max-width: calc(100% - 70px); margin: 0; padding: 7px 10px; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 12px; background: var(--rail); border: 1px solid var(--line); border-radius: 8px; font-size: 11.5px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.ring-key { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--green); }
.line-key { width: 14px; border-top: 2px dashed var(--green); }
.coverage { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-height: 52px; max-height: 150px; overflow: auto; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 13px; }
.coverage .verdict { flex-basis: 100%; }
.coverage .tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }

.detail__empty { margin: auto; padding: 24px; text-align: center; }
.detail__body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.detail__top { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.detail__top h2 { font-size: 21px; }
.detail__meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.quote { margin: 0; padding: 10px 12px; background: var(--bg); border-radius: 8px; color: var(--text-2); overflow-wrap: anywhere; max-height: 90px; overflow: auto; }
.detail__scroll { flex: 1; min-height: 0; overflow: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 16px; }
.detail__actions { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.detail__actions .progress { margin: 0; }
.detail__reply { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.facts .full { grid-column: 1 / -1; }
.routes { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.routes span { display: flex; gap: 8px; align-items: center; }
.progress { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; font-size: 12px; }
.progress li { padding-top: 8px; border-top: 4px solid var(--line-2); color: var(--muted); }
.progress li.done { color: var(--text); border-top-color: currentColor; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.log li { display: grid; grid-template-columns: 46px 1fr; gap: 10px; overflow-wrap: anywhere; }
.log--lined li { padding-bottom: 8px; border-bottom: 1px solid var(--line); }

/* ---------- Puntos y red ---------- */
.split { display: flex; flex-wrap: wrap; gap: 16px; }
.split > .wide { flex: 999 1 640px; }
.split > .narrow { flex: 1 1 300px; }
.thirds { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.mono { white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 12px; }
.meter { display: inline-block; width: 48px; height: 4px; margin-right: 8px; vertical-align: middle; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.meter span { display: block; height: 4px; background: var(--green); }
.search { display: flex; align-items: center; gap: 8px; padding-left: 12px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; color: var(--muted); }
.search input { border: 0; background: transparent; padding-left: 0; }
.people, .notices { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.people li { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.notices li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; overflow-wrap: anywhere; }
.bignum { display: flex; align-items: baseline; gap: 10px; }
.bignum .mono { font-size: 28px; font-weight: 500; }
.chart { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 96px; border-bottom: 1px solid var(--line-2); }
.chart i { flex: 1; min-height: 1px; background: var(--btn); border-radius: 2px 2px 0 0; }
.chart i.hi { background: var(--amber); }
.chart i.none { background: transparent; }
.chart b { position: absolute; left: 0; right: 0; bottom: 80%; border-top: 1px dashed var(--amber); }
.kv { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- Radio ---------- */
.radiocard { display: flex; flex-direction: column; max-width: 860px; height: max(520px, calc(100vh - 130px)); }
.chat { flex: 1; overflow: auto; padding: 8px 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; align-self: flex-start; }
.msg--mine { align-self: flex-end; text-align: right; }
.msg__meta { color: var(--muted); font-size: 12px; }
.msg__text { display: inline-block; padding: 8px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); overflow-wrap: anywhere; text-align: left; }
.msg--sos .msg__text { border-color: var(--red); }

/* ---------- Diálogo, aviso emergente, mapa ---------- */
dialog { width: min(440px, calc(100vw - 32px)); padding: 20px; background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toast { position: fixed; z-index: 2000; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; background: var(--rail); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

.leaflet-container { background: var(--bg); font: 12px "Plex Sans", system-ui, sans-serif; }
.tiles-street { filter: var(--tile-filter); }
.mk { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.mk-inc { border-radius: 50%; border: 3px solid var(--rail); background: var(--grey); }
.mk-inc.sel { border-color: var(--text); }
.mk-inc.dot--red { background: var(--red); } .mk-inc.dot--amber { background: var(--amber); } .mk-inc.dot--blue { background: var(--blue); }
.mk-point { border-radius: 6px; background: var(--btn); border: 2px solid var(--rail); color: var(--btn-text); font-size: 11px; font-weight: 600; }
.mk-point.low { border-color: var(--amber); }
.mk-point.off { background: var(--surface); border: 2px dashed var(--red); color: var(--red); }
.mk-rep { background: var(--green); clip-path: polygon(50% 8%, 96% 90%, 4% 90%); }
.mk-rep.off, .mk-inst.off, .mk-other.off { background: var(--red); }
.mk-central { background: var(--btn); clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.mk-inst { background: var(--blue); border: 2px solid var(--rail); border-radius: 3px; transform: rotate(45deg); }
.mk-other { background: var(--grey); border: 2px solid var(--rail); border-radius: 50%; }
.mk-plan { background: var(--amber); border: 2px solid var(--rail); transform: rotate(45deg); }
.leaflet-tooltip.tag-map { background: var(--rail); color: var(--text); border: 1px solid var(--line-2); box-shadow: none; padding: 1px 7px; }
.leaflet-tooltip.tag-map::before { display: none; }

/* ---------- Adaptación ---------- */
@media (max-width: 1320px) {
  .ops { grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
  .ops > .detail { grid-column: 1 / -1; height: 720px; }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .rail { position: static; height: auto; flex-basis: auto; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { flex: 1 1 auto; }
  .ops { grid-template-columns: minmax(0, 1fr); }
  .ops > .queue { height: 420px; }
  .ops > .mapcard { height: 640px; }
  .view { padding: 14px; }
  .stat { border-right: 0; }
}
