:root {
  color-scheme: light;
  --bg: #f7f7f3;
  --text: #20231f;
  --muted: #6d736b;
  --line: #deded6;
  --panel: #ffffff;
  --accent: #24745b;
  --accent-dark: #15523f;
  --danger: #a13d2d;
  --warm: #f29d52;
  --shadow: 0 18px 40px rgba(32, 35, 31, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(242, 157, 82, 0.18), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.55);
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 28px 20px 92px;
}

.screen-active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none;
}

.brand-block {
  padding-top: 24px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.eyebrow,
.panel-label {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 28px;
  font-size: clamp(2.35rem, 13vw, 3.55rem);
  line-height: 0.96;
  letter-spacing: 0;
}

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

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

.auth-panel {
  margin-top: auto;
  padding: 14px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 8px;
  background: #f0f0eb;
}

.mode-button {
  min-height: 40px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.mode-button-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 5px rgba(32, 35, 31, 0.08);
}

.stacked-form {
  display: grid;
  gap: 12px;
}

.panel {
  margin: 18px 0 24px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-title-row h2 {
  margin: 0;
}

label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  color: var(--text);
}

select {
  appearance: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(36, 116, 91, 0.14);
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

.form-message.success-message {
  color: var(--accent-dark);
}

.auth-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
}

.top-bar h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 1;
}

.ghost-button {
  width: auto;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 0.9rem;
}

.summary-panel {
  margin: 28px 0;
  padding: 22px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
}

.summary-panel .panel-label {
  color: var(--warm);
}

.profile-name {
  margin-bottom: 6px;
  font-size: 2rem;
  font-weight: 850;
  line-height: 1;
}

.group-total {
  margin-bottom: 8px;
  font-size: 2.1rem;
  font-weight: 850;
  line-height: 1;
}

.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.summary-panel .muted {
  color: rgba(255, 255, 255, 0.68);
}

.summary-action {
  width: 100%;
  margin-top: 18px;
  background: #fff;
  color: var(--text);
}

.content-section {
  padding-bottom: 18px;
}

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

.section-heading span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #c8c8bf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

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

.empty-state p {
  margin-bottom: 14px;
  color: var(--muted);
}

.empty-action {
  width: 100%;
}

.item-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.item-list strong,
.item-list span {
  display: block;
}

.item-list strong {
  margin-bottom: 4px;
}

.item-list span {
  color: var(--muted);
  font-size: 0.88rem;
}

.item-list p {
  margin: 0;
  font-weight: 850;
  white-space: nowrap;
}

.open-group-button {
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

.expense-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.expense-card {
  display: grid;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.expense-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.expense-main strong,
.expense-main span {
  display: block;
}

.expense-main strong {
  margin-bottom: 4px;
}

.expense-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.expense-amount {
  margin: 0;
  font-weight: 850;
  white-space: nowrap;
}

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

.small-button {
  min-height: 38px;
  padding: 0 12px;
}

.small-danger-button {
  min-height: 38px;
  padding: 0 12px;
  background: var(--danger);
}

.detail-title {
  margin: 0 0 8px;
  font-size: 2.3rem;
  line-height: 1;
}

.danger-zone {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(161, 61, 45, 0.28);
  border-radius: 8px;
  background: rgba(161, 61, 45, 0.06);
}

.danger-zone h2 {
  margin-bottom: 6px;
}

.danger-zone p {
  margin-bottom: 14px;
  color: var(--muted);
}

.danger-button {
  width: 100%;
  background: var(--danger);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 10px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.nav-button {
  min-height: 44px;
  background: transparent;
  color: var(--muted);
}

.nav-button-active {
  background: var(--accent);
  color: #fff;
}

.stats-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat-value {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 850;
}

.chart-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chart-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chart-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chart-label-row strong {
  font-size: 0.95rem;
}

.chart-label-row span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.insight-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.insight-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
}

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

.insight-card p {
  margin: 0;
  color: var(--muted);
}

.bar-fill-muted {
  background: var(--warm);
}

@media (min-width: 700px) {
  body {
    padding: 28px 0;
  }

  .app-shell {
    position: relative;
    min-height: calc(100vh - 56px);
    border: 1px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }

  .screen {
    min-height: calc(100vh - 56px);
  }

  .bottom-nav {
    position: absolute;
  }
}
