:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1d2330; --muted: #667085; --line: #e3e6eb;
  --brand: #0b5cad; --brand-ink: #fff; --good: #137a3a; --bad: #b42318; --warn: #8a5a00;
  --warn-bg: #fff6e0; --bad-bg: #fdecea; --good-bg: #e8f6ee;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1b2029; --text: #e7eaf0; --muted: #98a2b3; --line: #2c3340;
    --brand: #5aa2ec; --brand-ink: #0b1220; --good: #5fd08b; --bad: #ff8a80; --warn: #f2c25b;
    --warn-bg: #3a2f12; --bad-bg: #3d1d1b; --good-bg: #173324;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
main { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }
h1 { font-size: 24px; margin: 0 0 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
h2 { font-size: 17px; margin: 0 0 12px; }
code { font-size: 12px; word-break: break-all; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn-text { color: var(--warn); }

.topbar { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.brand span { font-weight: 400; color: var(--muted); font-size: 13px; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.narrow { max-width: 440px; margin: 48px auto; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }

form label { display: block; margin-bottom: 12px; font-weight: 500; }
input, select, button { font: inherit; }
input:not([type=checkbox]), select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
button, .button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; font-size: 14px; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.link { border: 0; background: none; color: var(--brand); padding: 0; font-size: 13px; }
form.inline { display: inline; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.form { max-width: 720px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters select, .filters input:not([type=checkbox]) { width: auto; display: inline-block; margin: 0; }
.filters label.check { margin: 0; }

.alert { padding: 10px 12px; border-radius: 6px; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--good-bg); color: var(--good); }
.secret { font-size: 15px; padding: 2px 6px; background: var(--surface); border-radius: 4px; user-select: all; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.muted-tile { opacity: .75; }

.grid { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.archived td { color: var(--muted); }
.audit code { display: block; max-width: 280px; }
.pager { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 16px; }
dt { color: var(--muted); }
dd { margin: 0; }
ul.status { padding-left: 18px; }

@media (max-width: 720px) {
  .grid { display: block; overflow-x: auto; }
  .who { margin-left: 0; }
}
.inline-form { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.inline-form input[type=date] { width: auto; margin: 0; padding: 4px 6px; }
.value.good { color: var(--good); } .value.bad { color: var(--bad); }
textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; }
.grid input:not([type=checkbox]) { margin: 0; }
.ai-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ai-card { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.ai-card h4 { margin: 8px 0 4px; font-size: 14px; }
.ai-decision { margin-top: 8px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
/* Visualización: una serie = un tono (categórico 1), marcas finas, texto en tinta neutra. */
:root { --viz-1: #2a78d6; --viz-track: #eceff3; }
@media (prefers-color-scheme: dark) { :root { --viz-1: #3987e5; --viz-track: #262c36; } }
.hbars { display: grid; gap: 6px; margin: 8px 0 14px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.hbar-label { color: var(--muted); overflow-wrap: anywhere; }
.hbar-track { height: 14px; background: var(--viz-track); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; width: 0; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hbar:hover .hbar-fill { opacity: .8; }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.report-tabs { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; font-size: 14px; }
.report-tabs a { text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.report-tabs a.active { border-bottom-color: var(--brand); font-weight: 600; }
label.compact { display: flex; flex-direction: column; font-size: 12px; margin: 0; font-weight: 400; color: var(--muted); }
label.compact input { margin-top: 2px; }
.cols { align-items: start; }
.grid .num { white-space: nowrap; }
.tile .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value.money { font-size: 21px; padding: 4px 0; }
