/* ── CSS Custom Properties ── */
:root {
  --primary: #4a6aba;
  --primary-dark: #3a5492;
  --primary-light: #e8eef7;
  --secondary: #f59e0b;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --success: #22c55e;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --text: #1f2937;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --card-bg: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --primary-focus-shadow: rgba(74, 106, 186, 0.15);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  object-fit: cover;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: white;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

.btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.btn-google {
  background: white;
  color: #374151;
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  justify-content: center;
}
.btn-google:hover:not(:disabled) {
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.btn-google img {
  width: 20px;
  height: 20px;
}

.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.8rem;
}

/* ── Main Content ── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus-shadow);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Tables ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: #f9fafb;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #f9fafb;
}

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-pendiente {
  background: var(--warning-light);
  color: #92400e;
}
.badge-pagado {
  background: var(--info-light);
  color: #1e40af;
}
.badge-completado {
  background: var(--success-light);
  color: #166534;
}
.badge-admin {
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition);
}

.tab-btn:hover {
  color: var(--primary);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  line-height: 1;
  transition: background var(--transition);
}
.modal-close:hover {
  background: var(--border);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Book Table (catalog) ── */
.books-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.books-table th {
  background: #f9fafb;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.books-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.books-table tr:last-child td {
  border-bottom: none;
}

.books-table .col-price {
  text-align: right;
  white-space: nowrap;
}

.books-table .col-action {
  text-align: right;
  white-space: nowrap;
  width: 120px;
}

.book-row-selected {
  background: var(--primary-light);
}

.book-row-price {
  font-weight: 600;
  color: var(--primary);
}

.btn-row-add {
  background: var(--primary);
  color: white;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition);
}
.btn-row-add:hover { background: var(--primary-dark); }

.btn-row-remove {
  background: white;
  color: var(--danger);
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-row-remove:hover {
  background: var(--danger-light);
}

.year-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}

/* ── Catalog header ── */
.catalog-header {
  margin-bottom: 1.5rem;
}

.catalog-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.year-selector-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.year-selector-row label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

.year-select {
  max-width: 200px;
}

/* ── Order panel ── */
.order-panel {
  margin-top: 1.5rem;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem 1.5rem;
  border-top: 4px solid var(--primary);
}

.order-panel-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.order-count-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.order-total-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

/* ── Order success ── */
.order-success {
  text-align: center;
  padding: 3rem 1.5rem;
}

.order-success-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.order-success h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.order-success p {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.order-success-summary {
  max-width: 480px;
  margin: 0.5rem auto 1rem;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.order-success-summary-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.order-success-books {
  list-style: none;
  margin: 0;
  padding-left: 0;
}

.order-success-books li {
  color: var(--text);
  font-size: 0.88rem;
  margin-bottom: 0;
}

.order-success-total {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.order-number {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius-lg);
  padding: 0.75rem 2rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-family: 'Courier New', monospace;
  margin: 0.5rem 0 1rem;
  word-break: break-all;
}

/* ── Order detail page ── */
.order-detail-main {
  max-width: 900px;
}

.order-header-card {
  overflow: visible;
}

.order-header-body {
  padding: 0;
}

.order-status-banner {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-size: 0.95rem;
}

.order-status-warning { background: var(--warning-light); color: #92400e; }
.order-status-info    { background: var(--info-light);    color: #1e40af; }
.order-status-success { background: var(--success-light); color: #166534; }
.order-status-danger  { background: var(--danger-light);  color: #991b1b; }

.order-status-label { font-size: 1rem; }

.order-number-display {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  opacity: 0.8;
}

.order-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  border-top: 1px solid var(--border);
}

.order-info-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-right: 1px solid var(--border);
}

.order-info-item:last-child {
  border-right: none;
}

.order-info-icon {
  font-size: 1.25rem;
  margin-top: 0.1rem;
}

.order-info-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.order-info-value {
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-word;
}

.order-total-row td {
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.order-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.order-action-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Pagination ── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.pagination-nav {
  min-width: 2.25rem;
  font-size: 1rem;
  font-weight: 700;
}

.pagination-page {
  min-width: 2.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.pagination-page:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.pagination-page.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: default;
}

.pagination-ellipsis {
  padding: 0 0.25rem;
  color: var(--text-muted);
  user-select: none;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-size .form-control-sm {
  width: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.pagination-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Short order code ── */
.short-id {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* ── Book Grid (legacy styles — kept for admin table compatibility) ── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
}

.book-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.book-card.in-cart {
  outline: 2px solid var(--primary);
}

.book-cover-placeholder {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, var(--primary-light), #c7d2fe);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
}

.book-info {
  padding: 1rem;
}

.book-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  color: var(--text);
}

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

.book-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.book-price {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 0.375rem;
}

/* ── Cart badge ── */
.cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--secondary);
  color: white;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  margin-left: 0.25rem;
}

/* ── Checkout ── */
.checkout-book-list-ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.checkout-book-list-ul li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.checkout-book-list-ul li:last-child {
  border-bottom: none;
}

.checkout-total {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-align: right;
  padding-top: 0.5rem;
}

/* ── Login Page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 1rem;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.login-logo {
  margin-bottom: 2rem;
}

.login-logo h1 {
  font-size: 2.5rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Alerts ── */
.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border-left: 4px solid var(--danger);
}
.alert-success {
  background: var(--success-light);
  color: #166534;
  border-left: 4px solid var(--success);
}
.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border-left: 4px solid var(--warning);
}
.alert-info {
  background: var(--info-light);
  color: #1e40af;
  border-left: 4px solid var(--info);
}

/* ── Loading ── */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
  gap: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ── Search Bar ── */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-bar .form-control {
  flex: 1;
  min-width: 200px;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card.warning {
  border-left-color: var(--warning);
}
.stat-card.success {
  border-left-color: var(--success);
}
.stat-card.info {
  border-left-color: var(--info);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.375rem;
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-0 {
  margin-bottom: 0;
}

.pedido-books-list {
  margin: 0;
  padding-left: 1rem;
  font-size: 0.8rem;
}

/* ── Book Card List (mobile catalog) ── */
.books-card-list {
  display: none;
}

.book-card-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}

.book-card-item.book-card-selected {
  background: var(--primary-light);
  border-color: var(--primary);
}

.book-card-title {
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.book-card-subject {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.book-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.book-card-price {
  font-weight: 600;
  color: var(--primary);
  font-size: 0.95rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  #books-container .table-wrapper .books-table,
  #history-container .table-wrapper {
    display: none;
  }

  .books-card-list {
    display: block;
  }

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

  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .main-content {
    padding: 1rem;
  }

  .navbar-desktop-btn {
    display: none;
  }

  .navbar {
    padding: 0 1rem;
  }

  .user-name {
    display: none;
  }

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

  .login-card {
    padding: 2rem 1.5rem;
  }

  .tabs {
    overflow-x: auto;
  }

  .order-info-grid {
    grid-template-columns: 1fr 1fr;
  }

  .order-info-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .order-info-item:nth-child(odd) {
    border-right: 1px solid var(--border);
  }

  .order-info-item:last-child,
  .order-info-item:nth-last-child(2):nth-child(odd) {
    border-bottom: none;
  }

  .order-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .order-action-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ── Navbar Logo ── */
.navbar-logo-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 6px;
  width: 36px;
  height: 36px;
  overflow: hidden;
  flex-shrink: 0;
  padding: 2px;
}

.navbar-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Navbar avatar button (mobile dropdown trigger) ── */
.navbar-avatar-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 50%;
  outline-offset: 2px;
}

.navbar-avatar-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
}

/* ── Navbar mobile dropdown ── */
.navbar-mobile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.navbar-mobile-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition);
}

.navbar-mobile-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.navbar-mobile-divider {
  margin: 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ── Login Logo ── */
.login-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

/* ── Permissions modal ── */
.permissions-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin: 1rem 0;
}

.permissions-checkboxes label {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.permissions-checkboxes input[type="checkbox"] {
  margin-top: 0.1rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.perm-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* ── Book resource link in order detail ── */
.book-resource-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.book-resource-link:hover {
  text-decoration: underline;
}

/* ── Admin permissions badges ── */
.perm-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.25rem;
}
.perm-badge-administracion {
  background: var(--warning-light);
  color: #92400e;
}
.perm-badge-impresion {
  background: var(--info-light);
  color: #1e40af;
}
.perm-badge-owner {
  background: var(--primary-light);
  color: var(--primary-dark);
}
.perm-badge-contaduria {
  background: #dcfce7;
  color: #166534;
}

/* ── Finanzas payment method badges ── */
.badge-efectivo {
  background: #dcfce7;
  color: #166534;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-transferencia {
  background: #dbeafe;
  color: #1e40af;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ── Settings tab – danger zone ── */
.settings-danger-zone {
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--danger-light);
  flex-wrap: wrap;
}

.settings-danger-row-last {
  border-bottom: none;
}

.settings-danger-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.settings-danger-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.settings-check-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--danger);
  cursor: pointer;
}

/* ── Order success – prettier book list ── */
.order-success-books li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
}

.order-success-books li:last-child {
  border-bottom: none;
}

.order-success-book-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

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

.order-success-book-price {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

/* ── Division checkboxes (years 4-6) ── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── History page ── */
.history-pedido-row:hover td {
  background: var(--primary-light);
}

.history-detail-row td {
  padding: 0;
  background: #f9fafb;
}

.history-books-detail {
  padding: 1rem 1.5rem;
}

.history-books-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-book-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  gap: 1rem;
  flex-wrap: wrap;
}

.history-book-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.history-book-price {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.history-toggle-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* History mobile cards */
.history-pedido-card {
  cursor: pointer;
}

.history-pedido-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.history-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.history-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.history-card-detail {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
