/* SOCIA フロントエンド 共通スタイル
   承認済みモックアップ(mockups/frontend-mockup.html)のデザインを踏襲。
   カテゴリー3色: cat-a=緑(登録・組織) cat-b=琥珀(キャンペーン運用) cat-c=青(分析・お金) */
:root {
  --bg: #F3F6F7;
  --panel: #FFFFFF;
  --ink: #20303A;
  --muted: #5D6E78;
  --line: #DCE4E8;
  --brand: #0E7569;
  --brand-soft: #E3F1EF;
  --brand-ink: #FFFFFF;
  --accent: #B45309;
  --accent-soft: #FBF0DD;
  --ok: #15803D;
  --ok-soft: #E4F3E9;
  --warn: #B45309;
  --warn-soft: #FBF0DD;
  --bad: #B91C1C;
  --bad-soft: #FBE7E7;
  --new-bg: #FBF0DD;
  --new-ink: #92400E;
  --cat-a: #0E7569;
  --cat-a-soft: #E3F1EF;
  --cat-b: #B45309;
  --cat-b-soft: #FBF0DD;
  --cat-c: #44619D;
  --cat-c-soft: #E9EEF8;
  --shadow: 0 1px 3px rgba(24, 40, 48, 0.08), 0 4px 16px rgba(24, 40, 48, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E181D;
    --panel: #16242B;
    --ink: #E2EAEE;
    --muted: #8FA2AC;
    --line: #263840;
    --brand: #2FA99A;
    --brand-soft: #12312E;
    --brand-ink: #06211E;
    --accent: #E3A24A;
    --accent-soft: #33270F;
    --ok: #4CC272;
    --ok-soft: #10291A;
    --warn: #E3A24A;
    --warn-soft: #33270F;
    --bad: #E8756B;
    --bad-soft: #351717;
    --new-bg: #33270F;
    --new-ink: #E3A24A;
    --cat-a: #2FA99A;
    --cat-a-soft: #12312E;
    --cat-b: #E3A24A;
    --cat-b-soft: #33270F;
    --cat-c: #8CA5DC;
    --cat-c-soft: #1A2436;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Segoe UI", sans-serif;
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }

/* ===== アプリ全体レイアウト ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  /* 左サイドバーは固定し、右側の内容だけスクロールさせる(0822チェック「左サイドバー」行。3画面共通) */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); position: static; height: auto; }
}
.brand-row { display: flex; align-items: center; gap: 8px; padding: 0 16px 12px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
}
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.role-tag { font-size: 10px; color: var(--muted); display: block; line-height: 1.2; }
.navgroup {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 16px 3px; margin-top: 9px;
  border-top: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: 0.1em; color: var(--muted); font-weight: 700;
}
.sidebar .navgroup:first-of-type { border-top: none; margin-top: 0; }
.navgroup::before { content: ""; width: 4px; height: 12px; border-radius: 2px; background: var(--muted); flex: none; }
.navgroup.cat-a::before { background: var(--cat-a); }
.navgroup.cat-b::before { background: var(--cat-b); }
.navgroup.cat-c::before { background: var(--cat-c); }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 16px; color: var(--ink); text-decoration: none; font-size: 13px;
}
.nav a:hover { background: var(--bg); }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; border-right: 3px solid var(--brand); }
.nav.cat-a a.on { background: var(--cat-a-soft); color: var(--cat-a); border-right-color: var(--cat-a); }
.nav.cat-b a.on { background: var(--cat-b-soft); color: var(--cat-b); border-right-color: var(--cat-b); }
.nav.cat-c a.on { background: var(--cat-c-soft); color: var(--cat-c); border-right-color: var(--cat-c); }
.nav a.locked { color: var(--muted); cursor: not-allowed; }
.nav a.locked::after { content: "🔒"; font-size: 11px; }
/* 承認待ち・否認でロック中のメニュー説明(鍵マークの近くに常時表示。2026-09-03) */
.nav-locknote { padding: 4px 16px 8px; font-size: 11px; line-height: 1.5; color: var(--warn); }

/* 画面右上の登録状態バッジ(承認待ち=黄/承認済み=緑/否認=赤) */
.status-badge { font-size: 12px; padding: 4px 12px; border: none; font-family: inherit; }
.status-badge.clickable { cursor: pointer; text-decoration: underline; }

/* 画面中央のモーダル(登録完了の案内・否認理由) */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 30, 40, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 26px 28px; max-width: 520px; width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,0.25); font-size: 14px; line-height: 1.8; }
.modal-box h3 { margin: 0 0 10px; }
.modal-box .modal-lead { font-size: 15px; font-weight: 700; white-space: pre-line; margin: 0 0 6px; }
.modal-actions { margin-top: 16px; text-align: right; }
.sidebar-foot { margin-top: auto; padding: 12px 16px 0; border-top: 1px solid var(--line); font-size: 12px; }

.main { flex: 1; padding: 0; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: flex-end; align-items: center; gap: 12px;
  padding: 10px 26px; border-bottom: 1px solid var(--line); background: var(--panel);
  font-size: 12.5px; color: var(--muted);
}
.topbar .who { font-weight: 700; color: var(--ink); }
.content { padding: 22px 26px; }
/* プロジェクト別テーブルの合計行(0822チェック 行3) */
.data tr.total-row td { background: var(--bg); font-weight: 700; }
.main h2 { margin: 0 0 2px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.main h2::before { content: ""; width: 5px; height: 19px; border-radius: 3px; background: var(--brand); flex: none; }
.main h2.cat-a::before { background: var(--cat-a); }
.main h2.cat-b::before { background: var(--cat-b); }
.main h2.cat-c::before { background: var(--cat-c); }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }

/* ===== 汎用部品 ===== */
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--bg); color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.card .k { font-size: 11.5px; color: var(--muted); }
.card .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card .d { font-size: 11px; color: var(--muted); }

.callout {
  display: flex; gap: 10px; align-items: baseline;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 16px;
}
.callout .mark { font-weight: 800; color: var(--accent); flex: none; }
.callout b { font-variant-numeric: tabular-nums; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; }

table.data { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--panel); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); margin-bottom: 16px; }
table.data th {
  text-align: left; font-size: 11px; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line); padding: 8px 12px; white-space: nowrap;
}
table.data td { border-bottom: 1px solid var(--line); padding: 9px 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: none; }

.form { max-width: 620px; display: grid; gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="url"], .field input[type="tel"],
.field input[type="date"], .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); font-family: inherit; font-size: 13px;
}
.field textarea { min-height: 64px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.btn {
  border: none; border-radius: 8px; padding: 9px 18px; font-size: 13.5px; font-weight: 700;
  background: var(--brand); color: var(--brand-ink);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.small { padding: 4px 12px; font-size: 12px; }
.btn.approve { background: var(--ok); color: #fff; }
.btn.reject { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

/* 階段テーブルエディタ */
.tiers { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.tiers .thead, .tiers .trow {
  display: grid; grid-template-columns: 44px 1fr 1fr 34px; gap: 8px;
  align-items: center; padding: 7px 12px;
}
.tiers .thead { background: var(--bg); font-size: 11px; color: var(--muted); font-weight: 600; }
.tiers .trow { border-top: 1px solid var(--line); }
.tiers input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); font-variant-numeric: tabular-nums; font-family: inherit; }
.tiers .seq { color: var(--muted); font-weight: 700; }
/* 数値欄の共通部品(0822Ver NPO 25行目): 右寄せ・等幅数字。エラー時は赤枠+直下に赤字 */
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.num[aria-invalid="true"] { border-color: var(--bad); }
.numwrap { display: block; min-width: 0; }
.numwrap .field-error { white-space: normal; line-height: 1.3; }
.tiers .inf-label { color: var(--muted); font-size: 12.5px; }
.tiers .del { background: none; border: none; color: var(--bad); font-size: 15px; }
.tiers-note { font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ログイン */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 46px 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .brand-mark { width: 44px; height: 44px; font-size: 20px; margin: 0 auto 8px; border-radius: 12px; }
.role-tabs { display: flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin-bottom: 16px; }
.role-tabs button { flex: 1; border: none; background: var(--panel); color: var(--muted); padding: 8px 4px; font-size: 12.5px; font-weight: 600; }
.role-tabs button.on { background: var(--brand); color: var(--brand-ink); }
.login-alt { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 14px; }

/* ソーシャルログイン(Google/Facebook/X) */
.social-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0 10px; }
.social-divider::before, .social-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.social-btns { display: flex; flex-direction: column; gap: 8px; }
.btn-social {
  display: block; text-align: center; text-decoration: none;
  background: var(--panel, #fff); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600;
}
.btn-social:hover { background: var(--bg); }
.social-note { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; line-height: 1.6; }
.social-agree { text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; margin-top: 10px; }

/* 入力途中の下書き復元の案内(2026-09-04 8行目) */
.draft-note { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; margin-bottom: 12px; }
.login-lang { text-align: center; margin-top: 20px; }

/* 言語切替 */
.lang { display: inline-flex; }
.lang button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 3px 12px; font-size: 12px; font-weight: 600;
}
.lang button:first-of-type { border-radius: 6px 0 0 6px; }
.lang button:last-of-type { border-radius: 0 6px 6px 0; border-left: none; }
.lang button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* 通知・状態表示 */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  background: var(--ink); color: var(--bg);
  border-radius: 10px; padding: 12px 18px; font-size: 13px; box-shadow: var(--shadow);
  max-width: 340px;
}
.toast.error { background: var(--bad); color: #fff; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.error-box { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; }
.notice-box { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin-bottom: 14px; }
.progressbar { height: 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin: 6px 0 4px; }
.progressbar span { display: block; height: 100%; background: var(--brand); }
.linkbox { display: flex; gap: 8px; align-items: center; }
.linkbox input { flex: 1; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* 登録ステップ */
.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.steps .step {
  flex: 1 1 140px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); font-size: 12.5px;
}
.steps .step .no { font-size: 10.5px; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.steps .step.done { border-color: var(--ok); }
.steps .step.done .no { color: var(--ok); }

/* 登録フロー仕上げ(2026-09-02): 項目直下の赤字エラーと同意チェック行 */
.field-error { color: var(--bad); font-size: 12px; margin-top: 3px; }
.checkline { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.6; }
.checkline input[type="checkbox"] { margin-top: 3px; }
