:root {
  --bg: #FFF8F1;
  --card: #FFFFFF;
  --ink: #3B2A20;
  --muted: #8C7B70;
  --line: #F1E3D6;
  --brand: #FF6B35;
  --brand-dark: #E2531F;
  --sun: #FFC145;
  --soft: #FFEFE3;
  --s-new: #FA5252;
  --s-contacted: #F59F00;
  --s-booked: #FD7E14;
  --s-came: #C2255C;
  --s-bought: #B5830F;
  --s-lost: #A8A29E;
  --chart: #E8590C;
  --grid: #F1E8E0;
  --axis: #D9CBBE;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(120, 70, 30, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }

/* 示範說明列 */
.demo-bar {
  position: sticky; top: 0; z-index: 20;
  background: #3B2A20; color: #FFF3E8;
  font-size: 14px;
  padding: 8px 16px;
}
@media (max-width: 759px) { .demo-bar { position: static; } }
.demo-bar .row { max-width: 1080px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.demo-bar .tag { background: var(--sun); color: #3B2A20; font-weight: 700; border-radius: 999px; padding: 1px 10px; font-size: 13px; }
.demo-bar .spacer { flex: 1; }
.demo-bar a, .demo-bar button.link { color: #FFD9B8; font-weight: 600; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 0; }
.demo-bar a:hover, .demo-bar button.link:hover { text-decoration: underline; }
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.src-chip {
  border: 1px solid rgba(255, 220, 190, .45); background: transparent; color: #FFE9D6;
  border-radius: 999px; padding: 2px 10px; font-size: 13px; cursor: pointer;
}
.src-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

.explain {
  max-width: 1080px; margin: 12px auto 0; padding: 0 16px;
}
.explain details {
  background: var(--card); border: 1px dashed #F3C9A8; border-radius: 12px; padding: 10px 14px; font-size: 14px;
}
.explain summary { cursor: pointer; font-weight: 700; color: var(--brand-dark); }
.explain ol { margin: 8px 0 2px; padding-left: 20px; }

/* 留資頁 */
.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--sun), var(--brand) 70%);
  box-shadow: 0 0 0 4px var(--soft);
}
.fake-note { font-size: 12px; font-weight: 500; color: var(--muted); }

.hero { display: grid; gap: 24px; align-items: center; margin-top: 22px; }
@media (min-width: 860px) { .hero { grid-template-columns: 1.1fr 1fr; align-items: start; } }

.hero h1 { font-size: clamp(28px, 6vw, 42px); line-height: 1.25; margin: 6px 0 12px; letter-spacing: .5px; }
.hero h1 em { font-style: normal; color: var(--brand); }
.hero p.intro { color: #6B5649; font-size: 17px; margin: 0 0 18px; }

.offer {
  display: inline-flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  background: var(--sun); border-radius: 14px; padding: 10px 16px; font-weight: 800;
  transform: rotate(-1.2deg); box-shadow: var(--shadow);
}
.offer .price { font-size: 30px; }
.offer s { color: #7A5A3E; font-weight: 600; }

.points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.points li { display: flex; gap: 10px; align-items: flex-start; }
.points .dot {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 14px; margin-top: 1px;
}

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.form-card { border-top: 6px solid var(--brand); }
.form-card h2 { margin: 0 0 4px; font-size: 22px; }
.form-card .sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

.field { margin-bottom: 14px; }
.field label.title { display: block; font-weight: 700; margin-bottom: 6px; font-size: 15px; }
.field .req { color: var(--s-new); margin-left: 2px; }
.field .hint { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }
.field input[type=text], .field input[type=tel], .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #FFFCF9;
  font-size: 16px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); background: #fff; }
.field .err { color: var(--s-new); font-size: 13px; margin-top: 4px; display: none; }
.field.bad .err { display: block; }
.field.bad input { border-color: var(--s-new); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span {
  display: inline-block; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  background: #FFFCF9; font-size: 15px; user-select: none;
}
.pill input:checked + span { background: var(--soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 700; }
.pill input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--brand); color: #fff; width: 100%; font-size: 18px; padding: 14px; box-shadow: 0 4px 0 var(--brand-dark); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--brand-dark); }
.btn.ghost { background: var(--soft); color: var(--brand-dark); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.jump { margin-top: 20px; }
@media (min-width: 860px) { .btn.jump { display: none; } }
#formCard { scroll-margin-top: 60px; }
.privacy { color: var(--muted); font-size: 12.5px; text-align: center; margin: 10px 0 0; }

.done { text-align: center; }
.done .big { font-size: 46px; line-height: 1; }
.done h2 { margin: 10px 0 4px; }
.notify {
  text-align: left; margin: 18px 0 6px; background: #FFF6D6; border-radius: 14px; padding: 12px 14px;
  border: 1px solid #FFE08A; font-size: 14.5px; white-space: pre-line;
}
.notify-cap { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.done .actions { display: grid; gap: 8px; }

.faq { margin-top: 32px; display: grid; gap: 12px; }
@media (min-width: 860px) { .faq { grid-template-columns: repeat(3, 1fr); } }
.faq .card h3 { margin: 0 0 6px; font-size: 16px; }
.faq .card p { margin: 0; color: #6B5649; font-size: 14.5px; }

footer.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 16px 30px; }

/* 後台 */
.admin-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; }
.admin-head h1 { margin: 0; font-size: 26px; }
.admin-head .sub { color: var(--muted); font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.stats .stat:last-child { grid-column: 1 / -1; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(5, 1fr); } .stats .stat:last-child { grid-column: auto; } }
.stat { background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 800; line-height: 1.2; }
.stat .v small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.stat.hot { background: #FFF0EE; }
.stat.hot .v { color: var(--s-new); }

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 14px; }
.tab {
  background: none; border: 0; padding: 8px 14px; font-weight: 700; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab.on { color: var(--brand-dark); border-bottom-color: var(--brand); }

.toolbar { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.toolbar .search { grid-column: 1 / -1; }
@media (min-width: 760px) { .toolbar { grid-template-columns: 2fr 1fr 1.4fr auto; } .toolbar .search { grid-column: auto; } }
.toolbar input, .toolbar select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; font-size: 15px;
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--brand); }

.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.status-chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 12px; font-size: 14px; cursor: pointer;
}
.status-chip b { margin-left: 4px; }
.status-chip.on { border-color: var(--ink); background: var(--ink); color: #fff; }

.leads { display: grid; gap: 10px; }
.lead {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px;
  border-left: 5px solid var(--line);
}
.lead[data-status="新名單"] { border-left-color: var(--s-new); }
.lead[data-status="已聯絡"] { border-left-color: var(--s-contacted); }
.lead[data-status="已預約"] { border-left-color: var(--s-booked); }
.lead[data-status="已到課"] { border-left-color: var(--s-came); }
.lead[data-status="已購課"] { border-left-color: var(--s-bought); }
.lead[data-status="未成交"] { border-left-color: var(--s-lost); opacity: .88; }
.lead .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead .name { font-weight: 800; font-size: 18px; }
.badge { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 7px; }
.badge.new { background: var(--s-new); color: #fff; }
.badge.dup { background: #FFF0C2; color: #8A5A00; }
.lead .top .spacer { flex: 1; }
.status-select {
  border: 0; border-radius: 999px; padding: 5px 30px 5px 12px; font-weight: 700; font-size: 14px; color: #fff; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.status-select[data-status="新名單"] { background-color: var(--s-new); }
.status-select[data-status="已聯絡"] { background-color: var(--s-contacted); }
.status-select[data-status="已預約"] { background-color: var(--s-booked); }
.status-select[data-status="已到課"] { background-color: var(--s-came); }
.status-select[data-status="已購課"] { background-color: var(--s-bought); }
.status-select[data-status="未成交"] { background-color: var(--s-lost); }
.status-select option { color: var(--ink); background: #fff; }

.lead .meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.src { display: inline-block; border-radius: 6px; padding: 0 7px; font-size: 12.5px; font-weight: 700; }
.src.FB { background: #FFE3D3; color: #B5410F; }
.src.IG { background: #FFE0EC; color: #A61E4D; }
.src.自然 { background: #F1ECE7; color: #6B5649; }
.lead .info { display: grid; gap: 4px 16px; margin-top: 8px; font-size: 15px; }
@media (min-width: 760px) { .lead .info { grid-template-columns: 1fr 1fr; } }
.lead .info .k { color: var(--muted); font-size: 13px; margin-right: 6px; }
.mini {
  border: 1px solid var(--line); background: #FFFCF9; border-radius: 8px; padding: 0 8px; font-size: 13px; cursor: pointer; margin-left: 6px;
}
.mini:hover { border-color: var(--brand); color: var(--brand-dark); }
.lead .note {
  margin-top: 10px; width: 100%; border: 1.5px dashed var(--line); border-radius: 10px; padding: 7px 10px; font-size: 14.5px; background: #FFFCF9;
}
.lead .note:focus { outline: none; border-style: solid; border-color: var(--brand); background: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.insight {
  background: #FFF6D6; border: 1px solid #FFE08A; border-radius: 14px; padding: 12px 16px; margin-bottom: 14px; font-size: 15px;
}
.insight b { color: var(--brand-dark); }
.ads { display: grid; gap: 10px; }
@media (min-width: 760px) { .ads { grid-template-columns: 1fr 1fr; } }
.adcard { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.adcard .t { font-weight: 800; font-size: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.adcard .spend { display: flex; align-items: center; gap: 6px; margin: 8px 0; font-size: 14px; color: var(--muted); }
.adcard .spend input { width: 110px; border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 15px; color: var(--ink); }
.adcard .spend input:focus { outline: none; border-color: var(--brand); }
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin-top: 8px; }
.funnel > div { background: var(--soft); border-radius: 10px; padding: 6px 4px; }
.funnel .n { font-weight: 800; font-size: 20px; }
.funnel .l { font-size: 12.5px; color: var(--muted); }
.costs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; font-size: 14px; }
.adline { color: var(--muted); font-size: 13px; margin-top: 4px; }
.plan { border: 1.5px solid var(--line); border-radius: 8px; padding: 1px 6px; font-size: 14px; background: #FFFCF9; }
.costs > div { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.costs .l { color: var(--muted); font-size: 12.5px; }
.costs .n { font-weight: 800; font-size: 17px; }
.costs .best { border-color: var(--brand); background: #FFF4EC; }
.ads-note { color: var(--muted); font-size: 13px; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: all .25s; pointer-events: none; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 期間切換 */
.range { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; }
.range button { border: 0; background: none; padding: 5px 14px; border-radius: 999px; font-weight: 700; color: var(--muted); cursor: pointer; font-size: 14px; }
.range button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* 成效總覽 */
.insight-title { font-weight: 800; margin-bottom: 4px; }
.insight ul { margin: 0; padding-left: 20px; }
.insight li { margin: 3px 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpis .stat .v { font-size: 28px; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.grid2 { display: grid; gap: 14px; margin-top: 14px; }
@media (min-width: 860px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.chart-card h3 { margin: 0; font-size: 17px; }
.chart-sub { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }
.chart-note { color: #6B5649; font-size: 13.5px; margin: 10px 0 0; }

.hrows { display: grid; gap: 10px; }
.hrow { display: grid; grid-template-columns: 6.5em 1fr 7.5em; gap: 10px; align-items: center; }
.hl { font-size: 14px; color: var(--ink); }
.ht { height: 16px; }
.hf { height: 16px; background: var(--chart); border-radius: 0 4px 4px 0; }
.hv { font-size: 13px; color: var(--muted); line-height: 1.25; }
.hv b { display: block; color: var(--ink); font-size: 15px; }
@media (max-width: 420px) { .hrow { grid-template-columns: 5.6em 1fr 6.6em; gap: 8px; } }

.vbars { position: relative; }
.vbars svg { display: block; max-width: 100%; height: auto; overflow: visible; }
.vbars .bar { fill: var(--chart); transition: opacity .12s; }
.vbars .bar.on { opacity: .7; }
.vbars .grid { stroke: var(--grid); stroke-width: 1; }
.vbars .axis { stroke: var(--axis); stroke-width: 1; }
.vbars .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.vbars .vlabel { fill: var(--ink); font-size: 12px; font-weight: 700; }
.vbars .hit { fill: transparent; cursor: default; outline: none; }
.vbars .hit:focus-visible { stroke: var(--ink); stroke-width: 1; }
.tip {
  position: absolute; transform: translateX(-50%); pointer-events: none; z-index: 5;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(80, 40, 10, .12);
  border-radius: 10px; padding: 5px 10px; white-space: nowrap; font-size: 12.5px; color: var(--muted);
}
.tip b { display: block; color: var(--ink); font-size: 15px; }

.speed-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.speed-head .k { color: var(--muted); font-size: 13.5px; }
.speed-head .v { font-size: 24px; font-weight: 800; }

.table-view { margin-top: 14px; padding: 12px 16px; }
.table-view summary { cursor: pointer; font-weight: 700; color: var(--brand-dark); }
.table-wrap { overflow-x: auto; margin-top: 10px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.table-wrap th, .table-wrap td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.table-wrap th:first-child, .table-wrap td:first-child { text-align: left; }
.table-wrap th { color: var(--muted); font-weight: 600; font-size: 13px; }
