/* ===== Páginas: heading ===== */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h1 { color: #0b3d61; font-size: 22px; }
.page-head .back { font-size: 12px; color: #666; display: block; margin-bottom: 4px; }
.page-head .muted { font-size: 11px; color: #888; margin-top: 2px; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-secondary {
  background: #fff;
  border: 1px solid #cfd8dc;
  color: #1a1a1a;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}
.btn-secondary:hover { background: #f5f8fa; text-decoration: none; }
.btn-secondary.danger { color: #b3261e; border-color: #f3b8b3; }
.btn-secondary.danger:hover { background: #fff5f5; }

/* ===== Filtros ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e6ebee;
  margin-bottom: 14px;
}
.filters-search {
  flex: 1;
  min-width: 240px;
  padding: 8px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  font-size: 14px;
}
.filters-select {
  padding: 8px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  min-width: 180px;
}
.filters-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  user-select: none;
}

/* ===== Resultados meta ===== */
.results-meta { font-size: 13px; color: #555; margin-bottom: 8px; }

/* ===== Tabla ===== */
.table-wrap {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e6ebee;
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  background: #f5f8fa;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e0e6ea;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f3f5;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f5f8fa; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .num.low { color: #b06b00; font-weight: 700; }
.table .bold { font-weight: 600; color: #1a1a1a; }
.table .empty { text-align: center; color: #888; padding: 24px; font-style: italic; }
.table.compact { font-size: 12px; }
.table.compact th, .table.compact td { padding: 6px 10px; }
.table code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12px;
  color: #555;
}

/* ===== Paginación ===== */
.pagination {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin: 16px 0;
  font-size: 13px;
}
.pagination a {
  padding: 6px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 4px;
  background: #fff;
}
.pagination a:hover { background: #f5f8fa; text-decoration: none; }
.page-current { color: #666; }

/* ===== Form grid (detalle/nuevo) ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e6ebee;
}
.form-col { display: flex; flex-direction: column; gap: 12px; }
.form-col textarea {
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.form-col select {
  border: 1px solid #cfd8dc;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  background: #fff;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.card-section {
  background: #fff;
  margin-top: 16px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e6ebee;
}
.card-section h2 { font-size: 16px; color: #0b3d61; margin-bottom: 8px; }

/* ===== Ventas ===== */
.cart-section, .search-section {
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e6ebee;
  margin-bottom: 14px;
}
.cart-section h2, .search-section h2 {
  font-size: 14px; color: #0b3d61; margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .4px;
}
.empty {
  text-align: center; color: #888; padding: 20px;
  font-style: italic; font-size: 13px;
}
.confirm-bar {
  display: flex; justify-content: flex-end;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #f0f3f5;
}
.confirm-bar .btn-primary { font-size: 15px; padding: 12px 24px; }
.total-row td { background: #fafbfc; border-top: 2px solid #cfd8dc; }
.num.lg { font-size: 16px; color: #0b3d61; }
.btn-link {
  background: none; border: none; cursor: pointer;
  padding: 4px 8px; color: #b3261e; font-size: 14px;
}
.btn-link:hover { color: #7a1a14; }
.btn-link.danger { color: #b3261e; }

.badge-state {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .3px;
  font-weight: 600;
}
.badge-completada { background: #f0faf2; color: #1b7a35; border: 1px solid #b7e2c3; }
.badge-anulada { background: #fff5f5; color: #b3261e; border: 1px solid #f3b8b3; }
.muted { color: #999; font-size: 12px; font-style: italic; }

/* Badges de roles */
.badge-admin { background: #fff5f5; color: #b3261e; border: 1px solid #f3b8b3; }
.badge-vendedor { background: #f0faf2; color: #1b7a35; border: 1px solid #b7e2c3; }
.badge-consulta { background: #f5f8fa; color: #666; border: 1px solid #cfd8dc; }
.muted-row td { color: #aaa; }
.muted-row .bold { color: #888; }

.highlight-pos { color: #1b7a35; font-weight: 700; }
.highlight-neg { color: #b3261e; font-weight: 700; }

.sub-stat {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ===== Carátulas ===== */
.caratula-section { margin-bottom: 16px; }
.caratula-wrap {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.caratula-current { flex: 0 0 auto; }
.caratula-controls { flex: 1; }
.caratula-img {
  max-width: 160px;
  max-height: 230px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
  display: block;
  margin-bottom: 8px;
}
.caratula-placeholder {
  width: 130px;
  height: 180px;
  background: #f5f8fa;
  border: 2px dashed #cfd8dc;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 36px;
  text-align: center;
}
.caratula-placeholder span { font-size: 11px; margin-top: 4px; }
.caratula-preview {
  margin-top: 10px;
  padding: 12px;
  background: #f5f8fa;
  border-radius: 6px;
  border: 1px solid #e0e6ea;
}
.muted-bold { font-weight: 600; color: #555; }

/* ===== Título como link en lista ===== */
.titulo-link {
  color: #1a1a1a;
  text-decoration: none;
  border-bottom: 1px dotted #cfd8dc;
  cursor: pointer;
}
.titulo-link:hover {
  color: #186faf;
  border-bottom-color: #186faf;
  text-decoration: none;
}

/* ===== Modal carátula ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.modal-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none; border: none;
  font-size: 28px; line-height: 1;
  cursor: pointer; color: #888;
}
.modal-close:hover { color: #b3261e; }
.modal-titulo {
  color: #0b3d61;
  font-size: 16px;
  padding-right: 24px;
  margin-bottom: 4px;
}
.modal-isbn {
  font-size: 12px;
  font-style: normal;
  margin-bottom: 14px;
}
.modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 180px;
  justify-content: center;
}
.modal-img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.2);
}
.modal-loading {
  color: #888;
  padding: 40px;
  font-style: italic;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.links-manual {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.links-manual a {
  background: #f5f8fa;
  color: #0b3d61;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  border: 1px solid #cfd8dc;
  text-decoration: none;
}
.links-manual a:hover { background: #e0e8ee; text-decoration: none; }
