:root {
  --c-bg: #f5f7fa;
  --c-surface: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #1e293b;
  --c-text-muted: #64748b;
  --c-primary: #2563eb;
  --c-primary-dark: #1d4ed8;
  --c-success: #16a34a;
  --c-warning: #f59e0b;
  --c-danger: #dc2626;
  --c-info: #0891b2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.05);
  --font:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.6;
  font-size: 14px;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Layout ===== */
.app-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.app-header .brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
}
.app-header .brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--c-text-muted);
  letter-spacing: 0.05em;
}
.app-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.app-nav a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--c-text-muted);
  font-weight: 500;
}
.app-nav a:hover { background: #eef2ff; color: var(--c-primary); text-decoration: none; }
.app-nav a.active { background: var(--c-primary); color: #fff; }

/* ── ハンバーガーボタン ── */
.nav-toggle {
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 18px;
  cursor: pointer;
  color: var(--c-text);
  line-height: 1;
}
.nav-toggle:hover { background: #f1f5f9; }

/* ── ドロワー(サイドメニュー)── */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-overlay.open { opacity: 1; pointer-events: auto; }

.nav-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: #fff;
  z-index: 9100;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.15);
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  color: var(--c-text);
}
.nav-drawer-close {
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
  padding: 4px 10px;
}
.nav-drawer-close:hover { color: #dc2626; }
.nav-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  overflow-y: auto;
}
.nav-drawer-body a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--c-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.nav-drawer-body a:hover {
  background: #eef2ff;
  color: var(--c-primary);
}
.nav-drawer-body a.active {
  background: var(--c-primary);
  color: #fff;
}

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--c-text);
  margin: 0 0 4px;
}
.page-subtitle {
  color: var(--c-text-muted);
  margin: 0 0 24px;
  font-size: 13px;
}

/* ===== Card ===== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; font-weight: 700; color: var(--c-text); margin: 0 0 12px; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header h2 { margin: 0; }

/* ===== Form ===== */
.form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}
.form-row label {
  padding-top: 8px;
  color: var(--c-text-muted);
  font-size: 13px;
  font-weight: 500;
}
.form-row .req::after { content: " *"; color: var(--c-danger); }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="url"],
input[type="month"],
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea { min-height: 80px; resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--c-surface);
  color: var(--c-text);
  font-family: var(--font);
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(0.95); }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); filter: none; }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-ghost { background: transparent; border-color: var(--c-border); color: var(--c-text-muted); }
.btn-sm { padding: 4px 8px; font-size: 12px; }

/* ===== Table ===== */
table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.list th, table.list td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
table.list th {
  background: #f8fafc;
  color: var(--c-text-muted);
  font-weight: 600;
  font-size: 12px;
}
table.list tr:hover td { background: #f8fafc; }
table.list td.actions { white-space: nowrap; }

/* ===== Status badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #e2e8f0;
  color: #475569;
}
.badge.new        { background: #dbeafe; color: #1d4ed8; }
.badge.contacted  { background: #fef3c7; color: #b45309; }
.badge.scheduled  { background: #ede9fe; color: #6d28d9; }
.badge.experienced{ background: #cffafe; color: #0e7490; }
.badge.joined     { background: #dcfce7; color: #166534; }
.badge.declined   { background: #f1f5f9; color: #64748b; }
.badge.active     { background: #dcfce7; color: #166534; }
.badge.paused     { background: #fef3c7; color: #b45309; }
.badge.inactive   { background: #f1f5f9; color: #64748b; }
.badge.join       { background: #dcfce7; color: #166534; }
.badge.leave      { background: #fee2e2; color: #991b1b; }
.badge.email      { background: #e0e7ff; color: #3730a3; }
.badge.line       { background: #d1fae5; color: #065f46; }
.badge.queued     { background: #fef3c7; color: #b45309; }
.badge.sent       { background: #dcfce7; color: #166534; }

/* ===== Stats ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--c-text-muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .diff  { font-size: 12px; margin-top: 4px; color: var(--c-text-muted); }
.stat .diff.up   { color: var(--c-success); }
.stat .diff.down { color: var(--c-danger); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 13px;
  animation: toast-in 0.2s ease-out;
}
.toast.success { background: var(--c-success); }
.toast.error   { background: var(--c-danger); }
@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }

/* ===== Utility ===== */
.muted { color: var(--c-text-muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; gap: 8px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.spacer { flex: 1; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }

/* ===== Charts (reports.html) ===== */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0 8px;
}
@media (max-width: 640px) {
  .chart-row { grid-template-columns: 1fr; }
}
.chart-box {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px 16px 8px;
}
.chart-title {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 600;
}

/* ===== Embedded form (trial-form.html) ===== */
body.embed {
  background: transparent;
  padding: 0;
}
body.embed .app-header,
body.embed .app-nav {
  display: none;
}
body.embed .app-main {
  padding: 16px;
  max-width: 600px;
}

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; gap: 4px; }
  .form-row label { padding-top: 0; }
  .app-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .app-main { padding: 16px 12px 80px; }
}

/* 🎬 デモ閲覧モード: 書き込み系ボタンを半透明化 */
body.demo-mode .btn-primary,
body.demo-mode .btn-danger,
body.demo-mode button[type="submit"]:not(#btn-login):not(#btn-demo) {
  opacity: 0.55;
}
body.demo-mode .btn-primary::after,
body.demo-mode .btn-danger::after {
  content: ' 🔒';
  font-size: 10px;
  vertical-align: middle;
}

/* ===== モバイル: 上部検索バー + 下部クイックアクション(640px以下のみ表示 / コーチのスマホ運用)===== */
.mobile-searchbar { display: none; }
.mobile-quickbar { display: none; }
@media (max-width: 640px) {
  .mobile-searchbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 8px 12px;
    margin: -16px -12px 12px;   /* .app-main の padding 16/12 を相殺して全幅に */
  }
  .mobile-searchbar input {
    flex: 1;
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    font-size: 14px;
    background: var(--c-bg);
  }
  .mobile-quickbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  }
  .mobile-quickbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    color: var(--c-text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
  }
  .mobile-quickbar a:active,
  .mobile-quickbar a:hover { color: var(--c-primary); background: #f1f5ff; }
  .mobile-quickbar .qb-ico { font-size: 19px; line-height: 1; }
  /* 埋め込みフォーム画面では出さない */
  body.embed .mobile-searchbar,
  body.embed .mobile-quickbar { display: none; }
}
