/* Paleta financiera: teal / slate (Frost Bright adaptada).
   Estilo funcional tipo Linear/Stripe: bordes 1px, radio 8px, sin degradados ni glass. */
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-hover: #0d9488;
  --accent-soft: #ccfbf1;
  --danger: #be123c;
  --danger-soft: #ffe4e6;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --ok: #0f766e;
  --radius: 8px;
  --font: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.num-tab { font-variant-numeric: tabular-nums; }

/* —— Chrome —— */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  height: 52px;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}
.brand:hover { text-decoration: none; color: var(--accent); }

.topbar nav {
  display: flex;
  gap: 0.15rem;
  align-items: center;
  flex-wrap: wrap;
}
.topbar nav .nav-link {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition-property: background-color, color;
  transition-duration: 120ms;
  transition-timing-function: ease;
}
.topbar nav .nav-link:hover {
  color: var(--ink);
  background: var(--bg);
  text-decoration: none;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.25rem auto 2.5rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 1rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.meta-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.meta-row strong { color: var(--ink); font-weight: 600; }
.period-name {
  font-weight: 600;
  color: var(--ink);
  text-transform: capitalize;
}
.link-quiet {
  color: var(--muted);
  font-size: 0.875rem;
}
.chart-caption {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.period-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: end;
}
.period-form label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

input, select, button, textarea { font: inherit; }
input, select, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  min-height: 36px;
  transition-property: border-color, box-shadow;
  transition-duration: 120ms;
  transition-timing-function: ease;
}
input:focus, select:focus, textarea:focus, button:focus-visible, .btn-icon:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  outline-offset: 1px;
  border-color: var(--accent);
}

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  min-height: 36px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink);
  transition-property: background-color, border-color, color;
  transition-duration: 120ms;
  transition-timing-function: ease;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.inline { display: inline; }

/* Métricas: contenedores simples, sin “KPI theater” */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
}
.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  margin-bottom: 0.3rem;
}
.stat strong {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.stat-warn strong { color: var(--danger); }
.stat-ok strong { color: var(--ok); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
}

/* Fondos pastel por rubro (ciclo de 8) — solo vista Presupuesto */
.panel-rubro {
  border-color: transparent;
}
.panel-rubro table {
  background: transparent;
}
.panel-pastel-0 { background: #e8f5f3; border-color: #c5e8e2; } /* menta */
.panel-pastel-1 { background: #eef2ff; border-color: #d4dbf7; } /* lavanda */
.panel-pastel-2 { background: #fff4e8; border-color: #f0dcc4; } /* durazno */
.panel-pastel-3 { background: #e8f4fc; border-color: #c5dff0; } /* cielo */
.panel-pastel-4 { background: #f5eef8; border-color: #e0d0eb; } /* lila */
.panel-pastel-5 { background: #f3f8e8; border-color: #d8e6c0; } /* lima suave */
.panel-pastel-6 { background: #fceef2; border-color: #f0d0da; } /* rosa */
.panel-pastel-7 { background: #eef7f0; border-color: #cfe4d4; } /* sage */

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 0.75rem;
}
.panel-head > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.panel-head h2 { margin: 0; }
.panel-head .muted {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
}
.num { text-align: right; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
tfoot td { border-bottom: none; font-weight: 600; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.form-grid label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.span-2 { grid-column: span 2; }
.actions {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.flash {
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  color: #115e59;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.flash-error {
  background: var(--danger-soft);
  border-color: #fecdd3;
  color: var(--danger);
}
.field-error { color: var(--danger); font-size: 0.8rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

.row-actions {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  justify-content: flex-end;
}
.row-actions form {
  display: inline-flex;
  margin: 0;
}
.col-actions { width: 5.5rem; white-space: nowrap; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition-property: background-color, border-color, color;
  transition-duration: 120ms;
  transition-timing-function: ease;
}
.btn-icon:hover {
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
}
.btn-icon-sm {
  width: 2rem;
  height: 2rem;
}
.btn-icon-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-icon-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}
.btn-icon-danger {
  color: var(--danger);
  border-color: #fecdd3;
}
.btn-icon-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-icon .icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: currentColor;
}
.btn-icon-sm .icon {
  width: 0.95rem;
  height: 0.95rem;
}

/* Estado: texto simple, no pills decorativas */
.status {
  font-size: 0.8rem;
  font-weight: 600;
}
.status-ok { color: var(--ok); }
.status-open { color: var(--warn); }

.tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--line);
}

.form-stack {
  display: grid;
  gap: 0.75rem;
  max-width: 520px;
}
.form-stack label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.form-stack textarea {
  resize: vertical;
  min-height: 4rem;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.kv {
  display: grid;
  gap: 0;
  margin: 0;
}
.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.kv > div:last-child { border-bottom: none; }
.kv dt { color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.kv dd { margin: 0; font-weight: 600; font-size: 0.9rem; }

.callout {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  background: var(--bg);
  font-size: 0.9rem;
}
.callout strong { display: block; margin-bottom: 0.15rem; }
.callout p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.callout-ok { background: var(--accent-soft); border-color: #99f6e4; }
.callout-warn { background: var(--warn-soft); border-color: #fde68a; }

.footer {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.muted { color: var(--muted); }

.row-muted td { opacity: 0.55; }

.pago-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.pago-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: var(--surface);
}
.pago-item-done {
  background: var(--accent-soft);
  border-color: #99f6e4;
}
.pago-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.pago-title {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}
.pago-dot {
  width: 1rem;
  height: 1rem;
  margin-top: 0.2rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
}
.pago-check {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  color: var(--ok);
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
.pago-meta { font-size: 0.8rem; margin-top: 0.15rem; }
.pago-amount {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.pago-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}
.pago-pay-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
  width: 100%;
}
.pago-pay-form label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}
.pago-pay-form input[type="number"] { width: 7rem; }
.pago-pay-form input[type="date"] { width: 9.5rem; }
.pago-notas { flex: 1 1 10rem; min-width: 8rem; }
.pago-item-done .pago-actions { border-top-color: #99f6e4; }

@media (max-width: 900px) {
  .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .stats, .stats-3, .stats-4, .grid-2, .form-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel-head,
  .page-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .row-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
