:root {
  --bg: #f5f6f4;
  --surface: #fff;
  --line: #d9dfd9;
  --text: #17201b;
  --muted: #657168;
  --accent: #186a5a;
  --blue: #2f6fbd;
  --warn: #b36b00;
  --danger: #b43a3a;
  --paid: #297a3b;
  --shadow: 0 16px 34px rgba(25, 34, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

.sidebar {
  min-height: 100vh;
  padding: 22px 18px;
  background: #16231d;
  color: #f4f7f3;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4c95d;
  color: #142019;
  font-weight: 800;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #b8c6bd;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 7px;
}

nav a {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: #d6e0da;
  text-decoration: none;
}

nav a:hover {
  background: #24342b;
  color: #fff;
}

.main {
  min-width: 0;
  padding: 22px;
}

.page-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-head {
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 5px;
  font-size: 28px;
}

h2 {
  font-size: 16px;
}

p,
.panel-head span {
  color: var(--muted);
}

.button,
button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  padding: 10px 12px;
  border: 1px solid #cfe3d9;
  border-radius: 8px;
  background: #e9f5ef;
  color: var(--accent);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.kpis article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpis article {
  min-height: 112px;
  padding: 16px;
}

.kpis span {
  color: var(--muted);
  font-size: 12px;
}

.kpis strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
}

.panel {
  min-width: 0;
  padding: 14px;
  margin-bottom: 12px;
  overflow: auto;
}

.split {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: #fafbf9;
}

.amount {
  text-align: right;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 74px;
  height: 24px;
  justify-content: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
}

.status.paid {
  background: #e2f1e5;
  color: var(--paid);
}

.status.pending {
  background: #f6edd8;
  color: var(--warn);
}

.status.overdue {
  background: #f8e6e3;
  color: var(--danger);
}

.form {
  display: grid;
  gap: 10px;
}

.form p {
  display: grid;
  gap: 5px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
}

textarea {
  padding-top: 8px;
}

.ai-panel {
  background: #fbfcfa;
}

.ai-list {
  display: grid;
  gap: 10px;
}

.ai-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ai-card p {
  margin: 5px 0 0;
}

.score {
  height: 64px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 8px;
  background: #eef2ee;
}

.score strong,
.score span {
  display: block;
}

.score strong {
  font-size: 20px;
  line-height: 1;
}

.score span {
  margin-top: 4px;
  color: currentColor;
  font-size: 11px;
  text-transform: uppercase;
}

.score.alta {
  background: #dceee9;
  color: var(--accent);
}

.score.media {
  background: #e7eef9;
  color: var(--blue);
}

.score.baja {
  background: #f6edd8;
  color: var(--warn);
}

@media (max-width: 1000px) {
  body,
  .split {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: 0;
  }

  nav,
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  nav,
  .kpis,
  .ai-card {
    grid-template-columns: 1fr;
  }
}


.danger-link {
  margin-top: 12px;
  color: var(--danger);
}

.form .helptext {
  color: var(--muted);
  font-size: 11px;
}


.inline-search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-search input {
  min-width: 280px;
}


.danger-button {
  color: var(--danger);
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}


.row-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}


.flow-panel {
  overflow: hidden;
}

.flow-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.flow-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.flow-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.flow-summary strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.flow-chart {
  display: grid;
  gap: 10px;
}

.flow-row {
  display: grid;
  grid-template-columns: 116px minmax(220px, 1fr) 116px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.flow-label {
  color: var(--muted);
  font-size: 12px;
}

.flow-bars {
  display: grid;
  gap: 6px;
}

.flow-bar-line {
  display: grid;
  grid-template-columns: 72px minmax(80px, 1fr) 110px;
  gap: 8px;
  align-items: center;
}

.flow-name {
  font-size: 12px;
}

.flow-name.income,
.positive {
  color: var(--paid);
}

.flow-name.expense,
.negative {
  color: var(--danger);
}

.flow-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2ee;
}

.flow-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.flow-fill.income {
  background: var(--paid);
}

.flow-fill.expense {
  background: var(--danger);
}

.flow-bar-line strong,
.flow-net {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .flow-summary,
  .flow-row,
  .flow-bar-line {
    grid-template-columns: 1fr;
  }

  .flow-bar-line strong,
  .flow-net {
    text-align: left;
  }
}


.date-flow-panel {
  overflow: hidden;
}

.date-flow-head {
  align-items: flex-start;
}

.date-range-form {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-range-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.date-range-form input {
  width: 150px;
}

.chart-note {
  margin: 0 0 10px;
  color: var(--warn);
}

.date-flow-shell {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  min-height: 312px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.date-flow-y-axis {
  height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0 0 28px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.date-flow-plot {
  position: relative;
  min-width: max(620px, calc(var(--columns) * 34px));
  height: 268px;
}

.date-flow-grid {
  position: absolute;
  inset: 0 0 28px;
  background:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, #eef2ee 1px, transparent 1px) 0 0 / 34px 100%;
  pointer-events: none;
}

.date-flow-bars {
  position: relative;
  z-index: 1;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(24px, 1fr));
  gap: 6px;
  align-items: end;
}

.date-flow-day {
  height: 100%;
  display: grid;
  grid-template-rows: 240px 28px;
  align-items: end;
  min-width: 24px;
}

.date-bar-pair {
  height: 240px;
  display: flex;
  gap: 3px;
  align-items: end;
  justify-content: center;
}

.date-bar {
  width: 9px;
  min-height: 0;
  border-radius: 5px 5px 0 0;
}

.date-bar.income {
  background: var(--paid);
}

.date-bar.expense {
  background: var(--danger);
}

.date-label {
  min-height: 18px;
  display: block;
  padding-top: 6px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 999px;
  vertical-align: -1px;
}

.legend-dot.income {
  background: var(--paid);
}

.legend-dot.expense {
  background: var(--danger);
}

@media (max-width: 760px) {
  .date-flow-head,
  .date-range-form {
    display: grid;
    justify-content: stretch;
  }

  .date-range-form input {
    width: 100%;
  }

  .date-flow-shell {
    grid-template-columns: 74px minmax(0, 1fr);
  }
}


.statement-filters {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
}

.statement-form,
.statement-shortcuts {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.statement-form label {
  display: grid;
  gap: 4px;
  min-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

.statement-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.statement-summary article {
  min-height: 98px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.statement-summary span {
  color: var(--muted);
  font-size: 12px;
}

.statement-summary strong {
  display: block;
  margin-top: 10px;
  font-size: 25px;
}

.positive {
  color: var(--paid);
}

.negative {
  color: var(--danger);
}

@media (max-width: 900px) {
  .statement-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .statement-filters,
  .statement-form,
  .statement-shortcuts,
  .statement-form label {
    display: grid;
    width: 100%;
  }

  .statement-summary {
    grid-template-columns: 1fr;
  }
}


.document-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.document-filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.document-totals {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
}

.document-totals span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
}

@media (max-width: 1200px) {
  .document-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .document-filters,
  .filter-actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .document-totals {
    justify-content: flex-start;
  }
}


.bulk-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.select-col {
  width: 42px;
  text-align: center;
}

.select-col input {
  width: 16px;
  min-height: 16px;
}
