/* =============================================================================
 * notion-theme.css — 経営アプリ Notion風デザイン
 * Notionの配色・余白・フォント・サイドバー・中央カラム・カラーピル・テーブルを再現。
 * 既存のクラス名(.card/.kpi/.panel/.badge/.kanban/table等)は維持＝JS無改変。
 * ========================================================================== */
:root {
  --n-text:#37352f;        /* Notionの本文黒 */
  --n-muted:#787774;       /* 補助グレー */
  --n-desc:#9b9a97;        /* 説明文グレー */
  --n-line:#e9e9e7;        /* 罫線 */
  --n-bg:#ffffff;          /* メイン背景 */
  --n-sidebar:#f7f7f5;     /* サイドバー背景 */
  --n-hover:#efefed;       /* ホバー */
  --n-sel:#e8e7e4;         /* 選択中 */
  --n-blue:#2383e2;        /* Notionブルー(リンク/アクセント) */
  /* レガシー変数を Notion 値にマップ（既存インラインstyleの色を吸収） */
  --ink:#37352f; --muted:#787774; --line:#e9e9e7; --bg:#ffffff;
  --brand:#2383e2; --brand-soft:#e7f3f8; --estimate:#cb912f;
  --confirmed:#448361; --rock:#337ea9; --aband:#9065b0; --bband:#c14c8a;
}
* { box-sizing:border-box; }
body {
  margin:0; background:var(--n-bg); color:var(--n-text);
  font-family:ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Kaku Gothic ProN","Noto Sans JP",sans-serif;
  font-size:15px; line-height:1.5; -webkit-font-smoothing:antialiased;
}

/* ---- Auth gate ---- */
#gate { position:fixed; inset:0; background:#fbfbfa; display:flex; align-items:center; justify-content:center; z-index:100; }
#gate .card { background:#fff; border:1px solid var(--n-line); border-radius:8px; padding:36px; width:360px; box-shadow:0 1px 3px rgba(15,15,15,.1); }
#gate h1 { font-size:22px; font-weight:700; margin:0 0 4px; color:var(--n-text); }
#gate p { color:var(--n-muted); font-size:13px; margin:0 0 20px; }
#gate input { width:100%; border:1px solid var(--n-line); border-radius:5px; padding:10px 12px; margin-bottom:10px; font-size:14px; background:#fbfbfa; }
#gate input:focus { outline:none; border-color:var(--n-blue); background:#fff; }
#gate button { width:100%; background:var(--n-blue); color:#fff; border:0; border-radius:5px; padding:10px; font-size:14px; cursor:pointer; font-weight:500; }
#gate button:hover { background:#1a6fc0; }
#gate .err { color:#eb5757; font-size:12px; margin-top:8px; min-height:16px; }
#gate .note { color:var(--n-desc); font-size:11px; margin-top:16px; line-height:1.6; }

/* ---- App shell: サイドバー + 中央カラム ---- */
#app { display:none; }
#app.shown { display:flex; min-height:100vh; }
.n-sidebar {
  width:240px; flex-shrink:0; background:var(--n-sidebar); border-right:1px solid var(--n-line);
  padding:10px 8px; display:flex; flex-direction:column; gap:1px; height:100vh; position:sticky; top:0; overflow-y:auto;
}
.n-sidebar .n-brand { font-size:14px; font-weight:600; color:var(--n-text); padding:8px 10px 12px; display:flex; align-items:center; gap:8px; }
.n-sidebar .n-brand .logo { width:22px; height:22px; border-radius:5px; background:var(--n-text); color:#fff; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:700; }
.n-navitem {
  display:flex; align-items:center; gap:9px; padding:6px 10px; border-radius:5px; cursor:pointer;
  font-size:14px; color:var(--n-muted); background:none; border:0; width:100%; text-align:left; line-height:1.3;
}
.n-navitem .ic { width:18px; text-align:center; font-size:15px; opacity:.85; }
.n-navitem:hover { background:var(--n-hover); }
.n-navitem.active { background:var(--n-sel); color:var(--n-text); font-weight:500; }
.n-sidebar .n-spacer { flex:1; }
.n-sidebar .n-foot { padding:10px; border-top:1px solid var(--n-line); font-size:11px; color:var(--n-desc); }
.n-sidebar .n-foot button { background:none; border:0; color:var(--n-blue); cursor:pointer; font-size:11px; padding:0; }

.n-main { flex:1; min-width:0; background:var(--n-bg); }
.n-page { max-width:900px; margin:0 auto; padding:56px 60px 100px; }
.asof { font-size:12px; color:var(--n-desc); margin-bottom:20px; }

/* モバイル: ハンバーガー */
.n-hamburger { display:none; position:fixed; top:12px; left:12px; z-index:120; background:#fff; border:1px solid var(--n-line); border-radius:5px; width:34px; height:34px; cursor:pointer; font-size:16px; }
@media (max-width:820px){
  .n-sidebar { position:fixed; left:0; top:0; z-index:110; transform:translateX(-100%); transition:transform .2s; box-shadow:2px 0 12px rgba(0,0,0,.12); }
  .n-sidebar.open { transform:translateX(0); }
  .n-hamburger { display:block; }
  .n-page { padding:56px 20px 80px; }
}

.panel { display:none; }
.panel.active { display:block; }

/* ---- ページタイトル / 見出し ---- */
.n-page h1, .panel > h1 { font-size:32px; font-weight:700; letter-spacing:-.4px; margin:0 0 18px; color:var(--n-text); }
.card h2, .panel h2 { font-size:18px; font-weight:600; margin:26px 0 4px; color:var(--n-text); }
h3 { font-size:16px; font-weight:600; margin:18px 0 6px; }
.card .desc, .panel .desc { font-size:13px; color:var(--n-desc); margin:0 0 12px; line-height:1.5; }

/* ---- KPI / カード（Notionはフラット寄り） ---- */
.kpis { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:24px; }
.kpi { background:#fbfbfa; border:1px solid var(--n-line); border-radius:6px; padding:14px 16px; }
.kpi .lbl { font-size:12px; color:var(--n-muted); display:flex; align-items:center; gap:6px; }
.kpi .val { font-size:24px; font-weight:700; margin-top:6px; letter-spacing:-.5px; color:var(--n-text); }
.kpi .sub { font-size:11px; color:var(--n-desc); margin-top:4px; }
.dot { width:9px; height:9px; border-radius:50%; display:inline-block; }
.card { background:#fff; border:1px solid var(--n-line); border-radius:6px; padding:18px 20px; margin-bottom:16px; }
.chartbox { position:relative; height:300px; }
.chartbox.tall { height:340px; }
.legend-note { font-size:12px; color:var(--n-desc); margin-top:10px; line-height:1.6; }
.legend-note b { color:var(--estimate); }
.scope-banner { background:#fbf3db; border:1px solid #f5e0a3; color:#9a6700; border-radius:6px; padding:12px 14px; font-size:12px; line-height:1.7; margin-bottom:18px; }
.scope-banner b { color:#8a5a00; }

/* ---- インラインDB風テーブル ---- */
table { width:100%; border-collapse:collapse; font-size:14px; }
th, td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--n-line); }
th { font-size:12px; color:var(--n-muted); font-weight:500; cursor:pointer; user-select:none; white-space:nowrap; background:#fff; }
thead tr { border-bottom:1px solid var(--n-line); }
th.num, td.num { text-align:right; font-variant-numeric:tabular-nums; }
tbody tr:hover { background:var(--n-sidebar); }
a { color:var(--n-blue); text-decoration:none; }
a:hover { text-decoration:underline; }

/* ---- Notion風カラーピル/タグ ---- */
.badge, .b-bucket { display:inline-block; padding:2px 9px; border-radius:4px; font-size:12px; font-weight:500; line-height:1.5; }
.b-active   { background:#dbeddb; color:#2b593f; }   /* 緑 = Active/Paid/Invoiced */
.b-inactive { background:#e3e2e0; color:#5a5852; }   /* グレー = inactive/Forecast */
.b-lead     { background:#fbf3db; color:#86601a; }   /* 黄 = lead */
.b-bucket { background:#e3e2e0; color:#5a5852; }
.b-bucket.warn { background:#ffe2dd; color:#9b3327; } /* 赤 = overdue/cancelled */
/* status pill ヘルパー（JSが付与する場合用） */
.pill { display:inline-block; padding:2px 9px; border-radius:4px; font-size:12px; font-weight:500; }
.pill-green { background:#dbeddb; color:#2b593f; }
.pill-gray  { background:#e3e2e0; color:#5a5852; }
.pill-red   { background:#ffe2dd; color:#9b3327; }
.pill-blue  { background:#d3e5ef; color:#28456c; }
.pill-yellow{ background:#fbf3db; color:#86601a; }
.pill-purple{ background:#ede0f3; color:#492f64; }

/* ---- ツールバー / 入力（Notion風・控えめ） ---- */
.toolbar { display:flex; gap:8px; margin-bottom:12px; flex-wrap:wrap; align-items:center; }
.toolbar input, .toolbar select, input, select {
  border:1px solid var(--n-line); border-radius:5px; padding:6px 10px; font-size:13px; background:#fff; color:var(--n-text);
}
.toolbar input:focus, .toolbar select:focus, input:focus, select:focus { outline:none; border-color:var(--n-blue); }
.toolbar .count { font-size:12px; color:var(--n-desc); margin-left:auto; }
button { font-family:inherit; }

/* ---- Kanban（Notionのボードビュー風） ---- */
.kanban { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; }
.kcol { background:var(--n-sidebar); border:0; border-radius:6px; padding:10px; }
.kcol h3 { font-size:13px; margin:0 0 10px; display:flex; justify-content:space-between; font-weight:600; }
.kcol h3 span { color:var(--n-desc); font-weight:500; }
.kcard { background:#fff; border:1px solid var(--n-line); border-radius:5px; padding:9px 11px; margin-bottom:8px; font-size:13px; box-shadow:0 1px 2px rgba(15,15,15,.05); }
.kcard .meta { color:var(--n-desc); font-size:11px; margin-top:5px; display:flex; gap:8px; flex-wrap:wrap; }

.loading { color:var(--n-desc); font-size:13px; padding:30px; text-align:center; }
tr.ar-alert td { background:#fdecea; }
td.ar-overdue { color:#d9534f; font-weight:600; }

/* ---- プロパティ行（詳細ページ） ---- */
.n-prop { display:flex; gap:10px; font-size:14px; padding:4px 0; }
.n-prop .k { color:var(--n-muted); min-width:150px; display:flex; align-items:center; gap:6px; }

@media (max-width:760px){ .kpis,.kanban{ grid-template-columns:1fr 1fr; } }
@media (max-width:480px){ .kpis,.kanban{ grid-template-columns:1fr; } }
