:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #172033;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #176b87;
  --primary-dark: #0f4c5c;
  --primary-soft: #e0f2fe;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.page {
  min-height: 100vh;
  padding: 24px 0 48px;
}

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

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 800;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
}

.navbar-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

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

.nav-link {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}

.nav-link:hover,
.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  text-decoration: none;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card + .card {
  margin-top: 18px;
}

.card-title {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 800;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
}

.stat-value {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 900;
}

.form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  color: var(--text);
  background: white;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid var(--primary-soft);
  border-color: var(--primary);
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: var(--primary);
  color: #ffffff;
  text-decoration: none;
}

button:hover,
.btn:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

button:disabled,
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Completion-rule controls may still be disabled for rule-type semantics
   (for example the N input when another rule type is selected). */
#completionRuleBox select:disabled,
#completionRuleBox input:disabled,
#completionRuleBox input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 1;
}

#completionRuleBox select:disabled {
  color: var(--muted);
}

#completionRuleBox .completion-rule-live-warning {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid #fbbf24;
  border-left: 5px solid var(--warning);
  border-radius: 12px;
  background: var(--warning-soft);
  color: #78350f;
}

#completionRuleBox .completion-rule-live-warning strong {
  color: var(--warning);
}

#completionRuleBox .completion-rule-live-warning span {
  line-height: 1.6;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #7f1d1d;
}

.btn-sm {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 14px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-success {
  color: var(--success);
  background: var(--success-soft);
}

.badge-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.badge-muted {
  color: var(--muted);
  background: var(--surface-2);
}

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

.kv-item {
  padding: 12px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
}

.kv-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kv-value {
  margin-top: 3px;
  font-weight: 800;
  word-break: break-word;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  transition: all 0.25s ease;
}

.toast-info {
  border-left: 5px solid var(--primary);
}

.toast-success {
  border-left: 5px solid var(--success);
}

.toast-warning {
  border-left: 5px solid var(--warning);
}

.toast-danger {
  border-left: 5px solid var(--danger);
}

.toast-hide {
  opacity: 0;
  transform: translateY(8px);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: white;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

.btn-secondary .spinner {
  border-color: rgba(15, 23, 42, 0.25);
  border-top-color: var(--text);
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(23, 107, 135, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(21, 128, 61, 0.12), transparent 34%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
}

.code-block {
  padding: 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 820px) {
  .page-header,
  .toolbar,
  .navbar-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .form-row,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
}


/* QR / Kiosk navigation refinements */
.nav-links {
  flex-wrap: wrap;
}

.qr-scanner .toolbar-actions,
.kiosk-hero + .qr-scanner {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .navbar-inner {
    align-items: flex-start;
  }

  .nav-links {
    gap: 6px;
  }

  .nav-link {
    padding: 8px 10px;
  }

  .qr-video-wrap {
    min-height: 240px;
  }

  .qr-video {
    min-height: 240px;
  }
}


/* --------------------------------------------------------------------------
   Registration marketplace mobile overrides
   - Desktop layout remains unchanged.
   - Mobile "熱門目的地" uses banner + city buttons.
   - Mobile "熱門分類" and "企業 ESG 推薦" keep 3 cards per row.
   Banner image path for app.css: web/shared/images/mobile-destination-banner.jpg
   -------------------------------------------------------------------------- */
.marketplace-home .mobile-destination-panel {
  display: none;
}

.marketplace-home .mobile-destination-banner {
  position: relative;
  display: flex;
  min-height: 132px;
  padding: 20px;
  align-items: flex-end;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
  color: #fff;
  text-decoration: none;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .08), rgba(15, 23, 42, .68)),
    url("./images/mobile-destination-banner.jpg") center/cover no-repeat,
    linear-gradient(135deg, #176b87, #20a66a);
  box-shadow: 0 8px 22px rgba(17, 52, 60, .07);
}

.marketplace-home .mobile-destination-banner:hover {
  color: #fff;
  text-decoration: none;
}

.marketplace-home .mobile-destination-banner__label {
  position: absolute;
  left: 20px;
  bottom: 48px;
  z-index: 1;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 1px 8px rgba(15, 23, 42, .32);
}

.marketplace-home .mobile-destination-banner strong {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 950;
  text-shadow: 0 1px 8px rgba(15, 23, 42, .38);
}

.marketplace-home .mobile-city-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 14px 18px;
  border: 1px solid #e2eaec;
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(17, 52, 60, .07);
}

.marketplace-home .mobile-city-buttons a {
  min-width: calc((100% - 20px) / 3);
  padding: 9px 10px;
  border: 1px solid #e2eaec;
  border-radius: 10px;
  color: #172326;
  background: #fff;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .04);
}

.marketplace-home .mobile-city-buttons a:hover {
  color: #007f85;
  border-color: rgba(0, 167, 167, .35);
  text-decoration: none;
}

@media (max-width: 640px) {
  .marketplace-home .desktop-destination-grid {
    display: none !important;
  }

  .marketplace-home .mobile-destination-panel {
    display: block !important;
  }

  .marketplace-home .category-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .marketplace-home .category-tile {
    min-height: 112px !important;
    padding: 12px 8px !important;
    border-radius: 18px !important;
  }

  .marketplace-home .cat-icon {
    margin-bottom: 7px !important;
    font-size: 22px !important;
  }

  .marketplace-home .cat-title {
    font-size: 13px !important;
    line-height: 1.25 !important;
    letter-spacing: -0.02em !important;
  }

  .marketplace-home .cat-copy {
    margin-top: 4px !important;
    font-size: 11px !important;
    line-height: 1.35 !important;
  }
}

/* Venue Onboarding v1.4.3-A Foundation */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.summary-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.summary-card .label { color: var(--muted); font-size: 13px; }
.summary-card .value { margin-top: 4px; font-weight: 800; font-size: 20px; }
.onboarding-stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.stepper-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: left;
  cursor: default;
}
.stepper-item.current { outline: 2px solid var(--primary); }
.stepper-item.completed { background: var(--success-soft); border-color: #86efac; }
.stepper-item.in-progress { background: var(--primary-soft); border-color: #7dd3fc; }
.stepper-item.skipped { background: var(--warning-soft); border-color: #fbbf24; }
.stepper-item.blocked,
.stepper-item.failed { background: var(--danger-soft); border-color: #fca5a5; }
.stepper-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; background: var(--surface); margin-bottom: 8px; font-weight: 900; }
.stepper-label { display: block; font-weight: 800; font-size: 13px; }
.stepper-status { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.progress-bar-wrap { display: flex; align-items: center; gap: 10px; }
.progress-bar-track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s ease; }
.progress-bar-label { min-width: 44px; text-align: right; font-weight: 800; }
.missing-list { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.missing-list li { border: 1px solid var(--warning-soft); background: #fff7ed; border-radius: 12px; padding: 10px 12px; }
.missing-list strong { display: block; color: var(--warning); }
.missing-list span { color: var(--muted); font-size: 14px; }
.checklist { display: grid; gap: 8px; }
.checklist-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.checklist-item.passed { background: var(--success-soft); }
.checklist-item.failed { background: var(--danger-soft); }
.checklist-mark { font-weight: 900; }
.checklist-item p { margin: 2px 0 0; color: var(--muted); }
.sticky-action-bar { position: sticky; bottom: 0; margin-top: 18px; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); display: flex; justify-content: space-between; gap: 12px; z-index: 5; }
.placeholder-panel { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 22px; background: var(--surface-2); color: var(--muted); }
.compact { padding: 12px; }
@media (max-width: 900px) {
  .form-grid, .summary-grid, .onboarding-stepper { grid-template-columns: 1fr; }
  .sticky-action-bar { position: static; flex-direction: column; }
}

/* Phase 2 Activity Route Core */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.tab {
  border: 1px solid #d8e3ea;
  background: #fff;
  border-radius: 16px;
  padding: 10px 16px;
  font-weight: 700;
  color: #456;
  cursor: pointer;
}
.tab.active {
  background: #0f6f84;
  color: #fff;
  border-color: #0f6f84;
}
.tab-panel {
  display: none;
  padding: 12px 0;
}
.tab-panel.active {
  display: block;
}
.route-card {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid #dfe9ef;
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
  margin: 10px 0;
  cursor: pointer;
}
.route-card:hover {
  border-color: #0f6f84;
  box-shadow: 0 8px 24px rgba(15, 111, 132, 0.08);
}
.checkpoint-table td,
.checkpoint-table th,
.compact-table td,
.compact-table th {
  padding: 10px 12px;
}
.qr-preview,
.code-block {
  background: #f6f9fb;
  border: 1px solid #e3edf3;
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
}
.completion-rule-card {
  border: 1px solid #dfe9ef;
  border-radius: 18px;
  padding: 16px;
  background: #fff;
}
.inline-action-bar,
.inner-sticky {
  margin-top: 18px;
  justify-content: flex-end;
}
@media (max-width: 768px) {
  .route-card {
    grid-template-columns: 1fr;
  }
}

/* Sprint 4B dining merchant/product setup */
.dining-two-stage { display: grid; gap: 18px; }
.sub-card { border: 1px solid var(--border, #dce6ee); border-radius: 16px; padding: 18px; background: rgba(255,255,255,.72); }
.merchant-table td, .dining-item-table td { vertical-align: top; }
.btn-sm { padding: 8px 10px; font-size: .9rem; border-radius: 10px; }
@media (max-width: 860px) { .dining-two-stage .form-grid { grid-template-columns: 1fr; } }


/* Venue template / activity-apply alignment */
.template-summary-head,
.gate-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.template-summary-head h3,
.gate-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}
.summary-grid.compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.compact-list {
  margin-top: 14px;
}
.badge-success {
  background: var(--success-soft);
  color: var(--success);
}
.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.template-flow-note {
  border: 1px dashed var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 12px;
}
.template-flow-note strong {
  display: block;
  margin-bottom: 4px;
}
.action-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.action-card h3 {
  margin: 0 0 8px;
}
.action-card p {
  margin: 0 0 12px;
  color: var(--muted);
}
@media (max-width: 900px) {
  .summary-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .template-summary-head,
  .gate-head {
    display: grid;
  }
}


.template-source-note { margin: 12px 0; padding: 10px 12px; border-radius: 10px; background: rgba(15, 118, 110, 0.08); color: #0f766e; font-size: 0.92rem; line-height: 1.5; }

/* Venue-first / activity-applies product editor */
.venue-apply-card {
  border: 1px solid rgba(15, 118, 145, 0.18);
}
.template-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.template-summary-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px;
  min-height: 96px;
}
.template-summary-card span {
  display: block;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 8px;
}
.template-summary-card strong {
  display: block;
  color: #0f172a;
  font-size: 1.25rem;
  margin-bottom: 8px;
}
.template-summary-card small {
  color: #64748b;
  line-height: 1.5;
}
.gate-panel {
  margin-top: 16px;
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
}
.gate-panel ul {
  margin: 8px 0 0 20px;
  padding: 0;
}
.gate-panel-ok {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}
.gate-panel-warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}
.gate-panel-muted {
  border-color: #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}
@media (max-width: 900px) {
  .template-summary-grid {
    grid-template-columns: 1fr;
  }
}
