/* App legal. Colores, tipografía y disposición de docs/design/prototipo.html.
   IBM Plex (OFL-1.1, vendor/plex) servida por la propia app: cargarla de
   Google mandaría a Google cada visita de un cliente. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/plex/IBMPlexSans-Regular.5aaadb685d3c.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("../vendor/plex/IBMPlexSans-Medium.02ec16345450.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../vendor/plex/IBMPlexSans-SemiBold.51d76d33ef85.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../vendor/plex/IBMPlexMono-Regular.b51685c998a0.woff2") format("woff2"); }

:root {
  --bg: #F5F5F2;
  --surface: #FFFFFF;
  --text: #1A1D21;
  --muted: #5B6270;
  --border: #E2E2DC;
  --border-strong: #D3D3CC;
  --primary: #1F4E8C;
  --primary-dark: #163A69;
  --primary-soft: #EAF0F8;
  --ok: #1E6B3A;
  --ok-soft: #E6F2EA;
  --warn: #7A4B00;
  --warn-soft: #FFF3D6;
  --danger: #A11D2B;
  --danger-soft: #FBE9EB;
  --mark: #FFE58A;
  --radius: 8px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
mark { background: var(--mark); color: var(--text); padding: 0 2px; border-radius: 2px; }
h1 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.25; }
h2 { margin: 0; font-size: 15px; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); }
.skip:focus { left: 8px; }

/* ---- Estructura: barra lateral + contenido ---- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 220px; max-width: 250px; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; text-decoration: none; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.brand-name { font-weight: 600; font-size: 16px; display: block; }
.brand-firm { font-size: 12px; color: var(--muted); display: block; }
.nav-link { padding: 10px 12px; border-radius: 6px; text-decoration: none; color: var(--text); }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav-spacer { flex-grow: 1; min-height: 16px; }
.nav-muted { color: var(--muted); }
.firm-switch { padding: 12px 10px 4px; border-top: 1px solid var(--border); margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.firm-switch fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.firm-switch legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; }
.firm-option { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; }
.firm-option:hover { background: var(--bg); }
.firm-option:has(input:checked) { background: var(--primary-soft); }
.firm-option input { margin-top: 3px; }
.firm-option-name { display: block; font-weight: 500; line-height: 1.3; }
.firm-option-role { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }
.user-line { font-size: 12px; color: var(--muted); padding: 8px 10px 0; display: flex; justify-content: space-between; gap: 8px; align-items: center; }

.content { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 40px; display: flex; gap: 12px; align-items: center; }
.topbar form { flex: 1 1 auto; display: flex; gap: 8px; max-width: 720px; }
.topbar input[type="search"] { flex: 1 1 auto; min-width: 0; }
main { padding: 28px 40px 48px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }

/* Menú plegable en pantallas angostas */
.sidebar .menu-toggle { display: none; }
@media (max-width: 760px) {
  /* nowrap: en columna con wrap, el ancho de la línea sale del contenido más
     ancho (el visor) y la página se desborda. */
  .shell { flex-direction: column; flex-wrap: nowrap; }
  .sidebar { max-width: none; flex: none; border-right: 0; border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; }
  .brand { padding: 4px 4px; }
  .sidebar .menu-toggle { display: inline-flex; }
  .sidebar-links { display: none; flex-direction: column; gap: 2px; padding-top: 8px; }
  .sidebar.open .sidebar-links { display: flex; }
  .topbar { padding: 10px 16px; }
  main { padding: 20px 16px 40px; }
  h1 { font-size: 21px; }
}
@media (min-width: 761px) {
  .sidebar-links { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
}

/* ---- Piezas ---- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.grid > .main-col { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.grid > .side-col { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.empty { color: var(--muted); padding: 8px 0; }
.group-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin: 20px 0 4px; }
h2 + .group-title { margin-top: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none; font: inherit; font-weight: 500; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--bg); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-danger { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"],
input[type="number"], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 9px 10px; min-height: 40px; width: 100%; max-width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type="file"] { font: inherit; max-width: 100%; }

.search-hero { display: flex; flex-direction: column; gap: 10px; }
.search-hero label { font-size: 13px; color: var(--muted); }
.search-box { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 2px solid var(--primary);
  border-radius: 10px; padding: 0 8px 0 16px; min-height: 56px; }
.search-box input { border: 0; font-size: 17px; padding: 8px 0; min-height: 0; background: transparent; }
.search-box input:focus-visible { outline: none; }
.search-box:focus-within { outline: 3px solid var(--primary-soft); }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 13px; font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); }
.field-error, .errorlist { color: var(--danger); font-size: 13px; margin: 0; padding: 0; list-style: none; }
.req { color: var(--danger); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px 16px; margin: 0; min-width: 0; background: var(--surface); }
legend { font-weight: 600; padding: 0 6px; }
.group-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.group .group { grid-column: 1 / -1; background: var(--bg); }
.rows { display: flex; flex-direction: column; gap: 12px; grid-column: 1 / -1; }
.row { border: 1px dashed var(--border-strong); border-radius: 8px; padding: 12px; display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.row-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.row-title { font-weight: 500; }
.null-toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
fieldset[data-null="true"] > .group-body { display: none; }
.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-mapped { background: var(--primary-soft); color: var(--primary); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* Tablas y listas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.pager { display: flex; gap: 12px; align-items: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar form { display: flex; gap: 8px; flex: 1 1 260px; }

.result { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.result:last-child { border-bottom: 0; }
.result-title { font-weight: 600; }
.snippet { font-family: var(--serif); font-size: 15px; }

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-dark); }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.messages li.success { background: var(--ok-soft); color: var(--ok); }

dl.data { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 8px 16px; margin: 0; }
dl.data dt { color: var(--muted); }
dl.data dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Visor */
.viewer-card { padding: 0; overflow: hidden; }
docs-viewer { display: block; height: 78vh; min-height: 460px; }
@media (max-width: 760px) { docs-viewer { height: 70vh; min-height: 380px; } }

/* Páginas de cuenta (allauth) */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; }
.auth form p { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.auth form label { font-size: 13px; font-weight: 500; }
.auth .helptext { font-size: 12px; color: var(--muted); }
.qr { max-width: 220px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.auth button[type="submit"], .auth button:not([type]) { font: inherit; font-weight: 500; padding: 10px 16px; min-height: 40px;
  border-radius: var(--radius); border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; }
.auth h1 { font-size: 21px; }
.auth a { overflow-wrap: anywhere; }

/* Zona de subida: el input de archivo queda accesible (enfocable y con su
   etiqueta), solo se esconde su aspecto. */
.dropzone { position: relative; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 20px 16px; background: var(--surface); }
.dropzone.is-over { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.dropzone-label { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; cursor: pointer; }
.dropzone-label .link { text-decoration: underline; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.dropzone-files { margin: 12px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.dropzone-files:empty { display: none; }
.dropzone-files li { display: flex; flex-direction: column; gap: 2px; }
.dropzone-files input { width: 100%; }
.rename { margin-top: 4px; }
.rename .form-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rename .form-inline input { flex: 1 1 220px; min-width: 0; }
.notice { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius); padding: 10px 12px; }

/* Importar desde Word: un bloque por espacio encontrado. */
.import-space { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; min-width: 0; }
.import-context { margin: 4px 0 10px; overflow-wrap: anywhere; }
.field-check label { display: flex; gap: 8px; align-items: center; font-weight: normal; }
