:root {
  --teal: #19d3b5;
  --teal-dark: #0b8f79;
  --ink: #2b2b2b;
  --text: #222;
  --muted: #6b7280;
  --line: #e2e5e9;
  --bg: #f4f6f7;
  --card: #fff;
  --ok: #0b6b3a; --ok-bg: #d9f2e3;
  --warn: #8a5a00; --warn-bg: #fff0c9;
  --err: #a61b1b; --err-bg: #fde3e3;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--teal-dark); }
h1 { font-size: 1.45rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; color: var(--ink); }
code { background: #eef2f3; padding: 1px 5px; border-radius: 4px; font-size: .85em; }
[hidden] { display: none !important; }

/* Barra superior */
.topbar { display: flex; align-items: center; gap: 18px; background: var(--ink); color: #fff; padding: 8px 20px; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; }
.brand img { height: 30px; }
.mainnav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.mainnav a { color: #d6d6d6; text-decoration: none; padding: 7px 12px; border-radius: 8px; }
.mainnav a:hover, .mainnav a.active { background: rgba(255,255,255,.1); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: #cfcfcf; }
.who form { margin: 0; }
.btn-link { background: none; border: 0; color: var(--teal); cursor: pointer; font: inherit; padding: 0; }
.btn-link.danger { color: var(--err); }

.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 110px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions form { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.req { color: var(--err); font-style: normal; }
.miss { color: var(--err); font-weight: 600; font-size: .85rem; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid #cfd5da; background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 42px; }
.btn:hover { border-color: var(--teal); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #08332c; }
.btn-primary:hover { background: #12bfa3; }
.btn-danger { background: var(--err-bg); border-color: #f2b8b8; color: var(--err); }
.btn-sm { padding: 5px 10px; min-height: 34px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-x { border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 1.1rem; color: var(--muted); flex: none; }
.btn-x:hover { color: var(--err); border-color: var(--err); }

/* Formularios */
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 600; color: #374151; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], select, textarea {
  font: inherit; font-weight: 400; padding: 9px 11px; border: 1px solid #cfd5da; border-radius: 8px; background: #fff; width: 100%; min-height: 42px; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(25,211,181,.4); border-color: var(--teal); }
textarea { resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: start; margin-top: 12px; }
.span-2 { grid-column: span 2; }
.boxed { background: #fafbfb; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; position: relative; }
.boxed > .btn-x { position: absolute; top: 8px; right: 8px; }
.big-input { font-size: 1.1rem !important; padding: 13px 14px !important; }

.switch { flex-direction: row; align-items: center; gap: 10px; font-size: .98rem; cursor: pointer; margin: 4px 0; }
.switch input { width: 22px; height: 22px; accent-color: var(--teal-dark); flex: none; }
.switch.sub { margin-top: 14px; }

/* Flash */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash ul { margin: 6px 0; padding-left: 20px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--err-bg); color: var(--err); }
.notice { background: #e9fbf7; border: 1px solid #b4efe4; border-left: 5px solid var(--teal); padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }

/* Login */
body.bare { background: linear-gradient(135deg, #2b2b2b 0%, #1d3d38 100%); min-height: 100vh; }
.login-wrap { min-height: 90vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login-logo { height: 54px; align-self: center; }
.login h1 { text-align: center; margin: 0; }
.login p { text-align: center; margin: 0; }

/* Pasos */
.steps { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.steps span { padding: 6px 12px; border-radius: 999px; background: #e7eaec; color: var(--muted); font-size: .82rem; font-weight: 600; }
.steps .on { background: var(--ink); color: #fff; }
.steps .done { background: #d4f5ee; color: var(--teal-dark); }

/* Clientes */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.client-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border: 2px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); text-align: center; background: #fff; }
.client-card img { max-height: 48px; max-width: 140px; }
.client-card:hover, .client-card.selected { border-color: var(--teal); background: #f0fdfa; }

/* Búsqueda de usuario */
.user-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.user-results button { display: flex; justify-content: space-between; gap: 10px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font: inherit; }
.user-results button:hover { border-color: var(--teal); background: #f0fdfa; }
.user-results .sub { color: var(--muted); font-size: .85rem; }

/* Datos clave-valor */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 16px; }
.kv-grid > div { display: flex; flex-direction: column; }
.kv-grid span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.kv-grid b { font-weight: 600; }
.kv-grid.compact { gap: 6px 14px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.span-all { grid-column: 1 / -1; }

/* Activos de GLPI */
.items { display: flex; flex-direction: column; gap: 10px; }
.item { flex-direction: row; gap: 12px; border: 2px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; font-weight: 400; }
.item.on { border-color: var(--teal); background: #f6fffd; }
.item > input { width: 22px; height: 22px; accent-color: var(--teal-dark); margin-top: 2px; flex: none; }
.item-body { flex: 1; }
.item-title { margin-bottom: 8px; }

/* Checklist */
.checklist, .rows { display: flex; flex-direction: column; gap: 8px; }
.rows { margin-bottom: 10px; }
.ck-row { display: grid; grid-template-columns: minmax(200px, 1.3fr) auto minmax(160px, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f2f3; }
.checklist .ck-row { grid-template-columns: minmax(200px, 1.3fr) auto minmax(160px, 1fr); }
.ck-label { display: flex; gap: 8px; align-items: center; }
.ck-label select { width: auto; }
.tag { font-size: .7rem; background: #eef2f3; color: var(--muted); padding: 2px 7px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid #cfd5da; border-radius: 8px; overflow: hidden; }
.seg label { flex-direction: row; margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 8px 12px; font-size: .82rem; font-weight: 600; color: var(--muted); border-right: 1px solid #e3e6e8; min-height: 40px; display: flex; align-items: center; }
.seg label:last-child span { border-right: 0; }
.seg-instalado input:checked + span { background: var(--ok-bg); color: var(--ok); }
.seg-no_aplica input:checked + span { background: #e5e7eb; color: #374151; }
.seg-pendiente input:checked + span { background: var(--warn-bg); color: var(--warn); }
.ck-edit { display: flex; gap: 8px; align-items: center; }
.ck-edit select { width: 170px; flex: none; }

/* Acciones fijas al pie */
.sticky-actions { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 12px 16px; display: flex; justify-content: flex-end; gap: 10px; z-index: 15; box-shadow: 0 -4px 14px rgba(0,0,0,.05); }
.discard { margin-top: 10px; }

/* Tablas */
.filters { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.bulk-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.bulk-bar .muted { margin-right: auto; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; background: #f7f8f9; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid #f0f2f3; vertical-align: top; }
.table input[type=checkbox] { width: 18px; height: 18px; }
.pager { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.pager a { padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; background: #fff; }
.pager a.active { background: var(--ink); color: #fff; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #eef2f3; color: var(--muted); white-space: nowrap; }
.badge-signed { background: var(--ok-bg); color: var(--ok); }
.badge-printed { background: #e0ecff; color: #1d4ed8; }
.badge-draft { background: var(--warn-bg); color: var(--warn); }
.badge-pending { background: #f3e8ff; color: #7e22ce; }

/* Revisión */
.finalize-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.pending-note { background: #f3e8ff; color: #581c87; border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.finalize-options .option { display: block; border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--text); margin: 0; }
.finalize-options .option:hover { border-color: var(--teal); background: #f0fdfa; }
.finalize-options button { all: unset; cursor: pointer; display: block; width: 100%; }
.finalize-options strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.finalize-options span { color: var(--muted); font-size: .9rem; }
.preview { overflow-x: auto; }
.preview .doc { max-width: 816px; margin: 0 auto; }
.preview .responsiva { margin-top: 28px; padding-top: 24px; border-top: 2px dashed var(--line); }

/* Firma */
.responsiva-screen p { text-align: justify; line-height: 1.6; }
.resp-screen-head { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.resp-screen-head img { max-height: 60px; max-width: 180px; }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sig-pad { width: 100%; height: 220px; border: 2px dashed #b9c2c8; border-radius: 8px; background: #fff; touch-action: none; display: block; cursor: crosshair; }
.sig-pad.signed { border-style: solid; border-color: var(--teal); }
.sig-name { text-align: center; border-top: 1px solid #333; margin: 10px 20px 0; padding-top: 6px; font-weight: 600; }

/* Admin */
.logo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.logo-preview { max-height: 70px; max-width: 220px; border: 1px solid var(--line); border-radius: 6px; padding: 6px; background: #fff; }

@media (max-width: 820px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .ck-row, .checklist .ck-row { grid-template-columns: 1fr; }
  .finalize-options, .sig-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .who span { display: none; }
}
@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
  .seg span { padding: 8px 8px; }
}
