:root {
  --navy: #132b50;
  --navy-dark: #0d1e38;
  --gold: #ffca50;
  --green: #2e8b57;
  --red: #c0392b;
  --gray: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--gray);
  color: #1a1a1a;
}

header.topbar {
  background: var(--navy);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px solid var(--gold);
}

header.topbar .brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

header.topbar a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  opacity: 0.85;
}
header.topbar a:hover { opacity: 1; text-decoration: underline; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.card {
  background: white;
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}

.login-card {
  width: 340px;
  text-align: center;
}
.login-card h1 { color: var(--navy); font-size: 22px; margin-bottom: 4px; }
.login-card p.sub { color: #666; font-size: 13px; margin-top: 0; margin-bottom: 20px; }

.home-card { width: 340px; text-align: center; }
.home-card h1 { color: var(--navy); font-size: 22px; margin-bottom: 4px; }
.home-card p.sub { color: #666; font-size: 13px; margin-top: 0; }
.depto-buttons { display: flex; flex-direction: column; gap: 12px; }
.depto-btn { font-size: 16px; padding: 14px; }

@media (max-width: 640px) {
  .home-card { width: 92vw; padding: 26px 20px; }
}

input[type=password], input[type=text], input[type=number], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 14px;
}

label { font-size: 13px; font-weight: 600; color: var(--navy); display: block; margin-bottom: 4px; }

.btn {
  display: inline-block;
  background: var(--navy);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--navy-dark); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { background: #e6b333; }
.btn-block { width: 100%; }
.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--navy);
}
.btn-outline:hover {
  background: var(--navy);
  color: white;
}

.role-grid {
  display: flex;
  gap: 20px;
  justify-content: center;
}
.role-card {
  width: 220px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
}
.role-card:hover { border-color: var(--gold); }
.role-card h3 { color: var(--navy); margin: 10px 0 4px; }
.role-card p { color: #666; font-size: 13px; }

.flash {
  background: #fff3cd;
  border: 1px solid #ffe58f;
  color: #7a5b00;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

h1.page-title { color: var(--navy); margin-bottom: 4px; }
p.page-sub { color: #666; margin-top: 0; margin-bottom: 24px; font-size: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.recientes {
  margin-top: 30px;
}
.recientes h2 { font-size: 16px; color: var(--navy); }
.thumb-row { display: flex; gap: 12px; flex-wrap: wrap; }
.thumb {
  width: 110px;
  text-align: center;
  font-size: 12px;
}
.thumb img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
}
.thumb .codigo { font-weight: 700; color: var(--navy); margin-top: 4px; }

.search-bar {
  background: white;
  padding: 20px;
  border-radius: 10px;
  display: flex;
  gap: 14px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.search-bar .field { min-width: 140px; }
.search-bar label { margin-bottom: 6px; }
.search-bar input, .search-bar select { margin-bottom: 0; }

.carousel {
  display: flex;
  gap: 18px;
  overflow-x: auto;
  padding: 10px 4px 20px;
}
.carousel-card {
  background: white;
  border-radius: 10px;
  min-width: 240px;
  max-width: 240px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
  flex-shrink: 0;
}
.carousel-card .photo {
  width: 100%;
  height: 200px;
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-card .photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.carousel-card .info { padding: 12px; }
.carousel-card .codigo { font-weight: 700; color: var(--navy); font-size: 16px; }
.carousel-card .specs { font-size: 12px; color: #555; margin: 4px 0 10px; }
.carousel-card .actions { display: flex; gap: 6px; }
.carousel-card .actions form, .carousel-card .actions a { flex: 1; }
.carousel-card .actions .btn { width: 100%; padding: 8px; font-size: 12px; text-align: center; }

.filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px 18px;
}
.filmstrip .fs-thumb {
  width: 56px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  flex-shrink: 0;
  cursor: pointer;
}
.filmstrip .fs-thumb.active { border-color: var(--gold); }
.filmstrip .fs-thumb img { width: 100%; height: 100%; object-fit: contain; }

.grid-section { margin-top: 34px; }
.grid-section h2 { font-size: 16px; color: var(--navy); }
.grid-table {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
}
.grid-cell {
  padding: 8px 0;
  text-align: center;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}
.grid-cell.disponible { background: var(--green); }
.grid-cell.reservado { background: var(--red); }
.grid-cell.baja { background: #888; }
.grid-cell:hover { opacity: 0.85; }

.ficha-grid { display: grid; grid-template-columns: 260px 1fr; gap: 30px; }
.ficha-photo { background: white; border-radius: 10px; padding: 16px; text-align: center; }
.ficha-photo img { max-width: 100%; border-radius: 6px; }
.ficha-qr { margin-top: 14px; }
.ficha-qr img { width: 130px; height: 130px; }
.estado-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; color: white; }
.estado-badge.disponible { background: var(--green); }
.estado-badge.reservado { background: var(--red); }
.estado-badge.baja { background: #888; }

.detail-table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; }
.detail-table td { padding: 10px 16px; border-bottom: 1px solid #eee; font-size: 14px; }
.detail-table td:first-child { font-weight: 700; color: var(--navy); width: 180px; }

.mov-table { width: 100%; border-collapse: collapse; margin-top: 12px; background: white; border-radius: 10px; overflow: hidden; }
.mov-table th { background: var(--navy); color: white; text-align: left; padding: 8px 12px; font-size: 12px; }
.mov-table td { padding: 8px 12px; font-size: 12px; border-bottom: 1px solid #eee; }

.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 10px; padding: 18px 24px; text-align: center; min-width: 120px; }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--navy); }
.stat-card .lbl { font-size: 12px; color: #666; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .lbl { width: 100px; font-size: 13px; }
.bar-row .bar-bg { flex: 1; background: #eee; border-radius: 6px; height: 14px; overflow: hidden; }
.bar-row .bar-fill { background: var(--navy); height: 100%; }
.bar-row .val { width: 30px; font-size: 12px; text-align: right; }

.pagination { margin-top: 14px; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.pagination a { color: var(--navy); text-decoration: none; font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 12px; margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.grid-scroll { overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.grid-table { min-width: 640px; }

.grid-photo-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 4px 14px;
  -webkit-overflow-scrolling: touch;
}
.grid-photo-card {
  flex-shrink: 0;
  width: 92px;
  text-align: center;
  text-decoration: none;
  color: inherit;
}
.grid-photo-thumb {
  position: relative;
  width: 92px;
  height: 92px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}
.grid-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.grid-photo-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 2px rgba(0,0,0,0.4);
}
.grid-photo-dot.disponible { background: var(--green); }
.grid-photo-dot.reservado { background: var(--red); }
.grid-photo-dot.baja { background: #888; }
.grid-photo-codigo {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 4px;
}

/* --------------------------------------------------------------------- */
/* Movil / pantallas estrechas                                            */
/* --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .container { padding: 16px 14px 50px; }

  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 12px 16px;
  }
  header.topbar .brand { font-size: 17px; }
  header.topbar a { font-size: 13px; }

  .login-card { width: 92vw; padding: 26px 20px; }

  .role-grid { flex-direction: column; align-items: center; }
  .role-card { width: 85vw; max-width: 320px; }

  .card { padding: 20px; }

  h1.page-title { font-size: 20px; }

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

  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar .field { min-width: 0; width: 100%; }
  .search-bar .btn { width: 100%; }

  .carousel-card { min-width: 78vw; max-width: 78vw; }

  .ficha-grid { grid-template-columns: 1fr; gap: 18px; }

  .detail-table td { display: block; width: 100% !important; padding: 8px 14px; }
  .detail-table td:first-child { border-bottom: none; padding-bottom: 2px; }
  .detail-table tr { display: block; border-bottom: 1px solid #eee; }

  .mov-table { display: block; overflow-x: auto; white-space: nowrap; }

  .stat-cards { gap: 10px; }
  .stat-card { min-width: 90px; padding: 14px 16px; }

  /* Los dos botones de "hacer foto" / "elegir archivo" apilados y a ancho
     completo, mas comodos para el pulgar en movil */
  #btn-camara, #btn-galeria { flex: 1; }
}
