:root {
  --bg-body: #f5f7fb;
  --bg-elevated: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-sidebar-active: #eef2ff;

  --border-soft: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;

  --primary: #2563eb;
  --primary-soft: #e0ecff;
  --primary-dark: #1d4ed8;

  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;

  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 18px 45px rgba(15, 23, 42, 0.06);
  --shadow-header: 0 10px 25px rgba(15, 23, 42, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-main);
  background: var(--bg-body);
  height: 100%;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: var(--shadow-header);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-menu-toggle {
  border: 1px solid var(--border-soft);
  background: #ffffff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.app-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-main);
}

.app-pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f9fafb;
}

/* ===================== */
/* LAYOUT                */
/* ===================== */

.app-shell {
  display: flex;
  min-height: calc(100vh - 48px);
}

/* BACKDROP NAV MOVIL */
.app-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  display: none;
  z-index: 30;
}

body.nav-open .app-nav-backdrop {
  display: block;
}

/* SIDEBAR */

.app-sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  padding: 12px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 48px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

/* Movil: sidebar deslizable */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    top: 48px;
    left: 0;
    height: calc(100vh - 48px);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
    z-index: 35;
  }

  body.nav-open .app-sidebar {
    transform: translateX(0);
  }
}

/* Ocultar botón menú en escritorio */
@media (min-width: 901px) {
  .app-menu-toggle {
    display: none;
  }
}

/* SIDEBAR contenido */

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-soft);
  padding: 4px 4px;
}

.sidebar-btn {
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 8px 8px;
  display: flex;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.06s ease;
}

.sidebar-btn-main {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.sidebar-btn-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #f3f4f6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar-btn:hover {
  background: #f3f4ff;
}

.sidebar-btn.active {
  background: var(--bg-sidebar-active);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.4);
}

.sidebar-btn.active .sidebar-btn-main {
  color: var(--primary-dark);
}

.sidebar-back-container {
  padding: 20px;
  margin-top: auto;
}

.sidebar-back-btn {
  width: 100%;
  padding: 12px;
  background: #f0f0f0;
  border-radius: 10px;
  text-align: center;
  font-size: 1rem;
  color: #333;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.sidebar-back-btn:hover {
  background: #e4e4e4;
}

/* Mostrar una sola sección a la vez */
.section {
  display: none;          /* todas ocultas */
}

.section.active {
  display: block;         /* solo la activa visible */
}

/* Para que los bloques de la sección se vean en columna normal */
.section .card {
  margin-bottom: 16px;
}
/* MAIN */

.app-main {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

body.modal-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}


/* ===================== */
/* TARJETAS / CONTENEDOR */
/* ===================== */

.card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-card);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 8px;
}

.card-header-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.card-header-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.card-header-icon {
  font-size: 1.1rem;
}

.card-header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Toolbars generales */
.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;  /* todo alineado a la derecha */
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Asegurar que cualquier toolbar-right dentro de una subsection tenga espacio abajo */
.subsection .toolbar-right {
  margin-bottom: 12px;
}

/* Split lateral (inventario) */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 6px;
}

.detail-card {
  background: #f9fafb;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* RESPONSIVE principal */

@media (max-width: 900px) {
  .app-main {
    padding: 12px;
  }

  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .card {
    padding: 12px 10px;
  }
}

/* ===================== */
/* CAMPOS / FORM         */
/* ===================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  padding: 7px 9px;
  font-size: 0.85rem;
  outline: none;
  background: #ffffff;
  color: var(--text-main);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(37, 99, 235, 0.9);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.textarea {
  resize: vertical;
  min-height: 70px;
}

.search-input {
  min-width: 180px;
}

/* iOS anti-zoom */
@media (max-width: 900px) {
  .input,
  .select,
  .textarea {
    font-size: 16px;
  }
}

/* ===================== */
/* BOTONES               */
/* ===================== */

.btn {
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.15);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  padding: 7px 12px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
  transition: transform 0.08s ease, box-shadow 0.1s ease, filter 0.1s ease;
  white-space: nowrap;
}

.btn-icon {
  font-size: 0.9rem;
}

.btn:hover {
  filter: brightness(1.04);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.2);
}

.btn.secondary {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-soft);
  box-shadow: none;
}

.btn.secondary:hover {
  background: #f3f4f6;
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 8px 18px rgba(220, 38, 38, 0.2);
}

.btn.danger:hover {
  filter: brightness(1.03);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
  box-shadow: none;
}

/* Toolbars GENERALES de las secciones (Inventario, Revisiones, etc.) */
.section .toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* El buscador crece, los botones mantienen tamaño */
.section .toolbar .search-input {
  flex: 1;
  min-width: 180px;
}

.section .toolbar .btn {
  flex: 0 0 auto;
}

/* Deja espacio entre la toolbar y la lista / mensaje vacío */
.section .toolbar + .empty-msg,
.section .toolbar + .list {
  margin-top: 10px;
}

/* Solo para Revisiones: botón Eliminar a la derecha */
#revVehiculos #btnDeleteVehiculo,
#revBotiquines #btnDeleteBotiquin {
  margin-left: auto;
}

/* Botón circular */

.btn-icon-circle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #ffffff;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, transform 0.06s ease;
}

.btn-icon-circle:hover {
  background: #f3f4f6;
  color: var(--primary-dark);
}

/* Botón "Enviado" en verde */
.btn.success {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-color: rgba(22, 163, 74, 0.4);
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.25);
}

.btn.success:hover {
  filter: brightness(1.03);
}

/* Item seleccionado (para editar / enviar) */
.list-item.selected {
  background: #e0ecff;
  border-color: rgba(37, 99, 235, 0.45);
}

/* Badges de estado de herramienta (ya los usabas en JS) */
.badge-danger {
  border-color: rgba(220, 38, 38, 0.4);
  background: #fee2e2;
  color: #b91c1c;
}

.badge-warning {
  border-color: rgba(245, 158, 11, 0.4);
  background: #fef9c3;
  color: #92400e;
}


/* ===================== */
/* LISTAS                */
/* ===================== */

.list {
  max-height: 420px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: #ffffff;
}

.list-item {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: background 0.08s ease;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item:hover {
  background: #f3f4ff;
}

.list-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.list-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.list-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Estado "para eliminar" */
.list-item.to-delete {
  background: var(--danger-soft);
  border-color: #fecaca;
}

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

.badge {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  background: #f9fafb;
  color: var(--text-muted);
}

.badge-accent {
  border-color: rgba(37, 99, 235, 0.4);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge-outline {
  background: #ffffff;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f9fafb;
}

/* Mensaje vacío */

.empty-msg {
  font-size: 0.8rem;
  color: var(--text-soft);
  padding: 4px 2px 2px;
}

/* ===================== */
/* DETALLE INVENTARIO    */
/* ===================== */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.detail-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.detail-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.detail-image {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-soft);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.detail-image-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-hist {
  max-height: 180px;
  overflow-y: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  background: #ffffff;
}

.history-item {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item-alta {
  border-left: 3px solid #16a34a;
  background: #ecfdf3;
}

.history-item-baja {
  border-left: 3px solid #dc2626;
  background: #fef2f2;
}

.history-type {
  font-weight: 600;
  margin-right: 4px;
  font-size: 0.78rem;
}

.history-item-alta .history-type {
  color: #16a34a;
}

.history-item-baja .history-type {
  color: #dc2626;
}

/* ===================== */
/* SUBTABS               */
/* ===================== */

.subtabs {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: #f9fafb;
  overflow: hidden;
}

.subtab-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.subtab-btn.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.subsection {
  display: none;
  margin-top: 10px;
}

.subsection.active {
  display: block;
}

/* ===================== */
/* TABLA MATERIALES PARTE*/
/* ===================== */

/* Tabla de materiales del parte */
.parte-mat-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* que reparta bien el ancho */
}

.parte-mat-table th,
.parte-mat-table td {
  padding: 6px 8px;
  font-size: 0.85rem;
  text-align: left;
}

@media (max-width: 600px) {
  .parte-mat-table {
    border: 0;
  }

  .parte-mat-table thead {
    display: none;
  }

  .parte-mat-table,
  .parte-mat-table tbody,
  .parte-mat-table tr,
  .parte-mat-table td {
    display: block;
    width: 100%;
  }

  .parte-mat-table tr {
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    padding: 6px;
  }

  .parte-mat-table td {
    padding: 4px 6px;
  }

  .parte-mat-table td:last-child {
    text-align: right;
  }
}

.parte-mat-table th {
  background: #f3f4f6;
  font-weight: 500;
}

/* ===================== */
/* PACKING THUMB         */
/* ===================== */

.packing-thumb {
  width: 64px;
  height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  overflow: hidden;
  flex-shrink: 0;
  background: #f1f5f9;
}

.packing-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}



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

.alert {
  padding: 6px 8px;
  border-radius: 999px;
  background: #fef3c7;
  border: 1px solid #facc15;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #92400e;
}

.tool-row-warning {
  background: #fffbeb;
}

.tool-row-danger {
  background: #fef2f2;
}

/* ===================== */
/* MODAL                 */
/* ===================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.2);
  padding: 14px;
  width: min(440px, 92%);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.modal-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

/* ===================== */
/* IMAGE VIEWER PACKING  */
/* ===================== */

.image-viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.image-viewer-img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.55);
  object-fit: contain;
  background: #000000;
}

/* ===================== */
/* TEXTO DETALLE         */
/* ===================== */

.detail-text {
  font-size: 0.82rem;
  color: var(--text-main);
  white-space: pre-wrap;
}
