/* Panel de administración RUAV */
:root {
  --ink: #141312;
  --ink-2: #2a2826;
  --paper: #f5f3ef;
  --white: #ffffff;
  --line: #e2ddd6;
  --text: #1b1a19;
  --muted: #6c6762;
  --red: #d8141b;
  --red-dark: #b10f15;
  --ok: #178a45;
  --warn: #9a6400;
  --radius: 12px;
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--paper); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Botones y campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 999px; font-weight: 650; cursor: pointer; background: var(--white); border-color: var(--line); text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); border-color: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn-danger { color: var(--red); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13.5px; }
.field { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }
.field:focus, .btn:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
textarea.field { min-height: 90px; resize: vertical; }
label { display: grid; gap: 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
label > .field { font-weight: 400; color: var(--text); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--text); }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; margin: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; text-align: center; }
.login-card img { width: 160px; margin-bottom: 16px; }

/* Estructura */
.top { position: sticky; top: 0; z-index: 10; background: var(--ink); color: var(--white); }
.top-in { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.top-in strong { font-size: 17px; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.top-user .btn { min-height: 32px; background: transparent; color: var(--white); border-color: #4a4744; }
.role { padding: 2px 8px; border-radius: 999px; background: #3a3734; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.tabs button { border: 0; background: transparent; color: #cfcac4; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--white); border-color: var(--red); }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar label { min-width: 160px; }
.toolbar .grow { flex: 1 1 240px; }
.muted { color: var(--muted); }
.count { font-size: 14px; color: var(--muted); margin: 0 0 8px; }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #faf9f7; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.thumb { width: 52px; height: 52px; object-fit: contain; background: #faf9f7; border-radius: 6px; border: 1px solid var(--line); display: block; }
.sku { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.hidden-row td { opacity: .55; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: #eee; }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fff3dc; color: var(--warn); }
.badge.err { background: #fde5e6; color: var(--red-dark); }

/* Interruptor */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #cfcac4; border-radius: 999px; transition: background .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--white); border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.switch input:disabled + span { cursor: not-allowed; opacity: .6; }

/* Editor */
dialog.editor { width: min(860px, calc(100% - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 24px 60px rgba(20, 19, 18, .3); }
dialog.editor::backdrop { background: rgba(20, 19, 18, .55); }
.editor form { display: grid; grid-template-rows: auto 1fr auto; max-height: calc(100vh - 24px); }
.editor header, .editor footer { padding: 14px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.editor footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; flex-wrap: wrap; }
.editor footer .left { margin-right: auto; }
.editor header h2 { margin: 0; font-size: 18px; }
.editor header .btn { margin-left: auto; }
.editor .body { overflow-y: auto; padding: 20px; display: grid; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.photo { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo img { width: 140px; height: 140px; object-fit: contain; background: #faf9f7; border: 1px solid var(--line); border-radius: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; display: grid; gap: 10px; }
legend { font-weight: 700; padding: 0 6px; }
.price-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; gap: 8px; align-items: center; }
.error { color: var(--red-dark); font-size: 14px; margin: 0; }

/* Acabados */
.finish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.finish { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; text-align: center; cursor: pointer; }
.finish:hover { border-color: var(--ink); }
.finish img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.finish small { color: var(--muted); }

/* Publicar */
.publish { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.publish .card { margin: 0; display: grid; gap: 10px; align-content: start; }
details summary { cursor: pointer; color: var(--muted); }
pre.diff { white-space: pre-wrap; word-break: break-word; font: 12.5px/1.45 var(--mono); background: #faf9f7; padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 10px; z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.err { background: var(--red-dark); }

@media (max-width: 720px) {
  .grid2, .grid3, .publish { grid-template-columns: 1fr; }
  .toolbar label { min-width: 0; flex: 1 1 140px; }
  .top-user span.email { display: none; }
}
dialog.confirm { width: min(440px, calc(100% - 32px)); padding: 24px; border: 0; border-radius: var(--radius); box-shadow: 0 24px 60px rgba(20, 19, 18, .3); }
dialog.confirm::backdrop { background: rgba(20, 19, 18, .55); }
dialog.confirm p { margin: 0 0 20px; white-space: pre-line; line-height: 1.5; }
dialog.confirm .acciones { display: flex; justify-content: flex-end; gap: 10px; }
