:root {
  --bg: #12140D; --bg2: #1B1D14; --bg3: #23261a;
  --green: #556b2f; --green-hi: #657f39; --accent: #A5B983;
  --text: #F5F1E6; --muted: #B9B6A6; --line: rgba(245, 241, 230, 0.14);
  --bad: #E5604D; --warn: #E0B050; --ok: #8FBF6A;
  --radius: 10px;
  --serif: ui-serif, Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; margin-bottom: 8px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* ---- estructura */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-family: var(--serif); font-size: 1.4rem; padding: 4px 10px 18px; }
.brand b { background: var(--green); padding: 2px 8px; border-radius: 6px; font-weight: 500; }
.brand span { display: block; font: 0.7rem var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); margin-top: 8px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; min-height: 44px; }
.nav a:hover { background: var(--bg3); color: var(--text); }
.nav a[aria-current='page'] { background: var(--green); color: var(--text); }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 7px; min-width: 20px; text-align: center; }
.badge.soft { background: var(--bg3); color: var(--accent); border: 1px solid var(--line); }
.side-foot { margin-top: auto; padding: 10px; font-size: 0.85rem; color: var(--muted); }
.main { padding: 28px clamp(16px, 3vw, 40px) 80px; min-width: 0; max-width: 1280px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* ---- componentes */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .label { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.kpi .value { font: 500 1.7rem var(--serif); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); cursor: pointer; text-decoration: none; color: var(--text); }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); }
.btn.primary:hover { background: var(--green-hi); }
.btn.danger { color: #ffb4a8; border-color: rgba(229, 96, 77, 0.5); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.btn.link { background: none; border: 0; color: var(--accent); text-decoration: underline; min-height: 32px; padding: 4px 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 0.85rem; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: 0.8rem; color: var(--muted); }
.err { color: #ffb4a8; font-size: 0.88rem; min-height: 1.2em; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: none; cursor: pointer; color: var(--muted); min-height: 38px; }
.tab[aria-selected='true'] { background: var(--green); color: var(--text); border-color: var(--green); }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); background: var(--bg2); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--bg3); }
td.act { white-space: nowrap; text-align: right; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: rgba(143, 191, 106, 0.5); }
.pill.warn { color: var(--warn); border-color: rgba(224, 176, 80, 0.5); }
.pill.bad { color: #ffb4a8; border-color: rgba(229, 96, 77, 0.5); }
.pill.info { color: var(--accent); }

.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.alert.warn { border-color: rgba(224, 176, 80, 0.5); }
.alert.bad { border-color: rgba(229, 96, 77, 0.5); }

dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg2); z-index: 1; }
.dlg-body { padding: 20px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--green); padding: 10px 18px; border-radius: 10px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.toast.bad { background: #7a2a20; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); font-size: 0.85rem; }
.kv dd { margin: 0; }
.stepper { display: flex; gap: 4px; flex-wrap: wrap; }
.step { padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line); color: var(--muted); }
.step.done { color: var(--text); background: var(--green); border-color: var(--green); }
.step.now { color: var(--text); border-color: var(--accent); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 8px; }
.bars div { flex: 1; background: var(--green); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div:hover { background: var(--accent); }
.pl { width: 100%; }
.pl td { padding: 6px 4px; border: 0; }
.pl tr.total td { border-top: 1px solid var(--line); font-weight: 600; padding-top: 10px; }
.neg { color: #ffb4a8; }
.pos { color: var(--ok); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px; }
  .brand span { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 100%; }
  .nav a { white-space: nowrap; }
  .side-foot { display: none; }
  .kv { grid-template-columns: 1fr; }
}
