:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1b2330; --muted: #5d6878; --line: #dfe3e9;
  --accent: #1f5fbf; --ok: #1d7a46; --ok-bg: #e4f4ea; --warn: #8a5a00; --warn-bg: #fdf1d3;
  --bad: #a3271f; --bad-bg: #fbe5e3; --info: #1f5fbf; --info-bg: #e3edfb; --neutral-bg: #eceff3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1a2029; --text: #e7ebf1; --muted: #9aa5b5; --line: #2c3440;
    --accent: #7fb0ff; --ok: #6fd39a; --ok-bg: #173526; --warn: #f0c060; --warn-bg: #3a2e10;
    --bad: #ff9a90; --bad-bg: #3d1b18; --info: #8fbaff; --info-bg: #182b47; --neutral-bg: #262e3a;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
small { color: var(--muted); }
code { font: 13px/1.4 ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 650; color: var(--text); text-decoration: none; }
.session { display: flex; gap: .75rem; align-items: center; margin: 0; color: var(--muted); }
.banner { margin: 0; padding: .6rem 1rem; background: var(--warn-bg); color: var(--warn); font-weight: 600; }

button, input, select { font: inherit; color: inherit; }
input, select { width: 100%; padding: .45rem .55rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
button { padding: .5rem 1rem; border: 0; border-radius: 6px; background: var(--accent); color: var(--surface); font-weight: 600; cursor: pointer; }
button.link { padding: 0; background: none; color: var(--accent); font-weight: 400; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login { max-width: 22rem; margin: 3rem auto; padding: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.login label { display: block; margin: .9rem 0 .25rem; font-weight: 600; }
.login button { width: 100%; margin-top: 1.25rem; }
.alert { padding: .6rem .75rem; background: var(--bad-bg); color: var(--bad); border-radius: 6px; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .75rem; align-items: end; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.filters label { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.filters input, .filters select { height: 2.3rem; font-size: .93rem; font-weight: 400; color: var(--text); }
.filters .actions { display: flex; gap: .9rem; align-items: center; height: 2.3rem; }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); gap: .75rem; margin: 1rem 0 1.5rem; }
.card { display: flex; flex-direction: column; padding: .85rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.card .label { font-weight: 600; }
.card .definition { margin-top: .25rem; font-size: .8rem; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.evidence { min-width: 9rem; }

.pill, .tag { display: inline-block; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.pill { padding: .15rem .6rem; background: var(--neutral-bg); }
.tag { padding: .05rem .5rem; margin: 0 .15rem .15rem 0; background: var(--neutral-bg); color: var(--muted); }
.s-accepted, .r-awaiting_confirmation, .r-in_progress, .s-pending, .s-processing { background: var(--info-bg); color: var(--info); }
.r-opened, .r-observed, .r-user_confirmed { background: var(--ok-bg); color: var(--ok); }
.s-failed, .r-send_failed, .s-expired, .r-expired { background: var(--bad-bg); color: var(--bad); }
.r-user_denied, .r-unconfirmed { background: var(--warn-bg); color: var(--warn); }

.pager { display: flex; gap: 1.25rem; align-items: center; margin-top: 1rem; color: var(--muted); }
.footnote { margin-top: 1.5rem; font-size: .82rem; color: var(--muted); max-width: 60rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.crumb { margin: 0 0 .5rem; }
.verdict { display: flex; flex-wrap: wrap; gap: .5rem; }
.note { margin: .5rem 0; padding: .6rem .8rem; background: var(--warn-bg); color: var(--warn); border-radius: 6px; max-width: 60rem; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 0 1.5rem; }
dl { margin: 0; padding: .4rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
dt { margin-top: .55rem; font-size: .78rem; font-weight: 600; color: var(--muted); }
dd { margin: 0 0 .55rem; overflow-wrap: anywhere; }

.timeline { list-style: none; margin: 0; padding: 0; max-width: 60rem; }
.timeline li { display: grid; grid-template-columns: 12.5rem 1fr; gap: 1rem; padding: .7rem 0 .7rem 1rem; border-left: 3px solid var(--line); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; }
.timeline p { margin: .15rem 0 0; color: var(--muted); }
.timeline strong { margin-right: .4rem; }
.timeline .k-ok, .timeline .k-evidence { border-left-color: var(--ok); }
.timeline .k-error { border-left-color: var(--bad); }
.timeline .k-warn { border-left-color: var(--warn); }
.timeline .k-attempt, .timeline .k-request { border-left-color: var(--info); }
@media (max-width: 640px) { .timeline li { grid-template-columns: 1fr; gap: .1rem; } }

/* Navegación y pantallas de configuración */
.topbar { flex-wrap: wrap; }
.nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; margin-left: .5rem; }
.nav a { padding: .3rem .7rem; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .92rem; }
.nav a:hover { color: var(--text); background: var(--neutral-bg); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--info-bg); }
.flash { margin: 0; padding: .65rem 1rem; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.lead { max-width: 60rem; color: var(--muted); margin: -.4rem 0 1.25rem; }
.panel { margin: 0 0 1rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel h2 { margin: 0 0 .75rem; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; }
.panel-head .pill, .panel-head .tag { vertical-align: middle; margin-left: .35rem; }
.panel-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem 1rem; align-items: start; }
.form-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-grid label small { font-weight: 400; }
.form-grid input, .form-grid select, .form-grid textarea { font-size: .93rem; font-weight: 400; color: var(--text); }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .actions { grid-column: 1 / -1; }
textarea { width: 100%; padding: .5rem .55rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font: 13px/1.45 ui-monospace, Consolas, monospace; resize: vertical; }
input[type="file"] { padding: .3rem; }
input[type="checkbox"] { width: auto; margin: 0; }
form.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
form.inline input[type="text"], form.inline input[type="password"], form.inline select { width: auto; min-width: 11rem; flex: 1; }
.check { display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; white-space: nowrap; }
.sr { display: contents; font-size: 0; }
.sr > * { font-size: .93rem; }
button.secondary { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
button.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
table.plain th, table.plain td { padding: .5rem .5rem .5rem 0; }
table.plain tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.table-wrap + .panel, .empty + .panel { margin-top: 1rem; }
