:root {
  --ink: #2a1f14;
  --purpura: #6b2d3c;
  --purpura-light: #a35d6c;
  --purpura-dark: #4a1c28;
  --verde: #2d6a4f;
  --verde-light: #40916c;
  --lila: #f4ead8;
  --paper: #f4ead8;
  --card: #fffdf8;
  --line: #e4d8c4;
  --muted: #6b5e52;
  --bg: #f7f1e6;
  --gold: #b8860b;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Georgia, "Palatino Linotype", Palatino, "Times New Roman", serif; }
a { color: inherit; }

.top { background: linear-gradient(135deg, #4a1c28 0%, #6b2d3c 100%); color: #f7f1e6; }
.top-inner, .wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.top-inner { display: flex; justify-content: space-between; align-items: center; min-height: 68px; gap: 16px; }
.logo { text-decoration: none; font-weight: 700; font-size: 22px; letter-spacing: 0.02em; }
.logo small { display: block; font-weight: 400; font-size: 11px; opacity: 0.9; letter-spacing: 0.1em; text-transform: uppercase; font-family: "Segoe UI", system-ui, sans-serif; }
.top nav { display: flex; gap: 16px; align-items: center; font-size: 14px; font-family: "Segoe UI", system-ui, sans-serif; }
.top nav a { text-decoration: none; }
.btn { display: inline-block; background: #f4ead8; color: var(--purpura-dark); font-weight: 600; text-decoration: none; padding: 12px 20px; border: 0; border-radius: 6px; cursor: pointer; transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; box-shadow: 0 2px 8px rgba(74, 28, 40, 0.2); font-family: "Segoe UI", system-ui, sans-serif; }
.btn:hover { background: #fde68a; transform: translateY(-2px); box-shadow: 0 4px 16px rgba(74, 28, 40, 0.3); }
.btn-line { background: transparent; color: var(--purpura); border: 1px solid var(--purpura); box-shadow: none; }
.btn-line:hover { background: #f4ead8; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.hero { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 48px; padding: 56px 0 48px; align-items: center; }
.kicker { color: var(--gold); font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase; font-weight: 600; font-family: "Segoe UI", system-ui, sans-serif; }
.kicker.light { color: #fde68a; }
h1, h2, h3 { font-weight: 700; }
h1 { font-size: 40px; line-height: 1.2; margin: 12px 0; }
.lead { font-size: 17px; color: var(--muted); max-width: 34rem; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.hero-search { display: flex; gap: 8px; margin: 20px 0 16px; max-width: 28rem; }
.hero-search input { flex: 1; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); font: inherit; }
.hero-search .btn { padding: 12px 18px; }

.book-card { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 20px rgba(124, 58, 237, 0.1); border-left: 5px solid var(--purpura); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.book-card:hover { transform: translateY(-4px); box-shadow: 0 12px 30px rgba(124, 58, 237, 0.15); }
.book-img { height: 130px; overflow: hidden; }
.book-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.book-card:hover .book-img img { transform: scale(1.05); }
.book-body { padding: 24px; }
.book-card .cat { color: var(--purpura); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.book-card h3 { margin: 8px 0; font-size: 20px; }
.book-card .autor { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.book-card .precio { font-size: 24px; font-weight: 700; color: var(--purpura); }
.book-card .stock { font-size: 14px; color: var(--muted); margin-top: 8px; }

.section { padding: 36px 0 20px; }
.section h2 { font-size: 26px; margin-bottom: 16px; }
.modules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.modules article { background: var(--card); border-radius: 12px; padding: 24px; border-top: 4px solid var(--purpura); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.modules article:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(124, 58, 237, 0.1); }
.mod-icon { width: 52px; height: 52px; border-radius: 10px; overflow: hidden; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.mod-icon img { width: 100%; height: 100%; object-fit: cover; }
.modules h3 { margin: 0 0 10px; font-size: 17px; color: var(--purpura); }
.modules p { color: var(--muted); line-height: 1.55; margin: 0; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.05); }
th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: #f4f4f5; }
td, th { padding: 14px 12px; border-bottom: 1px solid var(--line); }
tbody tr { transition: background 0.2s ease; }
tbody tr:hover { background: #faf5ff; }
.note { color: var(--muted); font-size: 14px; margin-bottom: 12px; }

.tag { display: inline-block; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag.stock { background: #ede9fe; color: #5b21b6; }
.tag.bajo { background: #fef9c3; color: #854d0e; }
.tag.agotado { background: #fee2e2; color: #991b1b; }
.tag.pedido { background: #dbeafe; color: #1e40af; }

footer { padding: 36px 0 48px; color: var(--muted); font-size: 14px; }

.app { min-height: 100vh; display: grid; grid-template-rows: auto auto auto auto 1fr; }
.toolbar { display: flex; justify-content: space-between; gap: 16px; align-items: end; padding: 20px 24px 8px; background: var(--paper); }
.toolbar h1 { font-size: 26px; margin: 4px 0; }
.eyebrow { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.stats { display: flex; gap: 8px; padding: 0 24px 12px; flex-wrap: wrap; background: var(--paper); }
.stats button, .stats div { background: white; border: 1px solid var(--line); padding: 8px 12px; min-width: 100px; text-align: left; border-radius: 4px; cursor: pointer; }
.stats strong { display: block; font-size: 18px; color: var(--purpura); }
.stats .on { border-color: var(--purpura); background: #ede9fe; }

.workspace { display: grid; grid-template-columns: 1.3fr 0.7fr; min-height: 0; background: var(--paper); }
.list, .detail { padding: 0 24px 32px; }
.list { overflow-y: auto; }
.row { cursor: pointer; transition: background 0.15s; }
.row:hover { background: #faf5ff; }
.row.on { background: #ede9fe; }

.detail { background: white; border-left: 1px solid var(--line); padding: 16px 24px 32px; overflow-y: auto; }
.detail h2 { font-size: 18px; margin: 0 0 4px; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; font-size: 14px; }
.meta span { display: block; color: var(--muted); font-size: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
input, select, textarea { width: 100%; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--ink); }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ghost { background: transparent; border: 1px solid var(--line); padding: 8px 12px; border-radius: 4px; cursor: pointer; }
.btn-panel { background: var(--purpura); color: white; border: 0; padding: 10px 16px; border-radius: 4px; cursor: pointer; font-weight: 500; }
.btn-panel:hover { background: var(--purpura-dark); }

.timeline { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 8px; }
.timeline h3 { font-size: 14px; margin: 0 0 8px; color: var(--purpura); }
.timeline p { margin: 6px 0; font-size: 13px; }
.timeline time { display: block; color: var(--purpura); font-size: 11px; font-weight: 600; }

.factura-box { background: #f0fdf4; border: 1px solid #86efac; border-radius: 6px; padding: 12px; margin: 12px 0; font-size: 13px; }
.factura-box h4 { margin: 0 0 8px; font-size: 13px; color: #166534; }
.factura-box .cae { font-family: monospace; color: #166534; }

.arca-section { background: #ede9fe; border: 1px solid #a78bfa; border-radius: 6px; padding: 12px; margin: 12px 0; }
.arca-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--purpura); }

.pedido-especial { background: #dbeafe; border: 1px solid #93c5fd; border-radius: 6px; padding: 12px; margin: 12px 0; font-size: 13px; }
.pedido-especial h4 { margin: 0 0 8px; font-size: 13px; color: #1e40af; }

.create { display: none; background: white; border: 1px solid var(--line); border-radius: 6px; padding: 16px; margin: 0 24px 12px; }
.create.open { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.create button { align-self: end; }
.workspace[hidden], .panel-section[hidden], .create[hidden] { display: none !important; }
.detail form#edit { display: grid; gap: 4px; margin-top: 12px; }

.amount { text-align: right; font-variant-numeric: tabular-nums; }

.ghost, .btn-panel, input, select, textarea, .modules, .stats, table {
  font-family: "Segoe UI", system-ui, sans-serif;
}

@media (max-width: 960px) {
  .hero, .modules, .workspace, .create.open, .pedido-box { grid-template-columns: 1fr; }
  .top-inner, .toolbar { flex-direction: column; align-items: start; }
  h1 { font-size: 32px; }
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.catalog-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters button { background: var(--card); border: 1px solid var(--line); padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 13px; }
.filters button:hover { border-color: var(--purpura); }
.filters button.active { background: var(--purpura); color: white; border-color: var(--purpura); }
.filters button { font-family: "Segoe UI", system-ui, sans-serif; }
.catalog-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.search-field { min-width: 240px; }
.search-field input { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); font: inherit; }
.catalog-count { color: var(--muted); font-size: 14px; margin: -8px 0 16px; font-family: "Segoe UI", system-ui, sans-serif; }

.hero-covers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; }
.hero-covers img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); background: #eee; }
.hero-covers img:nth-child(2) { transform: translateY(-16px); }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.book-tile { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); display: flex; flex-direction: column; cursor: pointer; text-align: left; }
.book-tile:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }
.book-tile .cover { aspect-ratio: 2 / 3; background: #f4f4f5; overflow: hidden; }
.book-tile .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-tile .body { padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.book-tile h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.book-tile .cat { margin: 0; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--purpura); font-weight: 600; }
.book-tile .autor { margin: 0; font-size: 12px; color: var(--muted); }
.book-tile .desc { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: #3f3f46; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.book-tile .price { margin: 8px 0 0; font-size: 18px; font-weight: 700; color: var(--purpura); }
.book-tile .body { font-family: "Segoe UI", system-ui, sans-serif; }
.book-tile .stock { margin: 0; font-size: 12px; color: var(--muted); }
.book-tile .stock.bajo { color: #e67e22; }
.book-tile .stock.agotado { color: #e74c3c; }
.tile-actions { display: flex; gap: 8px; margin-top: 10px; }
.tile-actions button { flex: 1; font-size: 13px; }
.tile-actions button:disabled { opacity: 0.45; cursor: not-allowed; }

.cover-fallback { width: 100%; height: 100%; display: grid; place-items: center; background: #ede9fe; color: var(--purpura); font-size: 42px; font-weight: 700; }
.cover-fallback.mini, .thumb.fallback { width: 44px; height: 64px; font-size: 16px; border-radius: 4px; flex-shrink: 0; }

.pedido-box { background: linear-gradient(135deg, #4a1c28 0%, #6b2d3c 100%); color: #f7f1e6; padding: 28px; border-radius: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.pedido-box h2 { margin: 8px 0 10px; }
.pedido-box p { margin: 0; line-height: 1.5; font-family: "Segoe UI", system-ui, sans-serif; }
.pedido-form { display: grid; gap: 8px; }
.pedido-form label { color: #f4ead8; }
.pedido-form input { background: #fffdf8; }
.pedido-form .btn { justify-self: start; margin-top: 6px; }
.admin-link { text-align: center; margin-top: 32px; padding: 24px; background: var(--card); border-radius: 12px; }

.cart-wrap { position: relative; }
.cart-btn { background: none; border: 0; color: inherit; cursor: pointer; font-size: 18px; padding: 8px 12px; position: relative; }
.cart-badge { position: absolute; top: 0; right: 0; background: #e53935; color: white; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.cart-dropdown { position: absolute; top: 100%; right: 0; background: white; color: var(--ink); border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); width: 360px; z-index: 100; font-family: "Segoe UI", system-ui, sans-serif; }
.cart-dropdown[hidden] { display: none; }
.cart-dropdown h4 { margin: 0; padding: 16px; border-bottom: 1px solid #eee; }
.cart-items { max-height: 300px; overflow-y: auto; }
.cart-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f5f5f5; align-items: center; }
.cart-item img, .thumb { width: 44px; height: 64px; object-fit: cover; border-radius: 4px; background: #f4f4f5; flex-shrink: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .info .title { font-size: 13px; margin: 0; }
.cart-item .info .price { font-size: 13px; font-weight: 600; margin: 4px 0 0; }
.cart-item .remove { background: none; border: none; color: #999; cursor: pointer; font-size: 18px; }
.cart-footer { padding: 16px; border-top: 1px solid #eee; }
.cart-footer .total { display: flex; justify-content: space-between; margin-bottom: 12px; }
.cart-empty { padding: 24px 16px; text-align: center; color: var(--muted); }

.ficha-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; z-index: 180; padding: 20px; pointer-events: auto; }
.ficha-overlay[hidden] { display: none; }
.ficha-modal { position: relative; background: white; color: var(--ink); border-radius: 14px; max-width: 720px; width: 100%; max-height: min(90vh, 760px); overflow: auto; box-shadow: 0 16px 48px rgba(0,0,0,0.2); pointer-events: auto; }
.ficha-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 18px; background: #f4f4f5; cursor: pointer; font-size: 22px; line-height: 1; z-index: 2; }
.ficha-modal #fichaBody { display: grid; grid-template-columns: 220px 1fr; gap: 22px; padding: 22px; }
.ficha-cover { background: #f4f4f5; border-radius: 10px; overflow: hidden; aspect-ratio: 2 / 3; }
.ficha-cover img, .ficha-cover .cover-fallback { width: 100%; height: 100%; object-fit: cover; display: block; }
.ficha-info .cat { margin: 0; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--purpura); font-weight: 600; }
.ficha-info h2 { margin: 4px 36px 8px 0; font-size: 26px; line-height: 1.2; }
.ficha-info .stock.bajo { color: #e67e22; }
.ficha-info .stock.agotado { color: #e74c3c; }
.ficha-info .autor { margin: 0; color: var(--muted); }
.ficha-desc { margin: 12px 0; font-size: 15px; line-height: 1.55; }
.ficha-info .price { margin: 8px 0 0; font-size: 22px; font-weight: 700; color: var(--purpura); }
.ficha-info .editorial, .ficha-info .isbn { margin: 2px 0 0; font-size: 13px; color: var(--muted); font-family: "Segoe UI", system-ui, sans-serif; }
.ficha-info { font-family: "Segoe UI", system-ui, sans-serif; }
body.ficha-open { overflow: hidden; }

.shelf-head { margin-bottom: 16px; }
.shelf-head h2 { margin: 4px 0 0; }
.shelf-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.shelf-card { background: var(--card); border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; text-align: left; min-width: 0; }
.shelf-card:focus-visible { outline: 2px solid var(--purpura); outline-offset: 2px; }
.shelf-card .cover { aspect-ratio: 2 / 3; background: #f4f4f5; }
.shelf-card .cover img, .shelf-card .cover .cover-fallback { width: 100%; height: 100%; object-fit: cover; display: block; }
.shelf-card h3 { margin: 8px 10px 0; font-size: 14px; line-height: 1.3; }
.shelf-card .autor { margin: 2px 10px 0; font-size: 12px; color: var(--muted); font-family: "Segoe UI", system-ui, sans-serif; }
.shelf-card .price { margin: 6px 10px 12px; font-size: 14px; font-weight: 700; color: var(--purpura); font-family: "Segoe UI", system-ui, sans-serif; }

.qty-ctrl { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; }
.qty-ctrl button { width: 26px; height: 26px; border: 1px solid var(--line); background: #fff; border-radius: 4px; cursor: pointer; font-size: 16px; line-height: 1; }
.qty-ctrl span { min-width: 1.2em; text-align: center; font-size: 13px; font-weight: 600; }

.tabs { display: flex; gap: 0; padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line); }
.tabs button { background: transparent; border: none; padding: 12px 20px; font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; font-family: "Segoe UI", system-ui, sans-serif; }
.tabs button.on { color: var(--purpura); border-bottom-color: var(--purpura); }
.panel-section { padding: 16px 24px 32px; background: var(--paper); }
.pedido-card.on { outline: 2px solid var(--purpura); }
.pedido-card h3 { margin: 0 0 6px; font-size: 16px; }
.pedido-card .meta-line { font-size: 13px; color: var(--muted); margin: 0 0 8px; font-family: "Segoe UI", system-ui, sans-serif; }
.pedido-card .actions { margin-top: 8px; }
.tag.pendiente { background: #fef3c7; color: #92400e; }
.tag.encargado { background: #dbeafe; color: #1e40af; }
.tag.listo { background: #dcfce7; color: #166534; }
.tag.cancelado { background: #fee2e2; color: #991b1b; }

.checkout-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.checkout-overlay[hidden] { display: none; }
.checkout-modal { background: white; border-radius: 12px; padding: 24px; max-width: 420px; width: 100%; }
.checkout-modal h2 { margin: 0 0 12px; }
.checkout-total { font-weight: 700; margin-top: 8px; }
.checkout-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.detail-cover { width: 140px; height: 210px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.detail-desc { font-size: 14px; line-height: 1.5; margin: 8px 0 12px; }
.row-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #71717a; max-width: 280px; }
.ventas-panel { margin-top: 28px; }
.ventas-panel h3 { font-size: 16px; margin: 0 0 12px; }
.venta-card { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.venta-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; margin-bottom: 8px; }
.venta-items { display: flex; flex-direction: column; gap: 8px; }
.venta-line { display: flex; align-items: center; gap: 10px; font-size: 13px; }

@media (max-width: 960px) {
  .hero-covers { grid-template-columns: repeat(3, 1fr); }
  .hero-covers img:nth-child(2) { transform: none; }
}

@media (max-width: 640px) {
  .ficha-modal #fichaBody { grid-template-columns: 1fr; }
  .ficha-cover { max-width: 180px; }
  .pedido-box { grid-template-columns: 1fr; }
  .hero-search { flex-direction: column; }
  .catalog-tools { align-items: stretch; width: 100%; }
}
