:root {
  color-scheme: dark;
  --bg: #101413;
  --surface: #171d1a;
  --surface-2: #202721;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f3f0e8;
  --muted: #b8b6ad;
  --soft: #85887c;
  --accent: #f4b84a;
  --accent-2: #63c7a0;
  --danger: #ee6a5f;
  --ink: #0c100f;
  --radius: 8px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(99, 199, 160, 0.16), transparent 20rem),
    radial-gradient(circle at 85% 10%, rgba(244, 184, 74, 0.14), transparent 18rem),
    linear-gradient(180deg, #101413 0%, #111715 48%, #0d1110 100%);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  background: rgba(16, 20, 19, 0.72);
}

.hero {
  position: relative;
  min-height: 206px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.text-hero {
  background:
    linear-gradient(135deg, rgba(99, 199, 160, 0.18), transparent 40%),
    linear-gradient(180deg, #18211c 0%, #101413 100%);
}

.hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 206px;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px 18px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(1.65rem, 8.2vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hero-stats span,
.pill {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 8px;
  overflow: hidden;
  background: rgba(12, 16, 15, 0.58);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

main {
  padding: 16px 14px 8px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(23, 29, 26, 0.94);
  box-shadow: var(--shadow);
}

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

.two-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #101513;
  color: var(--text);
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(244, 184, 74, 0.86);
  box-shadow: 0 0 0 3px rgba(244, 184, 74, 0.14);
}

.native-multi-select {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.multi-select-field {
  position: relative;
}

.multi-select {
  position: relative;
  z-index: 3;
}

.multi-select-toggle {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #101513;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.multi-select-toggle span {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.multi-select.is-open .multi-select-toggle {
  border-color: rgba(244, 184, 74, 0.86);
  box-shadow: 0 0 0 3px rgba(244, 184, 74, 0.14);
}

.multi-select-menu {
  position: absolute;
  right: 0;
  left: 0;
  top: calc(100% + 6px);
  display: none;
  max-height: 240px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #171d1a;
  box-shadow: var(--shadow);
}

.multi-select.is-open .multi-select-menu {
  display: grid;
  gap: 4px;
}

.multi-select-option {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 8px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.multi-select-option:hover,
.multi-select-option.is-selected {
  background: rgba(99, 199, 160, 0.12);
}

.check-box {
  position: relative;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.multi-select-option.is-selected .check-box {
  border-color: var(--accent);
  background: var(--accent);
}

.multi-select-option.is-selected .check-box::after {
  position: absolute;
  top: 3px;
  left: 6px;
  width: 4px;
  height: 8px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  content: "";
  transform: rotate(45deg);
}

.multi-select-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.mini-chip {
  max-width: 100%;
  padding: 4px 7px;
  border: 1px solid rgba(99, 199, 160, 0.26);
  border-radius: 999px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.form-actions,
.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
}

.primary {
  background: var(--accent);
  color: var(--ink);
  font-weight: 900;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  padding-inline: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 2px 10px;
}

.section-title.compact {
  padding-top: 4px;
}

.section-title.in-panel {
  padding: 0;
}

.inline-control {
  width: min(190px, 48%);
}

.inline-control select {
  min-height: 40px;
  padding-block: 8px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.card-list.spaced {
  margin: 12px 0;
}

.restaurant-card,
.warning-card,
.leaderboard-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--surface);
}

.avatar {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, #63c7a0, #f4b84a);
  color: var(--ink);
  font-weight: 950;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.rank-badge {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  align-self: start;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--ink);
  font-weight: 950;
}

.thumb-strip,
.image-preview,
.visit-details {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.visit-details {
  flex-wrap: wrap;
  margin-top: -2px;
}

.thumb-strip img,
.image-chip img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
}

.image-preview {
  margin-top: -4px;
}

.image-chip {
  position: relative;
  display: block;
  width: 48px;
  height: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  padding: 2px;
  background: #101513;
}

.image-chip img {
  width: 100%;
  height: 100%;
}

.image-chip span {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 900;
}

.card-main {
  min-width: 0;
}

.card-top,
.meta-row,
.card-actions,
.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-top {
  justify-content: space-between;
}

.card-top h3 {
  overflow-wrap: anywhere;
}

.meta-row,
.score-row {
  flex-wrap: wrap;
  margin-top: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.chip.good {
  border-color: rgba(99, 199, 160, 0.34);
  color: #9be3c6;
}

.chip.warn {
  border-color: rgba(238, 106, 95, 0.34);
  color: #f0a29b;
}

.notes {
  margin: 8px 0 0;
  color: var(--soft);
  font-size: 0.85rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.mini-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.compact-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.score-meter {
  position: relative;
  height: 8px;
  flex: 1 1 120px;
  min-width: 120px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.score-meter span {
  display: block;
  width: var(--score);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

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

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

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

.toggle {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #101513;
}

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

.bill-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

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

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) 36px;
  gap: 8px;
  align-items: end;
}

.settlement-card,
.history-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
}

.settlement-card {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
}

.settlement-card strong {
  overflow-wrap: anywhere;
}

.settlement-card span:not(.chip) {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.history-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.history-total {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bill-result div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.bill-result span {
  color: var(--muted);
  font-weight: 800;
}

.bill-result strong {
  font-size: 1.05rem;
}

.bill-result .highlight {
  border-color: rgba(244, 184, 74, 0.44);
  background: rgba(244, 184, 74, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 44px;
  place-items: center;
  background: #101513;
  color: var(--muted);
  font-size: 0.85rem;
}

.segmented input:checked + span {
  background: var(--accent-2);
  color: var(--ink);
}

.warning-card {
  grid-template-columns: 1fr auto;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(16, 20, 19, 0.92);
  backdrop-filter: blur(18px);
}

.bottom-nav button {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  background: transparent;
  color: var(--soft);
}

.bottom-nav button.active {
  color: var(--accent);
}

.bottom-nav span {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.69rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 700px) {
  body {
    padding: 18px 0;
  }

  .app-shell {
    min-height: calc(100vh - 36px);
    border: 1px solid var(--line);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  }

  .bottom-nav {
    right: 50%;
    left: auto;
    transform: translateX(50%);
  }
}

@media (max-width: 390px) {
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .two-grid,
  .toggle-row {
    grid-template-columns: 1fr;
  }

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

  .person-row .mini-button {
    width: 100%;
  }

  .settlement-card,
  .history-card {
    grid-template-columns: 1fr;
  }
}
