/* ASIU · Digitalizacion de contratos */
:root {
  --brand: #6aa52b; --brand-dark: #4f7f1d; --brand-soft: #eef6e4;
  --ink: #1d2433; --ink-2: #4a5468; --muted: #7a8396; --line: #e3e7ee; --bg: #f5f7fa; --card: #fff;
  --green: #2f9e44; --green-bg: #ebf8ee; --yellow: #d99100; --yellow-bg: #fff6df; --red: #d6336c; --red-bg: #fdebf1;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-dark); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
code { background: #f0f2f6; padding: 1px 5px; border-radius: 4px; font-size: .85em; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem; height: 56px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.brand-mark { background: var(--brand); color: #fff; font-weight: 800; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; font-size: .9rem; }
.brand-mark.big { font-size: 1.6rem; padding: 6px 14px; border-radius: 10px; }
.brand-sub { font-weight: 600; }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.nav a { padding: .45rem .75rem; border-radius: 8px; text-decoration: none; color: var(--ink-2); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.userbox { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.userbox a { text-decoration: none; color: var(--ink); font-weight: 500; }
.userbox small { color: var(--muted); font-weight: 400; margin-left: .25rem; }
.userbox form { margin: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
main.wide { max-width: none; padding: 0; }
.page-head { margin-bottom: 1.25rem; }
.page-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- tarjetas y rejillas ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 520px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 1.25rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + * { margin-top: 1.25rem; }

/* ---------- botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: #c8cfdb; background: #fafbfc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { color: var(--red); border-color: #f2c2d3; }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.btn-big { padding: .75rem 1.4rem; font-size: 1rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; cursor: pointer; text-decoration: underline; }
.btn-mini { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); padding: .5rem .65rem; border: 1px solid #ccd3de; border-radius: 8px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(106,165,43,.35); border-color: var(--brand); }
label { display: block; font-weight: 500; font-size: .9rem; color: var(--ink-2); }
label > input, label > select, label > textarea { margin-top: .3rem; }
.stack { display: grid; gap: .9rem; }
.inline-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form label { flex: 1 1 160px; }
.row-form { display: inline-flex; gap: .35rem; align-items: center; margin: 2px 0; }
.row-form input, .row-form select { width: auto; padding: .3rem .5rem; font-size: .88rem; }
.w-sm { width: 150px !important; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: var(--green-bg); border-color: #bfe5c8; color: #1f6e31; }
.flash-error { background: var(--red-bg); border-color: #f2c2d3; color: #9c1f4d; }
.flash-warn { background: var(--yellow-bg); border-color: #f3dd9f; color: #7a5300; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
.table tr:hover td { background: #fbfcfd; }
.table.small td { font-size: .86rem; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.empty { text-align: center !important; color: var(--muted); padding: 2rem !important; }
.hl-row td { background: #fffbea; }
.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; font-weight: 500; color: var(--ink-2); padding: .35rem .5rem .35rem 0; width: 42%; vertical-align: top; }
.kv td { padding: .35rem 0; font-weight: 600; }
.kv tr.muted th, .kv tr.muted td { color: var(--muted); font-weight: 400; }
.pager { display: flex; gap: .35rem; flex-wrap: wrap; }
.pager a { padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.filters { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.filters label { flex: 1 1 150px; }
.filters label:first-of-type { flex: 3 1 260px; }

/* ---------- estados y semaforo ---------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 6px; vertical-align: middle; }
.dot-verde { background: var(--green); } .dot-amarillo { background: var(--yellow); } .dot-rojo { background: var(--red); }
.status { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; vertical-align: middle; }
.status-validado { background: var(--green-bg); color: #1f6e31; }
.status-por_validar { background: var(--yellow-bg); color: #7a5300; }
.status-procesando { background: #e7f0ff; color: #2853a6; }
.status-error { background: var(--red-bg); color: #9c1f4d; }
.status-anulado { background: #eceef2; color: #5b6475; text-decoration: line-through; }

/* ---------- subida ---------- */
.dropzone { border: 2px dashed #c3cbd8; border-radius: 14px; background: #fff; padding: 2.5rem 1rem; text-align: center; transition: .15s; cursor: pointer; margin-bottom: 1.25rem; }
.dropzone.over, .dropzone:focus { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.dz-icon { font-size: 2rem; color: var(--brand); }
.queue { display: grid; gap: .75rem; margin-bottom: 1.5rem; }
.qitem { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 4px solid #c3cbd8; border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow); }
.qitem.state-listo { border-left-color: var(--green); }
.qitem.state-error { border-left-color: var(--red); }
.qitem.state-revisar { border-left-color: var(--yellow); }
.qitem.state-procesando, .qitem.state-subiendo { border-left-color: #4c7bd9; }
.qitem.state-duplicado { border-left-color: var(--muted); }
.qthumbs { display: flex; gap: .5rem; }
.qthumb { position: relative; margin: 0; }
.qthumb img { width: 64px; height: auto; border: 1px solid var(--line); border-radius: 4px; display: block; background: #fff; }
.qitem.state-revisar .qthumb img { width: 120px; }
.qthumb figcaption { font-size: .7rem; color: var(--muted); text-align: center; }
.qname { font-weight: 600; word-break: break-all; }
.qstatus { color: var(--ink-2); font-size: .9rem; }
.qextra { color: var(--muted); font-size: .85rem; }
.qbar { height: 5px; background: #eef1f5; border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.qbar span { display: block; height: 100%; background: var(--brand); transition: width .6s; }
.qitem.state-procesando .qbar span { background: linear-gradient(90deg, #4c7bd9, #7aa3f0, #4c7bd9); background-size: 200% 100%; animation: shimmer 1.5s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.chips { white-space: nowrap; margin-left: .25rem; }

/* ---------- validacion ---------- */
.review { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(420px, 1fr); height: calc(100vh - 56px); }
.viewer { display: flex; flex-direction: column; background: #2b313c; min-width: 0; }
.viewer-bar { display: flex; gap: .5rem; padding: .5rem .75rem; background: #1f242d; align-items: center; flex-wrap: wrap; }
.viewer-bar .btn { background: #3a4150; color: #fff; border-color: #4a5263; }
.seg { display: inline-flex; border: 1px solid #4a5263; border-radius: 8px; overflow: hidden; }
.seg button { background: #3a4150; color: #dfe4ec; border: 0; padding: .35rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; }
.seg button + button { border-left: 1px solid #4a5263; }
.seg button.on { background: var(--brand); color: #fff; }
.viewer-stage { flex: 1; overflow: auto; padding: 1rem; }
.viewer-canvas { position: relative; width: 100%; margin: 0 auto; transition: width .2s; }
.viewer-canvas img { width: 100%; display: block; background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.35); }
.hl { position: absolute; display: none; border: 3px solid #ffb703; background: rgba(255,183,3,.12); border-radius: 4px; box-shadow: 0 0 0 9999px rgba(0,0,0,.18); pointer-events: none; transition: all .2s; }
.review-form { overflow-y: auto; padding: 1.25rem 1.5rem 3rem; background: var(--bg); }
.review-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; position: sticky; top: -1.25rem; background: var(--bg); padding: .75rem 0; z-index: 5; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.pending-box { padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; white-space: nowrap; }
.pending-box.has { background: var(--red-bg); color: #9c1f4d; }
.pending-box.done { background: var(--green-bg); color: #1f6e31; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .82rem; color: var(--ink-2); margin-bottom: 1rem; }
.section-title { margin: 1.25rem 0 .6rem; font-size: 1rem; }
.section-title small { color: var(--muted); font-weight: 400; }
.frow { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .55rem; transition: box-shadow .15s; }
.frow.s-amarillo { border-left-color: var(--yellow); }
.frow.s-rojo { border-left-color: var(--red); }
.frow.pending.s-rojo { background: #fff8fa; }
.frow.pending.s-amarillo { background: #fffdf5; }
.frow.resolved { border-left-color: var(--green); }
.frow.focus { box-shadow: 0 0 0 3px rgba(106,165,43,.25); }
.fhead { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; }
.fhead .dot { margin-left: 0; }
.fhead label { flex: 1; font-weight: 600; color: var(--ink); font-size: .92rem; }
.req { color: var(--red); }
.badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 99px; }
.badge-verde { background: var(--green-bg); color: #1f6e31; }
.badge-amarillo { background: var(--yellow-bg); color: #7a5300; }
.badge-rojo { background: var(--red-bg); color: #9c1f4d; }
.frow.resolved .badge { background: var(--green-bg); color: #1f6e31; }
.snip { width: 100%; background-repeat: no-repeat; border: 1px solid var(--line); border-radius: 6px; margin-bottom: .45rem; cursor: zoom-in; background-color: #fff; }
.finput { display: flex; gap: .6rem; align-items: center; }
.finput input, .finput select { font-size: 1.02rem; font-weight: 600; letter-spacing: .01em; }
.confirm { display: flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: .85rem; color: #7a5300; cursor: pointer; }
.confirm input { width: 18px; height: 18px; margin: 0; }
.reasons { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .84rem; color: var(--ink-2); }
.cands { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chip { border: 1px solid #c8d6b8; background: var(--brand-soft); color: var(--brand-dark); border-radius: 99px; padding: .2rem .65rem; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip:hover { background: var(--brand); color: #fff; }
.ai-reads { margin-top: .3rem; }
.ferror { color: var(--red); font-size: .85rem; font-weight: 600; }
.ferror:empty { display: none; }
.controls { margin: 1rem 0; font-size: .88rem; }
.controls summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
.crow { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.ai-notes { background: #eef3ff; border: 1px solid #d6e1fb; border-radius: 8px; padding: .7rem 1rem; font-size: .88rem; margin: 1rem 0; }
.ai-notes ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.notes { margin: 1rem 0; }
.declaration { display: flex; gap: .6rem; align-items: flex-start; background: #fff; border: 2px solid var(--brand); border-radius: 8px; padding: .8rem 1rem; font-size: .95rem; color: var(--ink); cursor: pointer; }
.declaration input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.form-actions { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.page-preview { width: 100%; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); border-top: 3px solid var(--line); }
.kpi span { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi strong { display: block; font-size: 1.7rem; letter-spacing: -.02em; margin-top: .15rem; }
.kpi small { color: var(--muted); }
.kpi-ok { border-top-color: var(--green); } .kpi-warn { border-top-color: var(--yellow); } .kpi-err { border-top-color: var(--red); }
.bars { display: grid; grid-template-columns: repeat(30, 1fr); gap: 4px; height: 170px; align-items: end; }
.bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar span { width: 100%; background: var(--brand); border-radius: 3px 3px 0 0; min-height: 1px; }
.bar em { font-style: normal; font-size: .68rem; color: var(--ink-2); order: -1; }
.bar small { font-size: .62rem; color: var(--muted); margin-top: 3px; }
.meter { position: relative; height: 18px; background: #eef1f5; border-radius: 99px; overflow: hidden; min-width: 120px; }
.meter span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.meter span.good { background: #8fd19e; } .meter span.mid { background: #ffd66b; } .meter span.low { background: #f5a3bd; }
.meter em { position: relative; font-style: normal; font-size: .75rem; font-weight: 600; padding-left: 8px; line-height: 18px; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }
.catlist { list-style: none; padding: 0; margin: 0 0 1rem; }
.catlist li { display: flex; justify-content: space-between; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: .4rem 0; border-bottom: 1px dashed var(--line); }

/* ---------- login ---------- */
body.bare { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #eef6e4, #f5f7fa); }
body.bare main { width: 100%; }
.login-card { max-width: 380px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(16,24,40,.08); padding: 2rem; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand p { margin: .6rem 0 0; color: var(--ink-2); font-weight: 500; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 100; transition: .25s; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #9c1f4d; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .review { grid-template-columns: 1fr; height: auto; }
  .viewer { height: 55vh; position: sticky; top: 56px; z-index: 6; }
  .review-head { top: 0; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: .5rem 1rem; gap: .5rem; }
  .topbar .nav { order: 3; flex-basis: 100%; }
  .userbox { margin-left: auto; }
  .viewer { top: 0; }
  .userbox small { display: none; }
  main { padding: 1rem; }
  .qitem { grid-template-columns: 1fr; }
  .finput { flex-direction: column; align-items: stretch; }
  .bars { gap: 2px; }
  .bar small { display: none; }
}
