:root {
  --bg: #f6f5ef;
  --ink: #1d2521;
  --muted: #66716b;
  --panel: #ffffff;
  --line: #d8ded7;
  --green: #187a52;
  --red: #b33846;
  --blue: #2d66b3;
  --gold: #b27822;
  --shadow: 0 18px 45px rgba(41, 50, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.planner {
  max-width: 1380px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0 18px;
}

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

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

h1 {
  max-width: 720px;
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.subhead {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.file-actions,
.section-heading,
.graph-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-band,
.graph-panel,
.metric-grid article,
.entry-panel,
.list-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-band {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 0.7fr) minmax(160px, 0.7fr) auto;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

label,
fieldset {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 9px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(45, 102, 179, 0.24);
  outline-offset: 2px;
}

.graph-panel {
  padding: 16px;
}

.graph-head {
  margin-bottom: 10px;
}

.graph-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

canvas {
  display: block;
  width: 100%;
  height: min(42vh, 420px);
  min-height: 280px;
  border-radius: 6px;
  background: linear-gradient(180deg, #fbfcfa 0%, #f1f5f1 100%);
}

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

.metric-grid article {
  padding: 14px;
  box-shadow: none;
}

.metric-grid span,
.section-heading span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-grid strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.15rem, 1.7vw, 1.55rem);
  line-height: 1.12;
}

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

.entry-panel,
.list-panel,
.panel {
  padding: 16px;
}

form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.weekday-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0;
  padding: 10px;
}

.weekday-picker legend {
  padding: 0 6px;
}

.weekday-picker label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-size: 0.82rem;
}

.weekday-picker input {
  width: auto;
  min-height: 0;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.text-btn {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 800;
}

.primary-btn {
  background: var(--green);
  color: white;
}

.ghost-btn {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.danger-btn {
  background: #fff3f3;
  color: var(--red);
  border-color: #efc9ce;
}

.text-btn {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--blue);
}

.compact {
  white-space: nowrap;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #ecf7ef;
  color: var(--green);
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.items-list,
.compact-list,
.month-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.item-row,
.event-row,
.month-row,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

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

.item-main strong,
.event-row strong {
  display: block;
}

.item-meta,
.event-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.amount {
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.deposit {
  color: var(--green);
}

.withdrawal {
  color: var(--red);
}

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

.row-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 14px;
  margin-top: 14px;
}

.event-row,
.month-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.date-chip {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.month-row {
  grid-template-columns: 100px minmax(0, 1fr) 92px;
}

.bar-track {
  position: relative;
  height: 28px;
  overflow: hidden;
  border-radius: 5px;
  background: #eef1ed;
}

.bar-income,
.bar-expense {
  position: absolute;
  top: 0;
  bottom: 0;
}

.bar-income {
  left: 50%;
  background: rgba(24, 122, 82, 0.72);
}

.bar-expense {
  right: 50%;
  background: rgba(179, 56, 70, 0.72);
}

.hidden {
  display: none !important;
}

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

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

@media (max-width: 980px) {
  .topbar,
  .workspace-grid,
  .insight-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .control-band,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .file-actions {
    justify-content: start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 2rem;
    line-height: 1.04;
  }

  .control-band,
  .metric-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .item-row,
  .event-row,
  .month-row {
    grid-template-columns: 1fr;
  }

  .amount {
    text-align: left;
  }

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