:root {
  --bg: #f5f7f2;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #64736c;
  --line: #dfe6df;
  --green: #1f7a4d;
  --green-dark: #155c39;
  --red: #b84436;
  --blue: #336d92;
  --yellow: #c08a1f;
  --shadow: 0 18px 45px rgba(31, 48, 40, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

input,
select,
button {
  touch-action: manipulation;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

.top-actions,
.filters,
.form-row {
  display: flex;
  gap: 10px;
}

.icon-button,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.install-button {
  border: 1px solid var(--green);
}

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

.ghost-button {
  background: #e8eee8;
  color: var(--green-dark);
}

.danger-button {
  background: #f8e4e1;
  color: var(--red);
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.file-button input {
  display: none;
}

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

.metric,
.entry-panel,
.chart-panel,
.insights-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span,
.field span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.65rem;
}

.metric small,
.section-title p {
  color: var(--muted);
}

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

.entry-panel,
.chart-panel,
.insights-panel,
.table-panel {
  padding: 18px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title p {
  font-size: 0.9rem;
}

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

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented input:checked + span {
  border-color: var(--green);
  background: #e3f1e9;
  color: var(--green-dark);
}

.field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  padding: 0 12px;
}

.form-row > * {
  flex: 1;
}

.primary-button {
  width: 100%;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.filters {
  align-items: end;
  padding: 14px;
  background: #e8eee8;
  border-radius: 8px;
}

.compact {
  max-width: 180px;
}

.search-field {
  max-width: none;
  flex: 1;
}

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

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

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

.insight {
  border-left: 4px solid var(--yellow);
  background: #fbf7eb;
  border-radius: 8px;
  padding: 12px;
}

.insight strong {
  display: block;
  margin-bottom: 6px;
}

.insight p {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-heading {
  align-items: center;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.value-income {
  color: var(--green-dark);
  font-weight: 800;
}

.value-expense {
  color: var(--red);
  font-weight: 800;
}

.delete-row {
  min-height: 32px;
  border: 0;
  border-radius: 8px;
  background: #f2f4f2;
  color: var(--muted);
  cursor: pointer;
}

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

  .workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
    padding-bottom: 90px;
  }

  .topbar,
  .top-actions,
  .filters,
  .form-row,
  .section-title {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .chart-grid,
  .insights {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2rem;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 1.35rem;
  }

  .entry-panel {
    position: relative;
    box-shadow: 0 10px 28px rgba(31, 48, 40, 0.1);
  }

  .field input,
  .field select,
  .icon-button,
  .ghost-button,
  .primary-button,
  .danger-button,
  .segmented span {
    min-height: 48px;
  }

  .primary-button {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    box-shadow: 0 12px 26px rgba(31, 122, 77, 0.24);
  }

  .filters {
    gap: 12px;
  }

  .table-panel {
    padding: 14px 10px;
  }

  .compact {
    max-width: none;
  }
}
