:root {
  --bg-top: #593523;
  --bg-bottom: #2d180f;
  --surface: rgba(246, 232, 207, 0.1);
  --surface-strong: #f0dec0;
  --surface-soft: rgba(240, 222, 192, 0.16);
  --text-main: #f6ebd7;
  --text-soft: #d9c3a4;
  --text-dark: #3b2116;
  --line: rgba(246, 235, 215, 0.12);
  --accent: #d7964f;
  --accent-2: #9cc289;
  --danger: #bd6255;
  --shadow: 0 18px 40px rgba(12, 5, 3, 0.3);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --content-max: 1040px;
  --font-main: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(241, 223, 191, 0.12), transparent 35%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
  font-family: var(--font-main);
}

body {
  min-height: 100vh;
  line-height: 1.45;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 18px 116px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.topbar h1,
.card h2,
.card h3,
.modal-card h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
  font-weight: 850;
  max-width: 11ch;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.version-badge {
  display: inline-flex;
  margin: 12px 0 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(240, 222, 192, 0.12);
  border: 1px solid rgba(240, 222, 192, 0.14);
  color: var(--text-soft);
  font-size: 0.84rem;
}

.content {
  display: grid;
  gap: 20px;
}

.tab-panel {
  display: none;
  gap: 22px;
  align-content: start;
}

.tab-panel.active {
  display: grid;
}

.hero {
  display: grid;
  gap: 22px;
}

.hero-grid,
.two-col,
.editor-grid,
.settings-grid {
  display: grid;
  gap: 18px;
}

.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(246, 235, 215, 0.12), rgba(246, 235, 215, 0.07));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.card::before {
  content: "";
  position: absolute;
  inset: auto -12% 72% auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(240, 222, 192, 0.08);
  pointer-events: none;
}

.card > h2,
.card > h3 {
  margin-bottom: 10px;
  font-size: clamp(1.3rem, 2vw, 1.75rem);
  letter-spacing: -0.03em;
}

.metric-value {
  margin: 0 0 12px;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 800;
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.metric-detail,
.helper-text,
.field-help,
.list-meta,
.muted {
  color: var(--text-soft);
}

.helper-text {
  max-width: 62ch;
  line-height: 1.55;
}

.metric-actions,
.form-actions,
.toolbar-row,
.inline-fields,
.row,
.budget-list,
.occurrence-header {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin: 22px 0 10px;
}

.summary-stats > * {
  min-height: 170px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(33, 18, 12, 0.24);
  border: 1px solid rgba(246, 235, 215, 0.08);
}

.pill-select,
.field,
.text-area,
.search-input,
.select-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(246, 235, 215, 0.14);
  border-radius: var(--radius-md);
  background: rgba(41, 22, 15, 0.62);
  color: var(--text-main);
  padding: 16px 18px;
}

input[type="date"].field {
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
}

.field::placeholder,
.text-area::placeholder,
.search-input::placeholder {
  color: rgba(217, 195, 164, 0.72);
}

.text-area {
  min-height: 120px;
  resize: vertical;
}

.field-row,
.field-stack,
.budget-item,
.occurrence-item,
.legend-list,
.budget-progress-list {
  display: grid;
  gap: 14px;
}

.field-group label,
.field-stack label,
.section-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button {
  background: var(--surface-strong);
  color: var(--text-dark);
  font-weight: 800;
}

.secondary-button {
  background: rgba(240, 222, 192, 0.15);
  color: var(--text-main);
  border: 1px solid rgba(240, 222, 192, 0.18);
}

.danger-button {
  background: var(--danger);
  color: var(--text-main);
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid rgba(240, 222, 192, 0.18);
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.metric-actions .primary-button,
.metric-actions .secondary-button {
  flex: 1 1 240px;
}

.inline-fields > * {
  flex: 1 1 240px;
}

.toolbar-row {
  margin-top: 14px;
}

.editor-form {
  gap: 18px;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(92vw, 820px);
  padding: 12px;
  border-radius: 999px;
  background: rgba(35, 18, 11, 0.88);
  border: 1px solid rgba(246, 235, 215, 0.1);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.tabbar-button {
  border: 0;
  border-radius: 999px;
  padding: 16px 12px;
  color: var(--text-soft);
  background: transparent;
  font-weight: 700;
}

.tabbar-button.active {
  background: var(--surface-strong);
  color: var(--text-dark);
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 14px;
  align-items: end;
  min-height: 220px;
  padding-top: 24px;
}

.chart-bar {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.chart-bar-fill {
  width: 100%;
  min-height: 6px;
  border-radius: 999px 999px 8px 8px;
  background: linear-gradient(180deg, var(--accent), #8e5225);
}

.chart-bar-label,
.chart-bar-value {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.progress-track {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: rgba(240, 222, 192, 0.12);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.progress-fill.over {
  background: linear-gradient(90deg, #d27a63, #f0a26f);
}

.budget-item,
.occurrence-item,
.legend-item {
  padding: 16px 0;
  border-top: 1px solid rgba(246, 235, 215, 0.08);
}

.budget-item:first-child,
.occurrence-item:first-child,
.legend-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.occurrence-group + .occurrence-group {
  margin-top: 22px;
}

.occurrence-header {
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.occurrence-item {
  display: grid;
  gap: 12px;
}

.occurrence-topline,
.legend-item,
.budget-item,
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(240, 222, 192, 0.12);
  color: var(--text-main);
  font-size: 0.84rem;
}

.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.amount {
  font-weight: 800;
}

.empty-state {
  min-height: 220px;
  place-content: center;
}

.hidden {
  display: none !important;
}

.modal {
  width: min(92vw, 760px);
  border: 0;
  border-radius: var(--radius-xl);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(8, 3, 2, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  padding: 0;
  background:
    radial-gradient(circle at top left, rgba(241, 223, 191, 0.12), transparent 32%),
    linear-gradient(180deg, #4c2e20, #2d180f);
  border: 1px solid rgba(246, 235, 215, 0.14);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.modal-header,
.modal-card .editor-form {
  padding: 26px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(240, 222, 192, 0.12);
  color: var(--text-main);
  font-weight: 800;
}

.status-banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(156, 194, 137, 0.16);
  border: 1px solid rgba(156, 194, 137, 0.26);
  color: var(--text-main);
}

.status-banner.error {
  background: rgba(189, 98, 85, 0.16);
  border-color: rgba(189, 98, 85, 0.28);
}

.install-note {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.88rem;
}

@media (min-width: 760px) {
  .hero-grid,
  .two-col,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    max-width: none;
    font-size: 2.4rem;
  }

  .card {
    padding: 22px 18px;
    border-radius: 24px;
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

  .tabbar-button {
    font-size: 0.82rem;
    padding-inline: 6px;
  }
}
