:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1c2530;
  --muted: #667085;
  --line: #e3e6ea;
  --accent: #1d63c4;
  --accent-ink: #fff;
  --ok: #157347;
  --warn: #9a6700;
  --err: #b42318;
  --pre: #157347;
  --pro: #b42318;
  --radius: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
h1, h2, h3 { margin: 0 0 .6rem; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }

.banner { text-align: center; font-weight: 700; letter-spacing: .05em; padding: 5px; color: #fff; font-size: 12px; }
.banner.pre { background: var(--pre); }
.banner.pro { background: var(--pro); }

.topbar { display: flex; align-items: center; gap: 1rem; padding: .55rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 1.1rem; }
.brand span { color: var(--accent); }
.spacer { flex: 1; }
.cliente-info { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: .5rem; }

.login-wrap { display: flex; justify-content: center; padding: 3rem 1rem; }
.login-card { width: 100%; max-width: 340px; }
.login-card .form { grid-template-columns: 1fr; }

.ayuda-resumen { padding-left: 1.2rem; }
.ayuda-resumen li { margin-bottom: .35rem; }
.ayuda-sec summary { cursor: pointer; font-weight: 700; list-style: revert; }
.ayuda-sec summary::marker { color: var(--accent); }
.ayuda-sec[open] summary { margin-bottom: .6rem; }
.ayuda-cuerpo { display: flex; flex-direction: column; gap: .5rem; }
.ayuda-cuerpo ul { margin: 0; padding-left: 1.2rem; }
.ayuda-cuerpo li { margin-bottom: .3rem; }
.ayuda-cuerpo p { margin: 0; }
#nav { display: flex; gap: .25rem; flex-wrap: wrap; }
#nav button { border: 1px solid transparent; background: transparent; color: var(--muted); padding: .4rem .7rem; border-radius: var(--radius); font-weight: 600; }
#nav button.activo { background: var(--bg); color: var(--ink); border-color: var(--line); }

main { max-width: 1180px; margin: 1.2rem auto; padding: 0 1rem 4rem; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card h2 { font-size: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.kpi .n { font-size: 1.8rem; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:hover { background: #fafbfc; }
.tbl-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 100px; font-size: 11px; font-weight: 700; border: 1px solid var(--line); background: #fff; white-space: nowrap; }
.badge.b-BORRADOR { color: var(--muted); }
.badge.b-VALIDADA { color: var(--accent); border-color: #bcd4f2; background: #eef4fc; }
.badge.b-INSCRIBIENDO, .badge.b-RECTIFICANDO, .badge.b-CANCELANDO { color: var(--warn); background: #fdf6e6; border-color: #f0dfae; }
.badge.b-INSCRITA { color: var(--warn); }
.badge.b-EMITIDA { color: var(--ok); background: #e8f5ee; border-color: #b7dfc7; }
.badge.b-INCIDENCIA { color: var(--err); background: #fdeceb; border-color: #f2c3bf; }
.badge.b-RECHAZADA { color: var(--err); }
.badge.b-CANCELADA { color: var(--muted); text-decoration: line-through; }
.badge.fin { background: #eef1f4; }

form.form { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
form.form label { display: flex; flex-direction: column; gap: .2rem; font-size: 12px; color: var(--muted); font-weight: 600; }
form.form input, form.form select, form.form textarea { font: inherit; padding: .45rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
form.form .full { grid-column: 1 / -1; }
form.form textarea { min-height: 70px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
form.form label.chk { flex-direction: row; align-items: center; font-weight: 500; color: var(--ink); }
form.form label.chk input { flex: none; }
.chk-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.param-form { grid-template-columns: 1fr 1fr; }

.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: .45rem .9rem; border-radius: 6px; font-weight: 600; }
.btn.sec { background: #fff; color: var(--accent); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: #fff; color: var(--err); border-color: #e6b3ad; }
.btn.sm { padding: .28rem .55rem; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row-actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }

pre.code { background: #0f1720; color: #d6e2f0; padding: .8rem; border-radius: 6px; overflow: auto; font-size: 12px; max-height: 45vh; }
.muted { color: var(--muted); }
.msg { padding: .5rem .7rem; border-radius: 6px; margin: .3rem 0; font-size: 13px; }
.msg.err { background: #fdeceb; color: var(--err); }
.msg.ok { background: #e8f5ee; color: var(--ok); }
.msg.warn { background: #fdf6e6; color: var(--warn); }

.toast { position: fixed; right: 1rem; bottom: 1rem; background: #1c2530; color: #fff; padding: .7rem 1rem; border-radius: 8px; z-index: 50; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

dialog#modal { border: none; border-radius: 10px; padding: 0; max-width: 780px; width: 92%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog#modal::backdrop { background: rgba(15,23,32,.5); }
.modal-inner { display: flex; flex-direction: column; max-height: 85vh; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-head .x { border: none; background: transparent; font-size: 1rem; color: var(--muted); }
.modal-body { padding: 1.1rem; overflow: auto; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; font-size: 13px; }
dl.kv dt { color: var(--muted); }
