@font-face {
  font-family: "Saira Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/saira-latin-wght-normal.woff2") format("woff2");
}
:root {
  font-family: "Saira Variable", "Arial Narrow", sans-serif;
  color: #153236;
  background: #f0eee5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #153236;
  --night: #10272a;
  --night-deep: #0b1e21;
  --paper: #f0eee5;
  --paper-bright: #f7f5ed;
  --muted: #596a68;
  --orange: #f0a746;
  --orange-hover: #ffc36a;
  --rust: #a4592e;
  --green: #3d7d68;
  --blue: #9bd0d0;
  --line: rgba(21, 50, 54, 0.22);
  --line-soft: rgba(21, 50, 54, 0.12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--paper);
}
body::selection { color: var(--night); background: var(--orange); }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}
svg.icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 64px;
  padding: 0 clamp(1rem, 3.5vw, 2.6rem);
  background: var(--paper-bright);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1rem;
  font-weight: 680;
  letter-spacing: 0.055em;
  text-decoration: none;
  white-space: nowrap;
}
.brand b { color: #66807d; font-weight: 480; }
.brand-mark { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 1.25; }
.brand-mark circle:first-of-type { fill: var(--orange); stroke: var(--orange); }
.topnav { display: flex; gap: clamp(0.9rem, 2vw, 1.9rem); }
.topnav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  font-weight: 560;
  color: #435a59;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 170ms ease, border-color 170ms ease;
}
.topnav a:hover { color: var(--rust); }
.topnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--orange); }

/* ---------- page ---------- */
main { max-width: 1120px; margin: 0 auto; padding: clamp(1.2rem, 3vw, 2.2rem) clamp(1rem, 3vw, 2rem) 3.4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin: 0.4rem 0 1.5rem; }
.page-head h1 { margin: 0; font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.88rem; }
h2 { margin: 1.9rem 0 0.7rem; font-size: 1.1rem; font-weight: 620; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 42px;
  padding: 0.5rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--orange);
  color: var(--night-deep);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 170ms ease, transform 170ms ease, border-color 170ms ease, color 170ms ease;
}
button:hover, .button:hover { background: var(--orange-hover); transform: translateY(-1px); }
button:active, .button:active { transform: translateY(0); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button.ghost, .button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
}
button.ghost:hover, .button.ghost:hover { background: var(--paper-bright); border-color: var(--ink); }
button.danger {
  background: transparent;
  border: 0;
  min-height: 30px;
  padding: 0.15rem 0.4rem;
  color: var(--rust);
  font-weight: 600;
}
button.danger:hover { background: rgba(164, 89, 46, 0.1); transform: none; }
button.ghost[disabled], button[disabled].ghost { color: var(--muted); }

/* ---------- forms ---------- */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 140px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
input, select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-bright);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 480;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color 170ms ease, background 170ms ease;
}
input:hover, select:hover { border-color: rgba(21, 50, 54, 0.4); }
input:focus, select:focus { border-color: var(--orange); outline: none; }
input::placeholder { color: #7d8a86; }
.row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
fieldset { border: 0; margin: 0; padding: 0; }

/* ---------- panels ---------- */
.panel {
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.15rem 1.2rem;
}
.panel + .panel { margin-top: 1rem; }
.panel > h2 { margin: 0 0 0.9rem; display: flex; align-items: center; gap: 0.55rem; }
.capture-strip { display: flex; }
.capture-strip .capture {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem 1.15rem;
}
.capture-strip .capture + .capture { border-left: 1px solid var(--line-soft); }
.icon-slot { display: inline-flex; }
.capture .icon { width: 22px; height: 22px; color: var(--rust); }
.capture .cap-title { font-weight: 650; font-size: 0.95rem; }
.capture .cap-hint { color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.preview-frame {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.preview-frame img {
  max-width: 210px;
  max-height: 210px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* ---------- status ---------- */
.status[hidden] { display: none; }
.status {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-bright);
  font-size: 0.88rem;
  margin: 0.8rem 0;
}
.status.is-error { border-color: rgba(164, 89, 46, 0.5); color: var(--rust); }
.status .bar { position: relative; overflow: hidden; width: 64px; height: 2px; background: var(--line-soft); flex: none; }
.status .bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--orange);
  animation: slide 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rust); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- tables ---------- */
.tablewrap {
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  position: sticky;
  top: 0;
  background: #edeade;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 680;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 150ms ease; }
tbody tr:hover { background: rgba(155, 208, 208, 0.12); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .doclink { display: inline-flex; margin-left: 0.4rem; color: var(--muted); }
td .doclink:hover { color: var(--rust); }
td form { display: inline; }

/* ---------- semantic tags ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.tag.ingreso { background: rgba(61, 125, 104, 0.14); color: var(--green); }
.tag.egreso { background: rgba(164, 89, 46, 0.13); color: var(--rust); }
.tag .icon { width: 11px; height: 11px; stroke-width: 2; }
.origin { font-size: 0.76rem; letter-spacing: 0.04em; color: var(--muted); text-transform: uppercase; }

/* ---------- stats ---------- */
.statstrip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--paper-bright);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin: 1.2rem 0 1.6rem;
}
.stat {
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat .stat-label { font-size: 0.7rem; font-weight: 680; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.stat strong { font-size: 1.25rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.stat strong.pos, strong.pos { color: var(--green); }
.stat strong.neg, strong.neg { color: var(--rust); }
.stat strong.pos { color: var(--green); }
.stat strong.neg { color: var(--rust); }

.catbars td.barline { position: relative; height: 14px; min-width: 120px; }
.catbars td.barline .track { position: absolute; inset: 5px 0; background: var(--line-soft); border-radius: 3px; }
.catbars td.barline i { position: absolute; inset: 5px auto 5px 0; border-radius: 3px; background: var(--rust); }
.catbars td.barline i.in { background: var(--green); }

/* ---------- filters ---------- */
.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; margin: 0 0 1rem; }
.filters label { flex: 0 1 auto; min-width: 0; }
.filters button { min-height: 38px; }
.filters .grow { flex: 1 1 220px; }

/* file input as button */
.filebtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.5rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 170ms ease, background 170ms ease;
}
.filebtn:hover { background: var(--paper-bright); border-color: var(--ink); }
.filebtn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- misc ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; }
.inlineform { display: flex; gap: 0.6rem; align-items: flex-end; margin: 0; }
.inlineform label { min-width: 0; }
.empty {
  padding: 2.6rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
}
.empty .icon { width: 30px; height: 30px; margin: 0 auto 0.7rem; color: #8a9793; }
.empty p { margin: 0 0 1rem; }
.transcript {
  margin: 0 0 0.9rem;
  padding: 0.55rem 0.8rem;
  border-left: 1px solid var(--orange);
  color: #435a59;
  font-size: 0.9rem;
  font-style: italic;
}
.footnote { margin-top: 1.6rem; font-size: 0.8rem; color: var(--muted); }

/* ---------- login ---------- */
.gate {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  background:
    radial-gradient(ellipse at 12% -10%, rgba(155, 208, 208, 0.1) 0, transparent 55%),
    linear-gradient(150deg, var(--night) 0%, var(--night-deep) 100%);
}
.gate-copy {
  align-self: center;
  max-width: 560px;
  padding: clamp(2rem, 6vw, 5.5rem);
  color: var(--paper-bright);
}
.gate-copy .brand { margin-bottom: 2.6rem; color: var(--paper-bright); }
.gate-copy .brand b { color: var(--blue); }
.gate-copy .brand-mark { stroke: var(--paper-bright); }
.gate-copy h1 {
  margin: 0 0 1.1rem;
  font-size: clamp(2.1rem, 4.2vw, 3.3rem);
  font-weight: 540;
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--paper-bright);
  max-width: 12ch;
}
.gate-copy p {
  margin: 0;
  max-width: 44ch;
  color: #c7d2cb;
  font-size: 1.02rem;
  line-height: 1.55;
}
.gate-copy .rule { width: 64px; height: 2px; background: var(--orange); margin: 1.9rem 0 1.4rem; }
.gate-copy .gate-meta {
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #a9bbb4;
}
.gate-form {
  display: flex;
  align-items: center;
  padding: clamp(1.2rem, 4vw, 3.4rem);
  background: var(--paper);
  border-left: 1px solid var(--line);
}
.gate-panel { width: min(420px, 100%); margin: 0 auto; padding: 1.7rem 1.6rem 1.6rem; }
.gate-panel h2 { margin: 0 0 1.1rem; font-size: 1.15rem; font-weight: 620; }
.gate-panel label { margin-bottom: 0.7rem; }
.gate-panel button { width: 100%; margin-top: 1.1rem; }
.gate-error { margin: 0 0 0.9rem; color: var(--rust); font-size: 0.88rem; font-weight: 600; }

@media (max-width: 860px) {
  .gate { grid-template-columns: 1fr; }
  .gate-copy { padding: 2.4rem 1.6rem 1.6rem; }
  .gate-copy .brand { margin-bottom: 1.6rem; }
  .gate-copy h1 { font-size: 1.9rem; }
  .gate-copy .rule { margin: 1.2rem 0 0.9rem; }
  .gate-form { border-left: 0; border-top: 1px solid var(--line); }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .capture-strip { flex-direction: column; }
  .capture-strip .capture + .capture { border-left: 0; border-top: 1px solid var(--line-soft); }
  .stat + .stat { border-left: 0; border-top: 1px solid var(--line-soft); }
  .row { flex-direction: column; gap: 0; }
  .row label { margin-bottom: 0.7rem; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
