:root {
  --bg: #f4f6fa; --card: #ffffff; --primary: #b91c1c; --primary-h: #991b1b;
  --text: #1e293b; --muted: #64748b; --border: #e2e8f0; --ok: #16a34a;
  --warn: #d97706; --err: #dc2626;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

header { background: linear-gradient(135deg, #7f1d1d, var(--primary)); color: #fff; padding: 16px 24px; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.logo { font-size: 26px; font-weight: 800; }
.logo span { font-weight: 300; }
.tagline { font-size: 13px; opacity: .85; }
nav { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
nav button { background: rgba(255,255,255,.12); color: #fff; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; }
nav button:hover { background: rgba(255,255,255,.25); }
nav button.active { background: #fff; color: var(--primary); font-weight: 600; }

main { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
.tab { display: none; }
.tab.active { display: block; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--card); border-radius: 12px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h3 { font-size: 22px; }
.card p { color: var(--muted); margin: 4px 0; }
.card span { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.panel { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px; }
.panel h3 { margin-bottom: 14px; font-size: 17px; }

button { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; color: var(--text); }
button:hover { border-color: var(--muted); }
button.primary { background: var(--primary); color: #fff; border: none; }
button.primary:hover { background: var(--primary-h); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; font-size: 14px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.modal-body label { margin-bottom: 8px; }

.msg { font-size: 13px; margin: 8px 0; min-height: 18px; }
.msg.ok { color: var(--ok); } .msg.err { color: var(--err); }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.hint code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; color: var(--muted); font-size: 12px; text-transform: uppercase; }
td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:hover td { background: #fafbfc; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .mini { padding: 3px 8px; font-size: 12px; margin-right: 4px; }

.resumen td { padding: 10px 8px; font-size: 14px; }
.resumen td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.resumen .saldo td { border-top: 2px solid var(--border); font-size: 16px; font-weight: 700; }

.ultimos { font-size: 13px; color: var(--muted); }
.ultimos div { padding: 6px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.ultimos b { color: var(--text); }

.val-resumen { margin: 14px 0; font-size: 14px; }
.problem { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.problem.error { background: #fef2f2; color: #991b1b; }
.problem.warn { background: #fffbeb; color: #92400e; }
.problem.info { background: #eff6ff; color: #1e40af; }
.problem .sev { font-weight: 700; text-transform: uppercase; font-size: 11px; }

.modal-back { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.hidden { display: none !important; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; z-index: 60; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
