:root {
  /* Lim Work テーマ: 白ベースに、くすみローズのアクセント。参考画面と同じく常にライト表示 */
  --bg: #f8f8fa;
  --panel: #ffffff;
  --panel-2: #f7f7f9;
  --line: #ececf0;
  --text: #24222a;
  --muted: #6f6c78;
  --faint: #a9a6b2;
  --brand: #c9446f;
  --brand-2: #e0658c;
  --brand-soft: #fcf0f4;
  --brand-grad: linear-gradient(90deg, #fdeef3 0%, #f5f0fb 100%);
  --violet: #6c5ce7;
  --violet-soft: #f1effd;
  --green: #2e9b63;
  --green-soft: #eaf8f0;
  --amber: #d9822b;
  --amber-soft: #fdf3e7;
  --red: #d64545;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 20, 40, .03), 0 8px 24px rgba(30, 20, 40, .045);
  --sidebar: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.app { display: flex; min-height: 100vh; }

/* ---------- サイドバー（1階層目＋2階層目） ---------- */
.side { display: flex; flex: none; position: sticky; top: 0; height: 100vh; z-index: 10; }
.rail { width: 132px; flex: none; position: relative; z-index: 2; }
.rail-inner { height: 100%; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px 10px; white-space: nowrap;
  font-weight: 800; font-size: 15px; letter-spacing: .01em;
  text-decoration: none; color: var(--brand);
}
.brand svg { width: 22px; height: 22px; flex: none; }
.rail-nav { flex: 1; overflow-y: auto; padding: 2px 8px 8px; scrollbar-width: none; }
.rail-nav::-webkit-scrollbar { display: none; }
.rail-item {
  position: relative; display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 9px; margin: 1px 0; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 12.5px; white-space: nowrap;
}
.rail-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-item:hover { background: var(--panel-2); color: var(--text); }
.rail-item.active { background: var(--brand-soft); color: var(--brand); }
.rail-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: 10.5px; line-height: 18px; text-align: center; }
.rail-group { margin: 10px 9px 3px; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--faint); }
.rail-sep { border-top: 1px solid var(--line); margin: 8px 10px; }

/* AIメーター（1階層目の一番下・小さく） */
.mini-meter { margin: 0 8px 8px; padding: 6px 7px 5px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: 9.5px; line-height: 1.25; cursor: default; }
.mm-head { display: flex; justify-content: space-between; font-weight: 800; letter-spacing: .04em; font-size: 9.5px; color: var(--muted); margin-bottom: 1px; }
.mm-head span { font-weight: 600; color: var(--faint); letter-spacing: 0; }
.mm-svc { display: flex; align-items: center; gap: 4px; margin-top: 3px; font-weight: 800; font-size: 9.5px; }
.mm-svc i { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.mm-g { display: grid; grid-template-columns: 14px 1fr 25px; align-items: center; gap: 4px; margin-top: 1px; }
.mm-g > span:first-child { color: var(--faint); font-weight: 700; font-size: 8.5px; }
.mm-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mm-bar b { display: block; height: 100%; }
.mm-g em { font-style: normal; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; font-size: 9px; }

.subnav {
  /* 2階層目: 1階層目にカーソルを当てると右に開く（画面の上に重ねる） */
  position: absolute; top: 0; left: 132px; height: 100%; width: 228px;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  box-shadow: 12px 0 32px rgba(30, 20, 40, .10);
  opacity: 0; visibility: hidden; transform: translateX(-8px);
  transition: opacity .14s, transform .14s, visibility 0s .14s;
}
.side.fly .subnav { opacity: 1; visibility: visible; transform: none; transition: opacity .14s, transform .14s; }
/* 2階層目を開いている間は、3階層目（画面）を2階層目の右に縮小して丸ごと見せる */
.side.fly { width: 360px; }
.side.fly ~ .main { zoom: var(--fly-zoom, 1); }
.rail-item.hover:not(.active) { background: var(--panel-2); color: var(--text); }
.workspace {
  margin: 16px 14px 6px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 12px; color: var(--muted);
}
.workspace b { display: block; color: var(--text); font-size: 13px; }
.sub-title { display: flex; align-items: center; gap: 8px; padding: 20px 22px 6px; font-weight: 800; font-size: 15px; }
.sub-title svg { width: 18px; height: 18px; fill: none; stroke: var(--brand); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 0;
  border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav-group { margin: 14px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--faint); }
.nav .badge { margin-left: auto; font-size: 11px; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 7px; }

/* タスクボード */
.taskboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; align-items: start; }
.task-list { margin: 0; padding: 0 0 0 18px; }
.task-list li { padding: 6px 0; border-top: 1px solid var(--line); line-height: 1.5; }
.task-list li:first-child { border-top: 0; }

/* SEO */
.heat-row { display: grid; grid-template-columns: 44px 1fr 44px; gap: 10px; align-items: center; margin: 8px 0; font-size: 12px; }
.heat-bar { height: 22px; border-radius: 6px; border: 1px solid var(--line); }
.heat-row b { text-align: right; }
.axes { display: grid; gap: 10px; }
.axis { display: grid; grid-template-columns: 80px 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.axis b { text-align: right; }

/* ナレッジ */
.split { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; }
.flow { display: block; min-width: 100%; height: auto; }
.flow rect { fill: var(--panel-2); stroke: var(--line); }
.flow text { fill: var(--text); font-size: 13px; font-weight: 700; }
.flow path { stroke: var(--brand); stroke-width: 2; fill: none; }

/* ---------- AIメーター（左下に常駐） ---------- */
.aimeter {
  margin: 8px 12px 12px;
  padding: 12px 12px 10px;
  border-radius: 12px;
  background: #0f1433;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: inset 0 0 0 3px #0f1433, inset 0 0 0 4px rgba(255, 255, 255, .25);
  font-size: 12px;
}
.am-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.am-head b { font-size: 12px; letter-spacing: .06em; }
.am-head span { font-size: 10px; color: rgba(255, 255, 255, .55); }
.am-service { margin-top: 6px; }
.am-name { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.am-name i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.am-name small { margin-left: auto; font-size: 9px; color: rgba(255, 255, 255, .5); font-weight: 600; letter-spacing: .06em; }
.am-row { display: grid; grid-template-columns: 34px 1fr 36px; align-items: center; gap: 6px; margin-top: 3px; }
.am-row .lbl { font-size: 10px; color: rgba(255, 255, 255, .7); }
.am-bar { height: 8px; border: 1px solid rgba(255, 255, 255, .8); border-radius: 2px; background: rgba(0, 0, 0, .5); overflow: hidden; }
.am-bar > div { height: 100%; background-image: linear-gradient(rgba(255, 255, 255, .3) 40%, transparent 40%); }
.am-row .val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.am-note { font-size: 10.5px; color: rgba(255, 255, 255, .5); margin-top: 3px; }

/* ---------- メイン ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumbs { min-width: 0; }
.crumb-group { font-size: 11px; color: var(--faint); }
.crumb-title { margin: 0; font-size: 17px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1360px; width: 100%; }

/* ---------- 部品 ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .sub { font-weight: 500; font-size: 12px; color: var(--faint); }
.card h3 .right { margin-left: auto; }

.kpi .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 30px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .note { font-size: 12px; color: var(--faint); }
.kpi.mini .value { font-size: 26px; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.live { color: var(--green); background: var(--green-soft); border-color: transparent; }
.chip.brand { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.chip.violet { color: var(--violet); background: var(--violet-soft); border-color: transparent; }
.chip.green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.chip.amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.btn, .pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-weight: 700; font-size: 13px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(194, 37, 92, .25); }
.btn.primary:hover { background: var(--brand-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--red); }
.pill-btn { border-radius: 999px; padding: 5px 14px; font-size: 12px; }
.pill-btn.alert { background: var(--brand); border-color: var(--brand); color: #fff; }
.pill-btn.alert:empty { display: none; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 16px; }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-align: left; min-width: 150px; }
.tab b { display: block; font-size: 14px; }
.tab span { font-size: 11.5px; color: var(--faint); }
.tab.active { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 25%, transparent); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 7px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.click { cursor: pointer; border-radius: 10px; }
.row.click:hover { background: var(--panel-2); }
.row.selected { background: var(--brand-soft); }
.row input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); flex: none; }
.done .title { text-decoration: line-through; color: var(--faint); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11.5px; color: var(--faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.scroll-x { overflow-x: auto; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea.input { resize: vertical; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { width: auto; flex: 1; min-width: 180px; }

.empty { padding: 28px; text-align: center; color: var(--faint); font-size: 13px; background: var(--panel-2); border-radius: 12px; }
.warn { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 700; margin-bottom: 16px; }
.warn .btn { margin-left: auto; }
.progress { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12px; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* チャート */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--faint); font-size: 11px; }
.chart .grid-line { stroke: var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* カレンダー */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.cal .dow { padding: 8px; text-align: center; font-size: 12px; font-weight: 700; color: var(--faint); background: var(--panel-2); border-bottom: 1px solid var(--line); }
.cal .cell { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.cal .cell:nth-child(7n) { border-right: 0; }
.cal .cell.out { background: var(--panel-2); opacity: .55; }
.cal .cell.today .d { background: var(--brand); color: #fff; }
.cal .cell:hover { background: var(--panel-2); }
.cal .d { display: inline-block; min-width: 22px; padding: 0 5px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center; }
.cal .ev { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.sent { opacity: .7; }

/* カンバン */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lane { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 160px; }
.lane h4 { margin: 2px 4px 10px; font-size: 13px; display: flex; justify-content: space-between; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 12.5px; }
.kcard .title { font-weight: 700; margin-bottom: 6px; }
.kcard select { font-size: 11px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); }

/* 広告 */
.promo { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 18px; align-items: start; }
.creative { border-radius: 12px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: #fff; font-weight: 900; font-size: 18px; line-height: 1.3; padding: 14px; white-space: pre-line; box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .18); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; background: var(--panel-2); border-radius: 12px; padding: 12px; }
.metrics div span { display: block; font-size: 11px; color: var(--faint); }
.metrics div b { font-size: 17px; font-variant-numeric: tabular-nums; }

/* メール編集 */
.compose { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.preview-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.checklist .row .state { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; background: var(--green); flex: none; }
.checklist .row .state.off { background: var(--faint); }

/* モーダル・トースト */
.modal-root:empty { display: none; }
.modal-root { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(20, 10, 30, .4); padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(860px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; }
.modal h3 .x { margin-left: auto; border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--faint); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; transition: .25s; background: #1d1b22; color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 13px; font-weight: 600; z-index: 60; pointer-events: none; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ハーネス連携 */
.lh-grid { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); }
.kpi.goal { padding: 12px 14px; }
.kpi.goal .value { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.goal .value .faint { font-size: 12px; }

/* ---------- レスポンシブ ---------- */
.tbl td:first-child { min-width: 160px; }
@media (max-width: 1200px) {
  .split, .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lh-grid { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .g2, .g3, .g-main, .compose { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .chip.live { display: none; }
}
@media (max-width: 560px) {
  .side { position: fixed; z-index: 30; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .side.fly { width: auto; }
  .side.fly ~ .main { zoom: 1; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 20; display: none; }
  .scrim.open { display: block; }
  .menu-btn { display: inline-block; }
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .kanban { grid-template-columns: minmax(0, 1fr); }
  .promo { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal .cell { min-height: 70px; }
  .cal .ev { font-size: 9px; padding: 1px 3px; }
}


/* ---------- Lim Work テーマの仕上げ（参考画面の質感） ---------- */
body { background: var(--bg); letter-spacing: .01em; }
.rail-inner, .subnav { background: #fff; border-color: #f0f0f3; }
.brand { color: var(--text); }
.brand svg { color: var(--brand); }
.rail-item { color: #8a8794; }
.rail-item:hover { background: #f8f7fa; color: var(--text); }
.rail-item.active { background: var(--brand-grad); color: var(--brand); }
.rail-item.active svg { stroke: var(--brand); }
.workspace { background: #fff; border-color: #efeef2; box-shadow: 0 1px 2px rgba(30, 20, 40, .03); }
.sub-title { color: var(--text); }
.nav a { color: #55525d; font-weight: 600; }
.nav a:hover { background: #f8f7fa; color: var(--text); }
.nav a.active { background: var(--brand-grad); color: var(--brand); box-shadow: inset 0 0 0 1px #f8e3ea; }
.nav-group, .rail-group { color: #b4b1bc; }

.topbar { background: rgba(255, 255, 255, .86); border-bottom-color: #f0f0f3; }
.crumb-group { color: #b0adb8; }
.crumb-title { font-weight: 800; }
.chip.live { background: #edf9f2; color: var(--green); border: 1px solid #d7f0e2; }
.pill-btn.alert { background: linear-gradient(135deg, #d4567e, #c13f69); border: 0; box-shadow: 0 4px 12px rgba(201, 68, 111, .25); }
.icon-btn { background: #fff; border-color: #ececf0; }
#themeBtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; margin: auto; }

.page-head h2 { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.card { border-color: #f0eff3; box-shadow: var(--shadow); }
.card h3 { font-weight: 800; }
.kpi .value { letter-spacing: -.02em; }

.btn { border-color: #e9e8ee; box-shadow: 0 1px 2px rgba(30, 20, 40, .03); }
.btn.primary { background: linear-gradient(135deg, #d4567e, #c13f69); border: 0; box-shadow: 0 6px 16px rgba(201, 68, 111, .25); }
.btn.primary:hover { background: linear-gradient(135deg, #dc6188, #c94671); }
.chip { background: #f6f5f8; border-color: #ecebf0; }
.chip.green { background: #eaf8f0; }

.tab { border-color: #ecebf0; box-shadow: var(--shadow); }
.tab.active { border: 1.5px solid #8fd1ad; background: #f1fbf5; box-shadow: none; }
.warn { background: linear-gradient(90deg, #fdeef3 0%, #fff7f9 100%); border: 1px solid #f7dde6; }
.warn::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #d64545; flex: none; }
.empty { background: #fafafc; border: 1px dashed #ebeaf0; }
.seg { background: #f6f5f8; }
.row.selected { background: var(--brand-grad); }
.input:focus { border-color: #e2a3b8; box-shadow: 0 0 0 3px rgba(201, 68, 111, .12); }
.tbl th { color: #a9a6b2; }
.lane { background: #fafafc; }
.cal .cell.today .d { background: linear-gradient(135deg, #d4567e, #c13f69); }

.warn.amber { background: linear-gradient(90deg, #fdf3e7 0%, #fffaf3 100%); border-color: #f6e2c8; color: var(--amber); }
.warn.amber::before { background: var(--amber); }

/* ログイン画面 */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 20% 0%, #fdeef3 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #f1effd 0%, transparent 60%), var(--bg); }
.login-wrap { width: min(400px, calc(100% - 32px)); }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 22px; margin-bottom: 18px; }
.login-brand svg { width: 30px; height: 30px; color: var(--brand); }
.login-card { padding: 28px; }
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.login-card .muted { font-size: 13px; margin: 0 0 18px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 0 0 8px; }
.user-chip { font-size: 12px; color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 1100px) { .user-chip { display: none; } }
.crumb-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 第2階層の拡充で増えた部品 ---------- */
.diff { font-size: 12px; font-weight: 700; color: var(--faint); }
.diff.up { color: var(--green); }
.diff.down { color: var(--red); }
.rank { width: 22px; text-align: center; color: var(--brand); }
.kpi-text { font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp { max-width: 360px; font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.board { display: grid; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.kcard2 { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; box-shadow: var(--shadow); }
.kc-title { all: unset; cursor: pointer; font-weight: 700; display: block; line-height: 1.45; }
.kc-title:hover { color: var(--brand); }
.kc-body { font-size: 12px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.kc-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; font-size: 12px; }
.kc-move { margin-left: auto; display: flex; }
.kc-move .btn { padding: 2px 7px; }
.funnel { display: grid; gap: 8px; }
.fn-row { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 120px 56px; gap: 10px; align-items: center; font-size: 13px; }
.fn-label { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-bar { position: relative; height: 18px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.fn-bar b { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 6px; }
.fn-bar i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .55; }
.fn-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.fn-rate { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gantt { display: grid; gap: 6px; margin-bottom: 6px; }
.gt-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 10px; align-items: center; font-size: 13px; }
.gt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.gt-track { position: relative; height: 16px; background: var(--panel-2); border-radius: 5px; }
.gt-track b { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; background: var(--violet); opacity: .8; }
.gt-track b.done { background: var(--green); }
.gt-track i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--red); z-index: 1; }
.day-group { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.day-group:first-child { border-top: 0; }
.dg-date { font-weight: 800; display: flex; flex-direction: column; }
.dg-date.late { color: var(--red); }
.dg-date .faint { font-weight: 600; font-size: 12px; }
.code-hint { display: flex; flex-direction: column; gap: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; font-size: 12.5px; }
.code-hint code { font-size: 12px; word-break: break-all; }
@media (max-width: 900px) {
  .fn-row { grid-template-columns: 1fr 90px 50px; }
  .fn-row .fn-bar { grid-column: 1 / -1; grid-row: 2; }
  .day-group { grid-template-columns: 1fr; }
}

/* ---------- ダークモード（設定 or 右上の月ボタンで切替） ---------- */
:root[data-theme="dark"] {
  --bg: #15131a;
  --panel: #1d1b23;
  --panel-2: #26232d;
  --line: #312d39;
  --text: #ebe9f0;
  --muted: #aaa6b4;
  --faint: #7a7684;
  --brand: #ec7fa2;
  --brand-2: #f394b3;
  --brand-soft: #3a2331;
  --brand-grad: linear-gradient(90deg, #3a2331 0%, #2d263a 100%);
  --violet: #9c8ff5;
  --violet-soft: #2a2542;
  --green: #4cc487;
  --green-soft: #1b3127;
  --amber: #eba25a;
  --amber-soft: #382b1b;
  --red: #f06a6a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px rgba(0, 0, 0, .28);
  color-scheme: dark;
}
:root[data-theme="dark"] .rail-inner,
:root[data-theme="dark"] .subnav { background: var(--panel); border-color: var(--line); }
:root[data-theme="dark"] .subnav { box-shadow: 12px 0 32px rgba(0, 0, 0, .45); }
:root[data-theme="dark"] .rail-item { color: var(--muted); }
:root[data-theme="dark"] .rail-item:hover,
:root[data-theme="dark"] .nav a:hover { background: var(--panel-2); color: var(--text); }
:root[data-theme="dark"] .nav a { color: var(--muted); }
:root[data-theme="dark"] .nav a.active { box-shadow: inset 0 0 0 1px #4a2c3d; }
:root[data-theme="dark"] .nav-group,
:root[data-theme="dark"] .rail-group,
:root[data-theme="dark"] .crumb-group,
:root[data-theme="dark"] .tbl th { color: var(--faint); }
:root[data-theme="dark"] .topbar { background: rgba(29, 27, 35, .88); border-bottom-color: var(--line); }
:root[data-theme="dark"] .chip.live { background: var(--green-soft); border-color: #24452f; }
:root[data-theme="dark"] .icon-btn { background: var(--panel); border-color: var(--line); color: var(--text); }
:root[data-theme="dark"] .card { border-color: var(--line); }
:root[data-theme="dark"] .btn { border-color: var(--line); background: var(--panel); color: var(--text); }
:root[data-theme="dark"] .btn.primary { color: #fff; }
:root[data-theme="dark"] .chip { background: var(--panel-2); border-color: var(--line); }
:root[data-theme="dark"] .chip.green { background: var(--green-soft); }
:root[data-theme="dark"] .tab { border-color: var(--line); background: var(--panel); }
:root[data-theme="dark"] .tab.active { background: var(--green-soft); border-color: #2f6b49; }
:root[data-theme="dark"] .warn { background: linear-gradient(90deg, #3a2331 0%, #2a2129 100%); border-color: #4a2c3d; }
:root[data-theme="dark"] .warn.amber { background: linear-gradient(90deg, #382b1b 0%, #2a241c 100%); border-color: #4d3a22; }
:root[data-theme="dark"] .empty { background: var(--panel-2); border-color: var(--line); }
:root[data-theme="dark"] .seg { background: var(--panel-2); }
:root[data-theme="dark"] .lane { background: var(--panel-2); }
:root[data-theme="dark"] .input,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: var(--panel-2); border-color: var(--line); color: var(--text); }
:root[data-theme="dark"] .preview-frame { background: var(--panel-2); }
:root[data-theme="dark"] .login-body { background: radial-gradient(1200px 600px at 20% 0%, #2c1b26 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #221d36 0%, transparent 60%), var(--bg); }
