:root{
  --bg:#0b0f0d;
  --card:#121a16;
  --text:#e7efe9;
  --muted:#a8b8ae;
  --border:#233129;
  --accent:#43d08a;
  --accent-hover:#36b976;
  --danger:#ff6b6b;
  --danger-hover:#e05555;

  --radius:16px;
}

*{ box-sizing:border-box; }
html, body { width:100%; }
body{
  margin:0;
  min-height:100dvh;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);

  background:
    linear-gradient(rgba(10,15,12,0.85), rgba(10,15,12,0.85)),
    url("/assets/bg.jpg");

  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}

/* iOS/Android: background-attachment fixed da problemas con sticky */
@media (max-width: 900px){
  body{ background-attachment: scroll; }
}

/* Evita desbordes por palabras/URLs largas */
a, td, th, .card, .wrap { overflow-wrap:anywhere; word-break:break-word; }

a{
  color:var(--text);
  text-decoration:none;
}
a:hover{ text-decoration:underline; }

.wrap{
  max-width:980px;
  margin:0 auto;
  padding:18px;
}

/* =========================
   HEADER
========================= */

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  border-bottom:1px solid var(--border);
  background: rgba(11,15,13,.85);
  backdrop-filter: blur(10px);

  /* “safe area” (notch) */
  padding-top: env(safe-area-inset-top);
}

.topbar .wrap{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;

  /* CLAVE para que flex pueda encoger y no desborde */
  min-width:0;
}

.brand{
  font-weight:800;
  letter-spacing:.3px;
  font-size:18px;
  white-space:nowrap;

  /* CLAVE para evitar que empuje todo */
  min-width:0;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
}

.nav{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;

  min-width:0;
}

.nav a, .nav .btn{
  white-space:nowrap;
}

/* =========================
   CARDS
========================= */

.card{
  background: linear-gradient(180deg, rgba(18,26,22,.95) 0%, rgba(18,26,22,.75) 100%);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  margin:14px 0;

  min-width:0;
}

.h1{
  font-size:28px;
  margin:8px 0 6px;
}

.h2{
  font-size:18px;
  margin:0 0 10px;
}

.muted{ color:var(--muted); }
.small{ font-size:12px; }

/* =========================
   GRID
========================= */

.grid{
  display:grid;
  gap:12px;
}

.grid-2{
  grid-template-columns: 1fr 1fr;
}

@media(max-width:720px){
  .grid-2{ grid-template-columns:1fr; }
}

/* =========================
   BUTTONS
========================= */

.btn{
  display:inline-block;
  padding:8px 14px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(67,208,138,.15);
  color:#ffffff;
  font-weight:600;
  transition: all .2s ease;
  cursor:pointer;

  min-width:0;
}
.btn:hover{
  background: rgba(67,208,138,.35);
  text-decoration:none;
}

.btn-primary{
  background: var(--accent);
  border-color: var(--accent);
  color:#ffffff;
}
.btn-primary:hover{ background: var(--accent-hover); }

.btn-danger{
  background: var(--danger);
  border-color: var(--danger);
  color:#ffffff;
}
.btn-danger:hover{ background: var(--danger-hover); }

/* =========================
   ALERTAS
========================= */

.alert{
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  margin:12px 0;
}
.alert-error{
  border-color: rgba(255,107,107,.35);
  background: rgba(255,107,107,.12);
}
.alert-success{
  border-color: rgba(67,208,138,.35);
  background: rgba(67,208,138,.12);
}

/* =========================
   FORMULARIOS
========================= */

label{
  display:block;
  margin:10px 0 6px;
}

input, select, textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
  transition: border .2s ease;

  min-width:0;
}

input:focus, textarea:focus, select:focus{
  border-color: var(--accent);
}

textarea{
  min-height:140px;
  resize:vertical;
}

.row{
  display:flex;
  gap:10px;
  align-items:center;
  min-width:0;
}
.row > * { flex:1; min-width:0; }

/* =========================
   TABLAS (desktop)
========================= */

.table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
}

.table{
  width:100%;
  border-collapse: collapse;
}

.table th, .table td{
  border-bottom:1px solid var(--border);
  padding:10px 8px;
  text-align:left;
  vertical-align:top;

  min-width:0;
}

.table th{
  color:var(--muted);
  font-weight:600;
}

/* =========================
   LISTADO HILOS (modo móvil bonito)
   (Usa tu tabla normal, pero en móvil se vuelve “cards”)
========================= */

@media (max-width: 640px){
  .table-wrap{ overflow: visible; }

  .table{
    width:100%;
    display:block;
  }

  .table thead{ display:none; }

  .table tbody{
    display:block;
  }

  .table tr{
    display:block;
    margin:10px 0;
    border:1px solid var(--border);
    border-radius:14px;
    background: rgba(0,0,0,.12);
    overflow:hidden;
  }

  .table td{
    display:flex;
    gap:10px;
    padding:10px 12px;
    border-bottom:1px solid rgba(35,49,41,.6);
    align-items:flex-start;
  }

  .table td:last-child{ border-bottom:0; }

  /* Si usas data-label en cada td, se verá el “título” */
  .table td::before{
    content: attr(data-label);
    flex:0 0 110px;
    color: var(--muted);
    font-weight:600;
  }

  /* Columna “título” más flexible */
  .table td:first-child{
    align-items:flex-start;
  }

  .table td:first-child a{
    display:inline-block;
    max-width:100%;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
}

/* =========================
   BADGES
========================= */

.badge{
  display:inline-block;
  padding:4px 10px;
  border:1px solid var(--border);
  border-radius:999px;
  color:var(--muted);
  font-size:12px;
  max-width:100%;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* =========================
   FOOTER
========================= */

.footer{
  border-top:1px solid var(--border);
  margin-top:28px;
  padding:10px 0;
  color:var(--muted);
  text-align:center;
}

/* =========================
   MOBILE OPTIMIZATIONS (header + nav)
========================= */

@media (max-width: 520px){
  .wrap{ padding: 14px; }

  .brand{ font-size: 16px; }

  .h1{ font-size: 22px; }
  .h2{ font-size: 16px; }

  /* Header: no amontonarse, que quede limpio como en tu captura 2 */
  .topbar .wrap{
    flex-direction: column;
    align-items:flex-start;
    gap:10px;
  }

  /* Nav en “grid” para que no se monte y quede perfecto */
  .nav{
    width:100%;
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:10px;
    justify-content:stretch;
  }

  .nav a, .nav .btn{
    white-space:normal;
    width:100%;
    text-align:center;
  }

  .btn{
    padding:8px 10px;
    font-size:14px;
  }

  /* Formularios: 1 columna */
  .row{
    flex-direction: column;
    align-items: stretch;
  }
}

/* =========================
   CIUDADES (sección nueva, responsive perfecta)
========================= */

.cities{
  display:grid;
  gap:12px;
}

.cities__head{
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  min-width:0;
}

.cities__search{
  flex: 1 1 240px;
  min-width: 0;
}

.cities__grid{
  display:grid;
  gap:10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.city-chip{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;

  padding:10px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(0,0,0,.18);
  color: var(--text);
  font-weight:600;

  min-width:0;
  text-align:center;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;

  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.city-chip:hover{
  text-decoration:none;
  background: rgba(67,208,138,.18);
  border-color: rgba(67,208,138,.45);
  transform: translateY(-1px);
}

.city-chip .muted{
  font-weight:600;
  color: var(--muted);
}

@media (max-width: 900px){
  .cities__grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px){
  .cities__grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px){
  .cities__grid{ grid-template-columns: 1fr; }
  .city-chip{ white-space:normal; border-radius:14px; }
}