/* 顧客管理とフォロー連絡の体験版。色は common/base.css のトークンだけを使う */
.cf { max-width: 1180px; margin: 0 auto; padding: 20px var(--gutter) 56px; }

/* 作業の流れ（1→4） */
.cf-steps { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; width: fit-content; max-width: 100%; margin: 0 auto 22px; box-shadow: var(--shadow-s); }
.cf-steps button { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }
.cf-steps button:disabled { cursor: default; opacity: .55; }
.cf-steps button:not(:disabled):hover { background: var(--sunken); color: var(--ink); }
.cf-steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); font-size: 13px; flex: none; }
.cf-steps button[aria-current="step"] { background: var(--brand); color: #fff; }
.cf-steps button[aria-current="step"] .n { background: var(--accent); color: #fff; }
.cf-steps button.done .n { background: var(--ok-soft); color: var(--ok); }
.cf-steps-line { width: 16px; height: 2px; background: var(--line-2); flex: none; }

.scr-head { max-width: 800px; margin-bottom: 16px; }
.scr-head h2 { font-size: 24px; font-weight: 800; line-height: 1.4; }
.scr-lead { margin-top: 6px; color: var(--ink-2); line-height: 1.85; }
.sub-t { font-size: 16px; font-weight: 800; margin: 26px 0 8px; }
.tbl-note { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.btn-big { min-height: 50px; padding: 0 26px; font-size: 16px; border-radius: 12px; }

/* 1. 台帳 */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile { padding: 12px 14px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-s); }
.tile span { display: block; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.tile b { display: block; font-size: 26px; line-height: 1.3; font-weight: 800; color: var(--brand); }
.tile b small, .mtile b small { font-size: 13px; font-weight: 700; margin-left: 3px; color: var(--ink-2); }
.acts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0 22px; }
.act { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px 18px; box-shadow: var(--shadow-s); display: flex; flex-direction: column; align-items: flex-start; }
.act-t { font-weight: 800; font-size: 16px; }
.act-b { margin: 4px 0 12px; color: var(--ink-2); font-size: 14px; line-height: 1.7; flex: 1; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button { padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--ink-3); border: 1.5px solid var(--line); background: var(--surface); }
.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.auto-note { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); max-width: 100%; }
#ledgerWrap { max-height: 440px; }
.table-wrap table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.table-wrap th { position: sticky; top: 0; z-index: 1; background: var(--brand); color: #fff; font-weight: 700; text-align: left; padding: 8px 8px; white-space: nowrap; }
.table-wrap th.r { text-align: right; }
.table-wrap th.auto { background: var(--brand-2); }
.table-wrap td { padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table-wrap td.memo { white-space: normal; min-width: 150px; max-width: 190px; color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.table-wrap td.r { text-align: right; }
.table-wrap td.nowrap { white-space: nowrap; }
.table-wrap td.auto.off { color: var(--ink-3); background: var(--paper); text-align: center; }
.table-wrap td.auto.flash { animation: flash 1.1s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.table-wrap .blank { color: var(--bad); font-size: 12px; }
.table-wrap .no { color: var(--bad); }

/* 2. 指標 */
.mtiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.mtile { padding: 10px 12px; border-radius: var(--r-m); background: var(--brand-soft); border: 1px solid var(--line); }
.mtile span { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 700; line-height: 1.4; min-height: 32px; }
.mtile b { display: block; font-size: 20px; line-height: 1.3; font-weight: 800; color: var(--brand); white-space: nowrap; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.chart { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 14px 10px; box-shadow: var(--shadow-s); min-width: 0; }
.chart figcaption { font-weight: 800; font-size: 14.5px; margin-bottom: 6px; }
.chart-svg { min-height: 220px; overflow: hidden; }
.chart svg { display: block; max-width: 100%; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--ink-3); font-size: 10.5px; }
.chart .val { fill: var(--ink); font-size: 11px; font-weight: 700; }
.chart .bar { fill: var(--c1); }
.chart .bar.part { fill: var(--c1); opacity: .45; }
.chart .ln { fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .ln.dash { stroke-dasharray: 4 4; }
.chart .dot { stroke-width: 2; }
.chart .dot.hollow { fill: var(--surface) !important; }
.l-second { stroke: var(--c1); fill: var(--c1); }
.l-third { stroke: var(--accent); fill: var(--accent); }
.l-dormant { stroke: var(--ok); fill: var(--ok); }
.chart .ln.l-second, .chart .ln.l-third, .chart .ln.l-dormant { fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.legend .lg { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.lg.l-second { background: var(--c1); } .lg.l-third { background: var(--accent); } .lg.l-dormant { background: var(--ok); }
#metricsTable td.soft { color: var(--ink-3); font-style: italic; }
#metricsTable td.st-c { white-space: normal; min-width: 190px; font-size: 12.5px; line-height: 1.5; color: var(--warn); }
#metricsTable td.st-c.fixed { color: var(--ok); }

/* 3. 連絡する人 */
.tg-summary { font-size: 15px; margin-bottom: 10px; color: var(--ink); }
.rule-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fchip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 700; color: var(--ink-2); }
.fchip .num { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--sunken); color: var(--ink-2); line-height: 20px; }
.fchip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.fchip[aria-pressed="true"] .num { background: rgba(255, 255, 255, .22); color: #fff; }
.rule-help { font-size: 13.5px; color: var(--ink-2); margin: -4px 0 10px; }
.tg-list { display: grid; gap: 8px; }
.tg-row { display: grid; grid-template-columns: 44px minmax(0, 200px) minmax(0, 1fr); gap: 4px 10px; align-items: start; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-m); padding: 12px 14px 12px 8px; }
.tg-row.ready.on { border-color: var(--brand-2); box-shadow: 0 0 0 2px var(--brand-soft); }
.tg-row.skipped { background: var(--paper); border-style: dashed; }
.tg-chk { display: grid; place-items: center; height: 28px; }
.tg-chk input { width: 22px; height: 22px; accent-color: var(--brand); margin: 0; cursor: pointer; }
.tg-chk input:disabled { cursor: default; }
.tg-who { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.tg-who b { font-size: 15px; font-weight: 700; }
.tg-who .num { font-size: 12px; color: var(--ink-3); }
.tg-who .rc { margin-top: 2px; }
.tg-body { min-width: 0; }
.tg-reason { font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.tg-hito { margin-top: 6px; font-size: 14px; line-height: 1.75; padding: 8px 10px; background: var(--warn-soft); border-radius: var(--r-s); }
.ai-badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 0 6px; border-radius: 4px; background: var(--warn); color: #fff; margin-right: 8px; line-height: 18px; vertical-align: 1px; }
.tg-skip { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; font-weight: 700; color: var(--bad); }
.tg-more { margin-top: 6px; padding: 5px 0; font-size: 13px; font-weight: 700; color: var(--brand-2); text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.tg-more:hover { color: var(--accent-deep); }
.rc { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--rc, var(--ink-2)); background: color-mix(in srgb, var(--rc, var(--ink-2)) 12%, var(--surface)); }
.rc-second { --rc: var(--c1); } .rc-next { --rc: var(--c2); } .rc-dormant { --rc: var(--c5); } .rc-birthday { --rc: var(--c4); }
.fchip.rc-second:not([aria-pressed="true"]), .fchip.rc-next:not([aria-pressed="true"]), .fchip.rc-dormant:not([aria-pressed="true"]), .fchip.rc-birthday:not([aria-pressed="true"]) { color: var(--rc); border-color: color-mix(in srgb, var(--rc) 40%, var(--surface)); }
.tg-detail { margin-top: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--paper); }
.cmp { display: grid; grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1.3fr); gap: 8px; align-items: start; }
.cmp h4 { font-size: 12.5px; color: var(--ink-3); font-weight: 700; margin-bottom: 4px; }
.cmp-arrow { align-self: center; text-align: center; font-weight: 800; color: var(--accent); font-size: 18px; }
.memo-raw { font-size: 13.5px; line-height: 1.7; padding: 8px 10px; background: var(--surface); border-radius: var(--r-s); border: 1px solid var(--line); }
.cmp-col.sent dl { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: 13px; background: var(--surface); border: 1px solid var(--brand-soft); border-radius: var(--r-s); padding: 8px 10px; }
.cmp-col.sent dt { color: var(--ink-3); }
.cmp-col.sent dd { margin: 0; overflow-wrap: anywhere; }
.mask-n { margin-top: 6px; }
.detail-note { margin-top: 8px; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.skip-h { margin-top: 24px; }
.skip-n { margin: -4px 0 8px; }
.empty-msg { padding: 40px 20px; text-align: center; color: var(--ink-3); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-l); }
.ai-note { margin-top: 14px; padding: 10px 12px; background: var(--ok-soft); color: var(--ok); border-radius: var(--r-s); font-weight: 600; }
.tg-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin: 18px calc(var(--gutter) * -1) 0; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom)); background: rgba(246, 244, 238, .94); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.tg-count { font-weight: 700; margin-right: auto; }
.lbl-short { display: none; }

/* 4. 下書き */
.mail { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.mail-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-s); max-height: 620px; overflow-y: auto; }
.ml-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--brand); color: #fff; font-weight: 700; }
.ml-n { font-size: 12px; background: rgba(255, 255, 255, .2); padding: 0 8px; border-radius: 999px; line-height: 20px; }
.ml-item { display: grid; gap: 2px; width: 100%; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ml-item:hover { background: var(--paper); }
.ml-item.sel { background: var(--brand-soft); }
.ml-draft { font-size: 11.5px; font-weight: 700; color: var(--bad); }
.ml-to { font-size: 13.5px; font-weight: 700; overflow-wrap: anywhere; }
.ml-sub { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-item .rc { justify-self: start; margin-top: 3px; height: 20px; font-size: 11px; padding: 0 8px; }
.mail-view { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-s); padding: 18px 22px 20px; min-width: 0; }
.mv-back { display: none; margin-bottom: 10px; font-weight: 700; color: var(--brand-2); font-size: 14px; padding: 4px 0; }
.mv-subject { font-size: 19px; font-weight: 800; line-height: 1.5; }
.mv-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.mv-meta b { margin-right: 6px; color: var(--ink-3); font-weight: 700; }
.mv-mode { display: inline-flex; margin-top: 12px; border: 1.5px solid var(--line-2); border-radius: 999px; overflow: hidden; }
.mv-mode button { padding: 6px 14px; font-size: 13px; font-weight: 700; color: var(--ink-2); background: var(--surface); }
.mv-mode button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.mv-body { margin-top: 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.95; font-size: 14.5px; }
.mv-body mark { background: var(--warn-soft); box-shadow: 0 0 0 2px var(--warn-soft); border-radius: 3px; color: inherit; }
.mv-note { margin-top: 14px; font-size: 12.5px; color: var(--ink-3); }
.draft-note { list-style: none; margin: 16px 0 0; padding: 12px 16px; display: grid; gap: 4px; background: var(--ok-soft); color: var(--ok); border-radius: var(--r-m); font-size: 13.5px; font-weight: 600; line-height: 1.7; }
.draft-note li::before { content: "✓"; margin-right: 8px; }

/* 動作中 */
.busy { position: fixed; inset: 0; z-index: 1050; display: grid; place-items: center; background: rgba(22, 36, 44, .45); padding: 16px; }
.busy-card { width: min(360px, 100%); background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-l); padding: 24px; text-align: center; }
.busy-spin { width: 36px; height: 36px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-t { margin-top: 14px; font-weight: 700; font-size: 16px; }
.busy-n { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

@media (max-width: 1100px) {
  .mtiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
  .mail { grid-template-columns: minmax(0, 1fr); }
  .mail[data-open="list"] .mail-view { display: none; }
  .mail[data-open="view"] .mail-list { display: none; }
  .mail-list { max-height: none; }
  .mv-back { display: inline-block; }
}
@media (max-width: 640px) {
  .cf { padding-top: 14px; }
  .cf-steps { gap: 4px; padding: 5px; margin-bottom: 16px; }
  .cf-steps button { padding: 6px 8px 6px 6px; gap: 6px; font-size: 13px; }
  .cf-steps button:not([aria-current="step"]) .t { display: none; }
  .cf-steps-line { width: 8px; }
  .scr-head h2 { font-size: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile b { font-size: 22px; }
  .acts { grid-template-columns: minmax(0, 1fr); }
  .act .btn { width: 100%; }
  .mtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mtile span { min-height: 0; }
  #ledgerWrap { max-height: 360px; }
  .tg-row { grid-template-columns: 38px minmax(0, 1fr); padding: 12px 12px 12px 4px; }
  .tg-body { grid-column: 1 / -1; padding-left: 4px; }
  .tg-row.skipped .tg-body { margin-top: 2px; }
  .cmp { grid-template-columns: minmax(0, 1fr); }
  .cmp-arrow { transform: rotate(90deg); }
  .tg-bar { gap: 10px; }
  .tg-bar .btn { flex: 1; min-width: 0; padding: 0 12px; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .mail-view { padding: 14px 14px 16px; }
  .mv-subject { font-size: 17px; }
  .fchip { padding: 6px 11px; font-size: 13.5px; }
}

/* 「AIに渡した内容を見る」を開いた状態 */
.tg-row.open { box-shadow: 0 0 0 2px var(--brand); border-radius: var(--r-m); }
.tg-more.is-open { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1.5px solid var(--brand); border-radius: 999px; background: var(--brand-soft); color: var(--brand-2); text-decoration: none; }
.tg-more::after { content: '▼'; font-size: 10px; margin-left: 6px; }
.tg-more.is-open::after { content: '▲'; }
.tg-detail { border-color: var(--brand); border-width: 2px; background: var(--surface); }
.detail-head { margin: -12px -12px 10px; padding: 8px 12px; background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 700; border-radius: calc(var(--r-m) - 2px) calc(var(--r-m) - 2px) 0 0; }
