:root {
  --green: #163828;
  --green-soft: #e7f0ea;
  --red: #9d1c24;
  --ink: #1f2420;
  --muted: #5c6560;
  --bg: #eef1ef;
  --line: #d5dbd6;
  --card: #ffffff;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--green); }

img { max-width: 100%; height: auto; }

.site-header {
  background: var(--green);
  color: #fff;
  border-bottom: 4px solid var(--red);
}

.site-header-inner,
.wrap {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}

.site-header-inner > div { min-width: 0; }

.site-header a { color: inherit; text-decoration: none; }

.crest {
  width: 58px;
  max-width: 58px;
  height: auto;
  display: block;
  flex: 0 0 58px;
}

.brand-kicker {
  margin: 0;
  color: #d5e4d4;
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 11px;
}

.brand-title {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 650;
}

.brand-sub {
  margin: 2px 0 0;
  color: #d7e0d8;
  font-size: 13px;
}

.site-main { padding: 28px 0 48px; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0 28px;
  background: #fff;
}

.site-footer p { margin: 3px 0; }

.site-footer a { color: var(--muted); }

h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.25;
  font-weight: 650;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 650;
}

.lead {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 40rem;
}

.portada {
  max-width: 640px;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 22px 22px 18px;
}

.pasos {
  margin: 16px 0 0;
  padding-left: 1.15rem;
}

.pasos li { margin: 0 0 6px; }

.ficha {
  box-sizing: border-box;
  width: min(640px, 100%);
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--green);
  padding: 7px;
  overflow: hidden;
}

.ficha-marco { border: 1px solid var(--green); }

.ficha-cabeza {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--green);
  color: #fff;
}

.ficha-cabeza .crest {
  width: 64px;
  max-width: 64px;
  flex: 0 0 64px;
  background: #fff;
  padding: 4px;
}

.ficha-cabeza > div { min-width: 0; }

.ficha-muni {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
}

.ficha-lugar {
  margin: 3px 0 0;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #d7e6d4;
}

.ficha-doc {
  margin: 6px 0 0;
  font-size: 14px;
  color: #e6eee7;
}

.banda {
  margin: 0;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--green);
}

.banda.ok {
  color: #145c24;
  background: #f3faf4;
}

.banda.off {
  color: #8d1422;
  background: #fdf6f6;
}

.identidad {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  background: #f7f8f7;
  border-bottom: 1px solid var(--green);
}

.identidad > div { padding: 16px 18px 14px; }

.identidad > div + div { border-left: 1px solid var(--line); }

.registro-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.identidad-valor {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.2;
}

.registro-grande {
  margin: 2px 0 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  word-break: break-word;
}

.datos {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.datos div {
  display: block;
  margin: 0;
  padding: 16px 18px 15px;
  border-bottom: 1px solid var(--line);
}

.datos div.ancho { grid-column: 1 / -1; }

.datos div:nth-child(odd):not(.ancho) { border-right: 1px solid var(--line); }

.datos dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}

.datos dd {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 650;
}

.datos dd.placa {
  font-family: Consolas, "Courier New", monospace;
  font-size: 20px;
  letter-spacing: 0.06em;
}

.ficha-pie {
  padding: 14px 18px 16px;
  background: #f6f8f6;
}

.ficha-pie p {
  margin: 0;
  color: #3e4742;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: break-word;
}

.ficha-pie .firma {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.nota {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.vacio {
  width: min(560px, 100%);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 22px;
}

.menu-principal {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.menu-principal a {
  padding: 10px 16px;
  color: var(--ink);
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.menu-principal a:hover { background: #f3f6f4; }

.menu-principal a.activo {
  color: var(--green);
  border-bottom-color: var(--green);
  background: var(--green-soft);
}

.admin-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn, button, .btn-link {
  appearance: none;
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: 2px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--ink);
}

.btn-primary, button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.btn-primary:hover, button.primary:hover { background: #0f291c; }

.btn-ghost {
  background: #fff;
  color: var(--green);
  border-color: #b7c4bb;
}

.btn-danger {
  background: #fff;
  color: var(--red);
  border-color: #e4c4c8;
}

.btn-ok {
  background: #fff;
  color: #145c24;
  border-color: #b7d7c0;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.layout-lista { grid-template-columns: 1fr; }

.cuenta { position: relative; }

.cuenta-btn {
  background: #fff;
  color: var(--green);
  border: 1px solid #b7c4bb;
  gap: 8px;
}

.icono-usuario { width: 18px; height: 18px; display: block; }

.cuenta-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
}

.cuenta-menu[hidden] { display: none; }

.cuenta-rol {
  margin: 0;
  padding: 6px 10px 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cuenta-menu a,
.cuenta-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 600;
  text-decoration: none;
}

.cuenta-menu a:hover,
.cuenta-menu button:hover { background: #f3f6f4; }

.fila-accion { display: flex; gap: 6px; align-items: center; }

.fila-accion select { width: auto; margin: 0; }

.card, .login-box, .aviso {
  background: var(--card);
  border: 1px solid var(--line);
}

.card { padding: 16px; }

.login-box {
  width: min(420px, 100%);
  margin: 12px auto;
  padding: 20px 18px;
}

.login-box h1 { font-size: 22px; }

label {
  display: block;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 650;
}

input[type="text"], input[type="password"], select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid #c5cdc7;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(22, 56, 40, 0.2);
  border-color: var(--green);
}

.tipo-elige {
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.tipo-elige legend {
  padding: 0;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 650;
}

.tipo-elige label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #c5cdc7;
  font-weight: 600;
  background: #fff;
}

.tipo-elige {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tipo-elige legend { grid-column: 1 / -1; }

.tipo-elige input { margin: 0; }

.tipo-elige label:has(input:checked) {
  border-color: var(--green);
  background: var(--green-soft);
}

.aviso {
  margin: 0 0 14px;
  padding: 12px 14px;
  color: var(--ink);
}

.aviso.error {
  background: #fdf6f6;
  border-color: #e4c4c8;
  color: #8d1422;
}

.aviso.ok {
  background: #f4faf5;
  border-color: #b7d7c0;
  color: #145c24;
}

.panel-admin .site-header-inner,
.panel-admin .wrap {
  width: calc(100% - 48px);
  max-width: none;
}

.tabla-unidades { overflow: visible; }

.tabla-unidades table { table-layout: fixed; }

.col-registro { width: 9%; }
.col-tipo { width: 8%; }
.col-nombre { width: 16%; }
.col-parqueo { width: 18%; }
.col-placas { width: 11%; }
.col-estado { width: 11%; }
.col-acciones { width: 11%; }

.tabla-unidades td,
.tabla-unidades th { overflow-wrap: break-word; }

.panel-admin td { overflow-wrap: break-word; }

.menu-fila { position: relative; display: inline-block; }

.menu-fila-lista {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
  box-shadow: 0 8px 24px rgba(22, 56, 40, 0.12);
}

.menu-fila-lista.abre-arriba {
  top: auto;
  bottom: calc(100% + 4px);
}

.menu-fila-lista[hidden] { display: none; }

.menu-fila-lista a,
.menu-fila-lista button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 600;
  text-decoration: none;
}

.menu-fila-lista a:hover,
.menu-fila-lista button:hover { background: #f3f6f4; }

.menu-fila-lista .peligro { color: var(--red); }

.menu-fila-lista form { margin: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  background: #f6f8f6;
}

th.ordenable a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}

th.ordenable a:hover,
th.ordenable.asc a,
th.ordenable.desc a { color: var(--ink); }

th.ordenable .marca {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  opacity: 0.28;
  flex: 0 0 auto;
}

th.ordenable.asc .marca,
th.ordenable.desc .marca { opacity: 1; }

th.ordenable.desc .marca {
  border-bottom: 0;
  border-top: 5px solid currentColor;
}

.ordenar-movil { display: none; }

.estado {
  display: inline-block;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid;
}

.estado.aprobado {
  background: #f4faf5;
  color: #145c24;
  border-color: #b7d7c0;
}

.estado.suspendido {
  background: #fdf6f6;
  color: var(--red);
  border-color: #e4c4c8;
}

.tabla-unidades td.acciones {
  display: table-cell;
  white-space: normal;
  vertical-align: middle;
}

.acciones { display: flex; flex-wrap: nowrap; gap: 6px; white-space: nowrap; }

.acciones form { margin: 0; }

.acciones .btn, .acciones button { padding: 5px 8px; font-size: 13px; }

.qr-preview {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
}

.qr-preview img {
  width: 160px;
  height: 160px;
  background: #fff;
  border: 1px solid var(--line);
}

.qr-preview p { margin: 0 0 8px; }

.buscar { margin: 0 0 12px; }

.buscar input { max-width: 320px; }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
}

.filtros label {
  margin: 0;
  flex: 1 1 160px;
  max-width: 280px;
}

.filtros label:first-child {
  flex: 2 1 240px;
  max-width: 360px;
}

.filtros input,
.filtros select { max-width: none; }

.filtros .btn { margin-bottom: 1px; }

.eleccion { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }

.parqueo-dir {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.editor {
  width: min(440px, calc(100% - 32px));
  border: 1px solid var(--green);
  padding: 0;
  background: #fff;
}

.editor::backdrop { background: rgba(22, 56, 40, 0.45); }

.editor form,
.editor-cuerpo { padding: 18px 18px 16px; }

.editor h2 { margin-bottom: 8px; }

.tipo-fijo {
  margin: 0 0 14px;
  padding: 8px 10px;
  background: #f6f8f6;
  border: 1px solid var(--line);
  font-size: 14px;
}

.editor-acciones { display: flex; gap: 8px; }

.ayuda {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

@media (max-width: 860px) {
  .layout, .qr-preview { grid-template-columns: 1fr; }
  .site-header-inner { align-items: flex-start; }
  .admin-bar { flex-direction: column; align-items: flex-start; }
  .panel-admin .site-header-inner,
  .panel-admin .wrap { width: calc(100% - 24px); }
  .tabla-unidades table,
  .tabla-unidades thead,
  .tabla-unidades tbody,
  .tabla-unidades tr,
  .tabla-unidades td { display: block; width: 100%; }
  .tabla-unidades { overflow: visible; }
  .tabla-unidades table { table-layout: auto; }
  .tabla-unidades thead { display: none; }
  .ordenar-movil { display: block; flex: 1 1 140px; max-width: 220px; }
  .tabla-unidades tr {
    border: 1px solid var(--line);
    margin: 0 0 10px;
    padding: 8px 10px;
  }
  .tabla-unidades td {
    border: 0;
    padding: 4px 0;
  }
  .tabla-unidades td::before {
    content: attr(data-etiqueta);
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
  }
}

@media (max-width: 520px) {
  .crest { width: 48px; }
  .brand-title { font-size: 16px; }
  .ficha-cabeza { align-items: flex-start; padding: 14px; }
  .ficha-cabeza .crest { width: 56px; max-width: 56px; flex-basis: 56px; }
  .ficha-muni { font-size: 20px; }
  .identidad > div, .datos div, .banda, .ficha-pie { padding-left: 14px; padding-right: 14px; }
  .identidad, .datos { grid-template-columns: 1fr; }
  .identidad > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .datos div:nth-child(odd):not(.ancho) { border-right: 0; }
  .registro-grande { font-size: 28px; }
}
