
:root{--bg:#f6f7f9;--card:#fff;--text:#202124;--muted:#6b7280;--line:#e5e7eb;--accent:#18a8c9;--soft:#eaf8fb;--up:#269d42;--down:#e04c49}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Sans","Yu Gothic",sans-serif}
header{background:#fff;border-bottom:1px solid var(--line)}
.top{max-width:1180px;margin:auto;padding:16px 20px;display:flex;justify-content:space-between;gap:12px;align-items:center}
.brand{font-size:24px;font-weight:900}.tagline{font-size:13px;color:var(--muted);margin-top:3px}
nav{max-width:1180px;margin:auto;padding:0 20px;display:flex;gap:24px}
nav button{border:0;background:transparent;padding:12px 0;border-bottom:3px solid transparent;font-weight:800;color:var(--muted);cursor:pointer}
nav button.active{color:var(--text);border-color:var(--accent)}
main{max-width:1180px;margin:22px auto;padding:0 18px 70px}.panel{display:none}.panel.active{display:block}
.hero{display:flex;justify-content:space-between;gap:12px;align-items:end;margin-bottom:14px;flex-wrap:wrap}
h1{font-size:29px;margin:0 0 5px}h2{font-size:19px;margin:0 0 10px}h3{font-size:16px;margin:0 0 6px}
.card{background:#fff;border:1px solid var(--line);border-radius:16px;padding:17px}
.kpis{display:grid;grid-template-columns:repeat(5,1fr);gap:10px}.kpi .label{font-size:12px;color:var(--muted)}.kpi .value{font-size:25px;font-weight:900;margin:6px 0}
.delta{font-size:12px;font-weight:850}.up{color:var(--up)}.down{color:var(--down)}.flat{color:var(--muted)}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-top:14px}.section{margin-top:14px}
.todo{display:flex;flex-direction:column;gap:10px}.todo-card{border:1px solid var(--line);border-radius:13px;padding:14px}
.pill{display:inline-block;background:#f1f3f5;border-radius:999px;padding:4px 8px;font-size:11px;font-weight:800}
.why{color:var(--muted);font-size:13px;line-height:1.6;margin:6px 0}.rec{background:#f8fafc;border-radius:9px;padding:10px 12px;font-size:14px;line-height:1.6}
.primary,.secondary{font:inherit;border-radius:9px;padding:9px 12px;font-weight:800;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;min-height:40px;line-height:1.2;-webkit-appearance:none;appearance:none;text-decoration:none}
.primary{background:var(--text);color:#fff!important;border:1px solid var(--text)}.secondary{background:#fff;color:var(--text)!important;border:1px solid var(--line)}
.primary:focus-visible,.secondary:focus-visible,select:focus-visible{outline:3px solid rgba(24,168,201,.25);outline-offset:2px}
.compare-box{display:flex;gap:12px;align-items:end;flex-wrap:wrap;background:#fff;border:1px solid var(--line);border-radius:14px;padding:12px 14px}
.compare-field label{display:block;font-size:11px;font-weight:800;color:var(--muted);margin-bottom:4px}
.compare-field select{min-width:170px;border:1px solid #d8dde5;border-radius:9px;padding:9px 10px;font:inherit;background:#fff;color:var(--text)}
.compare-arrow{font-weight:900;color:var(--muted);padding-bottom:9px}
.period-note{font-size:12px;color:var(--muted);margin-top:6px}
table{width:100%;border-collapse:collapse;font-size:13px}th,td{padding:10px 8px;border-bottom:1px solid var(--line);text-align:right}
th:first-child,td:first-child,th:nth-child(2),td:nth-child(2){text-align:left}th{font-size:11px;color:var(--muted)}
.big{font-size:16px;font-weight:900}.bar{height:11px;background:#edf0f3;border-radius:999px;overflow:hidden}.bar span{display:block;height:100%;background:var(--accent)}
.pair{padding:10px 0;border-bottom:1px solid var(--line)}.plus{font-size:18px;color:var(--muted);margin:2px 0}
.detail-section{display:none}body.show-detail .detail-section{display:block}
.abcgrid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.abccard{border:1px solid var(--line);border-radius:13px;padding:14px}
.letter{width:30px;height:30px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-weight:900;margin-right:7px}.A{background:#e7f5ec;color:#167644}.B{background:#fff4dc;color:#8f5c00}.C{background:#f1f2f4;color:#5d6570}
.trend{display:flex;align-items:end;gap:18px;height:210px;padding:15px 8px 5px;border-bottom:1px solid var(--line)}.col{flex:1;height:100%;display:flex;flex-direction:column;justify-content:end;align-items:center;gap:5px}.colbar{width:52px;background:linear-gradient(#43c3dc,#beeaf2);border-radius:7px 7px 0 0}
.small{font-size:12px;color:var(--muted)}.empty{padding:22px;text-align:center;color:var(--muted);border:1px dashed #ccd1d7;border-radius:12px}
.measure{border:1px solid var(--line);border-radius:13px;padding:13px;margin-top:10px}
.modal{position:fixed;inset:0;background:rgba(20,25,35,.35);display:none;align-items:center;justify-content:center;padding:18px;z-index:30}.modal.show{display:flex}.modalbox{width:min(620px,100%);background:#fff;border-radius:16px;padding:18px}
.formgrid{display:grid;grid-template-columns:1fr 1fr;gap:10px}label{font-size:12px;font-weight:800}input,select,textarea{width:100%;padding:10px;border:1px solid #d8dde5;border-radius:8px;font:inherit;margin-top:4px}textarea{min-height:70px}.actions{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}
@media(max-width:850px){.kpis{grid-template-columns:repeat(2,1fr)}.grid2,.abcgrid{grid-template-columns:1fr}}
@media(max-width:520px){.kpis{grid-template-columns:1fr}.formgrid{grid-template-columns:1fr}.top{align-items:flex-start;flex-direction:column}.compare-box{width:100%}.compare-field{width:100%}.compare-field select{width:100%}.compare-arrow{display:none}}

.combo-controls{display:flex;gap:10px;align-items:end;flex-wrap:wrap;margin:10px 0 14px}
.combo-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
.combo-card{border:1px solid var(--line);border-radius:13px;padding:13px}
.combo-items{font-weight:850;line-height:1.55}
.combo-meta{display:flex;gap:10px;flex-wrap:wrap;margin-top:7px;font-size:12px;color:var(--muted)}
.metric-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.metric{background:#fff;border:1px solid var(--line);border-radius:12px;padding:12px}
.metric .n{font-size:22px;font-weight:900}
.basketdist{display:grid;grid-template-columns:repeat(6,1fr);gap:7px}
.basketcell{border:1px solid var(--line);border-radius:10px;padding:9px;text-align:center}
.basketcell .n{font-size:18px;font-weight:900}
@media(max-width:850px){.combo-grid,.metric-grid{grid-template-columns:1fr 1fr}.basketdist{grid-template-columns:repeat(3,1fr)}}
@media(max-width:520px){.combo-grid,.metric-grid{grid-template-columns:1fr}.basketdist{grid-template-columns:repeat(2,1fr)}}

/* 実データ画面：狭い画面では表の中だけ横スクロールする。 */
:root{--accent:#1389a2;--soft:#e9f5f7}body{line-height:1.65}.top{max-width:1240px}.brand{letter-spacing:.05em}main,nav{max-width:1240px}.kpis{grid-template-columns:repeat(5,minmax(0,1fr))}.kpi .value{font-size:clamp(21px,2.1vw,29px)}.card{box-shadow:0 2px 8px #142b3a04}.section{margin-top:20px}.hero h1{font-size:27px}.eyebrow{font-size:12px;letter-spacing:.1em;color:var(--accent);font-weight:800}.notice{border-left:3px solid #d4a63e;background:#fff9e9;padding:12px 16px;border-radius:6px;margin:15px 0;font-size:13px}.notice.error{border-color:#b63832;background:#fff0ee;color:#932722}.table-scroll{overflow-x:auto}table{min-width:570px}th{white-space:nowrap}td:first-child{min-width:150px}.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.toolbar input,.toolbar select{width:auto;margin:0}.toolbar label{white-space:nowrap}.muted{color:var(--muted)}[hidden]{display:none!important}.auth{max-width:520px;margin:7vh auto}.auth h1{font-size:25px}.auth input{margin:12px 0}.auth .primary{width:100%}.logout{font-size:12px}.summary{background:#eaf8fb;border:1px solid #c9eaf0;padding:17px;border-radius:12px}.summary strong{font-size:18px}.todo-card{background:white}.todo-card .primary{margin-top:12px}.panel-heading{margin-bottom:20px}.period-bar{margin-bottom:22px}.pill{color:#32606b;background:#edf5f7}.measure{background:#fff}.measure p{margin:6px 0}.measure .toolbar{margin-top:10px}details{margin-top:20px}summary{cursor:pointer;font-weight:800;padding:12px 0;color:#196879}dialog{border:0;border-radius:18px;max-width:640px;width:calc(100% - 32px);max-height:90vh;padding:24px;box-shadow:0 20px 80px #0003}dialog::backdrop{background:#15263788}.dialog-head{display:flex;justify-content:space-between;align-items:center}.dialog-head button{border:0;background:transparent;font-size:25px;cursor:pointer}.annual-bars{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:8px;min-width:720px;height:230px;align-items:end}.month-col{height:100%;display:flex;flex-direction:column;justify-content:end;text-align:center;font-size:11px}.month-bar{background:#62bacb;border-radius:5px 5px 0 0;min-height:1px;margin:5px 6px}.months{overflow:auto}.empty{background:#fafbfc}.metric .n{line-height:1.3;margin-top:8px}.footer{margin-top:28px;font-size:12px;color:var(--muted)}button:disabled{opacity:.5;cursor:wait}button:focus-visible,a:focus-visible,input:focus-visible,summary:focus-visible{outline:3px solid #18a8c966;outline-offset:3px}.table-search{max-width:340px;margin:10px 0}.rec{margin:10px 0}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
@media(max-width:900px){.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.kpis .kpi:first-child{grid-column:1/-1}.grid2{grid-template-columns:1fr}nav{gap:26px}.brand{font-size:22px}}
@media(max-width:520px){.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.kpi .value{font-size:23px}.card{padding:14px}.metric-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.formgrid{grid-template-columns:1fr}.top{gap:8px}.toolbar input{max-width:100%}.hero h1{font-size:24px}}
/* グリッド内の表はカード幅を押し広げず、カード内でスクロールする。 */
.grid2>*,.card,.panel{min-width:0}.table-scroll{max-width:100%}.combo-card,.measure,.todo-card{overflow-wrap:anywhere}
/* 年間計画：入力と実績を分け、空欄と0円を区別して表示する。 */
.budget-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin-top:18px}.budget-kpis .n{font-size:clamp(18px,2vw,25px);overflow-wrap:anywhere}.budget-inputs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}.budget-input{display:block;padding:12px;border:1px solid var(--line);border-radius:10px}.budget-input .small{display:block;margin-top:5px}.budget-match{background:#eff9f3;border-color:#23834b}.budget-table{min-width:850px}.budget-table th:first-child{min-width:48px}.budget-table th:nth-child(n+2),.budget-table td:nth-child(n+2){text-align:right}.budget-table td:last-child{white-space:nowrap}.form-error{color:#a32d2d;white-space:pre-wrap}#planFields{border:0;padding:0;margin:0;min-width:0}#planDialog{max-width:790px}#annualPlan{margin-bottom:24px}
@media(max-width:850px){.budget-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:520px){.budget-inputs{grid-template-columns:repeat(2,minmax(0,1fr))}.budget-input{padding:8px}#planDialog{padding:16px}}
/* 閲覧者には変更操作を表示しない。API側でも同じ権限を必ず検証する。 */
body[data-readonly="true"] [data-new],body[data-readonly="true"] [data-recommend]{display:none}.active-check{width:22px;height:22px}#loginMessage:empty,#accountMessage:empty{display:none}#userAdmin select{max-width:320px}
