/* ── Design Tokens ── */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --text-2: #78716c;
  --text-3: #a8a29e;
  --border: #e7e5e4;
  --divider: #f5f5f4;
  --green: #16a34a;
  --green-hover: #15803d;
  --green-light: #f0fdf4;
  --green-border: #bbf7d0;
  --red-light: #fef2f2;
  --red-border: #fecaca;
  --red-text: #991b1b;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #92400e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 4px;
  --font-display: "Literata", serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}
/* ── Toast ── */

.toast {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translate(-50%, 0);
  width: min(30rem, calc(100% - 2rem));
  padding: 0.8rem 1rem;
  background: var(--red-light);
  border: 1px solid var(--red-border);
  color: var(--red-text);
  border-radius: var(--radius-sm);
  box-shadow:
    0 14px 28px rgba(28, 25, 23, 0.14),
    0 4px 10px rgba(28, 25, 23, 0.08);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.45;
  z-index: 150;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-message {
  flex: 1 1 auto;
  min-width: 0;
}

.toast-action {
  pointer-events: auto;
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.25rem -0.25rem 0;
  font: inherit;
  font-weight: 600;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.toast-action:hover {
  background: rgba(0, 0, 0, 0.06);
}

.toast.success {
  background: var(--green-light);
  border-color: var(--green-border);
  color: var(--green);
}

.toast.hidden {
  display: none;
}

.toast.fade-out {
  opacity: 0;
  transform: translate(-50%, 0.5rem);
}

/* ── Reset ── */

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

/* ── Focus ── */

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

input[type="text"]:focus-visible,
input[type="number"]:focus-visible {
  outline: none;
  border-color: var(--text-3);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

/* ── Skip Navigation ── */

.skip-nav {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  z-index: 200;
  background: var(--green);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
}

.skip-nav:focus {
  position: fixed;
  left: 50%;
  top: 0.5rem;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  margin: 0;
  width: auto;
  height: auto;
  clip: auto;
  clip-path: none;
  white-space: normal;
  border: 0;
}

/* ── Base ── */

html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

/* ── Header / Hero ── */

.hero {
  margin-bottom: 2.5rem;
}

.hero .brand {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.02em;
}

.hero-logo {
  width: 40px;
  height: 40px;
}

.top-bar .brand {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.top-bar .brand .brand-logo {
  width: 40px;
  height: 40px;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variation-settings: "opsz" 72;
  text-wrap: balance;
}

#merchant-title,
#tab-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.015em;
  color: var(--text);
  font-variation-settings: "opsz" 36;
}

.hero p {
  margin: 0.75rem 0 0;
  color: var(--text-2);
  max-width: 46ch;
  font-size: 1.0625rem;
  line-height: 1.55;
}

/* ── Card ── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.03);
}

.card + .card {
  margin-top: 1rem;
}

.card.upload-card {
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.start-tab-card + .balance-chip {
  margin-top: 1rem;
}

.recent-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
}

.recent-header .section-title {
  margin-bottom: 0;
}

.toggle-group {
  display: flex;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: 2px;
}

.toggle-group:not(.ready) {
  background: var(--border);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.toggle-group:not(.ready) .toggle-btn {
  visibility: hidden;
}

.toggle-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: transparent;
  color: #a8a29e;
  border: none;
  cursor: pointer;
  min-height: 2.75rem;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.65rem 0;
  border-top: 1px solid var(--divider);
}

.recent-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.recent-link:hover {
  text-decoration: none;
}

.recent-link:hover:not(:has(.recent-tab-link:hover)) .recent-title {
  text-decoration: underline;
}

.recent-text {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
  flex: 1;
}

.recent-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.recent-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-3);
  overflow-wrap: anywhere;
}

.recent-time {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: right;
  flex-shrink: 0;
  margin-left: auto;
  min-width: 0;
}

.recent-show-more {
  text-align: center;
  padding: 0.5rem 0 0.25rem;
}

/* ── Form ── */

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
}

.form-grid > * {
  min-width: 0;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 0.375rem;
}

input[type="file"],
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 150ms, box-shadow 150ms;
  touch-action: manipulation;
}

input[type="number"] {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

input[type="file"] {
  font-size: 0.8125rem;
  color: var(--text-2);
  cursor: pointer;
}

select,
textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 150ms, box-shadow 150ms;
}

textarea {
  resize: vertical;
  min-height: 96px;
}

/* ── Buttons ── */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
}

button {
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.625rem 1.125rem;
  transition: background 150ms, transform 80ms;
  touch-action: manipulation;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  color: var(--bg);
  background: linear-gradient(135deg, #16a34a, #15803d);
  transition: background 300ms, transform 80ms, box-shadow 200ms;
}

.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #15803d, #166534);
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
}

.primary:active:not(:disabled) {
  transform: scale(0.98);
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  line-height: 1.2;
}

.compact {
  font-size: 0.8125rem;
  padding: 0.625rem 0.875rem;
  min-height: 2.75rem;
}

.ghost.copied,
.ghost.copied:hover {
  background: var(--green);
  color: var(--bg);
  border-color: var(--green);
}

.primary.copied {
  background: linear-gradient(135deg, #166534, #14532d);
}

.ghost:hover:not(:disabled):not(.copied) {
  background: #e2fce9;
  border-color: #86efac;
}

/* ── Preview ── */

.preview-shell {
  position: relative;
  /* brand green dashed: marks the dropzone as the page's primary CTA. Hover and
     dragover keep the green border and fill the background; dragover adds a glow. */
  border: 1.5px dashed var(--green);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 240px;
  display: grid;
  place-items: center;
  background: var(--divider);
  transition: border-color 200ms, background 200ms, box-shadow 200ms;
  cursor: pointer;
  touch-action: manipulation;
}

@media (hover: hover) {
  .preview-shell:hover:not(:has(img:not(.hidden))) {
    background: var(--green-light);
  }
}

.preview-shell:active:not(:has(img:not(.hidden))) {
  background: var(--green-light);
  transition-duration: 0ms;
}

.preview-shell.dragover {
  border-color: var(--green);
  background: var(--green-light);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-3);
  text-align: center;
  pointer-events: none;
}

.upload-placeholder svg {
  color: var(--green);
}

.upload-placeholder strong {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-2);
}

.upload-placeholder small {
  font-size: 0.8125rem;
}

.upload-placeholder .ai-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  opacity: 1;
  background: rgba(76, 175, 80, 0.08);
  border-radius: 999px;
  color: var(--green);
}

.upload-placeholder .ai-hint .sparkle {
  flex-shrink: 0;
  color: var(--green);
}

.preview-shell:has(img:not(.hidden)) {
  border-style: solid;
  border-color: var(--green-border);
  background: var(--surface);
}

.preview-shell img {
  max-width: 100%;
  max-height: 320px;
  display: block;
  border-radius: 6px;
}

/* Upload status + errors live inside the dropzone, pinned to the bottom edge,
   so progress and failures read as part of the box (the spinner already does).
   Click-through so the box stays tappable to retry. */
.preview-shell > .message {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.75rem;
  width: fit-content;
  max-width: calc(100% - 1.5rem);
  margin-inline: auto;
  z-index: 2;
  text-align: center;
  pointer-events: none;
}

/* ── Scan Spinner ── */

.scan-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-sm);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.scan-spinner-ring {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--green-border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Messages ── */

.message {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.5;
  border: 1px solid transparent;
}

.message.error {
  color: var(--red-text);
  background: var(--red-light);
  border-color: var(--red-border);
}

.message.info {
  color: var(--green);
  background: var(--green-light);
  border-color: var(--green-border);
}

.message.warning {
  color: var(--amber-text);
  background: var(--amber-light);
  border-color: var(--amber-border);
}

.turnstile-shell {
  display: flex;
  justify-content: center;
  width: 100%;
  min-width: 0;
}

#turnstile-widget {
  display: flex;
  justify-content: center;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  min-width: 0;
}

#turnstile-widget > div,
#turnstile-widget iframe {
  max-width: 100% !important;
  min-width: 0 !important;
}

.cf-turnstile,
.cf-turnstile iframe,
iframe[src*="challenges.cloudflare.com"] {
  max-width: 100% !important;
}

.hidden {
  display: none !important;
}

/* iOS Safari can treat hidden file inputs as overflow; keep this one off-layout. */
.file-input-proxy {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  max-width: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

/* ── Mono ── */

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ── Receipt Page: Top Bar ── */

.top-bar {
  margin-bottom: 2rem;
}

.top-bar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.top-bar .brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.02em;
}

.top-bar h1 {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variation-settings: "opsz" 28;
}

.top-bar-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

.tab-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  margin-top: 0.25rem;
  padding: 0.18rem 0.65rem;
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  background: var(--amber-light);
  color: var(--amber-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.top-bar h1.receipt-title-editable,
.top-bar h1.tab-title-editable {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 0.2rem;
  margin-left: -0.2rem;
  margin-right: -0.2rem;
  transition: background 150ms;
}

.top-bar h1.receipt-title-editable:hover,
.top-bar h1.tab-title-editable:hover {
  background: var(--divider);
}

.top-bar h1.receipt-title-editable:focus-visible,
.top-bar h1.tab-title-editable:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.receipt-meta-editable {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 0.2rem;
  margin-left: -0.2rem;
  margin-right: -0.2rem;
  transition: background 150ms;
}

.receipt-meta-editable:hover {
  background: var(--divider);
}

.receipt-meta-editable:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.editable-placeholder {
  font-style: italic;
  opacity: 0.5;
}

.inline-date-input {
  font-family: var(--font-mono);
  font-size: inherit;
  line-height: inherit;
}

.top-bar p {
  margin: 0.25rem 0 0;
  color: var(--text-2);
  font-size: 0.875rem;
}

.receipt-presence {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
}

.receipt-presence.hidden {
  display: none;
}

.receipt-presence.is-reconnecting .presence-stack {
  opacity: 0.55;
  filter: grayscale(0.4);
  transition: opacity 200ms ease-out, filter 200ms ease-out;
}

.presence-stack {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  padding-left: 0.5rem;
}

.presence-chip {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  min-height: 1.75rem;
  border-radius: 9999px;
  border: 2px solid var(--surface);
  margin-left: -0.5rem;
  background: var(--divider);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 150ms ease-out;
  box-sizing: content-box;
}

.presence-chip:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  z-index: 12;
}

.presence-chip:hover {
  transform: translateY(-2px);
  z-index: 10;
}

.presence-chip img {
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  object-fit: cover;
  display: block;
}

.presence-chip-initial {
  pointer-events: none;
  line-height: 1;
}

.presence-chip-fruit {
  font-size: 1rem;
  line-height: 1;
  pointer-events: none;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}

.presence-chip.is-self {
  box-shadow: 0 0 0 1px var(--green);
}

.presence-chip-overflow {
  background: var(--divider);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: default;
}

.presence-popover {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateX(-50%);
  background: var(--text);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  z-index: 20;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.presence-popover::before {
  content: "";
  position: absolute;
  top: -0.25rem;
  left: 50%;
  margin-left: -0.25rem;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--text);
  transform: rotate(45deg);
}

.top-bar-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.top-bar-header-text {
  flex: 1;
  min-width: 0;
}

.top-bar-qr-inline {
  display: none;
  flex-shrink: 0;
  margin-top: 0.5rem;
}

.top-bar-qr-inline canvas {
  display: block;
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
}

.top-bar .actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-title-row .section-title {
  margin-bottom: 0;
}

.section-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.18em;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.section-inline-link:hover {
  color: var(--text);
  text-decoration-color: currentColor;
}

.section-inline-link-icon {
  flex-shrink: 0;
  color: var(--green);
}

.hero-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

#hero-actions,
.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.guest-payment-grid {
  display: grid;
  gap: 1rem;
}

.saved-payment-methods {
  display: grid;
  gap: 0.9rem;
}

.profile-form {
  display: contents;
}

.payment-method-list {
  display: grid;
  gap: 0;
  margin-bottom: 0.25rem;
}

.payment-row {
  display: grid;
  grid-template-columns: minmax(4rem, auto) minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
}

.payment-row:last-child {
  border-bottom: none;
}

.payment-row--other {
  align-items: start;
}

.payment-row--other .payment-row-label,
.payment-row--other .payment-row-default {
  margin-top: 0.5rem;
}

.payment-row-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.payment-row-default {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-3);
  cursor: pointer;
  white-space: nowrap;
  margin: 0;
  padding: 0.15rem 0.1rem;
}

.payment-row-default input {
  margin: 0;
  cursor: pointer;
}

.payment-row-default:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.45;
}

.payment-row--configured .payment-row-default {
  color: var(--text-2);
}

.payment-row--configured:has(input[type="radio"]:checked) .payment-row-default {
  color: var(--green-hover);
  font-weight: 500;
}

.profile-identity {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  align-items: start;
  gap: 1rem 1.5rem;
}

.profile-identity .name-field {
  min-width: 0;
  padding-top: 0.15rem;
}

.profile-photo-block {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  width: 5rem;
}

.profile-photo-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--divider);
  color: var(--text-2);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-photo-preview:hover {
  border-color: var(--green-border);
  color: var(--green);
}

.profile-photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo-controls {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  align-items: center;
}

.profile-photo-controls .compact {
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
}

.profile-photo-controls .owner-danger-btn {
  background: transparent;
  border-color: transparent;
}

.profile-photo-controls .owner-danger-btn:hover:not(:disabled) {
  background: var(--red-light);
  border-color: var(--red-border);
}

#profile-photo-status {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
  line-height: 1.35;
}

.guest-payment-field {
  min-width: 0;
}

.guest-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2357534e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.guest-settings-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border);
}

.profile-form-card > .profile-form-section + .profile-form-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border);
}


.guest-device-link-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.passkey-auth-copy {
  margin-top: 0.75rem;
}

.forget-device-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.status-inline-error {
  color: #b91c1c;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.owner-menu {
  position: relative;
  display: inline-block;
  margin-top: 0.3rem;
}

.owner-menu-trigger {
  padding: 0.35rem 0.25rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  transition: color 150ms;
}

.owner-menu-trigger:hover {
  color: var(--text);
}

.owner-menu-caret {
  font-size: 0.85rem;
  vertical-align: 0.05em;
}

.owner-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 50;
  padding: 0.25rem;
}

.owner-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
}

.owner-menu-item:hover {
  background: var(--divider);
}

.owner-menu-danger {
  color: var(--red-text);
}

.owner-menu-danger:hover {
  background: var(--red-light);
}

.result-note {
  margin-top: 0.5rem;
  color: var(--text-2);
}

.status-error-gap {
  margin-top: 1.5rem;
}

.brand-link {
  text-decoration: none;
  color: var(--green);
}

.brand-link:hover {
  text-decoration: underline;
}

/* ── Stack ── */

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.section-title {
  margin: 0 0 0.875rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variation-settings: "opsz" 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-icon {
  color: var(--text-3);
  flex-shrink: 0;
}

.badge-recommended {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.5rem;
  letter-spacing: 0;
}

details.card {
  background: none;
  border-color: transparent;
  box-shadow: none;
  padding: 0;
}

details.card > summary {
  cursor: pointer;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 400;
  list-style: revert;
  margin-bottom: 0;
}

details.card > summary::-webkit-details-marker {
  color: var(--text-3);
}

details.card[open] > summary {
  margin-bottom: 0.75rem;
}

details.card > .card > :first-child {
  margin-top: 0;
}

.passkey-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.passkey-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.passkey-item:last-child {
  border-bottom: none;
}

.passkey-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.passkey-item-name {
  font-size: 0.875rem;
  font-weight: 500;
}

.passkey-item .btn-delete {
  background: none;
  border: none;
  color: var(--red-text);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0;
  white-space: nowrap;
}

.owner-only-badge {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-3);
}

.not-found-card {
  text-align: center;
  padding: 2rem 1.5rem;
}

.not-found-card p {
  margin: 0.65rem 0 1rem;
  color: var(--text-2);
}

.not-found-link {
  text-decoration: none;
}

/* ── Summary Grid ── */

.summary-summary {
  cursor: pointer;
  align-items: center;
  list-style: none;
}

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

.summary-disclosure:not([open]) > .summary-summary {
  margin-bottom: 0;
}

.summary-title-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.summary-chevron {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform 0.18s ease;
}

.summary-disclosure[open] .summary-chevron {
  transform: rotate(180deg);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.summary-chip {
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--divider);
}

.summary-chip .small {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.summary-chip strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 500;
  margin-top: 0.125rem;
  color: var(--text);
}

/* ── Name Field ── */

.name-field {
  display: grid;
  gap: 0.45rem;
}

.name-field label {
  margin: 0;
  transition: color 150ms, transform 150ms;
}

.name-field input[type="text"] {
  transition: border-color 150ms, box-shadow 150ms, background 150ms, transform 150ms;
}

.name-hint {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  color: var(--red-text);
}

.name-input-error {
  border-color: var(--red-border) !important;
  box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.08);
}

.name-input-error:focus {
  border-color: var(--red-border) !important;
  box-shadow: 0 0 0 3px rgba(153, 27, 27, 0.12);
}

@keyframes name-nudge {
  0%, 100% {
    border-color: var(--border);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0);
    background: var(--surface);
    transform: translateY(0);
  }
  35%, 65% {
    border-color: var(--green-border);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
    background: var(--green-light);
    transform: translateY(-1px);
  }
}

@keyframes name-label-nudge {
  0%, 100% {
    color: var(--text);
    transform: translateX(0);
  }
  35%, 65% {
    color: var(--green);
    transform: translateX(2px);
  }
}

.name-field-nudge input[type="text"] {
  animation: name-nudge 1.1s ease-in-out;
}

.name-field-nudge label {
  animation: name-label-nudge 1.1s ease-in-out;
}

/* ── Owner Inline Editing ── */

.owner-danger-btn {
  color: var(--red-text);
  border-color: var(--red-border);
  background: var(--red-light);
}

.owner-danger-btn:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fee2e2;
}

.summary-chip.editable-chip {
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
  position: relative;
  border-style: dashed;
  border-color: var(--text-3);
}

.summary-chip.editable-chip:hover {
  border-color: var(--green-border);
  background: var(--green-light);
}

.summary-chip.editing {
  border-color: var(--green);
  background: var(--surface);
}

.chip-edit-input {
  display: block;
  width: 100%;
  margin-top: 0.125rem;
  padding: 0.2rem 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--green);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.add-item-trigger {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0;
  border: none;
  background: none;
  color: var(--green);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 150ms;
}

.add-item-trigger:hover {
  opacity: 1;
}

.add-item-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  margin-top: 0.5rem;
  padding: 1.5rem 1.25rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 12px;
}

.add-item-empty-headline {
  margin: 0;
  font-family: "Literata", serif;
  font-variation-settings: "opsz" 20;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text);
}

.add-item-empty-sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-2);
}

.add-item-empty-cta {
  margin-top: 0.375rem;
  width: 100%;
  max-width: 18rem;
}

.add-item-inline {
  padding: 0.75rem;
  border: 1px dashed var(--green-border);
  border-radius: var(--radius-sm);
  background: var(--green-light);
  margin-top: 0.5rem;
}

.add-item-inline .add-item-fields {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(5.25rem, 7rem) minmax(6.5rem, 8rem);
  gap: 0.45rem 0.55rem;
  align-items: start;
}

.add-item-inline label {
  font-size: 0.6875rem;
  color: var(--text-3);
  margin-bottom: 0.15rem;
}

.add-item-inline input,
.add-item-inline textarea {
  font-size: 0.8125rem;
  padding: 0.35rem 0.5rem;
}

.add-item-inline textarea,
.inline-item-edit textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
}

.add-item-inline textarea {
  min-height: 3.5rem;
}

.inline-item-edit textarea {
  min-height: 4.5rem;
}

.add-item-name-field,
.add-item-qty-field,
.add-item-total-field {
  grid-row: 1;
}

.add-item-name-field {
  grid-column: 1;
}

.add-item-details-field {
  grid-column: 1 / -1;
  grid-row: 2;
}

.add-item-qty-field {
  grid-column: 2;
}

.add-item-total-field {
  grid-column: 3;
}

.add-item-inline .add-item-buttons {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.item-owner-actions {
  display: inline-flex;
  align-items: center;
  vertical-align: baseline;
  margin-left: 0.5rem;
  opacity: 0;
  transition: opacity 150ms;
  height: 0;
  overflow: visible;
}

.item-row:hover .item-owner-actions {
  opacity: 1;
}

.item-owner-actions button {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  transition: color 150ms;
}

.item-owner-actions button:hover {
  color: var(--text);
}

.item-owner-actions button.owner-action-delete:hover {
  color: var(--red-text);
}

.item-owner-actions .action-sep {
  color: var(--border);
  font-size: 0.75rem;
  margin: 0 0.15rem;
}

.inline-item-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
}

.inline-item-edit label {
  font-size: 0.6875rem;
  color: var(--text-3);
  margin-bottom: 0.1rem;
}

.inline-item-edit input,
.inline-item-edit textarea {
  font-size: 0.8125rem;
  padding: 0.3rem 0.4rem;
}

.inline-item-edit-full {
  grid-column: 1 / -1;
}

.inline-item-edit .inline-edit-buttons {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.35rem;
}

.inline-item-split-preview {
  font-size: 0.8125rem;
  color: var(--text-2);
}

.inline-item-split-preview.invalid {
  color: var(--red-text);
}

.ghost.cancel-btn {
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
}

.ghost.cancel-btn:hover:not(:disabled) {
  background: var(--bg);
  border-color: var(--border);
}

/* ── Pick Header ── */

.split-ways {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.split-ways .split-label {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

.split-ways input[type="number"] {
  width: 3rem;
  padding: 0.2rem 0.3rem;
  text-align: center;
  font-size: 0.75rem;
}

.split-ways input[type="number"].locked {
  background: var(--divider);
  color: var(--text-3);
  cursor: not-allowed;
}

/* ── Item List ── */

.item-list {
  margin-top: 0.75rem;
}

.item-row {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--divider);
  position: relative;
}

.item-row:last-child {
  border-bottom: none;
}

.item-row.claimed {
  opacity: 0.6;
}

.item-row.claimed .item-controls {
  display: none;
}

.item-row.claimed-hidden {
  display: none;
}

.all-claimed-banner {
  text-align: center;
  padding: 1.5rem 1rem;
  margin: 0;
}

.all-claimed-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.25rem;
}

.all-claimed-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.all-claimed-subtitle {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin: 0.2rem 0 0;
}

.claimed-items-toggle {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--divider);
}

.claimed-toggle-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0;
  font-family: inherit;
}

.claimed-toggle-btn:hover {
  color: var(--text);
}

.item-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.item-row h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: default;
  border-radius: 4px;
  padding: 0 0.2rem;
  margin: 0 -0.2rem;
  transition: background 150ms;
  position: relative;
  flex: 1;
  min-width: 0;
}

.item-row h3.editable {
  cursor: pointer;
}

.item-row h3.editable:hover {
  background: var(--divider);
}


.inline-rename {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  border: none;
  border-bottom: 1px solid var(--green);
  background: transparent;
  outline: none;
  padding: 0;
  width: 100%;
}

.receipt-title-input,
.tab-title-input {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.item-price {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

.item-detail {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-2);
}

.item-detail-lines {
  margin: 0.2rem 0 0.3rem;
  padding: 0 0 0 1rem;
  color: var(--text-2);
  font-size: 0.8rem;
  line-height: 1.4;
}

.item-detail-lines li + li {
  margin-top: 0.1rem;
}

.item-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.claim-presets {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.preset-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  transition: background 150ms, border-color 150ms, color 150ms, transform 100ms;
}

.preset-btn:active:not(:disabled) {
  transform: scale(0.97);
}

@media (hover: hover) {
  .preset-btn:hover:not(:disabled) {
    background: var(--green-light);
    border-color: var(--green-border);
    color: var(--green);
  }
}

.preset-btn.active {
  background: var(--green);
  color: var(--surface);
  border-color: var(--green);
}

.preset-btn:disabled {
  opacity: 0.4;
}

.item-controls .qty-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: auto;
}

.item-controls .qty-group .qty-label {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-bottom: 0;
}

.item-controls .qty-group .qty-value {
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

.qty-fraction {
  margin-left: auto;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--amber-text);
}

/* Shared/split claims read amber, visually distinct from green "mine" (DESIGN.md). */
.preset-btn[data-preset="shared"].active {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--surface);
}

@media (hover: hover) {
  .preset-btn[data-preset="shared"]:hover:not(:disabled) {
    background: var(--amber-light);
    border-color: var(--amber-border);
    color: var(--amber-text);
  }
}

.shared-line {
  margin: 0.3rem 0 0;
}

.shared-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--amber-text);
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.shared-pill::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--amber);
}

.claim-actions {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.claims-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.claim-row {
  border-top: 1px solid var(--divider);
  padding: 0.65rem 0;
}

.claim-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.7rem;
}

.claim-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.claim-name-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.claim-avatar {
  display: inline-block;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.claim-you {
  color: var(--green);
  font-size: 0.75rem;
  margin-left: 0.4rem;
}

.claim-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
}

.claim-total {
  margin: 0;
  min-width: 7ch;
  font-size: 1.125rem;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.claim-items {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.claim-time {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  color: var(--text-3);
}

/* ── Paid Status ── */

.paid-toggle {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, color 150ms;
  flex-shrink: 0;
  white-space: nowrap;
}

.paid-toggle:hover {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-light);
}

.paid-toggle.paid {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.paid-toggle.paid:hover {
  background: var(--green-hover);
  border-color: var(--green-hover);
}

.paid-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  flex-shrink: 0;
}

.claim-delete {
  font-size: 0.875rem;
  line-height: 1;
  color: var(--text-3);
  background: none;
  border: none;
  padding: 0.1rem 0.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.claim-delete:hover {
  color: var(--red-text);
}

.claim-paid .claim-name,
.claim-paid .claim-total,
.claim-paid .claim-items {
  opacity: 0.5;
}

.all-paid-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: var(--green-light);
  border-radius: var(--radius);
}

.all-paid-icon {
  font-size: 0.9rem;
  color: var(--green);
}

.all-paid-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  margin: 0;
}

.recent-paid {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 500;
}

.recent-unpaid {
  color: var(--text-muted);
}

.recent-activity {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 500;
}

.recent-tab {
  font-size: 0.75rem;
  color: var(--text-3);
}

.recent-tab-link {
  color: var(--green);
  text-decoration: none;
}

.recent-tab-link:hover {
  text-decoration: underline;
}

/* ── Payment Info ── */

.payment-info-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.receipt-image-modal {
  z-index: 220;
  padding: 1rem;
}

.receipt-image-modal-box {
  width: min(960px, 100%);
  max-height: calc(100vh - 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.receipt-image-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--divider);
}

.receipt-image-modal-heading {
  min-width: 0;
}

.receipt-image-modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.receipt-image-status {
  margin: 0.35rem 0 0;
}

.receipt-image-close {
  flex-shrink: 0;
}

.receipt-image {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 8rem);
  margin: 0 auto;
  background: var(--bg);
}

.pay-display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pay-display-header > div {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pay-method-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.pay-method-card {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.pay-method-card-label {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}

.pay-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pay-display-row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pay-display-logo {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  border-radius: 4px;
}

.pay-display-logo--wide {
  width: auto;
  height: 1.25rem;
}

.pay-display-logo--tall {
  width: auto;
  height: 1.375rem;
}

.pay-btn-logo {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.pay-btn-logo--wide {
  width: auto;
  height: 0.875rem;
}

.pay-btn-logo--tall {
  width: auto;
  height: 1rem;
}

.pay-display-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.pay-display-body {
  margin-top: 0.25rem;
}

.pay-owner-note,
.pay-form-copy {
  margin: 0.75rem 0 0;
}

.pay-empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  text-align: center;
  margin-top: 0.5rem;
  padding: 1.5rem 1.25rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 12px;
}

.pay-empty-hero-headline {
  margin: 0;
  font-family: "Literata", serif;
  font-variation-settings: "opsz" 20;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text);
}

.pay-empty-hero-logos {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.pay-empty-hero-logos .pay-display-logo {
  width: 2rem;
  height: 2rem;
}

.pay-empty-hero-logos .pay-display-logo--wide {
  width: auto;
  height: 1.625rem;
}

.pay-empty-hero-logos .pay-display-logo--tall {
  width: auto;
  height: 1.875rem;
}

.pay-empty-hero-cta {
  width: 100%;
  max-width: 18rem;
}

.pay-display-handle {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.pay-display-note {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text);
  word-break: break-word;
  white-space: pre-line;
}

.pay-display-handle--link {
  display: block;
  text-decoration: none;
  color: var(--green);
}

.pay-display-handle--link:hover {
  text-decoration: underline;
}

.pay-cta-slot {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
  text-align: center;
}

.pay-cta-slot:has(.tab-banner) {
  border-top: none;
  padding-top: 0;
}

.pay-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 1.25rem;
  background: var(--green);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  text-decoration: none;
  transition: opacity 0.15s;
}

.pay-cta-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.pay-cta-btn svg {
  height: 1.125rem;
  width: auto;
  flex-shrink: 0;
}

.pay-alt-inline {
  margin: 0.65rem 0 0;
  color: var(--text-2);
}

.pay-alt-action {
  margin-top: 0.65rem;
}

.pay-alt-divider {
  margin: 0 0 0.45rem;
  color: var(--text-3);
  text-transform: lowercase;
}

.payment-info-edit-btn {
  font-size: 0.75rem;
}

.payment-info-add-btn {
  font-size: 0.8125rem;
}

.pay-method-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.pay-method-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  padding: 0.35rem 0.75rem;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}

.pay-method-btn:hover {
  opacity: 0.8;
}

.pay-method-btn.active {
  opacity: 1;
  background: var(--green-light);
  border-color: var(--green-border);
  color: var(--green);
  font-weight: 600;
}

.pay-handle-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.pay-handle-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.pay-handle-prefix {
  width: 2rem;
  padding: 0.5rem 0;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text-3);
  text-align: center;
  flex-shrink: 0;
  user-select: none;
}

.pay-handle-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: none;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: transparent;
  box-sizing: border-box;
}

.pay-handle-wrap:has(.pay-handle-prefix) .pay-handle-input {
  padding-left: 0.5rem;
}

.pay-handle-input:focus {
  outline: none;
}

.pay-note-input {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  box-sizing: border-box;
  resize: vertical;
  min-height: 2.5rem;
}

.pay-note-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.pay-form-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.625rem;
}

/* ── Result Card ── */

.result-card {
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.result-card .line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.3rem 0;
  font-size: 0.9375rem;
}

.result-card .line span {
  color: var(--text-2);
}

.result-card .line strong {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
}

.result-card .line.total-line {
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--green-border);
}

.result-card .line.total-line span {
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 600;
}

.result-card--empty .line {
  display: none;
}

.result-card--empty .result-note {
  text-align: center;
  color: var(--text-3);
  margin: 0;
  padding: 0.5rem 0;
}

.itemized-breakdown {
  margin-top: 0.8rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--green-border);
}

.itemized-breakdown summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  user-select: none;
}

.itemized-breakdown summary::-webkit-details-marker {
  display: none;
}

.itemized-breakdown summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.itemized-breakdown[open] summary::before {
  transform: rotate(90deg);
}

.itemized-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  padding: 0.35rem 0;
}

.itemized-name {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.itemized-meta {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-3);
}

.itemized-total {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  align-self: center;
}

.result-card .line .total {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--green);
  font-family: var(--font-mono);
}

/* ── Skeleton Loading ── */

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.15; }
}

.skeleton {
  background: var(--border);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 0.9rem;
  margin-bottom: 0.5rem;
}

.skeleton-text-sm {
  height: 0.7rem;
  width: 60%;
}

.skeleton-chip {
  height: 3.5rem;
  border-radius: var(--radius-sm);
}

.skeleton-row {
  height: 4rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
}

.skeleton-input {
  height: 2.75rem;
  border-radius: var(--radius-sm);
}

/* ── Other Tooltip ── */

.other-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.other-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-2);
  font-size: 0.625rem;
  font-weight: 700;
  cursor: help;
  flex-shrink: 0;
}

.result-card .line .other-info-tooltip,
.other-info-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.other-info-icon:hover + .other-info-tooltip,
.other-info-icon:focus + .other-info-tooltip {
  display: block;
}

/* ── Confirm Dialog ── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.confirm-overlay.hidden {
  display: none;
}

.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 360px;
  width: calc(100% - 2rem);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.confirm-box p {
  margin: 0 0 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}

.prompt-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 1.25rem;
  box-sizing: border-box;
}

.prompt-input:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: var(--green);
}

.prompt-suggestions {
  margin-top: -0.5rem;
  margin-bottom: 1.25rem;
}

.prompt-suggestions-label {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.prompt-suggestions-list {
  display: grid;
  gap: 0.5rem;
  max-height: 14rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.prompt-suggestion.selected {
  border-color: var(--green-border);
  background: var(--green-light);
}

.prompt-suggestion {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.prompt-suggestion:hover {
  border-color: var(--green-border);
  background: var(--green-light);
}

.prompt-suggestion:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-color: var(--green);
}

.prompt-suggestion-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.prompt-suggestion-detail {
  font-size: 0.75rem;
  color: var(--text-2);
}

.prompt-scroll-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 0.35rem 0 0;
  transition: opacity 150ms ease;
}

.prompt-scroll-hint-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

#confirm-cancel {
  color: var(--text-2);
  background: transparent;
  border-color: var(--border);
}

#confirm-cancel:hover {
  background: var(--bg);
}

.confirm-ok-danger {
  color: var(--red-text);
  background: var(--red-light);
  border-color: var(--red-border);
}

.confirm-ok-danger:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fee2e2;
}

.confirm-ok-positive {
  color: var(--green);
  background: var(--green-light);
  border-color: var(--green-border);
}

.confirm-ok-positive:hover:not(:disabled) {
  border-color: #86efac;
  background: #dcfce7;
}

/* ── Utility ── */

.small {
  font-size: 0.875rem;
  color: var(--text-2);
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-3);
}


/* ── Footer ── */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 1.25rem 2.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-3);
}

.site-footer img {
  width: 18px;
  height: 18px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-3);
  text-decoration: none;
  padding: 0.75rem 0;
}

a.footer-brand:hover {
  color: var(--text-2);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.footer-links::before {
  content: "\00b7";
  color: var(--text-3);
  opacity: 0.5;
}

.footer-links a {
  color: var(--text-3);
  text-decoration: none;
  transition: color 150ms;
  padding: 0.75rem 0;
}

.footer-links a:hover {
  color: var(--text-2);
  text-decoration: underline;
}

.signin-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  margin-top: 1rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
}

/* The card after the banner needs its own top gap: the banner div sits between
   two cards and breaks `.card + .card`, and when the banner is hidden
   (display:none) its margin is gone too. This keeps the 1rem rhythm in both
   states. */
.signin-banner + .card {
  margin-top: 1rem;
}

.inapp-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--amber-text);
}

.inapp-notice-text {
  flex: 1;
  min-width: 12rem;
}

.inapp-notice-copy {
  flex-shrink: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  background: var(--amber);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.inapp-notice-dismiss {
  flex-shrink: 0;
  padding: 0 0.3rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--amber-text);
  background: none;
  border: none;
  cursor: pointer;
}

.inapp-notice-url {
  flex-basis: 100%;
  margin-top: 0.4rem;
  padding: 0.45rem 0.55rem;
  font-size: 0.8125rem;
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
}

.receipt-signin-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.receipt-signin-text {
  flex: 1;
  min-width: 10rem;
  color: var(--text);
}

.signin-banner-icon {
  color: var(--green);
  flex-shrink: 0;
}

.signin-banner-text {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--text);
}

.signin-banner .primary {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
}

/* ── Legal Page ── */

.legal-header {
  margin-bottom: 2rem;
}

.legal-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--green);
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
}

.legal-header .brand:hover {
  opacity: 0.8;
}

.legal-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variation-settings: "opsz" 28;
}

.legal-updated {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-3);
}

.legal-toc {
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.legal-toc h2 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: none;
  padding-bottom: 0;
}

.legal-toc ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}

.legal-toc li {
  margin-bottom: 0.25rem;
}

.legal-prose {
  max-width: 65ch;
}

.legal-prose h2 {
  margin: 2.5rem 0 1rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-variation-settings: "opsz" 20;
}

.legal-prose h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.legal-prose p {
  margin: 0 0 1rem;
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.6;
}

.legal-prose ul,
.legal-prose ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.6;
}

.legal-prose li {
  margin-bottom: 0.35rem;
}

.legal-prose li strong {
  color: var(--text);
  font-weight: 500;
}

.legal-prose a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-prose a:hover {
  opacity: 0.8;
}

.legal-prose strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Recent Avatars & Chevrons ── */

.recent-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.recent-avatar--tab {
  border-radius: 6px;
  background: var(--amber-light);
  color: var(--amber-text);
}

.recent-type-label {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--amber-text);
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.375rem;
  vertical-align: middle;
  position: relative;
  top: -0.5px;
}

.recent-chevron {
  color: var(--text-3);
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 150ms, transform 150ms;
}

.recent-link:hover .recent-chevron,
.recent-link:focus-visible .recent-chevron {
  opacity: 1;
  transform: translateX(0);
}

@media (hover: none) {
  .recent-chevron {
    opacity: 0.5;
    transform: translateX(0);
  }
}

@keyframes recent-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.recent-item {
  animation: recent-fade-in 300ms ease both;
}

/* ── QR Code Popover ── */

.qr-menu {
  position: relative;
  display: inline-block;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.icon-button:hover {
  color: var(--green);
  border-color: var(--green-border);
  background: var(--green-light);
}

.icon-button[aria-expanded="true"] {
  color: var(--green);
  border-color: var(--green-border);
  background: var(--green-light);
}

.profile-avatar-link {
  border-color: transparent;
  background: transparent;
  transition: none;
}

.profile-avatar-link:hover {
  border-color: transparent;
  background: transparent;
}

.profile-link-avatar {
  display: block;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  object-fit: cover;
}

.qr-popover {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 50;
  padding: 1.25rem;
  text-align: center;
  width: max-content;
}

.qr-popover-title {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.qr-popover canvas {
  display: block;
  margin: 0 auto;
  width: 180px;
  height: 180px;
  border-radius: var(--radius-sm);
}

.qr-popover-url {
  margin: 0.6rem 0 0;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-3);
  word-break: break-all;
  max-width: 200px;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  button {
    min-height: 2.75rem;
  }

  .page {
    padding: 1.25rem 1rem 2rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .hero {
    margin-bottom: 1.5rem;
  }

  .hero h1,
  #merchant-title,
  #tab-title {
    font-size: 1.75rem;
    font-variation-settings: "opsz" 28;
  }

  .card {
    padding: 1.25rem;
  }

  .profile-identity {
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 1rem;
  }

  .profile-identity .name-field {
    padding-top: 0.15rem;
  }

  .profile-photo-block {
    width: 5rem;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.45rem;
  }

  .profile-photo-controls {
    justify-content: center;
  }

  #profile-photo-status {
    text-align: center;
  }

  .top-bar-brand-row {
    margin-bottom: 0.35rem;
  }

  .top-bar-qr-inline {
    display: block;
  }

  .qr-menu {
    display: none;
  }

  .qr-popover {
    right: auto;
    left: 0;
  }

  /* Scoped past .start-tab-row so it beats the base rule (align-items: center),
     which is defined later in the file and would otherwise win on mobile. */
  .start-tab-card .start-tab-row {
    flex-direction: column;
    align-items: stretch;
  }

  .start-tab-row > #start-tab {
    align-self: flex-start;
  }

  /* Prevent iOS zoom on input focus (requires >= 16px) */
  input[type="text"],
  input[type="number"],
  input[type="file"],
  select,
  textarea {
    font-size: 1rem;
  }

  .chip-edit-input {
    font-size: 1rem;
  }

  .split-ways input[type="number"],
  .pay-note-input {
    font-size: 1rem;
  }

  .split-ways input[type="number"] {
    min-height: 2.75rem;
  }

  /* Summary grid: 2 columns on small screens */
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Make owner actions always visible (no hover on touch) */
  .item-owner-actions {
    opacity: 1;
  }

  /* Stack add-item fields vertically */
  .add-item-inline .add-item-fields {
    grid-template-columns: 1fr;
  }

  .add-item-name-field,
  .add-item-details-field,
  .add-item-qty-field,
  .add-item-total-field {
    grid-column: 1;
    grid-row: auto;
  }

  /* Inline item edit: single column */
  .inline-item-edit {
    grid-template-columns: 1fr;
  }

  /* Larger touch targets on mobile */
  .compact {
    padding: 0.55rem 0.85rem;
  }

  .preset-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }

  /* Tooltip: wrap text to avoid overflow */
  .result-card .line .other-info-tooltip,
  .other-info-tooltip {
    white-space: normal;
    max-width: 200px;
  }

  .legal-header h1 {
    font-size: 1.5rem;
  }

  .site-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-links::before {
    display: none;
  }

  .tab-receipt-row {
    padding: 0.35rem 0.625rem;
    margin: -0.35rem -0.625rem;
  }

}

@media (max-width: 360px) {
  .profile-identity {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .profile-identity .name-field {
    padding-top: 0;
  }

  .profile-photo-block {
    width: 100%;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-items: start;
    gap: 0.75rem;
  }

  .profile-photo-controls {
    justify-content: flex-start;
  }

  #profile-photo-status {
    text-align: left;
  }
}

@media (max-width: 400px) {
  .item-controls {
    flex-wrap: wrap;
  }

  .split-ways {
    width: 100%;
  }
}

/* ── Start a tab (home page) ── */

.start-tab-card {
  text-align: left;
}

.start-tab-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.start-tab-text {
  min-width: 0;
}

.start-tab-row > #start-tab {
  flex-shrink: 0;
  white-space: nowrap;
}

.start-tab-text .section-title {
  margin-bottom: 0.125rem;
}

.start-tab-text .small {
  margin: 0;
}

/* ── Tab page ── */

.balances-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.balance-person {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--divider);
}

.balance-person:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.balance-person-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 1.35rem;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.25;
  margin-top: 0;
  margin-bottom: 0.125rem;
}

.balance-debt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
  padding: 0.125rem 0;
  padding-left: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.35;
}

.balance-debt-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.balance-arrow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.3rem;
  color: var(--text-2);
}

.balance-arrow strong {
  color: var(--text);
}

.tab-inline-person {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  vertical-align: baseline;
}

.tab-name-avatar,
.tab-payer-avatar {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.balance-person-name .tab-name-avatar {
  width: 1.35rem;
  height: 1.35rem;
}

.balance-arrow .tab-name-avatar,
.settlement-history-line .tab-name-avatar {
  width: 1.2rem;
  height: 1.2rem;
}

.balance-amount {
  font-weight: 600;
  white-space: nowrap;
}

.balance-breakdown-details {
  padding-left: 0.5rem;
  margin-top: 0.125rem;
  margin-bottom: 0.25rem;
}

.balance-breakdown-toggle {
  font-size: 0.8rem;
  color: var(--text-3);
  cursor: pointer;
  list-style: none;
}

.balance-breakdown-toggle::-webkit-details-marker {
  display: none;
}

.balance-breakdown-toggle::before {
  content: "▸ ";
}

.balance-breakdown-details[open] > .balance-breakdown-toggle::before {
  content: "▾ ";
}

.balance-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin-top: 0.25rem;
  padding-left: 0.25rem;
}

.balance-receipt-detail {
  font-size: 0.8rem;
  color: var(--text-3);
}

.balance-breakdown-label {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-3);
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.tab-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

.tab-section-header .section-title {
  margin-bottom: 0;
}

.tab-receipt-intake-owner-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.close-action {
  color: var(--red-text);
  background: var(--red-light);
  border-color: var(--red-border);
}

.close-action:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fee2e2;
}

.add-receipt-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--divider);
}

.tab-receipt-intake-banner {
  margin-top: 0.875rem;
  margin-bottom: 0;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-2);
}

.add-receipt-form {
  margin-top: 0.5rem;
}

.manual-item-row {
  margin-bottom: 0.375rem;
}

#manual-items-list {
  margin-bottom: 0.25rem;
}

.add-receipt-form label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  color: var(--text-2);
}

.add-receipt-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.add-receipt-field {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.add-receipt-field-payer {
  flex: 0 0 9rem;
}

.add-receipt-field-amount {
  flex: 0 0 7rem;
}


.add-receipt-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text);
}

.add-receipt-label {
  color: var(--text-3);
  margin-bottom: 0.125rem;
}

button.add-receipt-btn {
  align-self: flex-end;
  font-size: 0.875rem;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
  line-height: 1.6;
  border-radius: var(--radius-sm);
}

.add-receipt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.add-action-btn {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
}

.add-receipt-actions > form {
  flex: 1 1 100%;
  margin-top: 0;
}

#receipt-picker-field {
  margin-bottom: 0.5rem;
}

#receipt-picker-field .add-receipt-label {
  color: var(--text-2);
  margin-bottom: 0.125rem;
}

#receipt-picker {
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  line-height: 1.6;
}

.tab-receipt-row {
  display: flex;
  align-items: stretch;
  gap: 0.875rem;
  min-width: 0;
  padding: 0.35rem 0.75rem;
  margin: -0.35rem -0.75rem;
  border-radius: var(--radius-sm);
  transition: background 150ms ease;
}

.tab-receipt-row:hover,
.tab-receipt-row:focus-within {
  background: var(--green-light);
}

.tab-receipt-item {
  display: block;
}

.tab-receipt-link {
  min-width: 0;
  gap: 0.5rem;
}

.tab-receipt-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
}

.tab-receipt-title {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-receipt-amount {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.tab-claim-status {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 2.75rem;
  font-size: 0.75rem;
  line-height: 1;
}

.tab-claim-status.is-pending {
  color: var(--amber);
  font-weight: 600;
}

.tab-claim-status.is-partial {
  color: var(--text-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.tab-claim-status.is-done {
  color: var(--green);
  font-size: 0.875rem;
}

.tab-claim-summary {
  margin: -0.375rem 0 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.tab-claim-summary.is-complete {
  color: var(--green);
}

.tab-payer-name {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-receipt-row:hover .recent-title,
.tab-receipt-row:focus-within .recent-title {
  text-decoration: underline;
}

.tab-receipt-row:hover .recent-chevron,
.tab-receipt-row:focus-within .recent-chevron {
  color: var(--green);
}

.tab-receipt-item:has(.tab-receipt-menu-dropdown:not(.hidden)) {
  position: relative;
  z-index: 10;
}

.tab-receipt-menu {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.tab-receipt-menu-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-3);
  cursor: pointer;
  transition: color 150ms, background 150ms, border-color 150ms;
}

.tab-receipt-menu-trigger:hover,
.tab-receipt-menu-trigger:focus-visible {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.tab-receipt-menu-dropdown {
  position: absolute;
  top: 0;
  right: calc(100% + 0.35rem);
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 50;
  padding: 0.25rem;
}

.tab-receipt-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.625rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.tab-receipt-menu-item:hover {
  background: var(--divider);
}

.tab-receipt-menu-danger {
  color: var(--red-text);
}

.tab-receipt-menu-danger:hover {
  background: var(--red-light);
}

.tab-no-claims {
  font-style: italic;
}

.tab-claim-cta {
  color: var(--green);
  font-weight: 600;
}

.tab-receipt-payer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--text-2);
}

.tab-receipt-no-payer {
  color: var(--amber-text);
}

.tab-payment-setup {
  margin: 0.75rem 0 0.85rem;
  padding: 0.75rem;
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
}

.tab-payment-setup-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tab-payment-setup-copy {
  min-width: 0;
  flex: 1;
}

.tab-payment-setup-title {
  margin: 0;
  color: var(--text);
  font-weight: 600;
}

.tab-payment-setup-note {
  margin: 0.2rem 0 0;
  color: var(--text-2);
}

.tab-payment-setup-logos {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.tab-payment-setup-logos .pay-display-logo {
  width: 1.45rem;
  height: 1.45rem;
}

.tab-payment-setup-logos .pay-display-logo--wide {
  width: auto;
  height: 1.125rem;
}

.tab-payment-setup-logos .pay-display-logo--tall {
  width: auto;
  height: 1.35rem;
}

.tab-payment-setup-open {
  flex-shrink: 0;
}

.tab-payment-setup-form {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--green-border);
}

.tab-payment-setup-grid {
  gap: 0.75rem;
}

.settlement-note {
  color: var(--amber-text);
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.settlement-plan-summary {
  color: var(--text-2);
  background: var(--bg-2);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.settlement-plan-summary-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-3);
}

.balance-pay-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--green);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  padding: 0.1875rem 0.5rem;
  background: var(--green-light);
  transition: background 0.15s, border-color 0.15s;
}

.balance-pay-link svg {
  height: 0.875rem;
  width: auto;
  flex-shrink: 0;
}

.balance-pay-link:hover {
  background: var(--green-border);
  border-color: var(--green);
}

.balance-pay-note {
  font-size: 0.8125rem;
  color: var(--text-3);
  white-space: nowrap;
}

.balance-pay-note::before {
  content: "·";
  margin-right: 0.5rem;
}

.balance-settle-btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-1);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.1875rem 0.5rem;
  cursor: pointer;
}

.balance-settle-btn:hover:not(:disabled) {
  color: var(--text-1);
  background: var(--bg-2);
  border-color: var(--text-2);
}

.settlement-complete {
  color: var(--green-text);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.settlement-history {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--divider);
}

.settlement-history-title {
  margin: 0 0 0.625rem;
  color: var(--text-3);
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.settlement-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.settlement-history-copy {
  min-width: 0;
}

.settlement-history-line,
.settlement-history-meta {
  margin: 0;
}

.settlement-history-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.35rem;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.35;
}

.settlement-history-meta {
  color: var(--text-3);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.tab-link {
  display: inline-block;
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

.tab-link a {
  color: var(--green);
  font-weight: 500;
  text-decoration: none;
}

.tab-link a:hover {
  text-decoration: underline;
}

.tab-banner {
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.tab-banner a {
  color: var(--green);
  font-weight: 500;
  text-decoration: none;
}

.tab-banner a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .add-receipt-actions {
    flex-direction: column;
  }

  #manual-entry-toggle {
    order: 1;
  }

  #manual-receipt-form {
    order: 2;
    margin-bottom: 0.5rem;
  }

  #tab-upload-btn {
    order: 3;
  }

  #manual-receipt-form .add-receipt-btn {
    width: 100%;
  }

  .add-receipt-actions:has(#manual-receipt-form:not(.hidden)) #tab-upload-btn {
    display: none;
  }

  .add-receipt-row {
    flex-wrap: wrap;
  }

  .add-receipt-field-payer,
  .add-receipt-field-amount {
    flex: 1 1 100%;
  }

  .tab-receipt-menu-trigger {
    width: 2.75rem;
    height: 2.75rem;
  }

  .balance-pay-link,
  .balance-settle-btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
  }

  .tab-payment-setup-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .tab-payment-setup-open {
    width: 100%;
  }
}

/* ── Balance Chips ── */

.balance-chip {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}

.balance-chip-trigger {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.125rem 0.375rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.balance-chip-trigger::-webkit-details-marker { display: none; }

.balance-chip-trigger::after {
  content: "\25BE";
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-3);
  transition: transform 0.15s ease;
}

.balance-chip[open] .balance-chip-trigger::after {
  transform: rotate(180deg);
}

.balance-chip-label {
  font-weight: 500;
  font-size: 0.875rem;
}

.balance-chip-amount {
  font-weight: 600;
  font-size: 1.1875rem;
}

.balance-chip-count {
  font-size: 0.75rem;
  color: var(--text-2);
}

.balance-chip--owe,
.balance-chip--owed {
  background: var(--surface);
  border-color: var(--border);
  border-left: 3px solid;
}

.balance-chip--owed {
  border-left-color: var(--green);
}

.balance-chip--owe {
  border-left-color: var(--text-3);
}

.balance-chip-dropdown {
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0.25rem 0 0.75rem;
}


.summary-breakdown {
  list-style: none;
  margin: 0;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.summary-person {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.summary-person + .summary-person {
  border-top: 1px dashed var(--border);
}

.summary-overflow {
  border-top: 1px dashed var(--border);
  padding: 0.5rem 0;
}

.summary-overflow-btn {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.summary-overflow-btn:hover {
  color: var(--text);
}

.summary-person-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.summary-person-name {
  font-size: 0.9375rem;
  font-weight: 500;
}

.summary-person-amount {
  font-size: 0.9375rem;
  font-weight: 600;
}

.summary-person-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.summary-person-sources {
  font-size: 0.75rem;
  color: var(--text-3);
}

.summary-source-link {
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: color 150ms ease, text-decoration-color 150ms ease;
}

.summary-source-link:hover {
  color: var(--text);
  text-decoration-color: var(--text-3);
}

.summary-person-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  margin-left: auto;
}

.summary-pay-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--green);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--green-border);
  border-radius: var(--radius);
  padding: 0.1875rem 0.5rem;
  background: var(--green-light);
  width: fit-content;
}

.summary-pay-link svg {
  height: 0.875rem;
  width: auto;
  flex-shrink: 0;
}

.summary-pay-link:hover {
  background: var(--green-border);
  border-color: var(--green);
}

.summary-pay-note {
  font-size: 0.75rem;
  color: var(--text-3);
}

.summary-source-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-source-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.summary-source-row .summary-source-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-source-amount {
  font-size: 0.75rem;
  color: var(--text-2);
  flex-shrink: 0;
  min-width: 4.5ch;
  text-align: right;
}

.summary-mark-paid-btn {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, color 150ms;
  flex-shrink: 0;
  white-space: nowrap;
}

.summary-mark-paid-btn:hover {
  border-color: var(--green-border);
  color: var(--green);
  background: var(--green-light);
}

.summary-mark-paid-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.summary-person-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.summary-person-right {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.summary-row-chevron {
  display: inline-block;
  color: var(--text-3);
  font-size: 1.15rem;
  line-height: 1;
  transition: transform 0.15s ease, color 0.15s ease;
}

.summary-person.is-open .summary-row-chevron {
  transform: rotate(90deg);
  color: var(--text-2);
}

.summary-person-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.summary-person:not(.is-open) .summary-row-detail,
.summary-person:not(.is-open) .summary-person-actions--reveal {
  display: none;
}

.summary-person.is-open .summary-person-sources--summary {
  display: none;
}

.summary-row-detail {
  margin-top: 0.375rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-row-detail--end {
  align-items: flex-end;
}

.summary-detail-source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

.summary-detail-source .summary-source-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-mark-paid-btn--quiet {
  border: none;
  background: none;
  border-radius: 0;
  padding: 0.25rem 0;
  color: var(--text-2);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}

.summary-mark-paid-btn--quiet:hover {
  border-color: transparent;
  background: none;
  color: var(--green);
  text-decoration-color: var(--green);
}

.summary-copy-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.1875rem 0.5rem;
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 150ms, color 150ms;
}

.summary-copy-pill svg {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.summary-copy-pill:hover {
  border-color: var(--text-3);
  color: var(--text);
}

.summary-copy-pill.is-copied {
  color: var(--green);
  border-color: var(--green-border);
}

/* ── Feedback ── */

.feedback-btn {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  right: 1.25rem;
  z-index: 100;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.08);
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
}

@media (max-width: 480px) {
  .feedback-btn {
    right: 0.75rem;
    bottom: calc(0.75rem + env(safe-area-inset-bottom));
    padding: 0;
    min-height: 36px;
    width: 36px;
    font-size: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .feedback-btn::before {
    content: "?";
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
  }
}

.feedback-btn:hover {
  background: var(--divider);
  border-color: var(--text-3);
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.12);
}

.feedback-subtitle {
  margin: -1rem 0 1rem !important;
  font-size: 0.8125rem !important;
  color: var(--text-2) !important;
}

.feedback-textarea {
  width: 100%;
  min-height: 6rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  transition: border-color 150ms, box-shadow 150ms;
}

.feedback-textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: -1px;
  border-color: var(--green);
}

.feedback-textarea::placeholder {
  color: var(--text-3);
}

.feedback-meta {
  display: flex;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 0.25rem;
}

.feedback-toast {
  position: fixed;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  right: 1.25rem;
  z-index: 100;
  padding: 0.625rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--green);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.08);
  opacity: 1;
  transition: opacity 0.24s ease, transform 0.24s ease;
  pointer-events: none;
}

.feedback-toast.fade-out {
  opacity: 0;
  transform: translateY(0.5rem);
}

/* ── iOS Add-to-Home-Screen install dialog ── */

.ios-install-box {
  max-width: 380px;
}

.ios-install-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.ios-install-app-icon {
  flex-shrink: 0;
  border-radius: 13px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.ios-install-title {
  margin: 0 0 0.125rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.ios-install-subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-3);
}

.ios-install-steps {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
}

.ios-install-steps li {
  margin-bottom: 0.375rem;
}

.ios-install-steps li:last-child {
  margin-bottom: 0;
}

.ios-share-glyph {
  display: inline-block;
  vertical-align: -0.35em;
  margin: 0 0.125rem;
  color: #007aff;
}

/* ============================================
 * Notification center (bell + panel)
 * ============================================ */

#notif-mount {
  display: inline-flex;
  position: relative;
}

.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.notif-bell:hover {
  color: var(--text);
  background: var(--divider);
}

.notif-bell[aria-expanded="true"] {
  color: var(--green);
  background: var(--green-light);
}

.notif-bell:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.notif-bell-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: var(--green);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Setup-reminder state: small amber dot, no number. Amber (DESIGN.md) marks a
   gentle nudge, distinct from the green unread count. */
.notif-bell-badge.is-dot {
  min-width: 0;
  width: 10px;
  height: 10px;
  top: 7px;
  right: 7px;
  padding: 0;
  background: var(--amber);
}

.notif-bell-badge[hidden] {
  display: none;
}

.notif-panel {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
  max-height: 80vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notif-panel:focus {
  outline: none;
}

.notif-panel-desktop {
  width: 360px;
  max-height: min(70vh, 560px);
  animation: notif-slide-down 200ms ease-out;
}

.notif-panel-mobile {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 80vh;
  animation: notif-slide-up 240ms ease-out;
}

@keyframes notif-slide-down {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes notif-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .notif-panel-desktop,
  .notif-panel-mobile {
    animation: none;
  }
}

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.notif-panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.notif-panel-body {
  padding: 0;
}

.notif-panel-skeleton {
  padding: 16px;
}

.notif-panel-skeleton > div {
  height: 56px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--divider) 0%, var(--border) 50%, var(--divider) 100%);
  background-size: 200% 100%;
  animation: notif-shimmer 1200ms ease-in-out infinite;
}

@keyframes notif-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.notif-section {
  padding: 0;
}

.notif-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.notif-section-divider {
  margin: 8px 16px;
  border-top: 1px dashed var(--border);
  height: 0;
}

.notif-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  min-height: 56px;
  border-left: 3px solid transparent;
  background: var(--surface);
  cursor: default;
  transition: background-color 100ms ease-out;
}

.notif-row[role="link"] {
  cursor: pointer;
}

.notif-row[role="link"]:hover {
  background: var(--divider);
}

.notif-row:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.notif-row-tier1 {
  border-left-color: var(--green);
}

.notif-row-loud {
  background: var(--amber-light);
  border-left-color: var(--amber);
}

.notif-row-loud:hover {
  background: var(--amber-light);
  filter: brightness(0.98);
}

/* Once read, loud rows revert to the standard read look — the urgency is over,
   no need to keep pulling the eye in Recent. */
.notif-row-loud.notif-row-read {
  background: var(--surface);
  border-left-color: var(--green);
}

.notif-row-loud.notif-row-read:hover {
  background: var(--divider);
  filter: none;
}

.notif-row-tier2 {
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-left-color: transparent;
}

.notif-row-tier2.notif-row-read .notif-line1 {
  color: var(--text);
  font-weight: 600;
}

.notif-row-read .notif-line1 {
  color: var(--text-2);
  font-weight: 400;
}

.notif-row-resolved {
  opacity: 0.55;
}

.notif-row-resolved .notif-cta {
  display: none;
}

.notif-avatar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9999px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.notif-avatar-pear {
  background: var(--green-light);
  color: var(--green);
}

.notif-avatar-pear img {
  display: block;
}

.notif-avatar-photo {
  background: transparent !important;
  color: transparent;
}

.notif-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.notif-content {
  flex: 1;
  min-width: 0;
}

.notif-line1 {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.35;
}

.notif-line2 {
  margin-top: 2px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.4;
}

.notif-time {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.notif-cta {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--green-light);
  color: var(--green);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.notif-cta:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.notif-actions {
  flex-shrink: 0;
  display: inline-flex;
  align-items: flex-start;
}

.notif-row-tier2 .notif-actions {
  align-items: center;
  align-self: center;
}

.notif-row-tier2 .notif-cta {
  margin-top: 0;
  white-space: nowrap;
}

.notif-show-more {
  display: block;
  width: calc(100% - 32px);
  margin: 8px 16px 12px;
  padding: 8px 12px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.notif-show-more:hover {
  border-color: var(--text-3);
  color: var(--text);
}

.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-2);
}

.notif-empty-icon {
  margin-bottom: 12px;
  color: var(--green);
  opacity: 0.6;
}

.notif-empty p {
  margin: 0;
  font-size: 14px;
}

.notif-retry {
  margin-top: 12px;
  padding: 6px 14px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* ── Push notifications row ── */

.push-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.push-text {
  min-width: 0;
  flex: 1;
}

.push-text .section-title {
  margin-bottom: 0.25rem;
}

.push-text .small {
  margin: 0;
}

.ios-switch {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  height: 32px;
  min-height: 0;
  padding: 0;
  background: var(--border);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 200ms ease;
  -webkit-tap-highlight-color: transparent;
}

.ios-switch[aria-checked="true"] {
  background: var(--green);
}

.ios-switch:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ios-switch:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.ios-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.12);
  transition: transform 200ms ease;
}

.ios-switch[aria-checked="true"] .ios-switch-thumb {
  transform: translateX(20px);
}
