:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #17332a;
  background: #f9fafb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --green-lime: #22c55e;
  --green-action: #10b981;
  --green-deep: #064e3b;
  --green-dark: #022c22;
  --surface: #fff;
  --muted: #64756e;
  --border: #dce7e1;
}

#assignment-form {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

#assignment-form h2,
#assignment-form p {
  margin: 0;
}

#assignment-dialog .assignment-options {
  display: grid;
  max-height: min(50vh, 420px);
  gap: 0.5rem;
  overflow-y: auto;
  padding: 0.15rem;
}

.assignment-option {
  display: flex;
  min-height: 3.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfc;
  color: var(--green-dark);
  cursor: pointer;
}

.assignment-option input {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  accent-color: var(--green-action);
}

.assignment-option .participant-avatar {
  width: 2rem;
  height: 2rem;
  font-size: 0.72rem;
}

.assignment-option-name {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.assignment-option-detail {
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

* {
  box-sizing: border-box;
}

.icon-button.assign-icon {
  border-color: #99f6e4;
  background: #ccfbf1;
  color: #0f766e;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0, rgb(34 197 94 / 0.08), transparent 32rem),
    #f9fafb;
}

.participant-summary {
  display: grid;
  min-width: 0;
  gap: 0.25rem;
}

.participant-due {
  padding-left: 3.25rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.participant-items-button {
  min-height: 38px;
  padding: 0.45rem 0.65rem;
  border: 1px solid #99f6e4;
  background: #ccfbf1;
  color: #0f766e;
  font-size: 0.82rem;
}

main {
  width: min(100% - 2rem, 960px);
  margin: 0 auto;
  padding: 2.5rem 0 1.5rem;
}

.hero {
  display: flex;
  min-height: 250px;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  overflow: hidden;
  padding: 2.25rem 3rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 24px;
  background: linear-gradient(120deg, var(--green-deep), var(--green-dark));
  color: #fff;
  box-shadow: 0 18px 45px rgb(2 44 34 / 0.16);
}

.hero-copy {
  max-width: 590px;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: #a3f5b1;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 750;
  letter-spacing: -0.065em;
  line-height: 1;
}

.tagline {
  margin: 1rem 0 0;
  color: #a3f5b1;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 650;
  letter-spacing: -0.025em;
}

.subtitle {
  max-width: 32rem;
  margin: 0.75rem 0 0;
  color: #d5e8de;
  line-height: 1.6;
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 1rem;
}

.lang-button {
  min-height: 0;
  padding: 0.35rem 0.85rem;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.lang-button[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--green-action), var(--green-lime));
  color: var(--green-dark);
}

.export-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.export-form label {
  font-weight: 600;
}

select {
  min-width: 11rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfc;
  color: var(--green-dark);
  font: inherit;
}

select:focus-visible {
  border-color: var(--green-action);
  outline: 0;
  box-shadow: 0 0 0 4px rgb(16 185 129 / 0.15);
}

.brand-art {
  display: block;
  width: 160px;
  height: 160px;
  flex: 0 0 auto;
  object-fit: contain;
}

.lookup-card,
.result-card,
.participants-card {
  margin-top: 1.25rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  border: 1px solid #e7eeea;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 35px rgb(23 51 42 / 0.06);
}

.collapsible-card {
  display: block;
}

.collapsible-heading {
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
}

.collapsible-heading::-webkit-details-marker {
  display: none;
}

.collapsible-heading::after {
  width: 0.65rem;
  height: 0.65rem;
  flex: 0 0 auto;
  border-right: 2px solid var(--green-deep);
  border-bottom: 2px solid var(--green-deep);
  content: "";
  transform: rotate(45deg) translateY(-0.15rem);
  transition: transform 150ms ease;
}

.collapsible-card:not([open]) .collapsible-heading::after {
  transform: rotate(-45deg);
}

.collapsible-content {
  padding-top: 0.25rem;
}

.collapsible-card:not([open]) .collapsible-heading {
  margin: 0;
}

.result-card > .section-heading {
  margin-bottom: 1rem;
}

.invoices-card,
.combined-items {
  display: grid;
  gap: 1rem;
}

.invoices-card .section-heading {
  margin-bottom: 0;
}

.invoices-list {
  display: grid;
  gap: 0.75rem;
}

.invoice-accordion {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdfc;
}

.invoice-accordion summary {
  padding: 1rem 1.1rem;
  color: var(--green-deep);
  font-weight: 700;
  cursor: pointer;
}

.invoice-accordion summary:focus-visible {
  outline: 3px solid var(--green-action);
  outline-offset: -3px;
}

.invoice-content {
  display: grid;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.invoice-content .info {
  margin: 0;
}

.invoice-payments {
  color: #40574d;
}

.invoice-payments h3 {
  margin: 0;
  color: var(--green-dark);
}

.combined-items {
  margin-top: 1.25rem;
}

.combined-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.column-menu {
  position: relative;
  flex: 0 0 auto;
}

.column-menu > summary {
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--green-deep);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.column-menu > summary::-webkit-details-marker {
  display: none;
}

.column-menu > summary::after {
  content: " ▾";
}

.column-menu[open] > summary::after {
  content: " ▴";
}

.column-visibility {
  position: absolute;
  z-index: 5;
  top: calc(100% + 0.5rem);
  right: 0;
  display: grid;
  min-width: 190px;
  gap: 0.65rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgb(2 44 34 / 0.15);
}

.manual-item-form {
  display: grid;
  grid-template-columns: minmax(10rem, 2fr) minmax(6rem, 0.75fr) minmax(5rem, 0.6fr) minmax(9rem, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
}

.manual-item-form input {
  min-width: 0;
}

.manual-item-form button {
  min-height: 48px;
  padding-inline: 1rem;
}

.column-visibility legend {
  margin-bottom: 0.5rem;
  color: var(--green-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.column-visibility label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #40574d;
  font-size: 0.9rem;
}

.column-visibility input {
  width: auto;
  margin: 0;
  accent-color: var(--green-action);
}

.sort-button {
  display: inline-flex;
  min-height: 0;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  text-align: inherit;
}

.sort-button:hover:not(:disabled) {
  filter: none;
  transform: none;
  text-decoration: underline;
}

.sort-button:focus-visible {
  outline: 2px solid var(--green-action);
  outline-offset: 3px;
}

.actions-column {
  position: sticky;
  right: 0;
  z-index: 1;
  min-width: 148px;
  background: #fff;
  box-shadow: -8px 0 10px -8px rgb(2 44 34 / 0.3);
}

thead .actions-column {
  z-index: 2;
  background: #f0fdf4;
}

tfoot .actions-column {
  background: #f8fcf9;
}

.action-buttons {
  display: flex;
  gap: 0.4rem;
}

.actions-toggle {
  display: none;
  border-color: var(--border);
  background: #fff;
  color: var(--green-deep);
}

.action-menu.open .actions-toggle {
  background: #f0fdf4;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-button.edit-icon {
  border-color: #facc15;
  background: #fef3c7;
  color: #a16207;
}

.icon-button.delete-icon {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #b91c1c;
}

#item-edit-dialog,
#assignment-dialog {
  width: min(100% - 2rem, 480px);
  max-height: min(90vh, 720px);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: #17332a;
  box-shadow: 0 24px 80px rgb(2 44 34 / 0.3);
}

#item-edit-dialog::backdrop,
#assignment-dialog::backdrop {
  background: rgb(2 44 34 / 0.55);
}

#item-edit-form {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

#item-edit-form h2 {
  margin-bottom: 0.25rem;
}

#item-edit-form label {
  color: var(--green-dark);
  font-size: 0.9rem;
  font-weight: 650;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.assignment-bulk {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.assignment-bulk .secondary-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--green-deep);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.pagination[hidden] {
  display: none;
}

.page-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--green-deep);
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.page-button[aria-current="page"] {
  background: var(--green-deep);
  color: #fff;
}

.page-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.dialog-actions .secondary-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--green-deep);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.step-number {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: #dcfce7;
  color: var(--green-deep);
  font-size: 0.8rem;
  font-weight: 800;
}

h2 {
  margin: 0;
  color: var(--green-dark);
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.section-description {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

form {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.participants-card form {
  margin-top: 1.25rem;
}

#participant-form input {
  flex: 1;
}

.participant-status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--green-deep);
  font-size: 0.9rem;
}

.participant-status.error {
  color: #991b1b;
}

.empty-state {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.participants-list {
  display: grid;
  gap: 0.65rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid #e7eeea;
  border-radius: 12px;
  background: #fbfdfc;
}

.participant-name {
  min-width: 0;
  color: var(--green-dark);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.participant-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.participant-avatar {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.participant-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
}

.participant-actions button {
  min-height: 40px;
  padding: 0.55rem 0.8rem;
}

.participant-actions .icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.secondary-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--green-deep);
}

.participant-edit-form {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
}

.participant-edit-form input {
  flex: 1;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfc;
  color: var(--green-dark);
  font: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input::placeholder {
  color: #89968f;
}

input:focus-visible {
  border-color: var(--green-action);
  outline: 0;
  box-shadow: 0 0 0 4px rgb(16 185 129 / 0.15);
}

button {
  flex: 0 0 auto;
  padding: 0.85rem 1.35rem;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green-action), var(--green-lime));
  color: var(--green-dark);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: filter 150ms ease, transform 150ms ease;
}

button:hover:not(:disabled) {
  filter: saturate(1.12) brightness(0.97);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid var(--green-deep);
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

#invoice-form {
  align-items: center;
  gap: 0;
}

.qr-scan-button {
  position: relative;
  z-index: 1;
  display: grid;
  width: 3.75rem;
  height: 3.75rem;
  place-items: center;
  margin-right: -1.1rem;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgb(6 78 59 / 0.25);
}

#invoice-url {
  padding-left: 1.6rem;
  margin-right: 0.75rem;
}

#qr-dialog {
  width: min(32rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 18px;
}

#qr-dialog::backdrop {
  background: rgb(2 44 34 / 0.55);
}

#qr-panel {
  display: grid;
  gap: 0.75rem;
}

#qr-panel h2,
#qr-panel p {
  margin: 0;
}

.qr-viewport {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  background: #022c22;
}

.qr-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#status {
  margin: 1rem 0 0;
  padding: 0.8rem 1rem;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
  color: #1e3a5f;
  line-height: 1.5;
}

#status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.25rem;
  color: #40574d;
  font-size: 0.93rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.info strong {
  color: var(--green-dark);
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid #e7eeea;
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.consolidated-table {
  min-width: 0;
}

.item-name-cell {
  white-space: normal;
}

.item-name-cell,
.item-name {
  min-width: 0;
}

.item-name-content {
  display: flex;
  min-width: 12rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-name {
  flex: 1;
}

.item-name-content .item-share-stack {
  margin-left: auto;
}

.item-name {
  overflow-wrap: anywhere;
}

.item-share-stack {
  display: inline-flex;
  min-width: 2rem;
  flex: 0 0 auto;
  align-items: center;
  padding-left: 0.4rem;
}

.item-share-avatar,
.item-share-count {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 750;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 3px rgb(2 44 34 / 0.2);
}

.item-share-avatar + .item-share-avatar,
.item-share-count {
  margin-left: -0.65rem;
}

.item-share-count {
  position: relative;
  z-index: 2;
  background: #334155;
  font-size: 0.68rem;
}

.item-share-empty {
  color: #9ca3af;
  font-size: 1.15rem;
  text-align: center;
}

th,
td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid #edf2ef;
}

th {
  background: #f0fdf4;
  color: var(--green-deep);
  font-size: 0.83rem;
  font-weight: 700;
}

td {
  color: #40574d;
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #f8fcf9;
}

.num {
  text-align: right;
  white-space: nowrap;
}

tfoot td {
  border-bottom: 0;
  background: #f8fcf9;
  color: var(--green-dark);
  font-weight: 750;
}

.consolidated-table th:last-child,
.consolidated-table td.actions-column {
  position: sticky;
}

#payments {
  margin-top: 1.25rem;
  color: #40574d;
}

#payments h3 {
  color: var(--green-dark);
}

.page-footer {
  padding: 1.5rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

[hidden] {
  display: none !important;
}

@media (max-width: 600px) {
  .actions-column {
    min-width: 0;
  }

  .actions-toggle {
    display: inline-grid;
  }

  .action-menu .action-buttons {
    display: none;
    flex-direction: column;
    margin-top: 0.4rem;
  }

  .action-menu.open .action-buttons {
    display: flex;
  }
  main {
    width: min(100% - 1.25rem, 960px);
    padding-top: 0.75rem;
  }

  .hero {
    min-height: 0;
    gap: 1rem;
    padding: 1.5rem 1.25rem;
    border-radius: 20px;
  }

  .brand-art {
    width: 96px;
    height: 96px;
  }

  form {
    flex-direction: column;
  }

  #invoice-form {
    flex-direction: row;
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }

  #invoice-url {
    flex: 1;
    margin-right: 0;
  }

  #invoice-form #submit-btn {
    flex: 1 0 100%;
  }

  .manual-item-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .combined-heading {
    align-items: center;
  }

  .participant-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .participant-edit-form {
    align-items: stretch;
  }

  button {
    min-height: 48px;
  }

  th,
  td {
    padding: 0.7rem;
  }
}

@media (max-width: 380px) {
  .hero {
    align-items: flex-start;
  }

  .brand-art {
    width: 80px;
    height: 80px;
  }
}

.stepper {
  margin-top: 1.25rem;
}

.stepper ol {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-button {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 0.5rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--green-deep);
}

.step-button[aria-current="step"] {
  border-color: var(--green-action);
  background: linear-gradient(135deg, var(--green-action), var(--green-lime));
  color: var(--green-dark);
}

.step-badge {
  position: absolute;
  top: -0.45rem;
  right: -0.35rem;
  min-width: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--green-deep);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.15rem;
  text-align: center;
}

.step-nav {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.filter-button {
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--green-deep);
}

.filter-button[aria-pressed="true"] {
  border-color: var(--green-action);
  background: var(--green-deep);
  color: #fff;
}

.history-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-entry {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--green-action);
  border-radius: 10px;
}

.history-entry time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .stepper ol {
    gap: 0.35rem;
  }

  .step-label {
    font-size: 0.8rem;
  }
}
