:root {
  --brand: #61D0DF;
  --brand-dark: #4FB8C7;
  --brand-light: #E8F8FB;
  --text: #2C3E50;
  --text-soft: #5A6C7D;
  --text-light: #98A4B0;
  --border: #E0E6EC;
  --bg: #FAFBFC;
  --white: #FFFFFF;
  --err: #E74C3C;
  --warn: #F39C12;
  --shadow: 0 2px 12px rgba(97, 208, 223, 0.08);
}

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

html, body {
  font-family: -apple-system, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.hero { margin-bottom: 40px; }
.hero-logo {
  height: 64px; width: auto;
  display: block; margin-bottom: 16px;
}
.thanks-logo {
  height: 56px; width: auto;
  display: block; margin: 0 auto 28px;
}
.hero h1 {
  color: var(--brand);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.hero .sub {
  color: var(--text-soft);
  font-size: 15px;
  margin-top: 10px;
  line-height: 1.8;
}
.philosophy {
  background: var(--brand-light);
  border-left: 3px solid var(--brand);
  padding: 14px 18px;
  margin-top: 20px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.7;
}
.philosophy strong {
  color: var(--brand-dark);
  font-size: 15px;
}

.form { display: flex; flex-direction: column; gap: 32px; }
.q { display: flex; flex-direction: column; gap: 10px; }
.q-label {
  font-size: 16px;
  color: var(--text);
  font-weight: 500;
  display: block;
  line-height: 1.6;
}
.q-num {
  display: inline-block;
  min-width: 22px;
  color: var(--text-light);
  font-size: 14px;
  margin-right: 6px;
}
.req { color: var(--err); font-weight: 400; }

.hint {
  color: var(--text-light);
  font-size: 13px;
  font-weight: 400;
}
.hint-block { display: block; margin-top: -2px; line-height: 1.6; }

.input-line {
  width: 100%;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--white);
  padding: 12px 16px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: box-shadow .2s, border-color .2s;
}
.input-line::placeholder, .input-box::placeholder {
  color: var(--text-light);
}
.input-line:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(97, 208, 223, 0.12);
}

.input-box {
  width: 100%;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--white);
  padding: 14px 16px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: box-shadow .2s, border-color .2s;
}
.input-box:focus {
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px rgba(97, 208, 223, 0.12);
}

/* Radio cards */
.radio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.radio-card, .check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: background .2s, border-color .2s;
}
.radio-card:hover, .check-card:hover { background: var(--brand-light); }
.radio-card input[type=radio], .check-card input[type=checkbox] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--brand);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.radio-card input[type=radio] { border-radius: 50%; }
.check-card input[type=checkbox] { border-radius: 3px; }
.radio-card input[type=radio]:checked::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--brand);
}
.check-card input[type=checkbox]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.check-card input[type=checkbox]:checked::after {
  content: '✓';
  position: absolute;
  inset: -3px 0 0 1px;
  color: white;
  font-size: 13px;
  font-weight: bold;
  line-height: 14px;
  text-align: center;
}
.radio-card:has(input:checked), .check-card:has(input:checked) {
  background: var(--brand-light);
  border-color: var(--brand-dark);
}
.check-card-warn:has(input:checked) {
  background: #FFF5E6;
  border-color: var(--warn);
}
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

/* 酷澎警告 */
.coupang-warn {
  background: #FFF0F0;
  border: 1px solid #F4A4A4;
  border-left: 4px solid var(--err);
  border-radius: 6px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: #8B2828;
}
.coupang-warn strong { color: var(--err); }

/* Q11 Rules block */
.rules { background: #FFFAF0; border: 1px solid #F4C97E; border-radius: 8px; padding: 18px 20px; }
.rules .q-label { color: var(--text); }
.rule-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.7;
  transition: border-color .2s;
}
.rule-item input[type=checkbox] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--text-light);
  border-radius: 3px;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
  position: relative;
}
.rule-item input[type=checkbox]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.rule-item input[type=checkbox]:checked::after {
  content: '✓';
  position: absolute;
  inset: -3px 0 0 1px;
  color: white;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
}
.rule-item:has(input:checked) { border-color: var(--brand); }
.rule-item.rule-warn {
  background: #FFF5F5;
  border-color: #F4A4A4;
}
.rule-item.rule-warn:has(input:checked) {
  border-color: var(--err);
  background: #FFF0F0;
}

/* Readonly rules display + final agreement */
.rule-readonly {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 18px 14px 32px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.9;
  margin-top: 4px;
}
.rule-readonly ul { margin: 0; }
.rule-readonly li { padding: 2px 0; }
.rule-readonly strong { color: var(--text); }

.rule-final {
  margin-top: 12px;
  background: var(--brand-light);
  border-color: var(--brand);
  font-size: 15px;
  font-weight: 500;
}
.rule-final:has(input:checked) {
  background: #D8F2F6;
  border-color: var(--brand-dark);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: white;
  border-radius: 12px;
  padding: 40px 36px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  animation: slideUp .25s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 18px;
}
.modal-box h3 {
  color: var(--brand);
  font-size: 22px;
  margin-bottom: 12px;
}
.modal-box p {
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 28px;
}
.modal-close-btn {
  padding: 12px 40px;
  font-size: 15px;
  letter-spacing: 1px;
}

/* Captcha */
.captcha-q { margin-bottom: 8px; }
.captcha-label { color: var(--text-soft); font-size: 14px; }
.captcha-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.captcha-image-wrap {
  width: 160px;
  height: 60px;
  background: #F0FAFB;
  border: 1px solid var(--brand);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.captcha-image-wrap svg {
  width: 100%; height: 100%;
}
.captcha-loading {
  color: var(--text-light);
  font-size: 13px;
}
.captcha-loading.err { color: var(--err); }
.btn-reload {
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--brand);
  flex-shrink: 0;
  transition: background .2s;
}
.btn-reload:hover { background: var(--brand-light); }
.captcha-input {
  flex: 1;
  font-size: 18px;
  letter-spacing: 6px;
  text-align: center;
  text-transform: uppercase;
}

/* Submit */
.submit-wrap {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.btn-submit {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 14px 80px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, transform .1s;
  font-family: inherit;
  letter-spacing: 2px;
}
.btn-submit:hover:not(:disabled) { background: var(--brand-dark); }
.btn-submit:active:not(:disabled) { transform: translateY(1px); }
.btn-submit:disabled { background: var(--text-light); cursor: not-allowed; }
.submit-status { font-size: 13px; color: var(--text-soft); min-height: 18px; }
.submit-status.err { color: var(--err); font-weight: 500; }
.submit-hint {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
  margin-top: 4px;
}

/* Thanks page */
.thanks-box {
  text-align: center;
  padding: 60px 20px;
  max-width: 540px;
  margin: 0 auto;
}
.thanks-box .icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 24px;
}
.thanks-box h2 { color: var(--brand); margin-bottom: 8px; font-size: 24px; }
.thanks-box p { color: var(--text-soft); }

/* === Admin === */
.admin-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 24px;
}
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-title { display: flex; align-items: center; gap: 14px; }
.admin-logo { height: 36px; width: auto; display: block; }
.admin-header h1 {
  color: var(--brand);
  font-size: 24px;
  font-weight: 600;
}
.admin-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: white; }

.login-box {
  max-width: 380px;
  margin: 120px auto 0;
  padding: 40px 32px;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-box h2 { color: var(--brand); margin-bottom: 6px; }
.login-box p { color: var(--text-soft); font-size: 14px; margin-bottom: 24px; }
.login-box input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
  letter-spacing: 8px;
  font-family: inherit;
}
.login-box input:focus { border-color: var(--brand); }
.login-box .err-msg { color: var(--err); font-size: 13px; min-height: 18px; margin-bottom: 12px; }

/* 帳號選單 */
.acc-chooser {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.acc-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: all .2s;
}
.acc-btn:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}
.acc-btn.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}
.acc-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0;
}
.acc-avatar-admin { background: var(--brand); }
.acc-avatar-limited { background: #C04B7E; }
.acc-info { flex: 1; }
.acc-info .acc-name {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.acc-info .acc-sub {
  color: var(--text-light);
  font-size: 12px;
  margin-top: 2px;
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  margin-top: 12px;
  font-family: inherit;
  text-decoration: underline;
}
.btn-back:hover { color: var(--brand-dark); }

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-label { color: var(--text-soft); font-size: 14px; }
.filter-select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 14px;
  background: white;
  font-family: inherit;
  cursor: pointer;
  padding-right: 30px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.stat-card .label { color: var(--text-soft); font-size: 14px; }
.stat-card .value { color: var(--brand); font-size: 30px; font-weight: 600; margin-top: 4px; }

.dealer-list { display: flex; flex-direction: column; gap: 14px; }
.dealer-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}
.dealer-card.priority-高 { border-left: 4px solid var(--brand); }
.dealer-card.priority-低 { opacity: 0.85; }
.dealer-card.status-不適合 { background: #FAFAFA; opacity: 0.7; }

.dealer-head {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.dealer-name-bar {
  display: block;
  margin-bottom: 14px;
}
.dealer-name { color: var(--brand); font-size: 20px; font-weight: 600; line-height: 1.4; }
.dealer-meta { color: var(--text-light); font-size: 13px; margin-top: 6px; }
.dealer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: flex-end;
}
.dealer-controls .ctrl {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dealer-controls label {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
}
.dealer-controls select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 28px 7px 12px;
  font-size: 14px;
  background: white;
  font-family: inherit;
  cursor: pointer;
  min-width: 120px;
  color: var(--text);
}
.dealer-controls select:hover { border-color: var(--brand); }

.flag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-left: 6px;
}
.flag-red { background: #FEE; color: #C0392B; }
.flag-yellow { background: #FFF6E0; color: #B7791F; }
.flag-green { background: #E6F7E0; color: #2D7A20; }

.qa {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.7;
}
.qa .label { color: var(--text-soft); font-weight: 500; margin-bottom: 3px; font-size: 13px; }
.qa .value { color: var(--text); white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.qa .value a { color: var(--brand-dark); word-break: break-all; }
.qa .value.empty { color: var(--text-light); font-style: italic; }
.qa .chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  display: inline-block;
  background: var(--brand-light);
  color: var(--brand-dark);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.chip.warn { background: #FFF5E6; color: #B7791F; }

.dealer-note {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dealer-note textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
  outline: none;
}
.dealer-note textarea:focus { border-color: var(--brand); }
.note-status { font-size: 11px; color: var(--text-light); height: 14px; }
.note-status.saved { color: #2D7A20; }
.note-status.saving { color: var(--brand-dark); }

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-soft);
  margin-left: 8px;
}
.copy-btn:hover { background: var(--brand-light); color: var(--brand-dark); }

.role-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
}
.role-badge.role-admin { background: var(--brand-light); color: var(--brand-dark); }
.role-badge.role-limited { background: #FFE8F0; color: #C04B7E; }

.chip-pink { background: #FFE8F0; color: #C04B7E; }
.chip-role { background: #F0E8FF; color: #7C5AC2; }

.note-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.btn-delete {
  background: white;
  border: 1px solid #F4A4A4;
  color: #C0392B;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}
.btn-delete:hover { background: #FEE; }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-light);
}

/* Mobile */
@media (max-width: 700px) {
  .page { padding: 24px 14px 60px; }

  /* Hero */
  .hero { margin-bottom: 28px; }
  .hero-logo { height: 52px; margin-bottom: 12px; }
  .hero h1 { font-size: 21px; }
  .hero .sub { font-size: 14px; }

  /* Form spacing */
  .form { gap: 26px; }
  .q-label { font-size: 15px; }
  .hint-block { font-size: 12px; }

  /* Single column for grids */
  .radio-grid, .check-grid { grid-template-columns: 1fr; gap: 8px; }
  .radio-card, .check-card { padding: 11px 14px; font-size: 14px; }

  /* Inputs */
  .input-line { padding: 11px 14px; font-size: 15px; }
  .input-box { padding: 12px 14px; font-size: 15px; min-height: 72px; }

  /* Coupang warn */
  .coupang-warn { padding: 10px 12px; font-size: 12px; line-height: 1.6; }

  /* Rules block */
  .rules { padding: 14px 14px; }
  .rule-readonly { padding: 10px 12px 12px 26px; font-size: 12px; line-height: 1.8; }
  .rule-final { padding: 12px 14px; font-size: 14px; }

  /* Captcha */
  .captcha-row { flex-wrap: wrap; gap: 10px; }
  .captcha-image-wrap { flex: 1 1 auto; }
  .captcha-input {
    flex: 1 0 100%;
    margin-top: 4px;
    font-size: 17px;
    letter-spacing: 5px;
    padding: 12px;
  }

  /* Submit */
  .submit-wrap { margin-top: 20px; }
  .btn-submit { padding: 14px 0; width: 100%; font-size: 15px; }

  /* Modal */
  .modal-overlay { padding: 16px; }
  .modal-box { padding: 32px 22px; }
  .modal-icon { width: 56px; height: 56px; font-size: 28px; }
  .modal-box h3 { font-size: 20px; }
  .modal-box p { font-size: 14px; }

  /* Admin */
  .admin-page { padding: 18px 14px; }
  .admin-header { padding-bottom: 12px; margin-bottom: 16px; }
  .admin-header h1 { font-size: 18px; }
  .role-badge { font-size: 11px; padding: 2px 8px; }
  .dealer-card { padding: 14px 14px; }
  .dealer-head { grid-template-columns: 1fr; gap: 12px; }
  .dealer-controls { grid-template-columns: 1fr; gap: 6px 0; }
  .dealer-controls label { color: var(--text-light); font-size: 11px; margin-top: 4px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 10px 12px; }
  .stat-card .value { font-size: 22px; }
  .filters { font-size: 12px; }
}
