:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #071f30;
  --muted: #637380;
  --line: #d8e1e8;
  --panel: #ffffff;
  --income: #12715b;
  --expense: #df1f2d;
  --accent: #073552;
  --soft: #e7eef3;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px clamp(18px, 4vw, 48px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand img {
  width: clamp(118px, 18vw, 210px);
  height: auto;
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.icon-button,
.primary {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  background: var(--soft);
  color: var(--ink);
  font-size: 24px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 18px;
}

.shell > *,
.dashboard-grid > *,
.metrics > *,
.table-wrap {
  min-width: 0;
}

.composer,
.metrics,
.dashboard-grid,
.analysis,
.table-panel {
  width: 100%;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.composer > *,
.composer__controls,
.filebox {
  min-width: 0;
}

.composer label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 112px;
}

.composer__controls {
  display: grid;
  gap: 12px;
  align-content: end;
}

.filebox {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #aab8ac;
  border-radius: 8px;
  background: #fbfcfa;
}

.filebox input {
  max-width: 100%;
}

.primary {
  min-height: 48px;
  width: 100%;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

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

.metrics article,
.panel,
.analysis,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics article {
  padding: 16px;
  min-height: 106px;
  display: grid;
  align-content: space-between;
}

.metrics span,
.panel__head span {
  color: var(--muted);
  font-size: 14px;
}

.metrics strong {
  font-size: clamp(24px, 3vw, 34px);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 18px;
}

.panel,
.analysis,
.table-panel {
  padding: 18px;
}

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

h2 {
  margin: 0;
  font-size: 20px;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 76px 1fr 110px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  position: relative;
  height: 34px;
  background: #eef2ed;
  border-radius: 8px;
  overflow: hidden;
}

.bar-income,
.bar-expense {
  position: absolute;
  inset-block: 0;
  min-width: 2px;
}

.bar-income {
  left: 0;
  background: var(--income);
}

.bar-expense {
  right: 0;
  background: var(--expense);
  opacity: 0.88;
}

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

.category-item {
  display: grid;
  gap: 6px;
}

.category-line {
  height: 10px;
  background: #eef2ed;
  border-radius: 999px;
  overflow: hidden;
}

.category-line span {
  display: block;
  height: 100%;
  background: var(--expense);
}

.category-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.analysis p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

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

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

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

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.pill.income {
  color: var(--income);
  background: #e1f2ec;
}

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

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

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

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.danger {
  border: 0;
  background: #fae8e2;
  color: #8a2f20;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 10px;
  background: #fff;
}

@media (max-width: 820px) {
  .composer,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

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

  .bar-row {
    grid-template-columns: 1fr;
  }
}
