:root {
  --bg: #f6f4ef; --surface: #ffffff; --surface-2: #efece5; --line: #e2ddd2;
  --text: #1d1f22; --muted: #6b6f76; --accent: #1f6feb; --accent-ink: #fff;
  --hot: #1a9e5c; --hot-soft: #dff5e9; --warn: #c77700; --warn-soft: #fdf0db;
  --bad: #c9372c; --bad-soft: #fbe4e1; --info-soft: #e3edfd;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1e2125; --surface-2: #272b30; --line: #33383e;
    --text: #eceef0; --muted: #9aa1a9; --accent: #4c8dff; --accent-ink: #fff;
    --hot: #35c27d; --hot-soft: #183427; --warn: #f0a640; --warn-soft: #3a2c16;
    --bad: #ff6b5e; --bad-soft: #3b1f1c; --info-soft: #1d2b44;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1e2125; --surface-2: #272b30; --line: #33383e;
  --text: #eceef0; --muted: #9aa1a9; --accent: #4c8dff; --accent-ink: #fff;
  --hot: #35c27d; --hot-soft: #183427; --warn: #f0a640; --warn-soft: #3a2c16;
  --bad: #ff6b5e; --bad-soft: #3b1f1c; --info-soft: #1d2b44;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.wrap { max-width: 720px; margin: 0 auto; padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 12px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.top .who { color: var(--muted); font-size: 14px; }

/* nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-in { max-width: 720px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 9px; font-size: 11px; color: var(--muted); text-decoration: none; position: relative; }
.nav a .ic { font-size: 21px; line-height: 1; }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav .badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--bad); color: #fff; border-radius: 9px; font-size: 10px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

/* cards */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card h2 { font-size: 21px; margin: 0 0 4px; line-height: 1.25; letter-spacing: -.01em; }
.card h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }

.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.pill.hot { background: var(--hot-soft); color: var(--hot); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 12px 16px; min-height: 48px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text); text-decoration: none; text-align: center; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.hot { background: var(--hot); color: #fff; }
.btn.bad { background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 19px; border-radius: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 8px 4px; cursor: pointer; font-weight: 600; }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcomes .wide { grid-column: 1 / -1; }

/* script */
.script { white-space: pre-line; font-size: 17px; line-height: 1.55; }
.script mark { background: var(--warn-soft); color: inherit; padding: 0 3px; border-radius: 4px; }
details.fold { border-top: 1px solid var(--line); padding: 10px 0 2px; }
details.fold:first-of-type { border-top: 0; }
details.fold summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: "＋"; color: var(--muted); }
details.fold[open] summary::after { content: "－"; }
details.fold .script { padding: 6px 0 8px; }

.objgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.objgrid button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px; min-height: 46px; font-size: 14px; font-weight: 600; cursor: pointer; text-align: left; }

/* lead meta */
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.phone { font-size: 22px; font-weight: 700; letter-spacing: .01em; margin: 4px 0 12px; }

.hist { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.hist li { padding: 6px 0; border-top: 1px solid var(--line); }
.hist li:first-child { border-top: 0; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; display: flex; gap: 12px; align-items: center; cursor: pointer; border: 0; text-align: left; width: 100%; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex: none; }
.group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }

/* forms */
label.f { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
label.f > span { display: block; margin-bottom: 4px; }
.in { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px; min-height: 48px; font-size: 16px; }
textarea.in { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* stats */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 12px; }
.kpi b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--muted); }
.bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar.hot > i { background: var(--hot); }
.funnel .step { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; margin: 8px 0; }
.funnel .step .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.hours { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; align-items: end; height: 90px; }
.hours div { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.hours div i { position: absolute; bottom: 0; left: 0; right: 0; background: var(--hot); border-radius: 4px 4px 0 0; }
.hours-l { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.t td { padding: 8px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.goal { display: flex; align-items: center; gap: 14px; }
.goal .big { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.sheet-body { position: relative; background: var(--surface); width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
.sheet-body h3 { margin: 0 0 12px; font-size: 19px; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .e { font-size: 44px; }
.notice { background: var(--warn-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }
.notice.info { background: var(--info-soft); }
.mock { width: 100%; max-height: 280px; object-fit: cover; object-position: top; border-radius: 12px; display: block; margin: 8px 0; border: 1px solid var(--line); cursor: zoom-in; }
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login h1 { font-size: 28px; margin: 0 0 4px; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .7s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
