:root {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --primary-light: #fef3c7;
  --secondary: #1f2937;
  --gray-light: #f3f4f6;
  --gray: #9ca3af;
  --gray-dark: #6b7280;
  --danger: #ef4444;
  --success: #10b981;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  color: var(--secondary);
  min-height: 100vh;
}

/* ── Layout ── */
.app-header {
  background: var(--white);
  border-bottom: 1px solid #e5e7eb;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header .back-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  color: var(--secondary);
  padding: 4px;
  line-height: 1;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
}

.page-content {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}

/* ── Hero / main menu ── */
.hero {
  text-align: center;
  padding: 48px 20px 32px;
}

.hero-icon {
  font-size: 64px;
  margin-bottom: 12px;
}

.hero h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 8px;
}

.hero p {
  color: var(--gray-dark);
  font-size: 15px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
  width: 100%;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--secondary);
  border: 2px solid #e5e7eb;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.btn-success {
  background: var(--success);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
  padding: 8px 14px;
  font-size: 14px;
  width: auto;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

.btn-icon {
  font-size: 20px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.card h2 { font-size: 18px; font-weight: 700; }
.card h3 { font-size: 15px; font-weight: 600; }

/* ── Form ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-dark);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 15px;
  color: var(--secondary);
  background: var(--white);
  transition: border-color .15s;
  -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Upload zone ── */
.upload-zone {
  border: 3px dashed #d1d5db;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--gray-light);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-zone input { display: none; }
.upload-zone .upload-icon { font-size: 48px; margin-bottom: 8px; }
.upload-zone p { color: var(--gray-dark); font-size: 15px; }
.upload-zone p span { color: var(--primary); font-weight: 600; }

.upload-preview {
  margin-top: 12px;
  border-radius: var(--radius);
  overflow: hidden;
}
.upload-preview img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius);
}

/* ── Item list ── */
.item-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.item-row:last-child { border-bottom: none; }

.item-row input {
  padding: 8px 10px;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
}
.item-row input:focus { outline: none; border-color: var(--primary); }
.item-row .item-price { width: 110px; text-align: right; }

/* ── Claim item card ── */
.claim-item {
  background: var(--white);
  border-radius: var(--radius);
  border: 2px solid #e5e7eb;
  padding: 14px;
  margin-bottom: 10px;
  transition: all .15s;
  cursor: pointer;
}
.claim-item.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
.claim-item.fully-claimed {
  opacity: .5;
  cursor: not-allowed;
  background: var(--gray-light);
}
.claim-item.fully-claimed .item-name { text-decoration: line-through; }

.claim-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.claim-checkbox {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  transition: all .15s;
}
.selected .claim-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.item-name { font-weight: 600; font-size: 15px; flex: 1; }
.item-price-tag {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary-dark);
}

.claim-fraction-row {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  align-items: center;
  gap: 8px;
}
.selected .claim-fraction-row { display: flex; }

.claim-fraction-row label { font-size: 13px; color: var(--gray-dark); font-weight: 600; }

.claim-fraction-row select {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
}

.availability-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.availability-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width .3s;
}

/* ── Totals bar ── */
.totals-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  border-top: 2px solid #e5e7eb;
  padding: 12px 16px;
  box-shadow: 0 -4px 12px rgba(0,0,0,.08);
  z-index: 50;
}

.totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  max-width: 600px;
  margin: 0 auto 10px;
  text-align: center;
}
.totals-grid .label { font-size: 11px; color: var(--gray-dark); text-transform: uppercase; }
.totals-grid .value { font-size: 17px; font-weight: 700; }
.totals-grid .value.total { color: var(--primary-dark); font-size: 20px; }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-gray { background: var(--gray-light); color: var(--gray-dark); }

/* ── Summary diner card ── */
.diner-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.diner-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.diner-name { font-size: 17px; font-weight: 700; }
.diner-total {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}
.diner-items { list-style: none; }
.diner-items li {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
  color: var(--gray-dark);
}
.diner-items li:last-child { border-bottom: none; }

/* ── Bill info card ── */
.bill-info {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.bill-info h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.bill-info p { font-size: 14px; opacity: .85; }
.bill-info .total-amount { font-size: 28px; font-weight: 800; margin-top: 8px; }

/* ── Share link box ── */
.share-box {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.share-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.share-url {
  display: flex;
  gap: 8px;
}
.share-url input {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  background: var(--white);
  color: var(--gray-dark);
}
.share-url button {
  padding: 10px 14px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}

/* ── Loading spinner ── */
.spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-overlay p { margin-top: 16px; font-weight: 600; color: var(--gray-dark); }

/* ── Error / empty states ── */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-dark);
}
.empty-state .empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }

/* ── Step indicator ── */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e5e7eb;
  color: var(--gray-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  transition: all .2s;
}
.step.active .step-dot { background: var(--primary); color: var(--white); }
.step.done .step-dot { background: var(--success); color: var(--white); }
.step-label { font-size: 11px; color: var(--gray-dark); font-weight: 500; text-align: center; }
.step-line { height: 2px; flex: 1; background: #e5e7eb; margin-bottom: 18px; }
.step-line.done { background: var(--success); }

/* ── Bill list item ── */
.bill-list-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: transform .1s;
}
.bill-list-item:active { transform: scale(.98); }
.bill-list-item h3 { font-size: 16px; font-weight: 700; }
.bill-list-item p { font-size: 13px; color: var(--gray-dark); margin-top: 2px; }
.bill-list-item .arrow { font-size: 20px; color: var(--gray); }

/* ── Section title ── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--gray-dark);
  margin: 20px 0 10px;
}

/* ── Responsive ── */
@media (max-width: 400px) {
  .totals-grid .value { font-size: 15px; }
  .totals-grid .value.total { font-size: 17px; }
}

/* ── Support Footer ── */
.support-footer {
  max-width: 400px;
  margin: 40px auto 32px;
  text-align: center;
  padding: 0 16px;
}

.support-text {
  font-size: 13px;
  color: var(--gray-dark);
  line-height: 1.6;
  margin-bottom: 14px;
}

.support-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-support {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all .15s;
  cursor: pointer;
}

.btn-donate {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1.5px solid var(--primary);
}
.btn-donate:hover {
  background: var(--primary);
  color: var(--white);
}

.btn-contact {
  background: var(--gray-light);
  color: var(--gray-dark);
  border: 1.5px solid #e5e7eb;
}
.btn-contact:hover {
  border-color: var(--primary);
  color: var(--primary);
}
