:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f2;
  color: #16211b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(140deg, rgba(34, 112, 93, 0.14), transparent 38%),
    linear-gradient(310deg, rgba(184, 83, 42, 0.12), transparent 44%),
    #f4f6f2;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

.shell {
  width: min(100%, 780px);
  margin: 0 auto;
  padding: 18px 14px 42px;
}

.topbar,
.panel-title,
.user-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #65746b;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 1.05rem;
}

.login-card,
.panel,
.summary-card,
.user-strip,
.flash {
  border: 1px solid rgba(22, 33, 27, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 34px rgba(22, 33, 27, 0.08);
}

.login-card {
  margin-top: 9vh;
  padding: 20px;
}

.muted,
.empty,
.user-strip span,
.entry-item span,
.month-card-body p,
.mini-row span {
  color: #65746b;
}

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

label {
  display: grid;
  gap: 6px;
  color: #405047;
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd6cf;
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #16211b;
  outline: none;
}

input:focus,
select:focus {
  border-color: #22705d;
  box-shadow: 0 0 0 3px rgba(34, 112, 93, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  background: #b8532a;
  color: #fff;
}

.secondary-button {
  background: #22705d;
  color: #fff;
}

.ghost-button {
  padding: 0 14px;
  background: #e9efeb;
  color: #34463c;
}

.danger-button {
  min-height: 32px;
  padding: 0 9px;
  background: #f4ebe5;
  color: #9a4320;
  font-size: 0.78rem;
}

.secondary-link {
  display: inline-grid;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  background: #e6eeea;
  color: #22705d;
  font-weight: 900;
  text-decoration: none;
}

.panel-hint {
  color: #65746b;
  font-size: 0.82rem;
  font-weight: 800;
}

.flash {
  margin-bottom: 12px;
  padding: 12px;
  color: #9a4320;
  font-weight: 800;
}

.user-strip {
  margin-bottom: 12px;
  padding: 12px;
}

.user-strip div {
  display: grid;
  gap: 3px;
}

.inline-filter {
  min-width: 160px;
}

.money-hero,
.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-card,
.money-card,
.panel {
  padding: 14px;
}

.money-card {
  border: 1px solid rgba(22, 33, 27, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(22, 33, 27, 0.08);
}

.primary-money {
  background: #22705d;
  color: #fff;
}

.money-card span {
  display: block;
  color: #65746b;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.primary-money span,
.primary-money p {
  color: rgba(255, 255, 255, 0.78);
}

.money-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.35rem;
}

.primary-money strong {
  font-size: 1.75rem;
}

.money-card p {
  margin-top: 7px;
  font-size: 0.9rem;
}

.summary-card span {
  display: block;
  color: #65746b;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin: 5px 0 8px;
  font-size: 1.28rem;
}

.summary-card p {
  display: flex;
  justify-content: space-between;
  color: #65746b;
  font-size: 0.9rem;
}

.panel {
  margin-top: 12px;
}

.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 178px;
  overflow: hidden;
  border: 1px solid #cfd8d1;
  border-radius: 8px;
  background: #eef2ed;
}

.type-toggle button {
  border: 0;
  padding: 9px 10px;
  background: transparent;
  color: #4e5e55;
  font-weight: 900;
  cursor: pointer;
}

.type-toggle button.active {
  background: #22705d;
  color: #fff;
}

.month-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.state-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.state-grid div {
  border: 1px solid #e1e8e3;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.state-grid span {
  display: block;
  color: #65746b;
  font-size: 0.78rem;
  font-weight: 800;
}

.state-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
}

.compact-form {
  margin-top: 12px;
}

.expense-bars {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.expense-bar-row {
  display: grid;
  gap: 7px;
}

.expense-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.expense-bar-top span {
  color: #65746b;
  font-size: 0.86rem;
  font-weight: 800;
}

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

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: #b8532a;
}

.category-editor {
  margin-top: 14px;
  border-top: 1px solid #edf2ee;
  padding-top: 12px;
}

.category-editor summary,
.state-editor summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.category-editor summary::-webkit-details-marker,
.state-editor summary::-webkit-details-marker {
  display: none;
}

.category-editor summary {
  color: #22705d;
  font-weight: 900;
}

.state-editor summary span {
  color: #65746b;
  font-size: 0.82rem;
  font-weight: 800;
}

.month-kpis div {
  border: 1px solid #e1e8e3;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.month-kpis span,
.month-card summary span {
  display: block;
  color: #65746b;
  font-size: 0.78rem;
}

.month-kpis strong {
  display: block;
  margin-top: 4px;
}

.entry-list {
  display: grid;
  gap: 9px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.entry-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #e1e8e3;
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.entry-side {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.entry-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.edit-link {
  display: inline-grid;
  align-items: center;
  min-height: 32px;
  border-radius: 8px;
  padding: 0 9px;
  background: #e6eeea;
  color: #22705d;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.income {
  color: #22705d;
}

.expense {
  color: #b8532a;
}

.accordion-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.month-card {
  border: 1px solid #e1e8e3;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.month-card summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.month-card summary::-webkit-details-marker {
  display: none;
}

.month-card-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.mini-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid #edf2ee;
  padding-top: 8px;
}

@media (min-width: 620px) {
  .shell {
    padding-top: 26px;
  }

  .money-hero {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .form-grid .primary-button {
    grid-column: 1 / -1;
  }

  .month-kpis {
    grid-template-columns: repeat(4, 1fr);
  }

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

@media (max-width: 430px) {
  .topbar,
  .panel-title,
  .user-strip,
  .expense-bar-top,
  .category-editor {
  margin-top: 14px;
  border-top: 1px solid #edf2ee;
  padding-top: 12px;
}

.category-editor summary,
.state-editor summary {
    align-items: stretch;
    flex-direction: column;
  }

  .type-toggle,
  .inline-filter {
    width: 100%;
  }

  .entry-item,
  .mini-row,
  .state-grid {
    grid-template-columns: 1fr;
  }

  .entry-side {
    justify-items: start;
  }
}
