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

:root {
  --brand-blue: #003b84;
  --brand-blue-dark: #002a5e;
  --brand-blue-mid: #0050a4;
  --brand-blue-light: #e8f1fa;
  --brand-blue-soft: #f4f8fc;
  --brand-accent: #0078d4;
  --brand-red: #d32f2f;
  --page-bg: #eef2f7;
  --surface: #ffffff;
  --text: #1a2b3c;
  --text-secondary: #4a5d73;
  --muted: #6b7c90;
  --border: #d4dfea;
  --border-light: #e8eef4;
  --white: #fff;
  --line-green: #06c755;
  --header-h: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 59, 132, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 59, 132, 0.1);
  --shadow-lg: 0 12px 32px rgba(0, 42, 94, 0.16);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Helvetica Neue", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.menu-open { overflow: hidden; }

a {
  color: var(--brand-blue-mid);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--brand-blue); }

/* ── Top brand strip ── */
.brand-strip {
  height: 4px;
  background: linear-gradient(90deg, var(--brand-blue-dark) 0%, var(--brand-blue) 50%, var(--brand-accent) 100%);
}

/* ── Header ── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 120;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--header-h);
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px;
}

.logo-slot {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  min-width: 0;
}

.site-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.menu-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--brand-blue-soft);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.menu-btn:hover {
  background: var(--brand-blue-light);
  border-color: var(--brand-blue-mid);
}

.menu-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--brand-blue);
  border-radius: 1px;
}

/* ── Side menu ── */
.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 88vw);
  height: 100%;
  max-height: 100dvh;
  background: var(--white);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.side-menu.is-open { transform: translateX(0); }

.side-menu[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

.side-menu.is-open[hidden] {
  visibility: visible;
  pointer-events: auto;
}

.side-menu-header {
  padding: calc(var(--header-h) + 8px) 20px 0;
}

.side-menu-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border-radius: 20px;
}

.side-menu-inner { padding: 12px 20px 28px; }

.side-menu-inner h3 {
  margin: 0 0 16px;
  color: var(--brand-blue);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.4;
}

.side-menu-inner p {
  margin: 10px 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.menu-hours {
  color: var(--muted) !important;
  font-size: 0.8125rem !important;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.menu-close {
  margin-top: 24px;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--brand-blue-mid) 0%, var(--brand-blue) 100%);
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.menu-close:hover { opacity: 0.92; }

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 42, 94, 0.45);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.menu-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.menu-overlay[hidden] { display: block !important; }

/* ── Page layout ── */
.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100dvh - var(--header-h) - 4px);
}

.page-content {
  padding: 0 14px 28px;
}

.load-error {
  margin: 14px;
  padding: 14px 16px;
  background: #fef2f2;
  color: var(--brand-red);
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
}

/* ── Hero banner ── */
.hero-section {
  margin-bottom: 16px;
}

.product-banner {
  position: relative;
  overflow: hidden;
  background: var(--brand-blue-dark);
}

.product-banner-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
  opacity: 0.55;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 18px;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 42, 94, 0.75) 100%);
}

.hero-eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.hero-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
}

.hero-desc {
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
}

/* ── Card sections ── */
.card-section {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-section-head {
  margin: 0;
  padding: 13px 16px;
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-mid) 100%);
  color: var(--white);
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}

.section-icon {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

/* ── Data table ── */
.data-table { background: var(--surface); }

.data-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border-light);
  min-height: 50px;
}

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

.data-label {
  flex: 0 0 34%;
  max-width: 128px;
  padding: 12px 10px;
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-right: 1px solid var(--border-light);
}

.data-value {
  flex: 1;
  padding: 12px 14px;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  word-break: break-word;
  color: var(--text);
}

.kv-amount {
  color: var(--brand-red);
  font-weight: 700;
}

/* ── Form fields ── */
.form-field-stack {
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.form-field-stack:last-child { border-bottom: none; }

.field-head {
  margin: 0;
  padding: 10px 16px 8px;
  background: var(--brand-blue-light);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand-blue-dark);
  border-bottom: 1px solid var(--border-light);
}

.field-head em {
  font-style: normal;
  color: var(--brand-red);
  font-weight: 500;
  font-size: 0.75rem;
  margin-left: 4px;
}

.form-field-body { padding: 12px 16px 16px; }

.form-field-body input,
.form-field-body select,
.address-fields input,
.address-fields select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field-body input:focus,
.form-field-body select:focus,
.address-fields input:focus,
.address-fields select:focus {
  outline: none;
  border-color: var(--brand-blue-mid);
  box-shadow: 0 0 0 3px rgba(0, 80, 164, 0.15);
}

.form-field-body input::placeholder,
.address-fields input::placeholder {
  color: #a0aec0;
}

.form-field-body select,
.address-fields select {
  background-image: linear-gradient(45deg, transparent 50%, var(--brand-blue) 50%),
    linear-gradient(135deg, var(--brand-blue) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
  cursor: pointer;
}

.address-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.address-select-label { display: block; }

.address-select-title {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Terms block ── */
.terms-block { padding: 16px; }

.terms-open-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1.5px solid var(--brand-blue-mid);
  border-radius: var(--radius-md);
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.terms-open-btn:hover:not(:disabled) {
  background: var(--brand-blue-light);
  border-color: var(--brand-blue);
}

.terms-open-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.terms-open-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: var(--brand-blue);
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
}

.terms-open-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: translate(-60%, -50%) rotate(-45deg);
}

.agree-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.agree-row input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--brand-blue);
}

/* ── Submit area ── */
.submit-area {
  margin-top: 16px;
  padding: 0 2px;
}

/* ── Buttons ── */
.btn-primary,
.btn-outline,
.btn-line {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.0625rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.03em;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-blue-mid) 0%, var(--brand-blue) 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(0, 59, 132, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--brand-accent) 0%, var(--brand-blue-mid) 100%);
  box-shadow: 0 4px 12px rgba(0, 59, 132, 0.3);
}

.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-primary:disabled {
  background: #b0bec5;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-red {
  background: linear-gradient(180deg, #e53935 0%, var(--brand-red) 100%) !important;
}

.btn-red:hover:not(:disabled) {
  background: linear-gradient(180deg, #c62828 0%, #b71c1c 100%) !important;
}

.btn-outline {
  background: var(--white);
  color: var(--text);
  border: 1.5px solid var(--border);
}

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

.btn-line:hover { background: #05a847; }

.error-msg {
  margin: 10px 0 0;
  padding: 10px 12px;
  color: var(--brand-red);
  font-size: 0.875rem;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  border: 1px solid #fecaca;
}

.error-msg[hidden] { display: none !important; }

/* ── Reminder box ── */
.reminder-box {
  font-size: 0.875rem;
}

.reminder-box summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-blue);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

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

.reminder-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background: var(--brand-blue-light);
  border: 1.5px solid var(--brand-blue-mid);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.reminder-icon::before {
  content: "i";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 800;
  font-style: italic;
  color: var(--brand-blue);
  line-height: 1;
}

.reminder-box ul {
  margin: 0;
  padding: 0 16px 16px 36px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
}

.reminder-box li {
  margin-bottom: 8px;
  line-height: 1.55;
}

.reminder-box li::marker { color: var(--brand-blue-mid); }

/* ── Footer ── */
.page-footer { margin-top: 20px; }

.footer-band {
  padding: 20px 16px;
  background: var(--brand-blue-dark);
  border-radius: var(--radius-lg);
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.8125rem;
  font-weight: 500;
}

.footer-links a:hover { color: var(--white); }

.footer-divider {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.75rem;
}

.footer-note {
  margin: 8px 0;
  line-height: 1.55;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
}

.copyright {
  margin: 8px 0 0;
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.45);
}

/* ── Completion page ── */
.completion-hero-banner {
  background: linear-gradient(135deg, var(--brand-blue-dark) 0%, var(--brand-blue) 55%, var(--brand-blue-mid) 100%);
  padding: 28px 18px 32px;
}

.completion-hero-inner {
  text-align: center;
  color: var(--white);
}

.completion-status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.5);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.completion-hero-inner .hero-eyebrow {
  color: rgba(255, 255, 255, 0.75);
}

.completion-hero-inner .hero-title {
  font-size: 1.375rem;
}

.completion-hero-inner .hero-desc {
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.completion-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(90deg, var(--brand-blue-soft) 0%, var(--white) 100%);
}

.completion-badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.completion-badge-text {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--brand-blue);
}

.completion-badge-id {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 10px;
  background: var(--brand-blue-light);
  border-radius: 20px;
}

.completion-alert {
  padding: 18px 16px;
}

.completion-alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.completion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-blue);
  color: var(--white);
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

.completion-alert-title {
  margin: 0;
  color: var(--brand-blue);
  font-size: 1rem;
  font-weight: 700;
}

.completion-alert-notice {
  margin: 0 0 16px;
  color: var(--brand-red);
  font-size: 0.9rem;
  line-height: 1.65;
}

.completion-alert .btn-block {
  margin: 0;
}

#completion-view[hidden] {
  display: none !important;
}

/* ── Dialog modals ── */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  max-width: min(420px, calc(100vw - 28px));
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(0, 42, 94, 0.5);
  backdrop-filter: blur(2px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-mid) 100%);
  color: var(--white);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--white);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 16px;
  max-height: min(60vh, 420px);
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.text-modal-body h4 {
  margin: 14px 0 8px;
  font-size: 0.9375rem;
  color: var(--brand-blue);
}

.text-modal-body h4:first-child { margin-top: 0; }

.text-modal-body p { margin: 0 0 10px; }

.modal-footer { padding: 0 16px 16px; }

/* ── Desktop ── */
@media (min-width: 481px) {
  body {
    background: linear-gradient(180deg, #dde6f0 0%, var(--page-bg) 120px);
  }

  .page {
    margin-top: 12px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: var(--page-bg);
  }

  .hero-section { margin-bottom: 0; }

  .page-content { padding-top: 16px; }
}
