:root {
  --bg: #f7f0e5;
  --bg-alt: #fffaf2;
  --ink: #172326;
  --ink-soft: #4a5a5f;
  --card: rgba(255, 251, 243, 0.9);
  --line: rgba(23, 35, 38, 0.15);
  --line-strong: rgba(23, 35, 38, 0.2);
  --accent: #bf4f2c;
  --accent-strong: #98331b;
  --accent-soft: rgba(191, 79, 44, 0.14);
  --good: #1f6a46;
  --danger: #7e2525;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 16px 40px rgba(23, 35, 38, 0.1);
  --space-1: clamp(6px, 0.22vw + 5px, 8px);
  --space-2: clamp(10px, 0.38vw + 8px, 14px);
  --space-3: clamp(14px, 0.52vw + 11px, 18px);
  --space-4: clamp(18px, 0.8vw + 14px, 24px);
  --space-5: clamp(24px, 1.05vw + 18px, 34px);
  --space-6: clamp(28px, 1.4vw + 20px, 42px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  line-height: 1.45;
  background:
    radial-gradient(circle at 10% 14%, #ffe5c6, transparent 38%),
    radial-gradient(circle at 88% 6%, #ffd6c0, transparent 42%),
    linear-gradient(160deg, var(--bg), var(--bg-alt));
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(14px);
  opacity: 0.35;
  z-index: -1;
}

.bg-orb-1 {
  width: 360px;
  height: 360px;
  top: -160px;
  right: -130px;
  background: #f7b982;
}

.bg-orb-2 {
  width: 300px;
  height: 300px;
  left: -100px;
  bottom: -130px;
  background: #f39a7a;
}

.app-shell {
  width: min(1680px, calc(100vw - clamp(18px, 4vw, 72px)));
  margin: clamp(16px, 2.6vw, 34px) auto clamp(26px, 3vw, 46px);
  display: grid;
  gap: var(--space-5);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
}

.hero {
  padding: clamp(24px, 3vw, 42px) clamp(24px, 3.4vw, 44px);
}

.eyebrow {
  margin: 0 0 var(--space-2);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent-strong);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: "Literata", Georgia, serif;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 2.9vw, 3rem);
  line-height: 1.12;
}

h2 {
  font-size: clamp(1.2rem, 0.95vw + 1rem, 1.55rem);
  line-height: 1.22;
}

.hero-sub {
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
  max-width: 66ch;
  font-size: clamp(1rem, 0.42vw + 0.92rem, 1.14rem);
}

.page-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: minmax(350px, 0.95fr) minmax(0, 1.55fr);
  align-items: start;
}

.side-stack {
  display: grid;
  gap: var(--space-5);
}

.panel {
  padding: clamp(18px, 2.1vw, 30px);
}

.panel-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  column-gap: var(--space-3);
  row-gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.panel-title-row h2 {
  max-width: 26ch;
}

.summary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid rgba(191, 79, 44, 0.24);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
}

.trip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.trip-grid button {
  grid-column: 1 / -1;
  margin-top: 2px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.93);
  color: var(--ink);
  padding: 0 13px;
}

input:focus {
  outline: 2px solid rgba(191, 79, 44, 0.24);
  border-color: var(--accent);
}

button {
  height: 44px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff8f1;
  font-weight: 700;
  padding: 0 15px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.08s ease;
}

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

button:active {
  transform: translateY(1px);
}

.share-btn {
  height: 34px;
  border-radius: 999px;
  padding: 0 13px;
  font-size: 0.81rem;
  color: var(--accent-strong);
  border: 1px solid rgba(191, 79, 44, 0.3);
  background: rgba(191, 79, 44, 0.12);
}

.share-btn:hover {
  background: rgba(191, 79, 44, 0.21);
}

button:disabled,
.share-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.matrix-controls {
  display: grid;
  grid-template-columns: minmax(300px, 470px) minmax(240px, 1fr);
  gap: var(--space-3) var(--space-4);
  align-items: end;
  margin-bottom: var(--space-4);
}

.add-person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2);
}

.hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 64ch;
}

.matrix-wrap {
  overflow: hidden;
}

.matrix-list {
  display: grid;
  gap: 10px;
}

.matrix-person-row {
  display: grid;
  grid-template-columns: clamp(220px, 24vw, 300px) minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.matrix-person-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  border-right: 1px solid rgba(23, 35, 38, 0.14);
  padding-right: 10px;
}

.matrix-person-inner {
  width: 100%;
  display: grid;
  gap: 10px;
}

.matrix-person-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}

.person-name {
  min-width: 0;
  max-width: 100%;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
}

.tax-toggle-btn {
  height: 32px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.8rem;
  border: 1px solid rgba(191, 79, 44, 0.34);
  background: rgba(191, 79, 44, 0.12);
  color: var(--accent-strong);
}

.tax-toggle-btn:hover {
  background: rgba(191, 79, 44, 0.2);
}

.tax-toggle-btn.is-on {
  border-color: rgba(31, 106, 70, 0.35);
  background: rgba(31, 106, 70, 0.15);
  color: var(--good);
}

.tax-toggle-btn.is-on:hover {
  background: rgba(31, 106, 70, 0.23);
}

.ghost-btn {
  height: 32px;
  border-radius: 9px;
  padding: 0 11px;
  font-size: 0.8rem;
  border: 1px solid rgba(126, 37, 37, 0.27);
  color: var(--danger);
  background: transparent;
}

.ghost-btn:hover {
  background: rgba(126, 37, 37, 0.08);
}

.matrix-night-row {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(var(--night-count), minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}

.matrix-no-nights {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
}

.night-check {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-height: 64px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  padding: 6px 4px;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.night-check:hover {
  background: rgba(255, 242, 225, 0.74);
}

.night-check.is-on {
  border-color: rgba(31, 106, 70, 0.34);
  background: rgba(31, 106, 70, 0.08);
}

.night-check-text {
  min-width: 0;
  width: 100%;
  display: grid;
  gap: 2px;
  justify-items: center;
}

.night-check .night-dow {
  display: block;
  color: var(--ink-soft);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.night-check .night-date {
  display: block;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stay-checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--good);
  cursor: pointer;
}

.stay-checkbox:disabled {
  opacity: 0.72;
  cursor: wait;
}

.summary-grid {
  display: grid;
  gap: var(--space-2);
}

.summary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
  padding: 13px 14px;
}

.summary-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.summary-name {
  font-size: 1rem;
  font-weight: 700;
}

.summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-pill {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.79rem;
  border: 1px solid transparent;
}

.summary-pill-nights {
  color: var(--ink-soft);
  background: rgba(23, 35, 38, 0.08);
  border-color: rgba(23, 35, 38, 0.14);
}

.summary-pill-stay {
  color: var(--accent-strong);
  background: rgba(191, 79, 44, 0.13);
  border-color: rgba(191, 79, 44, 0.22);
}

.summary-pill-tax {
  color: var(--good);
  background: rgba(31, 106, 70, 0.13);
  border-color: rgba(31, 106, 70, 0.22);
}

.summary-amount {
  color: var(--good);
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink-soft);
  padding: 16px;
}

.unallocated {
  margin-top: var(--space-3);
  border-radius: 12px;
  border: 1px solid rgba(126, 37, 37, 0.28);
  background: rgba(126, 37, 37, 0.07);
  color: var(--danger);
  padding: 11px 12px;
}

#toast {
  position: fixed;
  right: clamp(12px, 2vw, 20px);
  bottom: clamp(12px, 2vw, 20px);
  max-width: min(460px, calc(100vw - 24px));
  color: #fff;
  background: rgba(23, 35, 38, 0.95);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.24s ease, transform 0.24s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1480px) {
  .page-grid {
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  }
}

@media (max-width: 1260px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
  }
}

@media (max-width: 980px) {
  .app-shell {
    width: calc(100vw - 14px);
    margin: 8px auto 20px;
    gap: 12px;
  }

  .hero,
  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .side-stack {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .matrix-controls {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .matrix-person-row {
    grid-template-columns: clamp(170px, 28vw, 220px) minmax(0, 1fr);
  }

  .night-check {
    min-height: 60px;
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: 1.74rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  .panel-title-row {
    margin-bottom: 11px;
  }

  .summary-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .add-person-row {
    grid-template-columns: 1fr;
  }

  .summary-item {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .summary-amount {
    justify-self: start;
  }

  .matrix-person-row {
    grid-template-columns: 146px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .matrix-person-cell {
    padding-right: 8px;
  }

  .matrix-person-inner {
    gap: 8px;
  }

  .matrix-person-actions {
    gap: 6px;
  }

  .tax-toggle-btn,
  .ghost-btn {
    height: 30px;
    padding: 0 9px;
    font-size: 0.74rem;
  }

  .night-check {
    min-height: 56px;
    border-radius: 8px;
    padding: 5px 3px;
  }

  .night-check .night-dow {
    font-size: 0.55rem;
  }

  .night-check .night-date {
    font-size: 0.66rem;
  }
}
