@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@500;600;700&family=Zen+Kaku+Gothic+New:wght@400;500;700&display=swap');

/* ============================================================
   つむぎ 共通スタイル(設計仕様書 v2 第15章)
   和モダン: 生成り紙 + 深松色 + 明朝見出し
   v2 で追加する UI も既存トーンを厳守し、新しい色を足さない
   ============================================================ */

:root {
  --ink: #1c3329;
  --ink-soft: #46594f;
  --paper: #f6f4ee;
  --card: #ffffff;
  --line: #e2ddd0;
  --pine: #2e5941;
  --pine-soft: #e7efe9;
  --amber: #a87b1f;
  --amber-soft: #f4ecd9;
  --red: #a9432b;
  --red-soft: #f6e6e0;
  --neutral-soft: #eceae2;
}

* { box-sizing: border-box; margin: 0; }

html, body {
  font-family: 'Zen Kaku Gothic New', 'Hiragino Kaku Gothic ProN', sans-serif;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.85;
}

a { color: var(--pine); }

.serif { font-family: 'Shippori Mincho', 'Hiragino Mincho ProN', serif; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.05em; }

/* ---------------- トップバー ---------------- */

.topbar {
  background: var(--ink);
  color: #f3efe6;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 12px; text-decoration: none; color: inherit; }
.brand h1 { font-size: 22px; font-weight: 600; letter-spacing: 0.12em; }
.brand small { font-size: 11px; letter-spacing: 0.2em; opacity: 0.7; }
.nametag {
  background: #f3efe6; color: var(--ink);
  border-radius: 4px; padding: 6px 14px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  border-left: 4px solid var(--pine);
}
.nametag b { font-size: 14px; }
.nametag button {
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 4px; padding: 2px 10px; font-size: 12px; cursor: pointer;
  font-family: inherit;
}
.nametag button:hover { background: var(--neutral-soft); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 40px 28px 80px; }

/* ---------------- タブ ---------------- */

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--ink); margin-bottom: 32px; flex-wrap: wrap; }
.tabs a, .tabs button {
  border: none; background: transparent; cursor: pointer; text-decoration: none;
  padding: 13px 22px; font-size: 15px; font-family: inherit; color: var(--ink-soft);
  border-radius: 6px 6px 0 0; display: inline-block;
}
.tabs a.on, .tabs button.on { background: var(--ink); color: #f3efe6; font-weight: 700; }
.tabs a:not(.on):hover, .tabs button:not(.on):hover { background: var(--neutral-soft); }
.tabs a:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

/* 科目タブ(10-1): 既存 .tabs を流用し、選択中は pine の下線 */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.subtabs button {
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  padding: 10px 18px; font-size: 14px; color: var(--ink-soft);
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.subtabs button.on { color: var(--pine); font-weight: 700; border-bottom-color: var(--pine); }
.subtabs button:hover:not(.on) { background: var(--neutral-soft); }

/* ---------------- カード ---------------- */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 30px 32px; margin-bottom: 24px;
}
.eyebrow {
  font-size: 12px; letter-spacing: 0.22em; color: var(--pine);
  font-weight: 700; text-transform: uppercase; margin-bottom: 10px;
}
h2 { font-size: 21px; font-weight: 600; margin-bottom: 20px; }
h3 { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
h4 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

.stucard {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  padding: 28px 30px; margin-bottom: 26px;
  border-top: 4px solid var(--pine);
}
.stucard .head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.muted { color: var(--ink-soft); font-size: 14px; }
.divline { border: none; border-top: 1px solid var(--line); margin: 26px 0; }

/* KPI カード(6-1) */
.kpigrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px;
}
.kpi .k { font-size: 12px; letter-spacing: 0.1em; color: var(--ink-soft); font-weight: 700; }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.3; font-family: 'Shippori Mincho', serif; }
.kpi .v.alert { color: var(--red); }

/* ---------------- チップ ---------------- */

.chip {
  display: inline-block; border-radius: 999px; padding: 2px 12px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.chip.good  { background: var(--pine-soft); color: var(--pine); }
.chip.ok    { background: var(--pine-soft); color: var(--ink-soft); }
.chip.warn  { background: var(--amber-soft); color: var(--amber); }
.chip.danger{ background: var(--red-soft); color: var(--red); }
.chip.neutral{ background: var(--neutral-soft); color: var(--ink-soft); }

.chipcol { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.chiprow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------------- 帯 ---------------- */

.alert {
  background: var(--red-soft); border-left: 4px solid var(--red);
  border-radius: 8px; padding: 16px 20px; color: var(--red);
  font-weight: 700; font-size: 15px; margin-bottom: 14px; line-height: 1.6;
}
.okline {
  background: var(--pine-soft); border-left: 4px solid var(--pine);
  border-radius: 8px; padding: 16px 20px; color: var(--pine);
  font-weight: 700; font-size: 15px; margin-bottom: 14px; line-height: 1.6;
}
.warnline {
  background: var(--amber-soft); border-left: 4px solid var(--amber);
  border-radius: 8px; padding: 16px 20px; color: var(--amber);
  font-weight: 700; font-size: 15px; margin-bottom: 14px; line-height: 1.6;
}

/* ---------------- テーブル ---------------- */

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
th {
  text-align: left; padding: 16px 18px; background: var(--ink); color: #f3efe6;
  font-weight: 500; font-size: 13px; letter-spacing: 0.06em; white-space: nowrap;
}
th:first-child { border-radius: 8px 0 0 0; }
th:last-child  { border-radius: 0 8px 0 0; }
td { padding: 18px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.7; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--paper); }
td.num, th.num { text-align: right; }
table.compact td { padding: 10px 14px; font-size: 14px; }
table.compact th { padding: 10px 14px; }

/* ---------------- ボタン ---------------- */

.btn {
  border: none; border-radius: 7px; padding: 12px 24px; font-size: 15px;
  cursor: pointer; font-family: inherit; font-weight: 700;
  display: inline-block; text-decoration: none; text-align: center;
  white-space: nowrap;
}
.btn.primary { background: var(--pine); color: #fff; }
.btn.primary:hover { background: #244a35; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); }
.btn.ghost:hover { background: var(--neutral-soft); }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: 7px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

.linkbtn {
  background: none; border: none; padding: 0; color: var(--pine);
  font-family: inherit; font-size: 13px; cursor: pointer; text-decoration: underline;
}

/* ---------------- フォーム ---------------- */

label.fl { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }
.req { color: var(--red); font-size: 12px; margin-left: 6px; }
.hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; line-height: 1.6; }
.hint.warn { color: var(--amber); background: var(--amber-soft); padding: 8px 12px; border-radius: 6px; }
.hint.err { color: var(--red); }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="time"], input[type="number"], input[type="tel"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 7px;
  padding: 12px 14px; font-size: 15px; font-family: inherit; background: #fff;
  color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pine); outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { background: var(--neutral-soft); color: var(--ink-soft); }

.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.frow3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.fone { margin-bottom: 22px; }
.radios { display: flex; gap: 22px; flex-wrap: wrap; font-size: 15px; }
.radios label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkcol { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.checkcol label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; line-height: 1.6; }
.checkcol input { margin-top: 6px; }

.errbox {
  background: var(--red-soft); border-left: 4px solid var(--red); color: var(--red);
  border-radius: 8px; padding: 12px 16px; font-size: 14px; font-weight: 700; margin-bottom: 16px;
}
.okbox {
  background: var(--pine-soft); border-left: 4px solid var(--pine); color: var(--pine);
  border-radius: 8px; padding: 12px 16px; font-size: 14px; font-weight: 700; margin-bottom: 16px;
}

/* ---------------- ログイン ---------------- */

.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { max-width: 460px; width: 100%; }
.login-title { text-align: center; margin-bottom: 32px; }
.login-title h1 { font-size: 40px; letter-spacing: 0.3em; font-weight: 600; }
.login-title p { color: var(--ink-soft); margin-top: 8px; font-size: 14px; letter-spacing: 0.08em; }

/* ---------------- 確認ダイアログ / モーダル(12章) ---------------- */

/*
  ★ 確認ダイアログは「既定で非表示」にし、JS が開いたときだけ表示する。
    x-show(JS)だけに隠蔽を任せると、CSP違反やJSの読み込み失敗で
    Alpine の式評価が止まった瞬間に全ダイアログが表示されたままになり、
    画面が操作不能になる(実際に起きた不具合)。
    CSS 側を fail-closed にしておけば、JS が動かない環境でも
    破壊的操作の確認ダイアログが勝手に出ることはない。
*/
.overlay {
  position: fixed; inset: 0; background: rgba(28, 51, 41, 0.45);
  display: none; align-items: center; justify-content: center; padding: 20px;
  z-index: 100;
}
.overlay.is-open { display: flex; }
.modal {
  background: var(--card); border-radius: 10px; max-width: 560px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 28px 30px;
  border: 1px solid var(--line);
}
.modal.wide { max-width: 860px; }
.modal h3 { font-size: 19px; font-family: 'Shippori Mincho', serif; margin-bottom: 18px; }
.modal .sumtable { margin: 16px 0; font-size: 14px; }
.modal .sumtable div.r { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 5px 0; }
.modal .sumtable div.r span:first-child { color: var(--ink-soft); font-weight: 700; }
.modal .body { font-size: 14px; line-height: 1.8; color: var(--ink-soft); margin-bottom: 20px; white-space: pre-wrap; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.modal.tone-danger { border-top: 4px solid var(--red); }
.modal.tone-warn { border-top: 4px solid var(--amber); }
.modal.tone-default { border-top: 4px solid var(--pine); }

/* ---------------- ウィザード(6-6a) ---------------- */

.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; font-size: 13px; }
.steps .step { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.steps .step .no {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.steps .step.on { color: var(--pine); font-weight: 700; }
.steps .step.on .no { border-color: var(--pine); background: var(--pine-soft); color: var(--pine); }
.steps .step.done .no { background: var(--pine); border-color: var(--pine); color: #fff; }
.steps .sep { color: var(--line); }

.subblock {
  border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px;
  margin-bottom: 18px; background: var(--paper);
}

/* ---------------- アコーディオン / 展開行 ---------------- */

.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 24px; margin-top: 14px;
}
.detailrow {
  display: grid; grid-template-columns: 150px 1fr; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.detailrow > .lbl { color: var(--ink-soft); font-weight: 700; font-size: 14px; }
.detailrow:last-child { border-bottom: none; }

/* ---------------- スコア推移グラフ(10-5) ---------------- */

.chart { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .goalline { stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .series { fill: none; stroke: var(--pine); stroke-width: 2; }
.chart .dot { fill: var(--pine); }
.chart text { font-size: 10px; fill: var(--ink-soft); }

/* ---------------- ポップオーバー ---------------- */

.pop { position: relative; display: inline-block; }
.pop .popbody {
  position: absolute; z-index: 30; top: 100%; left: 0; margin-top: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; min-width: 220px; box-shadow: 0 6px 18px rgba(28,51,41,0.12);
}

/* ---------------- レスポンシブ ---------------- */

@media (max-width: 900px) {
  .kpigrid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .frow, .frow3 { grid-template-columns: 1fr; }
  .wrap { padding: 20px 12px 48px; }
  .card { padding: 16px; }
  .kpigrid { grid-template-columns: 1fr; }
  .detailrow { grid-template-columns: 1fr; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ============================================================
   Laravel(Blade)版で追加したスタイル
   ============================================================ */

/* Alpine.js の x-cloak(初期表示のちらつき防止) */
[x-cloak] { display: none !important; }

/* バリデーションエラー */
.field-error { color: var(--red); font-size: 13px; margin-top: 6px; font-weight: 700; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--red); }

/* フラッシュメッセージ */
.flash { margin-bottom: 20px; }

/* テーブル内のフォーム要素を詰める */
td form { display: inline; }
td input[type="number"], td input[type="text"], td select { padding: 8px 10px; font-size: 14px; }

/* 一時パスワード表示 */
.temppw { font-size: 18px; letter-spacing: 0.08em; }
