/* Firma de documentos · Reig Patrimonia
   Guía visual de los informes de Reig: sobria, cálida, estilo Apple / Power BI. */
:root {
  --page: #f3f2ef;
  --surface: #ffffff;
  --surface-2: #fcfcfb;
  --ink: #252423;
  --ink-2: #605e5c;
  --ink-3: #8a8580;
  --ink-4: #a19f9d;
  --line: #e6e2dd;
  --line-soft: #f0eeeb;
  --hover: #faf9f8;
  --chip: #f3f2f1;
  --seg: #ebe8e4;
  --brand: #8b7b6e;
  --brand-ink: #5c4f45;
  --dark: #2f2925;
  --dark-2: #3e3631;
  --eyebrow: #c0701f;
  --orange: #e8892b;
  --ok: #1f7a3a; --ok-bg: #e7f2ea;
  --warn: #b26a00; --warn-bg: #fbf1e1;
  --bad: #a4262c; --bad-bg: #fde7e9; --bad-strong: #c0262d;
  --muted-bg: #f3f2f1;
  --shadow-card: 0 0 0 1px rgb(0 0 0 / .05), 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px -12px rgb(0 0 0 / .12);
  --shadow-lift: 0 0 0 1px rgb(139 123 110 / .3), 0 12px 24px -14px rgb(60 45 30 / .45);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

/* Colores de firmante (paleta de los informes, tonos legibles sobre blanco) */
.c0 { --c: #56708f; } .c1 { --c: #5f7530; } .c2 { --c: #c0701f; } .c3 { --c: #276a7c; } .c4 { --c: #2c4d75; }
.c5 { --c: #8b7b6e; } .c6 { --c: #4bacc6; } .c7 { --c: #6d93c9; } .c8 { --c: #a6c46f; } .c9 { --c: #b26a00; }

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 8% 0%, #ffffff 0%, transparent 45%),
    radial-gradient(ellipse at 95% 100%, #ffffff 0%, transparent 40%),
    var(--page);

  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { color: var(--ink); }
h1 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
p { margin: 0 0 8px; }
.eyebrow {
  margin: 0 0 6px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .16em; color: var(--eyebrow);
}
h2.eyebrow { margin-bottom: 14px; }
.sub { color: var(--ink-3); font-size: 12.5px; }
.muted { color: var(--ink-2); }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 11.5px; }
.tabular, .num { font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.tight { margin: 10px 0 0; }
.min0 { min-width: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Iconos de línea */
.ico, .icon-btn svg, .back svg, .ghost-btn svg, .search svg, .chev svg, .dl svg, .file-ico svg, .doc-ico svg, .empty-icon svg, .dz-ico svg {
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.ico { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--dark-2) 0%, var(--dark) 100%);
  box-shadow: 0 1px 0 rgb(0 0 0 / .25);
}
.topbar-inner {
  max-width: 1360px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; color: #fff; border-radius: 12px; padding: 4px 6px; margin: -4px -6px; transition: background .2s var(--ease); }
.brand:hover { background: rgb(255 255 255 / .06); color: #fff; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sep { width: 1px; height: 26px; background: rgb(255 255 255 / .18); }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: rgb(255 255 255 / .5); white-space: nowrap; }

.pills {
  display: flex; gap: 2px; padding: 4px; border-radius: 999px;
  background: rgb(255 255 255 / .08); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .1);
}
.pill {
  padding: 6px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  color: rgb(255 255 255 / .72); white-space: nowrap; transition: all .2s var(--ease);
}
.pill:hover { color: #fff; background: rgb(255 255 255 / .08); }
.pill.on { background: #fff; color: var(--dark); box-shadow: 0 1px 3px rgb(0 0 0 / .25); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: rgb(255 255 255 / .85); font-size: 13px; padding: 3px 10px 3px 3px; border-radius: 999px; background: rgb(255 255 255 / .06); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; font-weight: 600; letter-spacing: .02em; color: #fff; background: var(--brand); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .15); }
.user-name { max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  color: rgb(255 255 255 / .85); font-size: 13px; font-weight: 500;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25); transition: all .2s var(--ease);
}
.ghost-btn:hover { background: rgb(255 255 255 / .1); color: #fff; }
.ghost-btn svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- Página */
.container { width: 100%; max-width: 1360px; margin: 0 auto; padding: 28px 24px 40px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head .sub { margin: 6px 0 0; }
.back {
  display: inline-flex; align-items: center; gap: 4px; margin: -6px 0 14px -6px; padding: 4px 10px 4px 6px;
  border-radius: 999px; color: var(--ink-3); font-size: 13px; font-weight: 500; transition: all .2s var(--ease);
}
.back:hover { background: var(--chip); color: var(--ink); }
.back svg { width: 14px; height: 14px; }
.foot { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; color: var(--ink-4); font-size: 11.5px; padding: 18px 16px 26px; letter-spacing: .02em; }
.asterisk { position: fixed; right: 24px; bottom: 24px; width: 44px; height: 44px; opacity: .9; pointer-events: none; z-index: 0; }

/* ---------------------------------------------------------------- Tarjetas, botones, formularios */
.card { position: relative; z-index: 1; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-card); padding: 20px; margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 48px auto; padding: 32px 28px; }
.card.narrow h1 { margin: 6px 0 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  background: var(--surface); color: var(--ink-2); box-shadow: 0 0 0 1px var(--line);
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease), color .2s var(--ease);
}
.btn:hover { color: var(--ink); background: var(--hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; transform: none; }
.btn-primary { background: var(--dark); color: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2), 0 4px 12px -6px rgb(47 41 37 / .6); }
.btn-primary:hover { background: #453c36; color: #fff; }
.btn-soft { background: var(--chip); color: var(--ink-2); box-shadow: none; }
.btn-soft:hover { background: var(--seg); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad); box-shadow: 0 0 0 1px #f2c9cd; }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-3); cursor: pointer; transition: all .2s var(--ease);
}
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn.danger:hover { background: var(--bad-bg); color: var(--bad); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn svg { width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions form { display: contents; }

input, select {
  font: inherit; font-size: 14px; color: var(--ink); width: 100%;
  border: 0; border-radius: 10px; padding: 9px 12px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s var(--ease), background .2s var(--ease);
}
input::placeholder { color: var(--ink-4); }
input:hover, select:hover { box-shadow: inset 0 0 0 1px #d6d0c9; }
input:focus, select:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 1px var(--brand), 0 0 0 4px rgb(139 123 110 / .15); }
select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6.5 3.5 3.5 3.5-3.5' fill='none' stroke='%238a8580' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; }

.alert { position: relative; z-index: 1; border-radius: 12px; padding: 11px 14px; margin-bottom: 16px; background: var(--chip); color: var(--ink-2); font-size: 13.5px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); white-space: pre-line; }
.loading-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--chip); color: var(--ink-2); font-size: 13px; }
.loading-chip::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #d6d0c9; border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- Estados */
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 10px 3px 9px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--muted-bg); color: var(--ink-2);
}
.badge-lg { font-size: 13px; padding: 6px 14px 6px 12px; }
.badge-sm { font-size: 11px; padding: 1px 8px; }
.badge-pending, .badge-sending { background: var(--warn-bg); color: var(--warn); }
.badge-signed { background: var(--ok-bg); color: var(--ok); }
.badge-rejected, .badge-error, .badge-expired { background: var(--bad-bg); color: var(--bad); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c8c3bd; flex: none; }
.dot-pending { background: #e0a030; }
.dot-sending { background: #e0a030; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.dot-signed { background: var(--ok); }
.dot-rejected, .dot-error, .dot-expired { background: var(--bad-strong); }
.dot-cancelled { background: #b9b4ad; }

/* ---------------------------------------------------------------- Portada: resumen y filtros */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; position: relative; z-index: 1; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-card); color: var(--ink);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--ink); }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--ink-3); }
.stat-total { background: #1f1b18; color: #fff; }
.stat-total:hover { color: #fff; }
.stat-total .stat-label, .stat-total .stat-sub { color: rgb(255 255 255 / .55); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; position: relative; z-index: 1; }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--seg); }
.seg a, .seg button {
  border: 0; background: transparent; font: inherit; cursor: pointer;
  padding: 5px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #6b6662; white-space: nowrap;
  transition: all .2s var(--ease);
}
.seg a:hover, .seg button:hover { color: var(--ink); }
.seg .on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
.select-wrap select { width: auto; border-radius: 999px; background-color: #fff; padding: 7px 34px 7px 14px; font-size: 13px; }
.search { position: relative; flex: 1; min-width: 220px; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { border-radius: 999px; padding: 8px 14px 8px 34px; background: #fff; font-size: 13.5px; }

/* ---------------------------------------------------------------- Portada: tabla */
.table-card { padding: 0; overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: #fff; background: var(--brand); padding: 10px 16px; white-space: nowrap;
}
table.list th.num { text-align: right; }
table.list td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.list tbody tr { cursor: pointer; transition: background .15s var(--ease); }
table.list tbody tr:hover { background: var(--hover); }
table.list tbody tr:last-child td { border-bottom: 0; }
.cell-doc { display: flex; align-items: center; gap: 12px; min-width: 0; }
.doc-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #a08a6e 0%, #6e5c48 55%, #3d3227 100%); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12); }
.doc-ico svg { width: 17px; height: 17px; }
.doc-text { display: flex; flex-direction: column; min-width: 0; }
.doc-title { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.doc-text .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42ch; }
.signers-mini { display: flex; align-items: center; gap: 8px; min-width: 0; }
.signers-mini .dots { display: inline-flex; gap: 3px; }
.signers-mini .sub { max-width: 28ch; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.row-actions form { display: inline; }
.chev { display: inline-grid; place-items: center; width: 22px; color: #c8c3bd; transition: transform .2s var(--ease), color .2s var(--ease); }
.chev svg { width: 14px; height: 14px; }
tr:hover .chev { color: var(--brand); transform: translateX(2px); }

.empty { text-align: center; padding: 48px 20px; }
.empty h2 { margin: 14px 0 6px; font-size: 17px; }
.empty p { max-width: 46ch; margin: 0 auto 18px; }
.empty-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: #fff;
  background: linear-gradient(135deg, #a08a6e 0%, #6e5c48 55%, #3d3227 100%); box-shadow: 0 8px 20px -10px rgb(60 45 30 / .6); }
.empty-icon svg { width: 26px; height: 26px; }

/* ---------------------------------------------------------------- Detalle */
.detail-layout { display: grid; grid-template-columns: minmax(340px, 400px) 1fr; gap: 16px; align-items: start; }
.detail-info .card:last-child { margin-bottom: 0; }
.signer-status { list-style: none; padding: 0; margin: 0; }
.signer-status li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.signer-status li:first-child { padding-top: 0; }
.signer-status li:last-child { border-bottom: 0; padding-bottom: 0; }
.signer-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; display: inline-block; }
.signer-status .sw { margin-top: 5px; }

.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); color: var(--ink); transition: all .2s var(--ease); }
.file-row:hover { background: var(--hover); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.file-row .grow { display: flex; flex-direction: column; }
.file-row strong { font-weight: 600; font-size: 13.5px; }
.file-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--chip); color: var(--brand-ink); flex: none; }
.file-ico svg { width: 17px; height: 17px; }
.file-ico-ok { background: var(--ok-bg); color: var(--ok); }
.dl { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; color: var(--ink-3); transition: all .2s var(--ease); }
.dl svg { width: 15px; height: 15px; }
.file-row:hover .dl { background: var(--dark); color: #fff; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; font-size: 13.5px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex: none; background: #fff; box-shadow: inset 0 0 0 2px #c8c3bd; position: relative; }
.timeline li.last .tl-dot { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand); }

/* Visor */
.viewer { position: sticky; top: 76px; padding: 16px; display: flex; flex-direction: column; height: calc(100vh - 100px); min-height: 520px; margin-bottom: 0; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.viewer-tools { display: flex; align-items: center; gap: 4px; }
.viewer-tools .sub { margin-right: 6px; }
.viewer-note { margin: 10px 2px 0; }
.viewer-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.legend-chip { display: inline-flex; align-items: center; gap: 7px; border: 0; font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  padding: 4px 10px; border-radius: 999px; background: var(--chip); transition: all .2s var(--ease); }
.legend-chip:hover { background: var(--seg); color: var(--ink); }
.viewer-stage {
  flex: 1; min-height: 0; overflow: auto; margin-top: 12px; border-radius: 12px; padding: 16px;
  background: #ebe8e4; display: flex; flex-direction: column; align-items: center; gap: 16px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .03);
}
.viewer-stage .loading-chip, .viewer-stage .alert { margin: auto; }
.viewer:fullscreen { height: 100vh; border-radius: 0; padding: 20px; }
.pv-page { position: relative; flex: none; background: #fff; border-radius: 4px; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 10px 30px -12px rgb(60 45 30 / .35); overflow: hidden; }
.pv-page canvas { display: block; opacity: 0; transition: opacity .3s var(--ease); }
.pv-page canvas.in { opacity: 1; }
.pv-num { position: absolute; right: 8px; bottom: 8px; z-index: 3; font-size: 10.5px; font-variant-numeric: tabular-nums; color: var(--ink-3); background: rgb(255 255 255 / .85); padding: 1px 7px; border-radius: 999px; box-shadow: 0 0 0 1px var(--line-soft); }
.pv-box {
  position: absolute; z-index: 2; border-radius: 6px; padding: 4px 6px; display: flex; flex-direction: column; justify-content: space-between;
  border: 1.5px dashed var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); overflow: hidden; line-height: 1.2;
}
.pv-box.st-signed { border-style: solid; background: color-mix(in srgb, var(--c) 16%, transparent); }
.pv-box-name { font-size: 11px; font-weight: 600; color: var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-box-status { align-self: flex-start; font-size: 10px; font-weight: 600; color: #fff; background: var(--c); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.pv-box.pulse { animation: pulse 1.2s var(--ease); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 40% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 30%, transparent); } }

/* ---------------------------------------------------------------- Nuevo envío */
.new-layout { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.15fr); gap: 16px; align-items: start; }
.col-preview { position: sticky; top: 76px; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 14px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--dark); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.field { display: block; margin: 12px 0 0; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field > span .sub { font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; padding: 0; accent-color: var(--brand); box-shadow: none; flex: none; }
.dropzone {
  display: block; border-radius: 14px; padding: 26px 16px; text-align: center; cursor: pointer;
  background: var(--surface-2); border: 1.5px dashed #d6d0c9; transition: all .2s var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: #faf8f5; }
.dropzone.has-file { border-style: solid; border-color: var(--line); text-align: left; padding: 12px 14px; }
.dz-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink-2); }
.dz-empty u { color: var(--brand-ink); text-decoration-color: rgb(139 123 110 / .4); text-underline-offset: 2px; }
.dz-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; margin-bottom: 6px;
  background: linear-gradient(135deg, #a08a6e 0%, #6e5c48 55%, #3d3227 100%); box-shadow: 0 8px 18px -10px rgb(60 45 30 / .6); }
.dz-ico svg { width: 22px; height: 22px; }
.dz-file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-icon { background: var(--bad-strong); color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; border-radius: 6px; padding: 5px 6px; }
#file-name { font-weight: 600; word-break: break-all; }

#signers { margin-top: 4px; }
.signer { position: relative; border: 0; border-radius: 14px; padding: 12px 14px 14px; margin: 0 0 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s var(--ease), background .2s var(--ease); }
.signer.active { background: #fff; box-shadow: inset 0 0 0 1px var(--brand), 0 0 0 4px rgb(139 123 110 / .12); }
.signer-head { padding: 0; margin: 0 0 2px; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.signer .row:first-of-type { padding-top: 2px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.signer .remove { position: absolute; top: 6px; right: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { grid-template-columns: 1.1fr 1fr .8fr; }

.preview-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.preview-head h2 { margin: 0; }
.pager { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; padding: 2px; border-radius: 999px; background: var(--chip); }
.pager span { padding: 0 4px; }
.place-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.chip { display: inline-flex; align-items: stretch; border-radius: 999px; overflow: hidden; font-size: 12.5px; background: var(--chip); }
.chip.active { background: #fff; box-shadow: 0 0 0 1px var(--c), 0 0 0 4px color-mix(in srgb, var(--c) 15%, transparent); }
.chip button { border: 0; background: transparent; font: inherit; cursor: pointer; padding: 4px 11px; color: var(--ink-2); }
.chip-name::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 7px; }
.chip button:hover { color: var(--ink); }
.chip-here { border-left: 1px solid var(--line) !important; color: var(--brand-ink) !important; font-weight: 600 !important; }
.preview-stage { margin-top: 12px; background: #ebe8e4; border-radius: 12px; min-height: 440px; display: grid; place-items: center; padding: 13px; overflow: hidden; }
.preview-empty { color: var(--ink-3); font-size: 13px; }
.page-wrap { position: relative; background: #fff; line-height: 0; border-radius: 3px; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 10px 30px -12px rgb(60 45 30 / .35); }
.overlay { position: absolute; inset: 0; }
.sigbox {
  position: absolute; border: 1.5px solid var(--c); background: color-mix(in srgb, var(--c) 10%, transparent);
  border-radius: 6px; cursor: move; touch-action: none; user-select: none; line-height: 1.2; transition: background .15s;
}
.sigbox.active { background: color-mix(in srgb, var(--c) 18%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); z-index: 2; }
.sigbox-label { position: absolute; left: 6px; top: 4px; right: 14px; font-size: 11px; font-weight: 600; color: var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sigbox-handle { position: absolute; right: -5px; bottom: -5px; width: 11px; height: 11px; border-radius: 50%; background: #fff; border: 2px solid var(--c); cursor: nwse-resize; }

.cover-card { padding-top: 36px; }
.cover-logo { width: 260px; max-width: 80%; height: auto; display: block; margin: 0 auto 22px; }

/* ---------------------------------------------------------------- Portada */
body.home .container { max-width: 980px; }
.home-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 26px 0 30px; position: relative; z-index: 1; }
.home-logo { width: 340px; max-width: 78%; height: auto; display: block; }
.home-greet { margin: 18px 0 0; color: var(--ink-3); font-size: 15px; }
.home-group { margin-bottom: 26px; position: relative; z-index: 1; }
.home-group .eyebrow { margin-left: 4px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 18px; background: #fff; color: var(--ink);
  box-shadow: 0 0 0 1px rgb(0 0 0 / .05), 0 8px 20px -14px rgb(60 45 30 / .35);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
a.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); color: var(--ink); }
a.tile:active { background: var(--hover); }
.tile-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, #a08a6e 0%, #6e5c48 55%, #3d3227 100%); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12), 0 6px 14px -8px rgb(60 45 30 / .7); }
.tile-ico svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tile-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tile-title { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.tile-sub { color: var(--ink-3); font-size: 12.5px; line-height: 1.4; }
.tile-badge { flex: none; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--chip); color: var(--ink-2); }
.tile-badge.warn { background: var(--warn-bg); color: var(--warn); }
.tile-badge.bad { background: var(--bad-bg); color: var(--bad); }
.tile-badge.soon { background: transparent; color: var(--ink-4); box-shadow: inset 0 0 0 1px var(--line); }
.tile-chev { color: #c8c3bd; display: grid; place-items: center; transition: transform .2s var(--ease), color .2s var(--ease); }
.tile-chev svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a.tile:hover .tile-chev { color: var(--brand); transform: translateX(2px); }
.tile-disabled { background: rgb(255 255 255 / .55); box-shadow: 0 0 0 1px rgb(0 0 0 / .04); }
.tile-disabled .tile-ico { filter: grayscale(.6); opacity: .55; }
.tile-disabled .tile-title { color: var(--ink-2); }

/* ---------------------------------------------------------------- Hoja de contactos (Nou enviament) */
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.step-head .step-title { margin-bottom: 8px; }
.signer-tag { font-weight: 500; }
.sheet { border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 48px)); border-radius: 20px; background: #fff; color: var(--ink);
  box-shadow: 0 24px 60px -20px rgb(40 30 20 / .45), 0 0 0 1px rgb(0 0 0 / .05); }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .25s var(--ease); }
.sheet::backdrop { background: rgb(31 27 24 / .38); backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 20px 20px 8px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-tools { display: flex; flex-direction: column; gap: 10px; padding: 8px 20px 12px; border-bottom: 1px solid var(--line-soft); }
.sheet-tools .seg { align-self: flex-start; }
.sheet-list { flex: 1; overflow: auto; padding: 6px 10px; min-height: 160px; }
.sheet-empty { padding: 24px; text-align: center; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pick { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; cursor: pointer; transition: background .15s var(--ease); }
.pick:hover { background: var(--hover); }
.pick input { width: 17px; height: 17px; padding: 0; box-shadow: none; accent-color: var(--dark); flex: none; }
.pick.used { opacity: .5; cursor: default; }
.pick-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-text .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: #fff; flex: none; background: var(--brand); }
.g-familia { background: #56708f; }
.g-reig { background: #8b7b6e; }
.g-extern { background: #5f7530; }
.grp { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.grp-familia { background: #e8edf3; color: #3d5470; }
.grp-reig { background: #f1ece6; color: var(--brand-ink); }
.grp-extern { background: #edf1e4; color: #4a5c25; }

/* Rúbricas */
.row-place { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; padding-top: 10px; border-top: 1px dashed var(--line); }
.row-place .field { flex: 1 1 140px; min-width: 0; margin-top: 8px; }
.row-place .field-narrow { flex: 0 0 86px; }
.place-hint { margin: 8px 0 0; }
.sigbox.mark { border-style: dashed; background: color-mix(in srgb, var(--c) 6%, rgb(255 255 255 / .6)); }
.sigbox-del { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: #fff; color: var(--bad); font: 600 13px/18px var(--font); box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgb(0 0 0 / .15); }
.sigbox-del:hover { background: var(--bad-bg); }
.pv-box.pv-mark { border-style: dashed; background: color-mix(in srgb, var(--c) 5%, rgb(255 255 255 / .5)); }
.pv-box.pv-mark .pv-box-status { background: #fff; color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.help { margin-top: 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-soft); padding: 10px 14px; font-size: 13px; color: var(--ink-2); }
.help summary { cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "+"; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 8px; border-radius: 50%; background: var(--chip); color: var(--ink-2); font-size: 13px; }
.help[open] summary::before { content: "\2212"; }
.help p { margin: 10px 0 0; line-height: 1.55; }

/* ---------------------------------------------------------------- Contactes */
.seg-n { font-variant-numeric: tabular-nums; color: var(--ink-4); font-size: 12px; margin-left: 2px; }
.seg .on .seg-n { color: var(--ink-3); }
.contact-form-card .actions { margin-top: 18px; }
.contact-group { margin-bottom: 22px; position: relative; z-index: 1; }
.group-title { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 0 0 10px 2px; }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.contact { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; margin: 0; transition: box-shadow .2s var(--ease); }
.contact.editing { box-shadow: 0 0 0 2px var(--brand), var(--shadow-card); }
.contact .pick-av { width: 40px; height: 40px; font-size: 13px; }
.contact-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.contact-text .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-text a.sub:hover { color: var(--brand-ink); }
.contact-actions { display: flex; gap: 2px; flex: none; }
.contact-actions form { display: inline; }

/* ---------------------------------------------------------------- Administració */
.inline-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 200px; margin: 0; }
table.perms td { vertical-align: middle; }
table.perms tbody tr { cursor: default; }
table.perms tr.off td { opacity: .55; }
table.perms th.center { text-align: center; }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.cell-user form { display: none; }
.avatar-lg { width: 36px; height: 36px; font-size: 12px; flex: none; }
.switch { position: relative; display: inline-flex; cursor: pointer; }
.switch input[type=checkbox] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { width: 38px; height: 22px; border-radius: 999px; background: #e1dfdd; position: relative; transition: background .2s var(--ease); }
.switch-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .2s var(--ease); }
.switch input:checked ~ .switch-ui { background: #75665a; }
.switch input:checked ~ .switch-ui::after { transform: translateX(16px); }
.switch input:focus-visible ~ .switch-ui { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled ~ .switch-ui { opacity: .75; cursor: not-allowed; }
.switch input:disabled:checked ~ .switch-ui::before { content: ""; position: absolute; left: 7px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: rgb(255 255 255 / .7); }
.perm-help { margin: 4px 4px 0; position: relative; z-index: 1; }
.perm-help p { margin: 0 0 4px; }
table.log tbody tr { cursor: default; }
table.log td { vertical-align: top; }
.warn-row td { background: #fff8f0; }
.log-detail { max-width: 520px; word-break: break-word; }
.meta { margin: 14px 0 0; display: grid; gap: 6px; }
.meta div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.meta dt { color: var(--ink-3); }
.meta dd { margin: 0; color: var(--ink-2); }

/* ---------------------------------------------------------------- Pantalla de entrada (/entrar, /sortir) */
body.auth {
  background:
    radial-gradient(ellipse at 10% 0%, #ffffff 0%, transparent 55%),
    radial-gradient(ellipse at 90% 100%, #ffffff 0%, transparent 50%),
    radial-gradient(ellipse at 70% 30%, #ecebe8 0%, transparent 45%),
    #f3f2ef;
}
.auth-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px 32px; position: relative; z-index: 1; }
.auth-logo { width: 380px; max-width: 82%; height: auto; display: block; user-select: none; animation: auth-in .5s var(--ease) both; }
.auth-card {
  width: 100%; max-width: 420px; margin-top: 40px; padding: 30px 32px 26px; text-align: center;
  background: #fff; border-radius: 22px; box-shadow: var(--shadow-card), 0 24px 48px -28px rgb(60 45 30 / .35);
  animation: auth-in .5s .08s var(--ease) both;
}
@keyframes auth-in { from { opacity: 0; transform: translateY(8px); } }
.auth-app { display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .16em; color: var(--eyebrow); }
.auth-app-ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #a08a6e 0%, #6e5c48 55%, #3d3227 100%); }
.auth-app-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.auth-card h1 { margin: 14px 0 6px; font-size: 21px; }
.auth-text { color: #6b6662; font-size: 14px; line-height: 1.55; margin: 0 auto 22px; max-width: 34ch; }
.auth-alert { text-align: left; margin: -6px 0 18px; }
.btn-ms {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 12px 18px; border-radius: 999px; background: var(--dark-2); color: #fff; font-size: 14.5px; font-weight: 500;
  box-shadow: 0 1px 2px rgb(0 0 0 / .2), 0 8px 20px -10px rgb(47 41 37 / .7); transition: background .2s var(--ease), transform .2s var(--ease);
}
.btn-ms:hover { background: var(--dark); color: #fff; }
.btn-ms:active { transform: scale(.98); }
.btn-ms svg { width: 17px; height: 17px; flex: none; background: #fff; padding: 2px; border-radius: 3px; box-sizing: content-box; }
.auth-hint { margin: 12px 0 0; font-size: 12px; color: var(--ink-3); }
.auth-foot { margin-top: 28px; font-size: 11.5px; color: var(--ink-4); letter-spacing: .02em; }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: 1fr; }
  .viewer { position: static; height: 78vh; }
}
@media (max-width: 960px) {
  .new-layout { grid-template-columns: 1fr; }
  .col-preview { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .brand-sep, .brand-text { display: none; }
}
@media (max-width: 767px) {
  h1 { font-size: 19px; }
  .container { padding: 18px 16px 32px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .pills { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .pill { flex: 1; text-align: center; }
  .user-name, .hide-sm { display: none; }
  .user-chip { padding: 3px; }
  .ghost-btn { padding: 6px; }
  .brand-logo { height: 22px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head .btn { align-self: stretch; }
  .card { padding: 16px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 24px; }
  .toolbar .search { flex-basis: 100%; }
  .asterisk { display: none; }

  /* La tabla pasa a tarjetas: documento y estado primero, el detalle debajo */
  .table-card { background: transparent; box-shadow: none; overflow: visible; }
  table.list, table.list tbody { display: block; }
  table.list thead { display: none; }
  .card.table-card { padding: 0; }
  table.list tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 10px; padding: 14px 14px 10px; margin-bottom: 10px;
    border-radius: 16px; background: #fff; box-shadow: var(--shadow-card);
    grid-template-areas: 'doc status' 'signers signers' 'date actions';
  }
  table.list td { display: block; padding: 0; border: 0; min-width: 0; }
  table.list td.cell-doc { display: flex; grid-area: doc; }
  table.list td.cell-status { grid-area: status; align-self: start; }
  table.list td.cell-signers { grid-area: signers; }
  table.list td.cell-date { grid-area: date; align-self: center; text-align: left; }
  table.list td.cell-by { display: none; }
  table.list td.col-actions { grid-area: actions; width: auto; }
  .row-actions { margin-right: -6px; }
  .doc-title, .doc-text .sub { max-width: 100%; }
  .signers-mini .sub { max-width: none; flex: 1; }
  .row, .row-3 { grid-template-columns: 1fr; gap: 0; }
  .viewer { height: 72vh; padding: 12px; }
  .tiles { grid-template-columns: 1fr; }
  .auth-card { padding: 26px 22px 22px; margin-top: 30px; }
  .auth-screen { justify-content: flex-start; padding-top: 64px; }
  .home-hero { padding: 8px 0 20px; }
  .home-logo { width: 280px; }
  .tile { padding: 12px 14px; gap: 12px; }
  .tile-ico { width: 40px; height: 40px; }
  .tile-badge:not(.soon) { display: none; }
  .contact-grid { grid-template-columns: 1fr; }
  .step-head { flex-wrap: wrap; }
  /* Permisos: cada usuario en una tarjeta, interruptores en dos columnas */
  table.perms tbody tr { grid-template-columns: 1fr 1fr; grid-template-areas: none; }
  table.perms td.cell-user { grid-column: 1 / -1; min-width: 0; display: flex; }
  table.perms td.cell-perm { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--ink-2); }
  table.perms td.cell-perm::before { content: attr(data-label); }
  table.log tbody tr { grid-template-columns: 1fr; grid-template-areas: none; gap: 2px; }
  table.log td { grid-column: 1; }
  .inline-form .btn { width: 100%; }
  .viewer-stage { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
