:root {
  --bg: #f6f5f2; --surface: #fff; --ink: #1d1b18; --muted: #6b665e; --line: #e4e0d8;
  --brand: #f6c400; --brand-ink: #1d1b18; --accent: #0b5cad;
  --ok: #1d7a46; --ok-bg: #e5f4ea; --warn: #8a5a00; --warn-bg: #fff3d6; --err: #b3261e; --err-bg: #fde8e6;
  --info-bg: #e7f0fb; --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 8px; } a { color: var(--accent); }
.muted { color: var(--muted); } .mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand small { color: var(--brand); font-weight: 600; }
.logo { background: var(--brand); color: var(--brand-ink); width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; font-weight: 900; }
nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
nav::-webkit-scrollbar { display: none; }
nav a { color: #d8d4cc; text-decoration: none; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
nav a.active, nav a:hover { background: #ffffff1a; color: #fff; }
.seller { margin-left: auto; color: #bdb8ae; font-size: 13px; white-space: nowrap; }
.badge { background: var(--brand); color: var(--brand-ink); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.k2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stack > * + * { margin-top: 16px; }

.kpi { display: block; text-decoration: none; color: inherit; }
.kpi .n { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); }
.kpi.alert .n { color: var(--err); }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.steps li:first-child { border-top: 0; }
.steps li::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 700; flex: none; }
.steps li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.steps li .grow { flex: 1; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c9c3b8; }
button.primary, .btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.brand { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 650; }
button.danger { color: var(--err); }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
button.icon { border: 0; background: none; font-size: 24px; padding: 0 8px; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; background: #fbfaf7; cursor: pointer; transition: .15s; }
.drop.over { border-color: var(--accent); background: var(--info-bg); }
.drop input { display: none; }
.drop > b { display: block; margin-bottom: 4px; }

.summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.pill { border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; background: var(--bg); border: 1px solid transparent; cursor: default; white-space: nowrap; }
button.pill { cursor: pointer; }
button.pill.on { border-color: var(--ink); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: var(--err); } .pill.info { background: var(--info-bg); color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fbfaf7; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #fbfaf7; }
.issues { margin: 0; padding: 0; list-style: none; }
.issues li { padding-left: 18px; position: relative; margin: 2px 0; }
.issues li::before { position: absolute; left: 0; }
.issues li.error::before { content: "✕"; color: var(--err); font-weight: 700; }
.issues li.aviso::before { content: "!"; color: var(--warn); font-weight: 800; left: 4px; }
.fix { background: #fbfaf7; border-radius: 8px; padding: 10px; margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.fix label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }

input[type=text], input[type=number], input[type=search], select { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0; }
input.inline { width: 90px; padding: 4px 8px; text-align: right; }
input.dirty { border-color: var(--accent); background: var(--info-bg); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.book { display: flex; gap: 10px; align-items: center; }
.cover { width: 34px; height: 48px; border-radius: 3px; background: #ece8e0 center/cover; flex: none; display: grid; place-items: center; font-size: 10px; color: var(--muted); }

.drawer { position: fixed; inset: 0; background: #0006; z-index: 10; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-panel { width: min(560px, 100%); background: var(--surface); height: 100%; overflow-y: auto; padding: 24px; position: relative; }
.close { position: absolute; top: 12px; right: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 0 0 12px 16px; position: relative; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ink); position: absolute; left: -6px; top: 5px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

details.log { border-bottom: 1px solid var(--line); padding: 8px 0; }
details.log summary { cursor: pointer; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details.log pre { background: #f2efe9; border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; max-height: 300px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.err { background: var(--err); }
.empty { text-align: center; color: var(--muted); padding: 32px; }
.callout { background: var(--info-bg); border-radius: 8px; padding: 10px 14px; }
.callout.warn { background: var(--warn-bg); }

/* ---------- Alta por ISBN ---------- */
.isbn-card { margin-bottom: 8px; }
.isbn-row { display: flex; gap: 8px; max-width: 520px; }
.isbn-row input { flex: 1; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; letter-spacing: .03em; }
.isbn-row input:focus { outline: 2px solid var(--brand); border-color: var(--ink); }
#isbn-result:not(:empty) { margin-top: 16px; }
.isbn-found { display: grid; grid-template-columns: 120px 1fr; gap: 20px; align-items: start; }
.isbn-cover img { width: 120px; border-radius: 4px; box-shadow: 0 1px 4px #0002; display: block; }
.cover.big { width: 120px; height: 170px; font-size: 12px; }
.isbn-body h3 { font-size: 17px; margin-bottom: 2px; }
.isbn-body .form { margin-top: 12px; }
.form-fields { padding-top: 12px; border-top: 1px dashed var(--line); }
.form label.wide { grid-column: 1 / -1; }
.form label small { font-weight: 400; color: var(--muted); }
.placement { margin: 8px 0; }
.small { font-size: 12.5px; }
.callout.ok { background: var(--ok-bg); }
@media (max-width: 720px) { .isbn-found { grid-template-columns: 1fr; } }

/* ---------- Dashboard del marketplace ---------- */
.grid.k5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
h2.section { margin: 24px 0 12px; }
.kpi .delta { display: block; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--err); }
.grid.mini { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mini .kpi { padding: 12px; }
.mini .kpi .n { font-size: 22px; }
.mini .kpi .l { font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.chart { position: relative; margin-top: 8px; }
.chart svg { display: block; overflow: visible; }
.chart .grid-lines line { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bars path { fill: var(--accent); }
.chart .hits rect { fill: transparent; cursor: default; }
.chart .hits rect.on { fill: #0b5cad12; }
.chart .tip { position: absolute; top: 0; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; pointer-events: none; white-space: nowrap; }
.table-toggle { margin-top: 10px; }
.table-toggle summary { cursor: pointer; color: var(--accent); font-size: 13px; }
.table-toggle .table-wrap { margin-top: 8px; max-height: 260px; overflow-y: auto; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; margin-top: 12px; padding: 12px 18px; }
.facts b { font-size: 16px; font-variant-numeric: tabular-nums; }
.alerts { list-style: none; margin: 0; padding: 0; }
.alerts li { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.alerts li:first-child { border-top: 0; }
.alerts li span { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.pager span { margin-right: auto; }
.inline-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
input[type=date] { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; }
.warn-text { color: var(--warn); }

/* ---------- Acceso ---------- */
body.public { background: var(--bg); }
body.public main { max-width: none; padding: 0; }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.auth-brand small { color: var(--muted); font-weight: 600; }
.auth-card { width: min(420px, 100%); padding: 24px; }
.auth-card h1 { margin-bottom: 14px; }
.auth-foot { color: var(--muted); font-size: 13px; text-align: center; max-width: 420px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.form input, .form select, .form textarea { font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; background: #fff; font-weight: 400; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--ink); }
.form input:disabled { background: var(--bg); color: var(--muted); }
.form button[type=submit] { justify-content: center; }
.form-error { background: var(--err-bg); color: var(--err); border-radius: 8px; padding: 8px 12px; margin: 0; }
.grid.tight { gap: 12px; }
.grid.k2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.copy { display: flex; gap: 8px; margin-top: 8px; }
.copy input { flex: 1; min-width: 0; font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }

/* ---------- Cuenta y "ver como" ---------- */
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; font-size: 13px; max-width: 220px; text-align: right; }
.who small { color: #bdb8ae; font-size: 11.5px; }
button.ghost { background: transparent; color: #fff; border-color: #ffffff40; }
button.ghost:hover { border-color: #fff; }
.banner { background: var(--brand); color: var(--brand-ink); padding: 8px 24px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; position: sticky; top: 56px; z-index: 4; }

@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 12px; } .who { display: none; }
  .grid.k2.wide-left { grid-template-columns: 1fr; }
  main { padding: 16px; } .grid.k2 { grid-template-columns: 1fr; }
}

/* Mis libros: pestañas, subfiltros, línea de estado y barra de cambios sin guardar */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 12px; flex-wrap: wrap; }
.tabs .tab { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs .tab.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tabs .count { font-size: 12px; background: var(--bg); border-radius: 999px; padding: 1px 7px; margin-left: 6px; font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.book-line { font-size: 12.5px; margin-top: 2px; color: var(--muted); }
.book-line.ok { color: var(--ok); } .book-line.err { color: var(--err); }
.book-line a { color: var(--accent); }
table.books td.num, table.books th.num { width: 110px; }
.savebar { position: sticky; bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--surface); box-shadow: 0 4px 16px #0003; }
.savebar button:not(.primary) { background: transparent; color: var(--surface); border-color: #fff6; }
.savebar button.primary { background: var(--surface); color: var(--ink); border-color: var(--surface); }
@media (max-width: 640px) {
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs .tab { white-space: nowrap; padding: 8px 10px; }
  table.books .cover { display: none; }
  table.books th, table.books td { padding-left: 6px; padding-right: 6px; }
  table.books td.num, table.books th.num { width: auto; }
  table.books input.inline { width: 68px; }
}

.order-book + .order-book { margin-top: 8px; }
.order-item { display: grid; grid-template-columns: 110px 1fr; gap: 16px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.order-item .isbn-cover img { width: 110px; border-radius: 4px; }
.order-item .cover.big { width: 110px; height: 156px; }

fieldset.pickup { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 4px; margin: 4px 0 8px; }
fieldset.pickup legend { font-weight: 600; padding: 0 4px; }
.grid.k3 .wide2 { grid-column: span 1; }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .4s ease; }
