:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #eab308;
  --danger: #dc2626;
  --shadow: 0 20px 45px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, 0.12), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 28rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 104px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  background: rgba(247, 248, 251, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #134e4a);
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.muted,
.field small,
.expense-row small,
.category-card small {
  color: var(--muted);
}

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

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.message-success {
  border-color: rgba(15, 118, 110, 0.28);
}

.message-error {
  border-color: rgba(220, 38, 38, 0.28);
}

.dashboard-hero {
  padding: 26px 20px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.94), rgba(17, 24, 39, 0.96)),
    linear-gradient(45deg, #0f766e, #111827);
  box-shadow: var(--shadow);
}

.dashboard-hero.small {
  padding: 18px 20px;
}

.dashboard-hero h1,
.page-heading h1,
.hero-copy h1 {
  margin: 4px 0 8px;
  letter-spacing: 0;
}

.dashboard-hero h1 {
  font-size: clamp(2.4rem, 10vw, 4.8rem);
}

.dashboard-hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
}

.eyebrow {
  display: inline-block;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-hero .eyebrow {
  color: #fef3c7;
}

.page-heading {
  padding-top: 8px;
}

.page-heading h1,
.hero-copy h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
}

.page-heading h1,
.page-heading p,
.hero-copy h1,
.hero-copy p {
  margin-left: 0;
  margin-right: 0;
}

.card,
.panel-form,
.filter-form,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card {
  padding: 16px;
}

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

.card-header h2,
.panel-form h2 {
  margin: 2px 0 0;
  font-size: 1.15rem;
}

.card-header a,
.secondary-link {
  color: var(--primary-dark);
  font-weight: 800;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.bar-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.bar-track span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--bar-color, var(--primary));
}

.expense-stack {
  display: grid;
  gap: 10px;
}

.expense-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.expense-row strong,
.expense-row small {
  display: block;
  overflow-wrap: anywhere;
}

.expense-row b {
  white-space: nowrap;
}

.category-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.row-actions {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: #fff;
  background: var(--primary);
}

.secondary-button {
  padding: 0 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.danger-button {
  width: 100%;
  padding: 0 18px;
  color: #fff;
  background: var(--danger);
}

.icon-button {
  width: 46px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 980px) / 2 + 18px));
  bottom: 82px;
  z-index: 20;
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border-radius: 22px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 18px 38px rgba(15, 118, 110, 0.34);
  font-size: 2.4rem;
  font-weight: 700;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px max(10px, calc((100vw - 980px) / 2 + 10px)) calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: grid;
  min-height: 44px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.bottom-nav a:hover,
.bottom-nav a:focus {
  color: var(--primary-dark);
  background: #ecfdf5;
}

.auth-panel {
  display: grid;
  gap: 22px;
  min-height: calc(100dvh - 120px);
  align-content: center;
}

.hero-copy p {
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.panel-form,
.filter-form,
.empty-state {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.panel-form.compact {
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.field input[type="color"] {
  padding: 5px;
}

.field em,
.form-errors {
  color: var(--danger);
  font-style: normal;
  font-weight: 700;
}

.filter-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.category-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.category-swatch {
  width: 100%;
  height: 10px;
  border-radius: 999px;
}

.segmented-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.segmented-list a {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 850;
}

.segmented-list a.is-active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.member-list {
  display: grid;
  gap: 8px;
}

.member-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.member-row:first-child {
  border-top: 0;
}

.empty-state {
  text-align: center;
}

.empty-state h2,
.empty-state p {
  margin: 0;
}

@media (min-width: 760px) {
  .content {
    grid-template-columns: repeat(12, 1fr);
  }

  .dashboard-hero,
  .page-heading,
  .toolbar,
  .auth-panel,
  .filter-form,
  .empty-state,
  .segmented-list,
  .secondary-button {
    grid-column: 1 / -1;
  }

  .card,
  .panel-form,
  .expense-stack,
  .category-grid {
    grid-column: span 6;
  }

  .expense-stack,
  .category-grid {
    display: grid;
  }

  .auth-panel {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    align-items: center;
  }
}

@media (max-width: 640px) {
  .filter-form {
    grid-template-columns: 1fr;
  }

  .bottom-nav a {
    font-size: 0.72rem;
  }
}

.multi-action {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.multi-action .primary-button,
.multi-action .secondary-button {
  width: 100%;
}

.category-card > a {
  display: grid;
  gap: 6px;
}

.mini-list {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.mini-list a,
.mini-list span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.mini-list a {
  color: var(--primary-dark);
}
