:root {
  color-scheme: light;
  --bg: oklch(96.5% 0.018 78);
  --panel: oklch(99.2% 0.006 82);
  --panel-soft: oklch(94.7% 0.025 78);
  --ink: oklch(23% 0.025 64);
  --muted: oklch(43.5% 0.032 68);
  --line: oklch(88.5% 0.028 74);
  --primary: oklch(78% 0.145 73);
  --primary-dark: oklch(58% 0.15 57);
  --accent: oklch(56% 0.15 252);
  --danger: oklch(48% 0.13 38);
  --success: oklch(50% 0.12 151);
  --state-info: oklch(95% 0.035 250);
  --state-info-line: oklch(75% 0.075 250);
  --state-warning: oklch(93% 0.07 76);
  --state-warning-line: oklch(78% 0.11 76);
  --state-success: oklch(92% 0.055 151);
  --state-success-line: oklch(74% 0.075 151);
  --receive-bg: var(--state-success);
  --receive-line: var(--state-success-line);
  --owe-bg: var(--state-warning);
  --owe-line: var(--state-warning-line);
  --focus: rgba(242, 169, 59, 0.34);
  --shadow: 0 4px 8px rgba(52, 43, 31, 0.08);
  --shadow-soft: 0 3px 8px rgba(52, 43, 31, 0.07);
  --radius: 12px;
  --radius-card: 16px;
  --control-radius: 14px;
  --motion-standard: 180ms cubic-bezier(0.2, 0, 0, 1);
  --motion-emphasized: 240ms cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 18% -10%, rgba(242, 169, 59, 0.18), transparent 28rem),
    radial-gradient(circle at 92% 8%, rgba(47, 127, 211, 0.08), transparent 22rem),
    linear-gradient(180deg, oklch(98.5% 0.022 78) 0%, var(--bg) 34rem);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  padding: 8px 16px;
  transition: border-color var(--motion-standard), background var(--motion-standard), transform var(--motion-standard), box-shadow var(--motion-standard), color var(--motion-standard);
}

button:hover {
  border-color: rgba(217, 130, 25, 0.48);
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: color-mix(in oklch, var(--panel) 88%, var(--panel-soft));
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.35rem;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 1.12rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

p {
  color: var(--muted);
}

.app-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-button {
  min-height: 38px;
  padding: 0 13px;
}

#supportBtn {
  width: 38px;
  padding: 0;
  border-radius: 999px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.group-panel {
  margin-bottom: 16px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-header p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.compact-field {
  width: min(150px, 42vw);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tip-field {
  display: grid;
  gap: 8px;
  margin: 0;
  border: 0;
  padding: 0;
}

.tip-field legend {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  margin-bottom: 6px;
}

.tip-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tip-options label {
  cursor: pointer;
}

.tip-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tip-options span {
  display: grid;
  min-height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.tip-options input:checked + span {
  border-color: var(--primary);
  background: #fff2d8;
  color: #8b4f0c;
}

.inline-form,
.expense-form {
  display: grid;
  gap: 12px;
}

.inline-form {
  grid-template-columns: 1fr auto;
}

.full-action {
  width: 100%;
  margin-bottom: 16px;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #271706;
  box-shadow: 0 4px 8px rgba(217, 130, 25, 0.18);
}

.primary-button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.56);
}

.text-button {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
}

.counter {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 30px;
  border-radius: 999px;
  background: #fff2d8;
  color: #8b4f0c;
  font-weight: 850;
}

.list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: linear-gradient(180deg, var(--panel) 0%, color-mix(in oklch, var(--panel) 86%, var(--panel-soft)) 100%);
  box-shadow: var(--shadow-soft);
}

.person-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person-info::before {
  content: "";
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 2px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, var(--primary), var(--accent)) border-box;
  box-shadow: inset 0 0 0 8px #f8efe2;
}

.item-title {
  margin: 0;
  color: var(--ink);
  font-weight: 850;
}

.item-meta {
  margin: 2px 0 0;
  font-size: 0.84rem;
}

.danger-button {
  color: var(--danger);
  border-color: #f0d3a7;
  background: #fff8ed;
}

.single-expense {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fffdf8;
}

.single-expense summary {
  cursor: pointer;
  color: #8b4f0c;
  font-weight: 850;
}

.single-expense .expense-form {
  margin-top: 12px;
}

.split-box {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip,
.reminder-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff8ed;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
}

.item-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff8ed;
  color: var(--ink);
  font-weight: 750;
  min-height: 38px;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.2;
  transition: background 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.chip input {
  width: auto;
  min-height: auto;
}

.reminder-badge {
  min-height: 30px;
  width: fit-content;
  margin-top: 5px;
  cursor: pointer;
}

.reminder-badge.active {
  border-color: var(--accent);
  color: #155c9d;
  background: #eef7ff;
}

.guest-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff8ed;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
  min-height: 30px;
  width: fit-content;
  margin-top: 5px;
  cursor: pointer;
}

.guest-badge.active {
  border-color: var(--primary-dark);
  color: #8b4f0c;
  background: #fff0c8;
}

.item-bubble.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.balance-summary,
.settlements {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.inline-name-input,
.inline-expense-description,
.inline-expense-amount {
  min-height: 38px;
  padding: 7px 9px;
}

.inline-name-input {
  max-width: 100%;
  font-weight: 850;
}

.expense-edit-row {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.inline-expense-amount {
  max-width: 150px;
}

.guest-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border: 1px solid rgba(217, 130, 25, 0.32);
  border-radius: var(--radius);
  background: #fff4dc;
  padding: 12px;
}

.guest-panel-header h3 {
  margin-bottom: 4px;
}

.guest-panel-header p {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.guest-chips .guest-badge {
  min-height: 38px;
  margin-top: 0;
}

.balance-row,
.settlement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fffdf8;
  min-width: 0;
}

.balance-row span,
.settlement-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.balance-row strong,
.balance-row .positive,
.balance-row .negative,
.balance-row .neutral,
.settlement-row strong {
  flex: 0 0 auto;
  text-align: right;
  white-space: nowrap;
}

.balance-row.is-positive {
  border-color: var(--receive-line);
  background: var(--receive-bg);
}

.balance-row.is-negative {
  border-color: var(--owe-line);
  background: var(--owe-bg);
}

.balance-row.is-neutral {
  background: #f4efe7;
}

.positive {
  color: var(--success);
  font-weight: 850;
}

.negative {
  color: #9a5a0d;
  font-weight: 850;
}

.neutral {
  color: var(--muted);
  font-weight: 750;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-toggle label {
  cursor: pointer;
}

.mode-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  min-height: 1px;
  margin: 0;
}

.mode-toggle span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: #fff;
  font-weight: 800;
}

.mode-toggle input:checked + span {
  border-color: var(--primary);
  background: #fff2d8;
  color: #8b4f0c;
}

.privacy-note {
  min-height: 42px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

#copyMessageBtn {
  border-color: #35b861;
  background: #35c967;
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(53, 201, 103, 0.18);
}

#copyMessageBtn:hover {
  border-color: #2ca957;
  background: #2ca957;
}

.status-line {
  min-height: 22px;
  margin: 10px 0 0;
  color: #8b4f0c;
  font-weight: 850;
}

.ticket-status-line {
  margin-top: 8px;
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--muted);
  text-align: center;
  background: #fffaf2;
}

.restaurant-dialog,
.reminder-dialog,
.import-dialog {
  width: min(760px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  max-height: 90vh;
  overflow: auto;
}

.reminder-dialog,
.import-dialog {
  width: min(440px, calc(100% - 24px));
}

.restaurant-dialog::backdrop,
.reminder-dialog::backdrop,
.import-dialog::backdrop {
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog-subtitle {
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.dialog-person {
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 850;
}

.close-dialog-btn {
  min-height: auto;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  padding: 0 4px;
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.wizard-step {
  display: grid;
  gap: 16px;
}

.wizard-step.hidden {
  display: none;
}

.wizard-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.ticket-items-container {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  max-height: 300px;
  overflow: auto;
  margin-bottom: 12px;
}

.ticket-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ticket-table th,
.ticket-table td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}

.ticket-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.price-column {
  width: 75px;
}

.remove-column {
  width: 32px;
}

.ticket-table td input {
  min-height: 32px;
  padding: 4px 6px;
  font-size: 0.82rem;
}

.add-ticket-item {
  margin-bottom: 12px;
  font-weight: 850;
}

.ticket-summary-box,
.table-close {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 14px;
  min-width: 0;
  max-width: 100%;
}

.summary-line,
.close-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-weight: 750;
}

.summary-line:last-child {
  margin-bottom: 0;
  color: #8b4f0c;
}

.table-close-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  min-width: 0;
}

.table-close-header p {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.table-close-header > div {
  min-width: 0;
}

.table-close-header > strong {
  flex: 0 0 auto;
  text-align: right;
}

.close-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.close-header-row {
  display: none;
  grid-template-columns: minmax(110px, 0.8fr) minmax(100px, 1fr) minmax(110px, 0.9fr) minmax(90px, 0.7fr);
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.close-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  padding: 10px;
  min-width: 0;
}

.close-row.is-paid {
  border-color: var(--receive-line);
  background: var(--receive-bg);
}

.close-row.is-guest {
  border-color: var(--owe-line);
  background: #fff4dc;
}

.close-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
}

.close-check input {
  width: 18px;
  min-height: auto;
  accent-color: var(--accent);
}

.close-row-money {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.close-row-money label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  min-width: 0;
}

.close-row-money input {
  min-width: 0;
  max-width: 100%;
}

.guest-toggle {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  color: var(--ink) !important;
}

.guest-toggle input {
  width: 18px;
  min-height: auto;
  accent-color: var(--accent);
}

.guest-summary {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(180, 83, 9, 0.28);
  border-radius: var(--radius);
  background: #fff8ed;
  color: var(--accent);
  padding: 10px;
  margin-bottom: 12px;
}

.close-warning {
  border: 1px solid #efc5bd;
  border-radius: var(--radius);
  background: #fff1ee;
  color: var(--danger);
  padding: 10px;
  font-weight: 800;
}

.close-pending {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.close-pending p {
  margin: 0 0 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 720px) {
  body:not(.force-mobile) .app-shell {
    padding-top: 32px;
  }

  body:not(.force-mobile) .main-grid {
    grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
    align-items: start;
  }

  body:not(.force-mobile) .form-row,
  body:not(.force-mobile) .share-actions,
  body:not(.force-mobile) .wizard-actions {
    grid-template-columns: 1fr 1fr;
  }

  body:not(.force-mobile) .close-row {
    grid-template-columns: minmax(150px, 0.7fr) 1fr;
    align-items: start;
  }

  body:not(.force-mobile) .close-header-row {
    display: grid;
  }
}

@media (min-width: 1040px) {
  body:not(.force-mobile) .main-grid {
    grid-template-columns: 0.85fr 1.2fr 1fr;
  }
}

/* Tab Navigation System */
.tab-content.hidden {
  display: none !important;
}

.bottom-nav {
  display: flex;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid rgba(229, 221, 209, 0.9);
  border-radius: 999px;
  padding: 7px;
  width: fit-content;
  margin: 0 auto 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(140%);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 750;
  color: var(--muted);
  min-height: 38px;
  transition: transform var(--motion-standard), background var(--motion-standard), color var(--motion-standard);
}

.nav-item:hover {
  background: #fff2d8;
  color: var(--ink);
}

.nav-item.active {
  background: var(--primary);
  color: #271706;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 18px rgba(217, 130, 25, 0.18);
}

.tab-content {
  width: 100%;
}

@media (min-width: 720px) {
  body:not(.force-mobile) .bottom-nav {
    display: none !important;
  }

  body:not(.force-mobile) .tab-content.hidden {
    display: block !important;
  }

  body:not(.force-mobile) #tab-support.hidden {
    display: none !important;
  }
  
  body:not(.force-mobile) .tab-content {
    max-width: none !important;
    margin: 0 !important;
  }

  body:not(.force-mobile) .main-grid {
    grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
    align-items: start;
  }
  
  body:not(.force-mobile) #tab-settlements {
    grid-column: span 2;
  }
}

@media (min-width: 1040px) {
  body:not(.force-mobile) .main-grid {
    grid-template-columns: 0.85fr 1.2fr 1fr;
  }
  
  body:not(.force-mobile) #tab-settlements {
    grid-column: span 1;
  }
}

@media (max-width: 719px) {
  .app-shell {
    padding-bottom: 96px;
  }

  .bottom-nav {
    position: fixed;
    bottom: 16px;
    left: 50vw;
    transform: translateX(-50%);
    width: min(448px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    margin: 0;
    border-radius: 24px;
    box-shadow: 0 8px 14px rgba(52, 43, 31, 0.14);
    backdrop-filter: blur(16px) saturate(150%);
    background: rgba(255, 253, 248, 0.94);
    z-index: 1000;
    padding: 8px;
    gap: 6px;
  }

  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    font-size: 0.75rem;
    flex: 1;
    min-height: 48px;
    border-radius: 12px;
  }

}

/* Tab Flow Actions (Siguiente buttons) */
.tab-flow-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.tab-flow-actions button {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

@media (min-width: 720px) {
  body:not(.force-mobile) .tab-flow-actions {
    display: none !important;
  }
}

/* Force Mobile Mode Overrides (Desktop preview simulation) */
body.force-mobile {
  background: #eee7dc !important;
}

body.force-mobile .app-shell {
  background: var(--bg) !important;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  box-shadow: 0 8px 14px rgba(52, 43, 31, 0.10);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 24px 16px 110px !important;
}

body.force-mobile .bottom-nav {
  position: fixed;
  bottom: 16px;
  left: 50vw;
  transform: translateX(-50%);
  width: min(448px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  margin: 0;
  border-radius: 24px;
  box-shadow: 0 8px 14px rgba(52, 43, 31, 0.14);
  backdrop-filter: blur(16px) saturate(150%);
  background: rgba(255, 253, 248, 0.94);
  z-index: 1000;
  padding: 8px;
  gap: 6px;
  display: flex !important;
}

body.force-mobile .nav-item {
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  font-size: 0.75rem;
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
}

@media (max-width: 480px) {
  .table-close-header,
  .close-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .table-close-header > strong,
  .close-summary span {
    text-align: left;
  }

  .settlement-row {
    align-items: flex-start;
  }
}

/* Limit dialog width in mobile simulation mode */
body.force-mobile .restaurant-dialog,
body.force-mobile .reminder-dialog,
body.force-mobile .import-dialog {
  width: min(420px, calc(100% - 24px)) !important;
}

/* Support and Diagnostic Tab Styles */
.accordion-group {
  display: grid;
  gap: 10px;
}

.support-callout {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 15px;
}

.support-callout h3 {
  margin-bottom: 4px;
}

.support-callout p {
  margin-bottom: 0;
  font-size: 0.92rem;
}

.support-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.support-manual-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--primary);
  border-radius: var(--control-radius);
  background: var(--primary);
  color: #271706;
  font-weight: 750;
  padding: 8px 16px;
  text-decoration: none;
}

.support-manual-link:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}

.support-accordion {
  border: 1px solid rgba(229, 221, 209, 0.9);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, #fffdf8 100%);
  transition: border-color var(--motion-standard), box-shadow var(--motion-standard);
  overflow: hidden;
}

.support-accordion[open] {
  border-color: rgba(242, 169, 59, 0.4);
  box-shadow: var(--shadow-soft);
}

.support-accordion summary {
  padding: 14px 15px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.support-accordion summary::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff2d8;
  font-size: 0.95rem;
  color: #8b4f0c;
  font-weight: 850;
  transition: transform var(--motion-standard);
}

.support-accordion[open] summary::after {
  content: "-";
}

.support-accordion summary::-webkit-details-marker {
  display: none;
}

.accordion-content {
  padding: 0 15px 15px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.accordion-content p {
  margin-bottom: 6px;
}

.accordion-content p:last-child {
  margin-bottom: 0;
}

.support-dev-panel {
  margin-top: 16px;
}

.diagnostic-box {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.diagnostic-box p {
  margin-bottom: 10px;
}

.diagnostic-box code {
  display: inline-block;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  font-weight: 850;
  padding: 2px 7px;
}

.diagnostic-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 480px) {
  .diagnostic-actions {
    grid-template-columns: 1fr;
  }
}

body.force-mobile .diagnostic-actions {
  grid-template-columns: 1fr;
}

.diagnostic-actions button,
.compact-action {
  min-height: 38px;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.accent-button {
  border-color: rgba(180, 83, 9, 0.35);
  color: var(--accent);
}

.error-console-panel h3 {
  margin-bottom: 6px;
}

.error-console-box {
  max-height: 128px;
  overflow: auto;
  border-radius: var(--radius);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.error-console-box.no-errors {
  background: var(--receive-bg);
  border: 1px solid var(--receive-line);
  color: #17633a;
}

.error-console-box.has-errors {
  background: #fff1ee;
  border: 1px solid #efc5bd;
  color: var(--danger);
}

.error-log-item {
  border-bottom: 1px dashed rgba(153, 27, 27, 0.2);
  padding-bottom: 6px;
  margin-bottom: 6px;
  text-align: left;
}

.error-log-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}
/* Desktop spacing for support tab */
@media (min-width: 720px) {
  body:not(.force-mobile) #tab-support {
    grid-column: span 2;
    margin-top: 16px;
  }
}

@media (min-width: 1040px) {
  body:not(.force-mobile) #tab-support {
    grid-column: span 3;
  }
}

.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-hint {
  color: var(--muted);
  display: block;
  font-size: 0.8rem;
  line-height: 1.35;
  margin-top: 6px;
}

.ticket-item-name,
.ticket-item-price {
  width: 100%;
}

.delete-ticket-item-btn {
  border: 0;
  min-height: auto;
  padding: 4px;
}

@media (max-width: 520px) {
  .ticket-items-container {
    max-height: 54vh;
  }

  .ticket-table,
  .ticket-table tbody,
  .ticket-table tr,
  .ticket-table td {
    display: block;
  }

  .ticket-table thead {
    display: none;
  }

  .ticket-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px 36px;
    grid-template-areas:
      "product price remove"
      "consumers consumers consumers";
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
  }

  .ticket-table td {
    border-bottom: 0;
    padding: 0;
    min-width: 0;
  }

  .ticket-product-cell {
    grid-area: product;
  }

  .ticket-price-cell {
    grid-area: price;
  }

  .ticket-consumer-cell {
    grid-area: consumers;
    padding-top: 2px;
  }

  .ticket-consumer-cell::before {
    content: "Lo consumen";
    display: block;
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .ticket-remove-cell {
    grid-area: remove;
    align-self: start;
  }

  .ticket-consumer-cell .item-bubbles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
    gap: 6px;
  }

  .ticket-consumer-cell .item-bubble {
    width: 100%;
    min-height: 44px;
    padding: 6px 8px;
    font-size: 0.78rem;
    overflow-wrap: anywhere;
  }

  .delete-ticket-item-btn {
    width: 36px;
    min-height: 36px;
  }
}

.error-stack {
  color: #7f1d1d;
  font-size: 0.72rem;
  margin: 4px 0 0;
  overflow-x: auto;
  white-space: pre-wrap;
}

.restaurant-warning {
  border: 1px solid rgba(217, 130, 25, 0.32);
  border-radius: var(--radius);
  background: #fff4dc;
  color: #8b4f0c;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 0.88rem;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 8px;
}

.disabled-looking {
  opacity: 0.65;
  background: var(--panel-soft) !important;
  border-color: var(--line) !important;
  color: var(--muted) !important;
  cursor: pointer;
}

.group-summary-header {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.group-summary-header::-webkit-details-marker {
  display: none;
}

.group-summary-header::after {
  content: "v";
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform var(--motion-standard);
  display: inline-block;
  margin-left: 10px;
}

details[open] .group-summary-header::after {
  transform: rotate(180deg);
}

.person-name-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-person-btn {
  font-size: 0.76rem;
  padding: 2px 6px;
  min-height: auto;
  color: var(--muted);
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
}

.edit-person-btn:hover {
  color: var(--accent);
  background: #eef7ff;
}

.toast-notification {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1c1917;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 16px;
  font-size: 0.88rem;
  font-weight: 750;
  box-shadow: 0 8px 14px rgba(0,0,0,0.15);
  z-index: 2000;
  transition: transform var(--motion-emphasized), opacity var(--motion-standard);
  opacity: 0;
  pointer-events: none;
  max-width: calc(100vw - 40px);
  text-align: center;
  box-sizing: border-box;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* OCR styles */
.ocr-accordion {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 16px;
  overflow: hidden;
}

.ocr-accordion summary {
  padding: 10px 14px;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 0.88rem;
}

.ocr-accordion-content {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.ocr-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-upload-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: var(--control-radius);
  background: var(--primary);
  color: #271706;
  border: 1px solid var(--primary);
  min-height: 42px;
  transition: background 150ms ease;
}

.file-upload-label:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

.ocr-status-box {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--ink);
}

.ocr-status-box.hidden {
  display: none !important;
}

.ocr-progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.ocr-progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width var(--motion-standard);
}

@media (max-width: 719px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex: 0 0 auto;
  }

  h1 {
    font-size: 2rem;
  }

  .panel {
    padding: 16px;
  }

  .restaurant-dialog,
  .reminder-dialog,
  .import-dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
    max-height: 88vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
