:root {
  --bg: #f3efe5;
  --surface: rgba(255, 252, 246, 0.88);
  --surface-strong: #fffaf0;
  --text: #1f2933;
  --muted: #52606d;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.12);
  --border: rgba(31, 41, 51, 0.08);
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f4ea 0%, #efe7d7 100%);
}

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

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
  background: rgba(248, 244, 234, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.primary-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
}

.primary-nav a {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.nav-button {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: inherit;
}

.primary-nav a:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--text);
}

.page-shell {
  padding: 2rem 0 3rem;
}

.flash-message {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.flash-message.success {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(15, 118, 110, 0.18);
}

.flash-message.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.18);
}

.hero-panel,
.panel,
.page-hero {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--shadow);
  border-radius: 28px;
}

.hero-panel {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2rem;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.page-hero {
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.5rem;
}

.page-hero.compact h1,
.hero-panel h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
  margin: 0.2rem 0 0.8rem;
}

.page-hero.compact h1 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

.hero-copy,
.info-card p,
.empty-state {
  color: var(--muted);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 0.75rem;
}

.metric-card {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
}

.dashboard-metric-card {
  position: relative;
  overflow: hidden;
  min-height: 124px;
  display: grid;
  align-content: start;
  gap: 0.35rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 251, 245, 0.88) 100%);
  box-shadow:
    0 10px 24px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.dashboard-metric-card::after {
  content: "";
  position: absolute;
  inset: auto -18px -18px auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.12) 0%, rgba(15, 118, 110, 0) 72%);
}

.metric-card span,
.info-meta span,
.summary-strip span,
.panel-header span,
.chip-card small {
  display: block;
  color: var(--muted);
}

.metric-card strong {
  font-size: 1.35rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.metric-label {
  max-width: 18ch;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-note {
  position: relative;
  z-index: 1;
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-card.accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  box-shadow: 0 16px 28px rgba(17, 94, 89, 0.22);
}

.metric-card.accent span {
  color: rgba(255, 255, 255, 0.75);
}

.metric-card.accent .metric-note {
  color: rgba(255, 255, 255, 0.78);
}

.metric-card.accent::after {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 72%);
}

.quick-links,
.feature-nav-grid,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.quick-links {
  margin-top: 1.2rem;
}

.quick-link,
.feature-tile,
.chip-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}

.quick-link {
  padding: 0.75rem 1rem;
  border-radius: 999px;
}

.dashboard-grid,
.content-grid {
  display: grid;
  gap: 1.5rem;
}

.dashboard-grid,
.content-grid.two-col,
.report-grid {
  grid-template-columns: 1fr 1fr;
}

.panel {
  padding: 1.5rem;
}

.panel-header,
.card-title-row,
.info-card,
.settlement-row,
.button-row,
.filters-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header,
.card-title-row {
  align-items: center;
  margin-bottom: 1rem;
}

.form-panel.narrow-panel {
  max-width: 720px;
}

.app-form,
.stack-layout,
.stack-list,
.info-meta,
.settlement-panel {
  display: grid;
  gap: 0.85rem;
}

.app-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 500;
}

.form-control,
.form-select {
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 0.8rem 0.9rem;
  background: rgba(255, 255, 255, 0.92);
}

.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.25);
}

.btn-brand {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 0.85rem 1rem;
}

.btn-light {
  border-radius: 14px;
  padding: 0.85rem 1rem;
}

.info-card,
.feature-tile,
.settlement-row,
.block-card {
  padding: 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.info-card h3,
.feature-tile h3,
.panel-header h2 {
  margin: 0;
}

.info-card p,
.feature-tile p {
  margin: 0.35rem 0 0;
}

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

.feature-tile {
  min-height: 140px;
}

.chip-card {
  border-radius: 16px;
  padding: 0.85rem 1rem;
  min-width: 160px;
}

.right-align {
  text-align: right;
}

.text-link,
.mini-link {
  color: var(--accent-strong);
  font-weight: 600;
}

.mini-link {
  border: none;
  background: transparent;
  padding: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.summary-strip div {
  padding: 1rem;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.summary-strip strong {
  font-size: 1.4rem;
}

.balance-table {
  width: 100%;
  border-collapse: collapse;
}

.balance-table th,
.balance-table td {
  padding: 0.9rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.balance-table th {
  color: var(--muted);
  font-weight: 500;
}

.positive {
  color: var(--accent-strong);
  font-weight: 700;
}

.negative {
  color: var(--danger);
  font-weight: 700;
}

.status-pill {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.paid {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.pending {
  background: rgba(245, 158, 11, 0.16);
  color: #9a6700;
}

.filters-row {
  align-items: end;
}

.filters-row > * {
  flex: 1;
}

.expenses-layout {
  align-items: start;
}

.expenses-form-panel,
.expenses-ledger-panel {
  min-height: 72vh;
}

.compact-expense-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  align-content: start;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.ledger-filters {
  margin-bottom: 1rem;
}

.ledger-scroll-area {
  max-height: calc(72vh - 9rem);
  overflow-y: auto;
  padding-right: 0.35rem;
}

.ledger-scroll-area::-webkit-scrollbar {
  width: 10px;
}

.ledger-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(82, 96, 109, 0.28);
  border-radius: 999px;
}

.profile-layout {
  align-items: start;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: min(100%, 30rem);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.modal-header {
  margin-bottom: 1.25rem;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.25rem;
}

.search-results {
  display: grid;
  gap: 0.65rem;
}

.search-result-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 16px;
  padding: 0.8rem 0.9rem;
  display: grid;
  gap: 0.2rem;
}

.search-result-item span {
  color: var(--muted);
  font-size: 0.92rem;
}

.inline-role-form {
  display: grid;
  gap: 0.35rem;
}

.role-select {
  min-width: 8rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

@media (max-width: 980px) {
  .hero-panel,
  .dashboard-grid,
  .content-grid.two-col,
  .report-grid,
  .feature-nav-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip,
  .hero-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .expenses-form-panel,
  .expenses-ledger-panel {
    min-height: auto;
  }

  .ledger-scroll-area {
    max-height: 28rem;
  }
}

@media (max-width: 680px) {
  .header-shell,
  .panel-header,
  .card-title-row,
  .info-card,
  .settlement-row,
  .button-row,
  .filters-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero-metrics,
  .summary-strip,
  .compact-expense-form {
    grid-template-columns: 1fr;
  }

  .primary-nav {
    gap: 0.5rem;
  }

  .balance-table {
    display: block;
    overflow-x: auto;
  }

  .right-align {
    text-align: left;
  }

  .ledger-scroll-area {
    max-height: 24rem;
  }
}
