:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --ink: #202326;
  --muted: #65707a;
  --line: #dce1e5;
  --teal: #0f766e;
  --blue: #3c6fb6;
  --coral: #d95f50;
  --green: #23835b;
  --amber: #b7791f;
  --shadow: 0 18px 40px rgba(29, 36, 42, 0.08);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { min-height: 38px; border: 0; border-radius: 6px; padding: 0 13px; color: #fff; background: var(--teal); cursor: pointer; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary { background: var(--blue); }
button.ghost { color: var(--ink); background: #eef1f3; }
button.danger { background: var(--coral); }
a { color: var(--teal); font-weight: 800; text-decoration: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand, .top-actions, .card-actions, .summary, .toolbar, .section-head, .form-actions { display: flex; align-items: center; gap: 10px; }
.top-actions { flex-wrap: wrap; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 8px; color: #fff; background: var(--teal); font-weight: 800; }
.brand strong, .brand span { display: block; }
.brand span, .muted, .meta, label span { color: var(--muted); font-size: 0.82rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
  gap: 18px;
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 30px) 28px;
}

.summary {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.funnel { grid-column: 1 / -1; }
.funnel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.funnel-trust { margin-top: 10px; }

.stat, .operations, .learners, .material-card, .generator, .analytics {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat { min-height: 86px; padding: 14px; }
.stat span { display: block; color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.stat strong { display: block; margin-top: 8px; font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1; }

.operations, .learners, .generator, .analytics { padding: 16px; align-self: start; }
.learners { grid-column: 2; grid-row: 2 / span 3; position: sticky; top: 94px; max-height: calc(100vh - 112px); overflow: auto; }
.section-head { justify-content: space-between; margin-bottom: 12px; }
.section-head h2, .learners h2 { margin: 0; }
.section-head span { color: var(--muted); font-size: 0.82rem; }
.toolbar { align-items: end; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
label { display: grid; gap: 6px; min-width: min(100%, 240px); }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 10px 11px; background: #fbfcfd; }

.generate-form { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.generate-form .wide { grid-column: span 2; }
.check-row { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 10px 0; }
.check-row input { width: auto; }
.check-row span { font-weight: 800; }
.form-actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; min-height: 38px; }

.materials { display: grid; gap: 12px; }
.material-card { padding: 14px; }
.material-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.material-card h2 { margin: 0; overflow-wrap: anywhere; font-size: 1.05rem; }
.pill { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: 5px 9px; color: #fff; background: var(--green); font-size: 0.76rem; font-weight: 800; }
.pill.unpublished { background: var(--coral); }
.material-grid { display: grid; grid-template-columns: 110px 120px minmax(220px, 1fr); gap: 10px; margin-top: 12px; align-items: end; }
.notes { grid-column: 1 / -1; }
textarea { min-height: 74px; resize: vertical; }
.card-actions { justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

.learner-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 10px; background: #fbfcfd; }
.learner-card strong { display: block; overflow-wrap: anywhere; }
.learner-actions { margin-top: 10px; }
.learner-actions button { min-height: 32px; padding: 0 10px; font-size: 0.82rem; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; background: #f7f9fa; }
td strong, td span { display: block; }
tbody tr:last-child td { border-bottom: 0; }
tr.weak td { background: #fff7ed; }
.empty { padding: 20px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); background: #fff; }

@media (max-width: 940px) {
  .layout, .summary, .material-grid, .generate-form { grid-template-columns: 1fr; }
  .generate-form .wide { grid-column: auto; }
  .learners { grid-column: auto; grid-row: auto; position: static; max-height: none; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

/* 学習者招待（B2B 受け入れ入組） */
.invite-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.invite-form label { display: grid; gap: 4px; }
.invite-form span { color: var(--muted); font-size: 0.82rem; }
.invite-result { margin-top: 12px; display: grid; gap: 6px; }
.invite-link { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite-link code { flex: 1; min-width: 240px; padding: 8px 10px; border: 1px solid var(--line, rgba(128,128,128,0.35)); border-radius: 6px; word-break: break-all; font-size: 0.8rem; }
