/* Estilos generales: colores, tipografía, cabecera, pestañas, listas, formularios y panel lateral. */
/* Layout: cabecera fija con selector de rol y pestañas; área de trabajo en columnas que se apilan en móvil; panel lateral para avisos y formularios */
:root {
  --bg: #edf1f4;
  --surface: #ffffff;
  --surface-2: #f5f7f9;
  --ink: #15202b;
  --muted: #566473;
  --line: #d6dee6;
  --accent: #1c5cc0;
  --accent-ink: #ffffff;
  --accent-soft: #e2ebf9;
  --ok: #1d7448;
  --ok-soft: #dff1e6;
  --warn: #9a5800;
  --warn-soft: #fbeed6;
  --bad: #b0261d;
  --bad-soft: #fae2df;
  --vio: #5f45a6;
  --vio-soft: #ece7f8;
  --neutral-soft: #e6ebf0;
  --scrim: rgba(8, 14, 22, 0.42);
  --f-display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --f-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --r: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f141a;
    --surface: #171f28;
    --surface-2: #1c2530;
    --ink: #e6ecf2;
    --muted: #9aa8b6;
    --line: #2a3644;
    --accent: #72a6f6;
    --accent-ink: #0b1422;
    --accent-soft: #1b2a40;
    --ok: #5fca94;
    --ok-soft: #173226;
    --warn: #f0aa50;
    --warn-soft: #3a2a12;
    --bad: #f2806f;
    --bad-soft: #3d1d1a;
    --vio: #b8a2f2;
    --vio-soft: #2a2342;
    --neutral-soft: #232d39;
    --scrim: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0f141a;
  --surface: #171f28;
  --surface-2: #1c2530;
  --ink: #e6ecf2;
  --muted: #9aa8b6;
  --line: #2a3644;
  --accent: #72a6f6;
  --accent-ink: #0b1422;
  --accent-soft: #1b2a40;
  --ok: #5fca94;
  --ok-soft: #173226;
  --warn: #f0aa50;
  --warn-soft: #3a2a12;
  --bad: #f2806f;
  --bad-soft: #3d1d1a;
  --vio: #b8a2f2;
  --vio-soft: #2a2342;
  --neutral-soft: #232d39;
  --scrim: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.45;
}
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--surface);
}
p {
  margin: 0;
}
.hdr {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.in {
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.hdr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  flex-wrap: wrap;
  padding-block: 10px 4px;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--accent);
}
.brand b {
  display: block;
  font: 700 18px var(--f-display);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand small {
  font-size: 12.5px;
  color: var(--muted);
}
.role {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
select,
input,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}
.role select {
  width: auto;
  max-width: 230px;
}
textarea {
  resize: vertical;
}
.tabs {
  overflow-x: auto;
}
.tabs .in {
  display: flex;
  gap: 2px;
}
.tab {
  appearance: none;
  border: 0;
  background: none;
  font: 500 14px var(--f-body);
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-current='page'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
main.in {
  padding-block: 22px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
h1 {
  font: 700 24px/1.15 var(--f-display);
  margin: 0;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
h2 {
  font: 600 15px var(--f-display);
  margin: 0;
  text-wrap: balance;
}
.bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 14px;
  flex-wrap: wrap;
}
.acts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1.2 var(--f-body);
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--muted);
}
.btn.pri {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.sm {
  padding: 5px 9px;
  font-size: 12.5px;
}
.btn.danger {
  color: var(--bad);
  border-color: var(--bad);
  background: transparent;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sec {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}
.sec-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.sec-b {
  padding: 14px 16px;
}
.cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr));
  gap: 20px;
  align-items: start;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
  align-items: start;
}
.list {
  display: flex;
  flex-direction: column;
}
.item {
  display: grid;
  grid-template-columns: 5.6rem minmax(0, 1fr) auto;
  gap: 4px 14px;
  align-items: start;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
button.item {
  cursor: pointer;
}
button.item:hover {
  background: var(--surface-2);
}
.list > .item:last-child,
.list > details:last-child {
  border-bottom: 0;
}
.ref {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sub {
  color: var(--muted);
  font-size: 12.5px;
}
.desc {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.side.start {
  justify-content: flex-start;
}
html.movil .item {
  grid-template-columns: minmax(0, 1fr);
}
html.movil .side {
  justify-content: flex-start;
}
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--muted);
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.pill.info {
  background: var(--accent-soft);
  color: var(--accent);
}
.pill.vio {
  background: var(--vio-soft);
  color: var(--vio);
}
.pill.o {
  background: transparent;
  box-shadow: inset 0 0 0 1px currentColor;
}
.pill.no {
  text-decoration: line-through;
  font-weight: 600;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi b {
  font: 700 30px/1 var(--f-display);
  font-variant-numeric: tabular-nums;
}
.kpi.bad b {
  color: var(--bad);
}
.kpi span {
  font-size: 13px;
  color: var(--muted);
}
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
/* Buscador corto y el resto de filtros a su lado, en la misma fila (en el móvil, en columna) */
.filters > input[type='search'] {
  flex: 0 1 300px;
  min-width: 180px;
  width: auto;
}
.filters > .chips,
.filters > .franja-filtros {
  flex: 1 1 auto;
  min-width: 0;
}
html.movil .filters {
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
}
html.movil .filters > input[type='search'] {
  flex: none;
  width: 100%;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font: 500 13px var(--f-body);
  color: var(--muted);
  cursor: pointer;
}
.chip[aria-pressed='true'] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.chip i {
  font: normal 400 12px var(--f-mono);
  margin-left: 4px;
  opacity: 0.75;
}
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 16px;
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 12.5px;
  padding-top: 1px;
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
html.movil .kv {
  grid-template-columns: minmax(0, 1fr);
}
html.movil .kv dd {
  margin-bottom: 6px;
}
.mono {
  font-family: var(--f-mono);
  font-size: 13px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lbl {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}
.big {
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.note {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 14px;
}
.note.warn {
  background: var(--warn-soft);
  border-color: transparent;
}
.note.bad {
  background: var(--bad-soft);
  border-color: transparent;
}
.visit,
.hist {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.parte {
  border-left: 3px solid var(--line);
  padding-left: 10px;
}
.empty {
  padding: 16px;
  color: var(--muted);
}
.back {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font: 500 14px var(--f-body);
  padding: 0;
  cursor: pointer;
  align-self: flex-start;
}
.dir {
  border-top: 1px solid var(--line);
}
.dir:first-child {
  border-top: 0;
}
.dir-h {
  padding: 14px 16px 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.fld {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  min-width: 0;
}
.fld.wide,
.wide {
  grid-column: 1/-1;
}
.chk {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  cursor: pointer;
}
.chk input {
  width: auto;
  margin-top: 3px;
}
.checks {
  display: flex;
  gap: 6px 16px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}
.checks label {
  display: flex;
  gap: 6px;
  align-items: center;
}
.checks input {
  width: auto;
}
.formbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
html.movil .form {
  grid-template-columns: minmax(0, 1fr);
}
.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
}
.panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 100%);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
.ph {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.ph h2 {
  font-size: 18px;
}
.x {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.pb {
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  z-index: 60;
  max-width: calc(100% - 32px);
}
.when {
  font: 700 15px/1.2 var(--f-display);
}
details.av {
  border-bottom: 1px solid var(--line);
}
details.av > summary {
  list-style: none;
  cursor: pointer;
}
details.av > summary::-webkit-details-marker {
  display: none;
}
details.av[open] > summary {
  background: var(--surface-2);
}
.av-b {
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
a {
  color: var(--accent);
}

/* Ajustes de la app real */
.note.vio {
  background: var(--vio-soft);
  border-color: transparent;
}
.sec.mant {
  border-color: var(--vio);
}
.sec.mant .sec-h {
  background: var(--vio-soft);
}
.btn.wa {
  color: var(--ok);
  border-color: var(--ok);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn.wa::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
}
.kpi.warn b {
  color: var(--warn);
}
.hb {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hb-plot {
  position: relative;
  height: 190px;
  margin-left: 28px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.hb-grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--line);
}
.hb-grid span {
  position: absolute;
  left: -28px;
  top: -8px;
  width: 22px;
  text-align: right;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hb-col {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 1;
}
.hb-bar {
  width: min(26px, 60%);
  background: var(--accent);
  opacity: 0.55;
  border-radius: 4px 4px 0 0;
  min-height: 0;
}
.hb-col.cur .hb-bar,
.hb-col:hover .hb-bar {
  opacity: 1;
}
.hb-val {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hb-x {
  display: flex;
  gap: 2px;
  margin-left: 28px;
}
.hb-x span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
#print {
  display: none;
}

/* Usuarios agrupados por rol (plegables) */
details.ugrupo > summary {
  cursor: pointer;
  list-style: none;
}
details.ugrupo > summary::-webkit-details-marker {
  display: none;
}
details.ugrupo > summary h2::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s;
}
details.ugrupo[open] > summary h2::before {
  transform: rotate(90deg);
}
details.ugrupo + details.ugrupo {
  margin-top: 14px;
}
.filtros-sel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.pill.rol {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pill.rol i {
  font-style: normal;
}
.rol-av {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.95rem;
  background: var(--neutral-soft);
  color: var(--muted);
}
.rol-av.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.rol-av.info {
  background: var(--accent-soft);
  color: var(--accent);
}
.rol-av.vio {
  background: var(--vio-soft);
  color: var(--vio);
}
.rol-av.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

/* Ubicación del cierre de un parte (solo oficina) */
.ubic-mapa:not(:empty) {
  display: block;
  margin-top: 6px;
}
.ubic-iframe {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line, #ccc);
  border-radius: 8px;
}

/* Apartado plegable «Avisos» de la ficha de usuario o técnico, y notificaciones en este dispositivo */
.avisos-u {
  border: 1px solid var(--line, #d3dbe4);
  border-radius: 8px;
  padding: 8px 12px;
}
.avisos-u > summary {
  cursor: pointer;
}
.avisos-u[open] > summary {
  margin-bottom: 8px;
}
.avisos-u .lbl {
  margin: 10px 0 4px;
}
.avn-push {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.avn-push p {
  margin: 0;
}
