:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #6b6f76;
  --line: #e2e0db;
  --accent: #8a2d1f;
  --accent-soft: #f6e9e6;
  --good: #1f7a4d;
  --warn: #a35d00;
  --bad: #b42318;
  --radius: 8px;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 15px; line-height: 1.6; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

.topbar {
  display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; }
.brand-sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 8px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user { margin-left: auto; color: var(--muted); font-size: 13px; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.banner { background: #fff7e6; border-bottom: 1px solid #f1d9a8; color: #6b4300; padding: 8px 24px; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
th.sortable { cursor: pointer; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #faf9f7; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-wrap table { min-width: 760px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }

input[type="text"], input[type="date"], input[type="email"], input[type="url"], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; align-items: center; gap: 4px; }

.btn { font: inherit; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: #f3f2ef; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eeece8; color: var(--ink); white-space: nowrap; }
.badge.s-送信済 { background: #e8f0fb; color: #1d4f91; }
.badge.s-返信あり { background: #fff1d6; color: var(--warn); }
.badge.s-引き継ぎ済 { background: var(--accent-soft); color: var(--accent); }
.badge.s-成約 { background: #e3f4ea; color: var(--good); }
.badge.s-見送り { background: #f1f1f1; color: var(--muted); }
.badge.test { background: #ede7f6; color: #4527a0; }
.overdue { color: var(--bad); font-weight: 600; }
.stars { color: #b8860b; letter-spacing: 1px; }

.ai-note { font-size: 12px; color: var(--warn); background: #fff7e6; border-radius: 6px; padding: 4px 8px; display: inline-block; margin-bottom: 8px; }
dl.facts { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; word-break: break-word; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 12px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline pre { white-space: pre-wrap; font-family: inherit; margin: 4px 0 0; font-size: 13px; background: #faf9f7; padding: 8px; border-radius: 6px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 50; max-width: 90vw; }
.toast.error { background: var(--bad); }
.empty { color: var(--muted); padding: 12px 0; }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { gap: 12px; padding: 0 12px; }
  .brand-sub, .user { display: none; }
  .container { padding: 16px; }
  dl.facts { grid-template-columns: 1fr; }
}
