:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --text: #1e2328;
  --muted: #66707a;
  --panel: #ffffff;
  --line: #d9ded9;
  --accent: #126a5a;
  --accent-dark: #0d4d43;
  --warm: #f0b35b;
  --danger: #b84a3f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(18, 106, 90, 0.12), transparent 36rem),
    linear-gradient(315deg, rgba(240, 179, 91, 0.16), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
  max-width: 100%;
  min-width: 0;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0.75rem 1rem;
  overflow-wrap: anywhere;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: #9da7a5;
  cursor: not-allowed;
}

button.secondary {
  background: #e8eeeb;
  color: var(--accent-dark);
}

button.danger {
  background: #f3e1de;
  color: var(--danger);
}

button.danger:hover {
  background: #ead0cc;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 44px;
  padding: 0.7rem 0.8rem;
}

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

.shell {
  width: min(1120px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 32px 0;
}

.hidden {
  display: none !important;
}

.home {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: 32px;
  align-items: center;
}

.home > *,
.grid > *,
.topbar > *,
.panel,
label {
  min-width: 0;
}

.home-copy h1,
.topbar h1 {
  margin: 0;
  line-height: 1.06;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.home-copy h1 {
  max-width: 760px;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
}

.home-copy p:not(.eyebrow) {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 42px rgba(20, 30, 24, 0.08);
  padding: 20px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h1 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}

.stack,
#createGroupForm {
  display: grid;
  gap: 14px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chips span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7faf8;
  padding: 0.45rem 0.7rem;
  font-weight: 700;
}

.summary-numbers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-numbers div {
  border-radius: 8px;
  background: #f7faf8;
  padding: 12px;
}

.summary-numbers span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-numbers strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.settlements {
  display: grid;
  gap: 10px;
}

.settlement {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.settlement strong {
  color: var(--danger);
}

.expenses-panel {
  margin-top: 16px;
}

.expenses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
}

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

.expense-card > div {
  min-width: 0;
}

.expense-card img,
.receipt-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  object-fit: cover;
}

.receipt-placeholder {
  display: grid;
  place-items: center;
  background: #eef2ef;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.expense-card h3,
.expense-card p {
  margin: 0;
}

.expense-card h3 {
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.expense-card p,
.empty {
  color: var(--muted);
}

.expense-card strong {
  white-space: nowrap;
}

.expense-actions {
  display: flex;
  gap: 8px;
  grid-column: 2 / 4;
  justify-content: flex-end;
}

.expense-actions button {
  min-height: 36px;
  padding: 0.55rem 0.75rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  border-radius: 8px;
  background: var(--text);
  color: white;
  padding: 0.8rem 1rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

@media (max-width: 900px) {
  .home,
  .grid {
    grid-template-columns: 1fr;
  }

  .home {
    align-content: center;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .home-copy h1 {
    font-size: 2.35rem;
  }

  .inline-form,
  .form-actions,
  .summary-numbers,
  .settlement,
  .expense-card {
    grid-template-columns: 1fr;
  }

  .expense-actions {
    grid-column: auto;
    justify-content: stretch;
  }

  .expense-actions button {
    flex: 1;
  }

  .expense-card img,
  .receipt-placeholder {
    width: 100%;
    height: 160px;
  }
}
