:root {
  --chase-blue: #005eb8;
  --chase-blue-700: #004a93;
  --chase-blue-050: #eef6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #dbe5f1;
  --panel: #ffffff;
  --canvas: #f5f8fc;
  --income: #07854f;
  --income-soft: #e7f7ef;
  --expense: #d71920;
  --expense-soft: #fdecec;
  --pending: #0b66c3;
  --pending-soft: #e8f2ff;
  --warning: #f59e0b;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--chase-blue), var(--chase-blue-700));
  box-shadow: 0 10px 28px rgba(0, 94, 184, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.brand p {
  margin: 5px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.small-button,
.segment,
.type-button,
.icon-button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--chase-blue);
  box-shadow: 0 10px 22px rgba(0, 94, 184, 0.18);
}

.primary-button:hover {
  background: var(--chase-blue-700);
  transform: translateY(-1px);
}

.ghost-button {
  color: var(--chase-blue);
  background: #ffffff;
  border-color: var(--line);
}

.topbar .ghost-button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.22);
}

.topbar .primary-button {
  background: #ffffff;
  color: var(--chase-blue);
  box-shadow: none;
}

.ghost-button:hover,
.small-button:hover,
.icon-button:hover {
  border-color: var(--chase-blue);
  background: var(--chase-blue-050);
}

.topbar .ghost-button:hover {
  background: rgba(255, 255, 255, 0.22);
}

.workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 74px;
  height: calc(100vh - 74px);
  padding: 22px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  padding: 12px 14px;
  color: #334155;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
}

.nav-link.active,
.nav-link:hover {
  color: var(--chase-blue);
  background: var(--chase-blue-050);
}

.side-panel {
  margin-top: 28px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.side-panel strong,
.side-panel span {
  display: block;
}

.side-panel strong {
  margin-bottom: 8px;
}

.side-panel span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.content {
  min-width: 0;
  padding: 28px;
}

#resumen,
#registro,
#reportes,
#transacciones,
#categorias {
  scroll-margin-top: 96px;
}

.hero-panel,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.section-kicker {
  margin: 0 0 6px;
  color: var(--chase-blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2,
h3,
h4 {
  margin: 0;
  line-height: 1.16;
}

h2 {
  font-size: 25px;
}

h3 {
  font-size: 18px;
}

h4 {
  font-size: 15px;
}

.period-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented,
.type-actions {
  display: inline-grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.segmented {
  grid-template-columns: repeat(3, minmax(80px, 1fr));
}

.type-actions {
  width: 100%;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0;
}

.segment,
.type-button {
  min-width: 0;
  min-height: 38px;
  color: #334155;
  background: transparent;
  border-radius: 0;
  border-right: 1px solid var(--line);
  box-shadow: none;
}

.segment:last-child,
.type-button:last-child {
  border-right: 0;
}

.segment.active,
.type-button.active {
  color: #ffffff;
  background: var(--chase-blue);
}

.period-input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
}

.year-input {
  width: 96px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.metric-card {
  padding: 20px;
}

.metric-card span,
.metric-card small {
  display: block;
}

.metric-card span {
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  color: var(--chase-blue);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 13px;
}

.metric-card.income strong {
  color: var(--income);
}

.metric-card.expense strong {
  color: var(--expense);
}

.metric-card.pending strong {
  color: var(--pending);
}

.main-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 420px;
  gap: 16px;
  align-items: stretch;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 11px 12px;
  min-height: 78px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 94, 184, 0.18);
  outline-offset: 2px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.small-button {
  min-height: 42px;
  color: var(--chase-blue);
  background: var(--chase-blue-050);
  border-color: #b8d8f6;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.full {
  width: 100%;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(46px, 1fr));
  gap: 14px;
  align-items: end;
  min-height: 276px;
  padding: 16px 4px 0;
  border-top: 1px solid var(--line);
}

.bar-group {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  min-width: 0;
  height: 250px;
}

.bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  align-items: end;
  height: 210px;
  border-bottom: 1px solid var(--line);
}

.bar {
  min-height: 2px;
  border-radius: 5px 5px 0 0;
}

.bar.income {
  background: linear-gradient(180deg, #11a86c, var(--income));
}

.bar.expense {
  background: linear-gradient(180deg, #f43f5e, var(--expense));
}

.bar-label {
  min-height: 32px;
  color: #475569;
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  min-height: 274px;
}

.donut-chart {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: conic-gradient(var(--line) 0 100%);
}

.donut-chart::after {
  position: absolute;
  inset: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  background: #ffffff;
  content: attr(data-total);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  white-space: pre-line;
}

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

.legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  color: #334155;
  font-size: 13px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-amount {
  color: var(--ink);
  font-weight: 800;
}

.table-panel {
  margin-top: 16px;
  padding: 0;
  overflow: hidden;
}

.table-panel .panel-heading {
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-scroll {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #334155;
  background: #f8fafc;
  font-weight: 800;
}

td {
  color: #1e293b;
}

.amount-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.actions-cell {
  width: 220px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.pill.income,
.pill.paid {
  color: var(--income);
  background: var(--income-soft);
}

.pill.expense {
  color: var(--expense);
  background: var(--expense-soft);
}

.pill.commission,
.pill.pending {
  color: var(--pending);
  background: var(--pending-soft);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-button {
  min-height: 30px;
  padding: 0 9px;
  color: #334155;
  background: #ffffff;
  border-color: var(--line);
  font-size: 12px;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.categories-panel {
  margin-top: 16px;
}

.category-lists {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.category-lists h4 {
  margin-bottom: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 44px));
  padding: 14px 16px;
  color: #ffffff;
  background: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
}

.negative {
  color: var(--expense) !important;
}

.positive {
  color: var(--income) !important;
}

@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .main-grid .chart-panel:last-child {
    grid-column: 1 / -1;
  }

  .donut-wrap {
    grid-template-columns: 180px minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .topbar,
  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .period-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-link {
    white-space: nowrap;
  }

  .side-panel {
    display: none;
  }

  .metrics-grid,
  .main-grid,
  .category-lists {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }
}

@media (max-width: 560px) {
  .topbar {
    position: relative;
    top: auto;
    padding: 16px;
  }

  #resumen,
  #registro,
  #reportes,
  #transacciones,
  #categorias {
    scroll-margin-top: 18px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .brand p {
    font-size: 12px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-actions button {
    width: 100%;
  }

  .hero-panel,
  .panel,
  .metric-card {
    padding: 16px;
  }

  .segmented {
    width: 100%;
  }

  .type-button,
  .segment {
    padding: 0 8px;
    font-size: 13px;
  }

  .period-input {
    width: 100%;
  }

  .metrics-grid {
    gap: 12px;
  }

  .donut-wrap {
    justify-items: center;
    grid-template-columns: 1fr;
  }

  .bar-chart {
    overflow-x: auto;
    grid-template-columns: repeat(6, 58px);
  }
}

@media print {
  :root {
    background: #ffffff;
  }

  body {
    background: #ffffff;
  }

  .topbar,
  .sidebar,
  .form-panel,
  .topbar-actions,
  .period-controls,
  .row-actions,
  .actions-cell,
  .ghost-button,
  .primary-button,
  .small-button {
    display: none !important;
  }

  .workspace {
    display: block;
  }

  .content {
    padding: 0;
  }

  .hero-panel,
  .panel,
  .metric-card {
    box-shadow: none;
    border-color: #cbd5e1;
    break-inside: avoid;
  }

  .main-grid,
  .metrics-grid,
  .category-lists {
    grid-template-columns: 1fr 1fr;
  }

  table {
    min-width: 0;
  }
}
