@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
}
:root {
  --portal: #14285f; --fachada: #1e4db7; --fachada-ink: #173d93;
  --estuco: #e5e3c3; --ladrillo: #a9573f; --concreto: #f1f2f0;
  --talanquera: #ec7a2c; --tinta: #1a2236; --tinta-2: #556074; --linea: #d9dde1;
  --ok: #24502a; --ok-bg: #e3efe2; --err: #7d2f17; --err-bg: #f6e3dc;
}
* , *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: "Archivo", system-ui, sans-serif; font-size: 15.5px; line-height: 1.5; color: var(--tinta); background: var(--concreto); }
a { color: var(--fachada); }
:focus-visible { outline: 3px solid var(--talanquera); outline-offset: 2px; }
h1 { font-size: 1.7rem; font-stretch: 112%; font-weight: 640; color: var(--portal); margin: 0 0 6px; line-height: 1.2; }
.muted { color: var(--tinta-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: #e7e9ec; padding: 1px 5px; border-radius: 3px; font-size: .9em; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 18px; font: inherit; font-weight: 600; border-radius: 4px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; }
.btn--primary { background: var(--fachada); color: #fff; }
.btn--primary:hover { background: var(--fachada-ink); }
.btn--quiet { background: #fff; color: var(--portal); border-color: #c4cad1; }
.btn--quiet:hover { border-color: var(--portal); }
.btn--block { width: 100%; margin-top: 10px; }
.linkbtn { background: none; border: 0; padding: 4px 2px; font: inherit; color: var(--fachada); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn--danger { color: #a3341a; }
.iconbtn { display: inline-grid; place-items: center; width: 32px; height: 28px; border: 1px solid #c9cfd5; background: #fff; border-radius: 4px; cursor: pointer; font-size: 11px; color: var(--portal); padding: 0; }
.iconbtn:hover { border-color: var(--portal); }
.iconbtn.is-off { visibility: hidden; }
form.inline { display: inline; }

/* Formularios */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 560; margin-bottom: 5px; font-size: .95rem; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; font: inherit; color: var(--tinta); padding: 9px 11px; min-height: 42px;
  border: 1px solid #c4cad1; border-radius: 4px; background: #fff;
}
.field textarea { resize: vertical; }
.field textarea.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .9rem; line-height: 1.55; }
.field small { display: block; color: var(--tinta-2); margin-top: 5px; font-size: .85rem; }
.field input[type=file] { padding: 8px; background: #fafbfa; }
.req { font-weight: 500; font-size: .78rem; color: var(--ladrillo); margin-left: 6px; }
.check { display: flex; gap: 9px; align-items: flex-start; margin: 8px 0 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--fachada); }
fieldset { border: 0; margin: 0 0 18px; padding: 22px 24px 10px; background: #fff; border: 1px solid var(--linea); border-radius: 6px; }
legend { float: left; width: 100%; padding: 0; margin: 0 0 14px; font-weight: 640; font-stretch: 110%; color: var(--portal); font-size: 1.05rem; }
legend + * { clear: both; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.hint { background: #f4f5ef; border-left: 3px solid #b0ad6b; padding: 10px 14px; border-radius: 0 4px 4px 0; font-size: .9rem; color: #3f4636; margin: 0 0 12px; }
.hint p { margin: 0 0 6px; }
.hint ul { margin: 0 0 8px; padding-left: 18px; }

.flash { padding: 12px 16px; border-radius: 4px; font-weight: 550; margin: 0 0 18px; }
.flash p { margin: 0 0 6px; }
.flash--ok { background: var(--ok-bg); color: var(--ok); }
.flash--error { background: var(--err-bg); color: var(--err); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: .86rem; word-break: break-all; background: #fff; border: 1px dashed #9aa3ad; padding: 10px 12px; border-radius: 4px; color: var(--tinta); font-weight: 400; cursor: copy; }

/* Pantallas de acceso */
.authpage { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--portal); }
.authcard { width: min(440px, 100%); background: #fff; border-radius: 8px; padding: 0 0 26px; overflow: hidden; box-shadow: 0 24px 60px rgba(4,10,30,.4); }
.authcard > *:not(.authcard__logo) { margin-left: 28px; margin-right: 28px; }
.authcard__logo { display: block; width: 100%; height: auto; margin-bottom: 22px; }
.authcard__title { font-size: 1.35rem; margin-top: 0; }
.authcard .stack .btn { width: 100%; margin-top: 4px; }
.authcard__aside { margin-top: 16px; font-size: .92rem; }

/* Estructura del panel */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 22px; height: 58px; background: var(--portal); color: #fff; }
.topbar__brand { display: inline-flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; font-weight: 620; font-stretch: 112%; }
.topbar__brand img { border-radius: 6px; }
.topbar__user { display: flex; align-items: center; gap: 18px; font-size: .92rem; }
.topbar__user a, .topbar__user .linkbtn { color: #d4dcf1; }
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.sidenav { background: #fff; border-right: 1px solid var(--linea); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a { padding: 10px 12px; border-radius: 4px; color: var(--tinta); text-decoration: none; font-weight: 520; display: flex; justify-content: space-between; align-items: center; }
.sidenav a:hover { background: var(--concreto); }
.sidenav a.is-on { background: var(--portal); color: #fff; }
.count { background: var(--talanquera); color: #fff; font-size: .75rem; border-radius: 999px; padding: 1px 8px; }
.content { padding: 28px clamp(18px, 3vw, 40px) 60px; max-width: 1180px; width: 100%; }
.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px 24px; margin-bottom: 22px; }
.pagehead p { margin: 0; }
.pagehead__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.crumbs { margin: 0 0 6px; font-size: .92rem; }
.crumbs a::before { content: "‹ "; }

.tag { display: inline-block; font-size: .76rem; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.tag--on { background: var(--ok-bg); color: var(--ok); }
.tag--off { background: #e6e8eb; color: #59626f; }
.tag--new { background: #fdebdc; color: #8a3d0c; }
.tag--master { background: var(--talanquera); color: #fff; margin-left: 6px; }

.emptybox { background: #fff; border: 1.5px dashed #b9c0c7; border-radius: 6px; padding: 26px; max-width: 640px; }
.emptybox p { margin: 0 0 8px; }

/* Listas ordenables */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto auto; gap: 18px; align-items: center; background: #fff; border: 1px solid var(--linea); border-radius: 6px; padding: 10px 16px 10px 10px; }
.row--doc { grid-template-columns: minmax(0, 1fr) auto auto; padding-left: 18px; }
.row.is-hidden { background: #f7f8f7; }
.row.is-hidden .row__thumb, .row.is-hidden strong { opacity: .6; }
.row__thumb { width: 120px; height: 60px; display: grid; place-items: center; border: 1px solid #eceef0; border-radius: 4px; background: #fff; font-size: .78rem; color: var(--tinta-2); }
.row__thumb img { width: 100%; height: 100%; object-fit: contain; }
.row__main { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.row__order { display: flex; flex-direction: column; gap: 4px; }
.row__actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; margin-top: 16px; }
.editor--single { display: block; max-width: 860px; }
.editor--single.narrow { max-width: 560px; }
.editor__side { position: sticky; top: 76px; }
.sidebox { padding-bottom: 14px; }
.savebar { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--concreto) 30%); }
.logoedit { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 22px; align-items: start; }
.logobox { aspect-ratio: 2 / 1; width: 100%; display: grid; place-items: center; padding: 10px 14px; background: #fff; border: 1px solid var(--linea); border-radius: 6px;
  background-image: linear-gradient(45deg, #f2f3f1 25%, transparent 25%), linear-gradient(-45deg, #f2f3f1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #f2f3f1 75%), linear-gradient(-45deg, transparent 75%, #f2f3f1 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.logobox img { width: 100%; height: 100%; object-fit: contain; }
.logoedit__preview small { display: block; margin-top: 6px; color: var(--tinta-2); font-size: .82rem; }

/* Mensajes */
.filters { gap: 4px; }
.filters a { padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--tinta); border: 1px solid #c9cfd5; background: #fff; font-size: .9rem; }
.filters a.is-on { background: var(--portal); color: #fff; border-color: var(--portal); }
.msg { background: #fff; border: 1px solid var(--linea); border-radius: 6px; padding: 16px 20px; margin-bottom: 10px; }
.msg.is-new { border-left: 4px solid var(--talanquera); }
.msg__head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.msg__body { margin: 12px 0; white-space: normal; max-width: 75ch; }
.msg__actions { display: flex; gap: 18px; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--linea); border-radius: 6px; margin: 16px 0 26px; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e8eaec; vertical-align: top; }
.table th { font-weight: 600; color: var(--tinta-2); background: #f7f8f7; }
.table__actions { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.subrow td { background: #fafbfa; }
.inlineform { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.inlineform .field { margin: 0; min-width: 220px; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--linea); padding: 8px; }
  .sidenav a { white-space: nowrap; }
  .editor { grid-template-columns: 1fr; }
  .editor__side { position: static; }
  .twocol { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .row { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .row__thumb { width: 80px; height: 40px; }
  .row__actions { grid-column: 1 / -1; justify-content: flex-start; }
  .row--doc { grid-template-columns: minmax(0, 1fr) auto; }
  .grid2, .grid3, .logoedit { grid-template-columns: 1fr; }
  .topbar__user span { display: none; }
  .table { display: block; overflow-x: auto; }
}

/* Galería */
.row--photo { grid-template-columns: 120px minmax(0, 1fr) auto; }
.row--photo .row__actions { grid-column: 1 / -1; justify-content: flex-start; }
.row__thumb--photo { height: 72px; }
.row__thumb--photo img { object-fit: cover; border-radius: 4px; }
.photoedit img { width: 100%; max-width: 420px; border-radius: 8px; margin-bottom: 12px; }
