:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --brand: #1f4e79; --brand-2: #2f6ea8; --ok: #1e7b45; --ok-bg: #e5f4ea;
  --warn: #9a5b00; --warn-bg: #fdf1dc; --off: #8a1c1c; --off-bg: #fbe5e5;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px; }

.top { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--brand); color: #fff; flex-wrap: wrap; }
.top .brand { font-weight: 700; font-size: 17px; }
.top nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.top nav a { color: #dbe7f3; padding: 6px 12px; border-radius: 6px; }
.top nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.top nav a.on { background: rgba(255,255,255,.2); color: #fff; }
.top .user { font-size: 14px; display: flex; align-items: center; gap: 10px; }
.top .user .muted { color: #b9cde0; }

h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 4px; }
.stat .value.neg { color: var(--off); }

dl.datos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.datos dt { color: var(--muted); }
dl.datos dd { margin: 0; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef1f5; font-weight: 600; font-size: 13px; color: #374151; position: sticky; top: 0; }
tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; background: #f3f5f8; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-wrap table { border: 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.neutral { background: #eceff3; color: #4b5563; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input[type=text], input[type=number], input[type=password], select {
  padding: 8px 10px; border: 1px solid #cfd5dd; border-radius: 6px; font: inherit; background: #fff; min-width: 220px;
}
input:focus, select:focus { outline: 2px solid #9cc3e6; border-color: var(--brand-2); }
.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; font: inherit; cursor: pointer; }
.btn:hover { background: var(--brand-2); text-decoration: none; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.5); }
.btn.light { background: #fff; color: var(--brand); }
.btn.small { padding: 3px 10px; font-size: 13px; }
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.alert { padding: 12px 14px; border-radius: 8px; background: var(--off-bg); color: var(--off); margin-bottom: 14px; }
.info { padding: 12px 14px; border-radius: 8px; background: #e8f0f8; color: #1f4e79; margin-bottom: 14px; }

details > summary { cursor: pointer; color: var(--brand-2); }
.sub { margin: 8px 0 4px; font-size: 13px; }
.sub th { position: static; }

.login-box { max-width: 360px; margin: 10vh auto; }
.login-box h1 { text-align: center; }
.login-box label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 18px; padding: 10px; }

@media print {
  .top, form.inline, .tabs, .noprint { display: none !important; }
  body { background: #fff; }
  .card, .table-wrap { border: 0; }
}
.nowrap { white-space: nowrap; }

.form-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.form-row label { color: var(--muted); font-size: 14px; }
.recibo { max-width: 800px; margin: 0 auto; padding: 24px; }
.rec-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; border-bottom: 2px solid #333; padding-bottom: 12px; font-size: 13px; }
.rec-emisor { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.rec-letra { font-size: 36px; font-weight: 700; border: 2px solid #333; width: 70px; text-align: center; line-height: 1.1; padding: 6px 0; height: fit-content; }
.rec-letra small { display: block; font-size: 8px; font-weight: 400; padding: 0 2px; }
.rec-num { text-align: right; }
.rec-tit { font-size: 20px; font-weight: 700; }
.rec-cli { padding: 12px 0; border-bottom: 1px solid #999; font-size: 14px; }
.rec-body { padding: 12px 0; min-height: 140px; }
.rec-foot { display: flex; justify-content: space-between; align-items: end; border-top: 2px solid #333; padding-top: 12px; }
.rec-total { font-size: 20px; font-weight: 700; }
.rec-firma { border-top: 1px solid #333; padding-top: 4px; width: 220px; text-align: center; font-size: 12px; margin-top: 40px; }
@media print { .recibo { border: 0; max-width: none; } }
.mail-body { white-space: pre-wrap; background: #f7f8fa; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 14px/1.4 inherit; margin: 8px 0; }
