@font-face {
  font-family: Archivo;
  src: url("/assets/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #eff5fb;
  --text: #14263a;
  --muted: #55677a;
  --border: #d5e0ea;
  --orange: #f58220;
  --accent: #0b5cad;
  --accent-hover: #084a8c;
  --accent-text: #0b5cad;
  --on-accent: #ffffff;
  --ok: #17803d;
  --ok-bg: #dff3e5;
  --ok-text: #115c2d;
  --error: #c0272d;
  --error-bg: #fbe4e4;
  --error-text: #8f1d1d;
  --shadow: 0 1px 2px rgb(11 50 90 / 6%), 0 6px 18px rgb(11 50 90 / 6%);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1824;
  --surface: #162332;
  --surface-2: #1e2f42;
  --text: #edf3f9;
  --muted: #a3b4c5;
  --border: #2d4258;
  --accent: #1f6fc4;
  --accent-hover: #2f80d6;
  --accent-text: #86bdf5;
  --ok: #4fc47a;
  --ok-bg: #16392a;
  --ok-text: #c0f0d0;
  --error: #ff8a8a;
  --error-bg: #47191d;
  --error-text: #ffd5d5;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 18px rgb(0 0 0 / 25%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: var(--on-accent); }

html { scrollbar-color: var(--border) transparent; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  caret-color: var(--accent);
  font: 400 16px/1.45 Archivo, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p { margin: 0; }
h2 { font-size: 1.15rem; font-weight: 650; text-wrap: balance; }
a { color: inherit; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* El naranja del logo cierra la barra superior. */
.topbar { background: var(--surface); border-bottom: 3px solid var(--orange); }
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 16px;
}
.topbar-inner > div { display: flex; align-items: center; gap: 14px; margin-right: auto; }
/* El logo tiene fondo blanco: en modo oscuro queda sobre una placa blanca. */
.brand { line-height: 0; }
.brand img { height: 52px; width: auto; padding: 3px 6px; background: #ffffff; border-radius: 6px; }
.panel-name { color: var(--muted); font-size: 0.95rem; font-weight: 600; }
@media (max-width: 560px) {
  .topbar-inner { flex-wrap: nowrap; }
  .topbar-inner > div { flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
  .topbar-inner button { flex: none; min-height: 38px; padding: 4px 10px; font-size: 0.88rem; }
  .brand img { height: 42px; }
  .panel-name { font-size: 0.82rem; }
}

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 56px; }
main.narrow { max-width: 440px; padding-top: 32px; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.links { display: grid; gap: 10px; }
.links a { font-weight: 600; text-decoration: none; }

.stack { display: grid; gap: 14px; }
.narrow-form { max-width: 400px; margin: 16px auto 0; }

label { display: grid; gap: 5px; font-size: 0.86rem; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 8px; }

input, select, button { font: inherit; }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-weight: 500;
  transition: border-color 150ms ease;
}
input::placeholder { color: var(--muted); }
input:disabled { color: var(--muted); background: var(--surface-2); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--accent); }

button {
  min-height: 44px;
  padding: 8px 16px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, border-color 150ms ease;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.6; cursor: wait; }
button.primary { color: var(--on-accent); background: var(--accent); }
button.ghost { background: var(--surface); border-color: var(--border); }
button.big { min-height: 60px; font-size: 1.15rem; }
button.small { min-height: 36px; padding: 4px 12px; }

@media (hover: hover) {
  input:hover, select:hover { border-color: var(--muted); }
  button.primary:hover:not(:disabled) { background: var(--accent-hover); }
  button.ghost:hover:not(:disabled) { background: var(--surface-2); }
  tbody tr:hover td { background: var(--surface-2); }
  .links a:hover { border-color: var(--muted); }
}

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.message {
  padding: 12px 14px;
  border-radius: 7px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-weight: 600;
  animation: appear 220ms var(--ease-out);
}
.message.error { background: var(--error-bg); color: var(--error-text); }
#mensaje { font-size: 1.05rem; }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border-radius: 7px 7px 0 0; color: var(--muted); }
.tabs button.active { color: var(--accent-text); box-shadow: inset 0 -2px var(--orange); }
.tabs button:active:not(:disabled) { transform: none; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.filters label { flex: 1 1 150px; max-width: 280px; }

/* Totales en una sola regla, no en tarjetas: se leen como una línea del parte. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat { padding: 14px 18px; box-shadow: -1px 0 var(--border), 0 -1px var(--border); }
.stat span { display: block; color: var(--muted); font-size: 0.84rem; font-weight: 500; }
.stat strong { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }

.section { margin: 28px 0 10px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.columns .section { margin-top: 6px; }
.dot { display: flex; align-items: center; gap: 8px; }
.dot::before { content: ""; width: 10px; height: 10px; border-radius: 50%; }
.dot.ingreso::before { background: var(--ok); }
.dot.egreso::before { background: var(--error); }
@media (max-width: 760px) { .columns { grid-template-columns: minmax(0, 1fr); } }

.table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 650; }
td:first-child { font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.empty { padding: 32px; text-align: center; color: var(--muted); font-weight: 400; }
#tab-usuarios > button, #tab-bases > button { margin-bottom: 4px; }

.tag { padding: 2px 9px; border-radius: 99px; font-size: 0.8rem; font-weight: 700; }
.tag.ingreso { background: var(--ok-bg); color: var(--ok-text); }
.tag.egreso { background: var(--error-bg); color: var(--error-text); }

dialog {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
}
dialog[open] { animation: dialog-in 220ms var(--ease-out); }
dialog::backdrop { background: rgb(20 8 6 / 55%); }

@keyframes appear {
  from { opacity: 0; transform: translateY(6px); }
}
@keyframes dialog-in {
  from { opacity: 0; transform: scale(0.96); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
