:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #eef8f4;
  --ink: #18211f;
  --muted: #65716d;
  --line: #dce3df;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --accent: #eab308;
  --danger: #b42318;
  --shadow: 0 18px 46px rgba(19, 33, 29, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 14px calc(env(safe-area-inset-bottom) + 30px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.15rem;
  line-height: 1;
}

h2 {
  font-size: 1.05rem;
}

.topbar h1 {
  letter-spacing: 0;
}

.project-panel,
.workspace {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.project-panel {
  padding: 14px;
}

.workspace {
  padding: 16px;
}

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

.section-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.text-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.text-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.project-title {
  min-height: 52px;
  font-size: 1.2rem;
  font-weight: 800;
}

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

.primary-button,
.ghost-button,
.icon-button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
}

.primary-button:active {
  background: var(--brand-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
}

.ghost-button.danger {
  color: var(--danger);
}

.icon-button {
  width: 46px;
  flex: 0 0 46px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand);
  font-size: 1.4rem;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
  margin-top: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 0 8px 0 12px;
  font-weight: 800;
}

.chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip button,
.expense-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.09);
  color: var(--danger);
  font-weight: 900;
}

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

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

.participants-box {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.participants-box legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.payer-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.participant-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  font-weight: 700;
}

.participant-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.full-width {
  width: 100%;
}

.expense-list,
.summary-list {
  display: grid;
  gap: 8px;
}

.expense-item,
.summary-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

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

.expense-main strong,
.summary-main strong {
  overflow-wrap: anywhere;
}

.money {
  color: var(--brand);
  font-weight: 900;
  white-space: nowrap;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.summary-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f3fbf8 100%);
}

.empty-state {
  display: grid;
  gap: 5px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

@media (max-width: 560px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .workspace,
  .project-panel {
    padding: 13px;
  }

  .inline-form,
  .two-columns {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button,
  .text-input {
    min-height: 48px;
  }

  .participant-grid {
    grid-template-columns: 1fr;
  }
}
