:root {
  --brand: #2563eb;
  --brand-2: #0ea5e9;
  --bg: #eef2f7;
  --card: #ffffff;
  --soft: #f5f8fc;
  --text: #0f1b2d;
  --muted: #6a7a90;
  --border: #e4eaf2;
  --side: #111a2e;
  --side-2: #1b263f;
  --side-text: #aebbd0;
  --up: #16a34a;
  --down: #e11d48;
  --shadow: 0 1px 3px rgba(15,27,45,.07), 0 1px 2px rgba(15,27,45,.04);
  --radius: 14px;
  --c1: #2563eb; --c2: #0ea5e9; --c3: #22c55e; --c4: #f59e0b; --c5: #a855f7;
}
html[data-theme="dark"] {
  --brand: #4f8cff;
  --brand-2: #38bdf8;
  --bg: #0b1220;
  --card: #131c2e;
  --soft: #18233a;
  --text: #e6edf7;
  --muted: #8da0bb;
  --border: #25324a;
  --side: #0a1120;
  --side-2: #141f36;
  --side-text: #9fb0cb;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ===== サイドバー ===== */
.sidebar {
  background: linear-gradient(180deg, var(--side), var(--side-2));
  color: var(--side-text); padding: 18px 14px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 18px; color: #fff; }
.side-logo { font-size: 22px; }
.side-name { font-size: 18px; font-weight: 600; letter-spacing: .01em; }
.side-name b { color: var(--brand-2); }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; cursor: pointer; color: var(--side-text); transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.ni-ico { font-size: 16px; width: 18px; text-align: center; }
.side-note { margin-top: auto; font-size: 11px; opacity: .6; padding: 12px 8px 0; line-height: 1.6; }

/* ===== メイン ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.top-title h1 { font-size: 18px; }
.top-sub { font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.seg { display: flex; background: var(--soft); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg-btn {
  border: none; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.seg-btn.active { background: var(--card); color: var(--brand); box-shadow: var(--shadow); }
.btn { border: none; border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn-ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn {
  background: var(--soft); border: 1px solid var(--border); color: var(--text);
  width: 36px; height: 36px; border-radius: 9px; cursor: pointer; font-size: 16px;
}
.icon-btn:hover { border-color: var(--brand); }
.only-mobile { display: none; }

.content { padding: 22px; display: flex; flex-direction: column; gap: 18px; }

/* ===== KPIカード ===== */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.kpi-val { font-size: 25px; font-weight: 800; margin-top: 8px; letter-spacing: -.01em; }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 5px; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta.up { color: var(--up); }
.kpi-delta.down { color: var(--down); }
.kpi-delta .vs { color: var(--muted); font-weight: 500; }

/* ===== カード ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { font-size: 15px; }
.card-meta { font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }
.grid-2:last-of-type { grid-template-columns: 1fr 1.1fr; }
.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

/* SVGチャートの色 */
.axis-line { stroke: var(--border); stroke-width: 1; }
.grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .8; }
.axis-text { fill: var(--muted); font-size: 11px; }
.area-fill { fill: url(#areaGrad); }
#areaGrad .g0 { stop-color: var(--brand); stop-opacity: .28; }
#areaGrad .g1 { stop-color: var(--brand); stop-opacity: 0; }
.line-path { fill: none; stroke: var(--brand); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--card); stroke: var(--brand); stroke-width: 2; }
.bar-rect { transition: opacity .15s; }
.bar-label { fill: var(--text); font-size: 11.5px; }
.bar-val { fill: var(--muted); font-size: 11px; }

/* ドーナツ */
.donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut-wrap svg { width: 168px; height: 168px; flex: 0 0 auto; }
.donut-center-num { fill: var(--text); font-size: 22px; font-weight: 800; }
.donut-center-lbl { fill: var(--muted); font-size: 10px; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 130px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend .lg-name { flex: 1; }
.legend .lg-pct { font-weight: 700; color: var(--muted); }

/* テーブル */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill.done { background: #dcfce7; color: #15803d; }
.pill.ship { background: #dbeafe; color: #1d4ed8; }
.pill.proc { background: #fef3c7; color: #b45309; }
html[data-theme="dark"] .pill.done { background: #14331f; color: #4ade80; }
html[data-theme="dark"] .pill.ship { background: #16264a; color: #7eb0ff; }
html[data-theme="dark"] .pill.proc { background: #3a2a0c; color: #fbbf24; }

.dash-foot { padding: 14px 22px 28px; color: var(--muted); font-size: 12px; text-align: center; }

.side-scrim { display: none; }

/* ===== レスポンシブ ===== */
@media (max-width: 980px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2:last-of-type { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; width: 230px; transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: grid; place-items: center; }
  .side-scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .top-actions { gap: 7px; }
  .seg-btn { padding: 6px 9px; }
  .btn-ghost { padding: 8px 10px; }
}
