:root{
  --navy:#1F4E79; --navy-d:#163a5a; --navy-l:#2E75B6; --teal:#0e7490;
  --bg:#f4f6f9; --card:#ffffff; --line:#e3e8ef; --text:#1f2733; --muted:#7a8699;
  --green:#15803d; --green-bg:#dcfce7; --amber:#b45309; --amber-bg:#fef3c7;
  --red:#b91c1c; --red-bg:#fee2e2; --blue-bg:#e8f1fb;
}
*{box-sizing:border-box;}
body{margin:0;font-family:"Hiragino Kaku Gothic ProN","Meiryo UI","Segoe UI",sans-serif;
  background:var(--bg);color:var(--text);font-size:14px;line-height:1.6;}
a{color:var(--navy-l);text-decoration:none;}

/* topbar */
.topbar{background:var(--navy);color:#fff;padding:0 24px;height:54px;display:flex;
  align-items:center;justify-content:space-between;box-shadow:0 1px 4px rgba(0,0,0,.15);
  position:sticky;top:0;z-index:20;}
.brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:16px;letter-spacing:.03em;color:#fff;}
.brand a{color:#fff;}
.brand .logo{width:26px;height:26px;border-radius:6px;background:#fff;color:var(--navy);
  display:flex;align-items:center;justify-content:center;font-weight:800;}
.right{display:flex;align-items:center;gap:12px;font-size:13px;}
.dom{background:rgba(255,255,255,.15);padding:2px 8px;border-radius:10px;font-size:11px;}
.right .ava{width:30px;height:30px;border-radius:50%;background:var(--navy-l);
  display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;overflow:hidden;}
.right .ava img{width:100%;height:100%;object-fit:cover;}
.right .lo{color:rgba(255,255,255,.8);font-size:12px;}

.wrap{max-width:1240px;margin:0 auto;padding:22px 24px 60px;}
.pagehead{display:flex;align-items:flex-end;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:18px;}
.pagehead h1{margin:0;font-size:22px;color:var(--navy);}
.pagehead .meta{color:var(--muted);font-size:12px;}
.refresh{padding:6px 13px;border:1px solid var(--line);border-radius:8px;background:#fff;
  color:var(--navy);font-size:12px;font-weight:600;}
.refresh:hover{background:var(--blue-bg);border-color:var(--navy-l);}

.sectitle{font-size:13px;font-weight:700;color:var(--navy);margin:26px 0 12px;display:flex;align-items:center;gap:8px;}
.sectitle::before{content:"";width:4px;height:15px;background:var(--navy);border-radius:2px;}
.sectitle .hint{font-weight:400;color:var(--muted);font-size:11px;}

/* KPI cards */
.grid{display:grid;gap:14px;}
.kpis{grid-template-columns:repeat(6,1fr);}
@media(max-width:980px){.kpis{grid-template-columns:repeat(3,1fr);}}
.kpi{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:14px 16px;
  box-shadow:0 1px 2px rgba(20,40,70,.04);}
.kpi .label{color:var(--muted);font-size:11.5px;margin-bottom:5px;}
.kpi .val{font-size:26px;font-weight:800;color:var(--navy);line-height:1.1;}
.kpi .val small{font-size:12px;font-weight:600;color:var(--muted);}
.kpi .sub{font-size:11px;margin-top:4px;}
.up{color:var(--green);} .down{color:var(--red);} .flat{color:var(--muted);}

.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px 20px;
  box-shadow:0 1px 2px rgba(20,40,70,.04);}
.cols2{display:grid;grid-template-columns:1fr 1fr;gap:14px;}
@media(max-width:980px){.cols2{grid-template-columns:1fr;}}
.cardttl{font-size:14px;font-weight:700;color:var(--navy);margin:0 0 14px;}

/* funnel */
.funnel{display:flex;align-items:flex-end;gap:0;flex-wrap:nowrap;overflow-x:auto;padding-top:8px;}
.fstep{flex:1;min-width:120px;text-align:center;position:relative;padding:0 6px;
  display:flex;flex-direction:column;justify-content:flex-end;}
.fnum{font-size:30px;font-weight:800;color:var(--navy);line-height:1;margin-bottom:6px;}
.fnum small{font-size:13px;font-weight:700;color:var(--muted);margin-left:2px;}
.fnum.zero{color:var(--muted);}
.fbar{margin:0 auto;width:78%;border-radius:8px 8px 0 0;}
.fstep .fname{font-size:13px;color:var(--text);margin-top:10px;font-weight:700;}
.fstep .fpct{font-size:11px;color:var(--muted);margin-top:2px;}
.conv{position:absolute;bottom:34px;right:-10px;z-index:2;background:#fff;border:1px solid var(--line);
  border-radius:10px;font-size:11px;color:var(--teal);font-weight:700;padding:2px 7px;box-shadow:0 1px 2px rgba(20,40,70,.06);}

/* stacked bar chart */
.bars{display:flex;align-items:flex-end;gap:18px;height:170px;padding:8px 4px 0;}
.bcol{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;height:100%;}
.bstack{width:60%;max-width:46px;display:flex;flex-direction:column;justify-content:flex-end;position:relative;height:100%;}
.bseg{width:100%;}
.bseg.active{background:linear-gradient(180deg,var(--navy-l),var(--navy));border-radius:6px 6px 0 0;}
.bseg.passed{background:#cbd2dc;}
.bv{position:absolute;top:-19px;left:50%;transform:translateX(-50%);font-size:12px;font-weight:700;color:var(--navy);}
.blabel{font-size:11px;color:var(--muted);margin-top:7px;}
.legend-inline{font-size:11px;color:var(--muted);margin-top:8px;display:flex;gap:14px;}
.legend-inline .sw{display:inline-block;width:10px;height:10px;border-radius:3px;margin-right:5px;vertical-align:middle;}

/* donut */
.donutwrap{display:flex;align-items:center;gap:22px;}
.donut{width:130px;height:130px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;}
.donut .hole{width:84px;height:84px;border-radius:50%;background:#fff;display:flex;
  flex-direction:column;align-items:center;justify-content:center;}
.donut .hole b{font-size:24px;color:var(--navy);}
.donut .hole span{font-size:10px;color:var(--muted);}
.legend{font-size:12.5px;}
.legend div{display:flex;align-items:center;gap:8px;margin-bottom:8px;}
.legend .sw{width:11px;height:11px;border-radius:3px;}

/* horizontal stage bars */
.hbar{display:flex;align-items:center;gap:10px;margin-bottom:9px;font-size:12.5px;}
.hbar .hl{width:90px;text-align:right;color:var(--text);flex:none;}
.hbar .ht{flex:1;background:#eef1f5;border-radius:5px;height:16px;overflow:hidden;}
.hbar .hf{height:100%;background:var(--navy-l);border-radius:5px;}
.hbar .hf.last{background:var(--green);}
.hbar .hn{width:24px;color:var(--muted);font-weight:700;}

/* table */
table{width:100%;border-collapse:collapse;font-size:12.5px;}
th,td{padding:8px 10px;border-bottom:1px solid var(--line);text-align:left;vertical-align:middle;}
thead th{color:var(--muted);font-weight:600;font-size:11px;border-bottom:2px solid var(--line);}
tbody tr:hover{background:#f8fafc;}
.fa{color:var(--muted);}
.num{text-align:right;font-variant-numeric:tabular-nums;}

/* pills / stage */
.pill{display:inline-block;padding:2px 8px;border-radius:9px;font-size:11px;font-weight:600;white-space:nowrap;}
.pill.stg{background:#eef1f5;color:var(--navy);}
.pill.stg.mou{background:#e0e7ff;color:#4338ca;}
.pill.stg.dd{background:#dcfce7;color:var(--green);}
.pill.stg.pass{background:#f1f3f6;color:var(--muted);}
.pill.high{background:var(--red-bg);color:var(--red);}
.pill.mid{background:var(--amber-bg);color:var(--amber);}
.pill.low{background:var(--green-bg);color:var(--green);}

/* ball-in-court */
.ball{display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:9px;font-size:11px;font-weight:700;white-space:nowrap;}
.ball.ours{background:var(--red-bg);color:var(--red);}
.ball.theirs{background:var(--amber-bg);color:var(--amber);}
.ball.none{background:#f1f3f6;color:var(--muted);}
.ball .bd{width:7px;height:7px;border-radius:50%;background:currentColor;}

.days{font-weight:700;}
.days.stale{color:var(--red);} .days.warn{color:var(--amber);} .days.ok{color:var(--muted);}
.stalebadge{background:var(--red-bg);color:var(--red);padding:1px 6px;border-radius:8px;font-size:10px;margin-left:5px;}
.digest{color:var(--text);font-size:12px;}
.digest .dt{color:var(--muted);font-size:10.5px;display:block;}
.glink{color:var(--navy-l);text-decoration:none;font-size:13px;}

/* filter chips */
.chips{display:flex;flex-wrap:wrap;gap:7px;margin-bottom:12px;}
.chip{padding:5px 12px;border-radius:14px;border:1px solid var(--line);background:#fff;
  color:var(--muted);font-size:12px;cursor:pointer;user-select:none;}
.chip.on{background:var(--navy);color:#fff;border-color:var(--navy);font-weight:600;}
.chip:hover{border-color:var(--navy-l);}

.note{background:#fffbeb;border:1px solid #fcd9a4;border-radius:10px;padding:12px 16px;
  font-size:12.5px;color:#7a5a16;margin-top:26px;display:flex;gap:10px;}
code{background:#eef1f5;padding:1px 5px;border-radius:4px;font-size:11.5px;}
.empty{color:var(--muted);text-align:center;padding:30px;}

/* ===== 案件詳細 ===== */
.crumbs{color:var(--muted);font-size:12px;margin-bottom:10px;}
.crumbs a:hover{text-decoration:underline;}
.backbtn{display:inline-flex;align-items:center;gap:6px;margin:2px 0 12px;padding:7px 14px;
  background:#fff;border:1px solid var(--line);border-radius:8px;color:var(--navy);
  font-size:13px;font-weight:600;box-shadow:0 1px 2px rgba(20,40,70,.04);}
.backbtn:hover{background:var(--blue-bg);border-color:var(--navy-l);}
.dealhead{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;flex-wrap:wrap;}
.dealhead h1{font-size:23px;margin:0 0 4px;color:var(--navy);}
.dealhead .sub{color:var(--muted);font-size:13px;}
.reco{display:inline-flex;align-items:center;gap:8px;padding:9px 16px;border-radius:10px;font-weight:700;font-size:14px;}
.reco.go{background:var(--green-bg);color:var(--green);border:1px solid #a7e3bf;}
.reco.cond{background:var(--amber-bg);color:var(--amber);border:1px solid #fcd9a4;}
.reco.nogo{background:var(--red-bg);color:var(--red);border:1px solid #f3b4b4;}
.reco.none{background:#f1f3f6;color:var(--muted);border:1px solid var(--line);}
.reco .dot{width:9px;height:9px;border-radius:50%;background:currentColor;}

.tabs{display:flex;gap:4px;margin:20px 0 0;border-bottom:2px solid var(--line);flex-wrap:wrap;}
.tab{padding:11px 20px;cursor:pointer;font-weight:600;color:var(--muted);border-bottom:3px solid transparent;
  margin-bottom:-2px;user-select:none;font-size:14px;}
.tab .n{display:inline-flex;width:20px;height:20px;border-radius:50%;background:var(--line);color:var(--muted);
  align-items:center;justify-content:center;font-size:11px;margin-right:7px;}
.tab:hover{color:var(--navy);}
.tab.active{color:var(--navy);border-bottom-color:var(--navy);}
.tab.active .n{background:var(--navy);color:#fff;}
.panel{display:none;padding-top:22px;}
.panel.active{display:block;}

.kpi .tag{display:inline-block;margin-top:7px;font-size:11px;padding:2px 8px;border-radius:9px;}
.tag.ok{background:var(--green-bg);color:var(--green);}
.tag.warn{background:var(--amber-bg);color:var(--amber);}
.tag.info{background:var(--blue-bg);color:var(--navy-l);}

/* rendered markdown */
.md h2{font-size:15px;color:var(--navy);margin:18px 0 8px;}
.md h3{font-size:13.5px;color:var(--navy-d);margin:14px 0 6px;}
.md h4{font-size:12.5px;color:var(--text);margin:10px 0 4px;}
.md p{margin:6px 0;}
.md ul,.md ol{margin:6px 0;padding-left:20px;}
.md li{margin-bottom:4px;}
.md table{margin:10px 0;}
.md th{background:var(--navy);color:#fff;border:1px solid var(--line);padding:7px 9px;}
.md td{border:1px solid var(--line);padding:7px 9px;}
.md hr{border:none;border-top:1px solid var(--line);margin:14px 0;}
.cardgrid{display:grid;grid-template-columns:1fr 1fr;gap:14px;}
@media(max-width:980px){.cardgrid{grid-template-columns:1fr;}}
.card h3.ch{margin:0 0 12px;font-size:15px;color:var(--navy);display:flex;align-items:center;gap:8px;
  padding-bottom:9px;border-bottom:1px solid var(--line);}

/* forms (members管理) */
input[type=text], input[type=email], select{font-family:inherit;font-size:13px;padding:7px 9px;
  border:1px solid var(--line);border-radius:7px;background:#fff;color:var(--text);width:100%;}
input:focus, select:focus{outline:none;border-color:var(--navy-l);}
.btn{display:inline-flex;align-items:center;gap:5px;padding:7px 14px;border-radius:7px;border:1px solid var(--navy);
  background:var(--navy);color:#fff;font-size:12.5px;font-weight:600;cursor:pointer;}
.btn:hover{background:var(--navy-d);}
.btn.sm{padding:5px 10px;font-size:11.5px;}
.btn.ghost{background:#fff;color:var(--navy);}
.btn.ghost:hover{background:var(--blue-bg);}
.btn.danger{background:#fff;color:var(--red);border-color:#f3b4b4;}
.btn.danger:hover{background:var(--red-bg);}
.formrow{display:grid;grid-template-columns:1.4fr 1.6fr 0.8fr 1.4fr auto;gap:10px;align-items:center;margin-bottom:10px;}
@media(max-width:880px){.formrow{grid-template-columns:1fr;}}
.flash{border-radius:8px;padding:10px 14px;font-size:12.5px;margin-bottom:16px;}
.flash.ok{background:var(--green-bg);color:var(--green);}
.flash.err{background:var(--red-bg);color:var(--red);}
.flbl{font-size:11px;color:var(--muted);margin-bottom:3px;}

/* login */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#1F4E79,#163a5a);}
.login-card{background:#fff;border-radius:16px;padding:42px 40px;width:380px;max-width:90%;
  box-shadow:0 20px 50px rgba(0,0,0,.3);text-align:center;}
.login-card .llogo{width:54px;height:54px;border-radius:12px;background:var(--navy);color:#fff;
  display:flex;align-items:center;justify-content:center;font-weight:800;font-size:26px;margin:0 auto 18px;}
.login-card h1{font-size:18px;color:var(--navy);margin:0 0 6px;}
.login-card p{color:var(--muted);font-size:12.5px;margin:0 0 26px;}
.gbtn{display:inline-flex;align-items:center;gap:10px;width:100%;justify-content:center;
  padding:12px;border:1px solid var(--line);border-radius:10px;background:#fff;color:var(--text);
  font-weight:600;font-size:14px;cursor:pointer;}
.gbtn:hover{background:#f8fafc;border-color:var(--navy-l);}
.gbtn svg{width:18px;height:18px;}
.login-err{background:var(--red-bg);color:var(--red);border-radius:8px;padding:9px 12px;font-size:12px;margin-bottom:18px;}
.login-note{margin-top:22px;font-size:11px;color:var(--muted);}
