/* 経営管理ツールの見た目 */
:root {
  --bg: #f5f6f8; --card: #fff; --text: #1f2933; --muted: #6b7280; --line: #e3e6ea;
  --primary: #1f5fbf; --primary-dark: #174a96; --danger: #c0392b;
  --ok-bg: #e8f5ec; --ok: #1e7b3c; --err-bg: #fdecea; --err: #b42318;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px; line-height: 1.7; }
a { color: var(--primary); }
.nav { background: #12263f; color: #fff; }
.nav-top { display: flex; align-items: center; gap: 16px; padding: 10px 24px 4px; }
.nav a { color: #dbe6f5; text-decoration: none; }
.nav a:hover { color: #fff; }
.nav .brand { font-weight: 700; color: #fff; font-size: 17px; }
.nav .spacer { flex: 1; }
.nav .me { font-size: 14px; }
.nav .link { background: none; border: 0; color: #dbe6f5; cursor: pointer; font: inherit; font-size: 14px; padding: 0; }
.nav .link:hover { color: #fff; text-decoration: underline; }
.menu { display: flex; gap: 4px; padding: 4px 18px 0; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.menu::-webkit-scrollbar { display: none; }
.menu a { padding: 8px 12px; border-bottom: 3px solid transparent; font-size: 15px; }
.menu a.active { color: #fff; border-bottom-color: #7fb0ff; font-weight: 700; }
.main { max-width: 1180px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 22px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
h2 { font-size: 17px; margin: 0 0 12px; }
h2.sub { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.card.narrow { max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0f5; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn { display: inline-block; padding: 8px 16px; border: 1px solid #c9ced6; border-radius: 6px; background: #fff; color: var(--text);
  text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f0f2f5; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #e7b3ad; }
.btn.danger:hover { background: #fdecea; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.form .btn { align-self: flex-start; margin-top: 6px; }
form.inline { display: inline; }
.row-form { display: inline-flex !important; gap: 6px; align-items: center; margin-right: 6px; }
.row-form input { width: 210px; padding: 4px 8px; font-size: 13px; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.field-error { color: var(--err); margin: -4px 0 0; font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { padding: 5px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 14px; }
.tab.active { background: #12263f; color: #fff; border-color: #12263f; }
.tab .count { margin-left: 6px; font-size: 12px; opacity: .75; }
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.list th { background: #f0f2f5; font-size: 13px; color: #4b5563; white-space: nowrap; }
table.list tr.inactive td { color: var(--muted); background: #fafafa; }
.pname { font-weight: 700; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.st-todo { background: #eef0f3; color: #4b5563; }
.st-doing { background: #e3eefc; color: #1f5fbf; }
.st-wait { background: #fff4d6; color: #8a5a00; }
.st-done { background: #e3f4e8; color: #1e7b3c; }
.st-stop { background: #f1f1f1; color: #8b8b8b; }
.due.over { color: var(--err); font-weight: 700; }
.due.soon { color: #8a5a00; font-weight: 700; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; }
.sum-item { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.sum-item.wide { grid-column: 1 / -1; }
.k { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 8px; }
.sum-item .k { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.logs { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow: auto; }
.log { border-left: 3px solid var(--line); padding: 4px 0 10px 12px; margin-bottom: 8px; }
.log-head { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.log-body { font-size: 14px; }
.log .note { margin-top: 4px; padding: 6px 10px; background: #f7f8fa; border-radius: 6px; }

/* 第2段階で足した部品 */
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sec-head h2 { margin: 0; }
.h3 { font-size: 15px; margin: 12px 0 4px; }
.mini-list { margin: 0; padding-left: 0; list-style: none; }
.mini-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.mini-list li:last-child { border-bottom: 0; }
ol.mini-list { counter-reset: n; }
ol.mini-list li::before { counter-increment: n; content: counter(n) "."; font-weight: 700; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none; }
.card .kpi { background: #f7f8fa; }
.kpi.link:hover { border-color: var(--primary); }
.kpi strong { font-size: 22px; line-height: 1.3; }
.neg { color: var(--err); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ach { font-weight: 700; }
.ach.good, .bar-num.good, .good-text { color: var(--ok); }
.ach.mid, .bar-num.mid { color: #8a5a00; }
.ach.bad, .bar-num.bad { color: var(--err); }
.reason { display: inline-block; font-size: 13px; font-weight: 600; }
.reason.lv3 { color: var(--err); }
.reason.lv2 { color: #8a5a00; }
.reason.lv1 { color: #4b5563; }
tr.worst td { background: #fff6f5; }
tr.overdue td { background: #fff8f0; }
.rank { font-weight: 700; color: var(--muted); }
.card.alert { border-color: #f0b4ad; background: #fffafa; }
.card.alert h2 { color: var(--err); }
.period-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.period-nav input { width: auto; }
.filter-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; flex-wrap: wrap; }
.filter-row label { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; }
.filter-row select { width: auto; min-width: 200px; }
.calc-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #f2f6fd; border-radius: 8px; padding: 10px 12px; }
.calc-box > div { display: flex; flex-direction: column; }
progress.bar { width: 110px; height: 10px; vertical-align: middle; appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; background: #eceff3; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: #eceff3; border-radius: 99px; }
progress.bar::-webkit-progress-value { border-radius: 99px; background: var(--primary); }
progress.bar.good::-webkit-progress-value { background: #2e9e57; }
progress.bar.mid::-webkit-progress-value { background: #d69a00; }
progress.bar.bad::-webkit-progress-value { background: #d64535; }
progress.bar::-moz-progress-bar { background: var(--primary); }
progress.bar.good::-moz-progress-bar { background: #2e9e57; }
progress.bar.mid::-moz-progress-bar { background: #d69a00; }
progress.bar.bad::-moz-progress-bar { background: #d64535; }
.bar-num { margin-left: 6px; font-weight: 700; }
.badge.kind { background: #eef0f3; color: #4b5563; font-weight: 600; }
.badge.vis-members { background: #efe9fb; color: #5b3fa8; }
.pr-high { background: #fdecea; color: #b42318; }
.pr-mid { background: #eef0f3; color: #4b5563; }
.pr-low { background: #f5f5f5; color: #9a9a9a; }
.path { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: #f3f4f6; padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.add-box { margin-top: 10px; }
.add-box summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.add-box .form { margin-top: 10px; }
.radio, .check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.radio input, .check input { width: auto; }
.checks { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 8px 12px; }
.checks legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.ball-group h2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.count-text { font-size: 13px; color: var(--muted); font-weight: 400; }
.over-row a { color: var(--err); }
.main ul.small { padding-left: 1.2em; }

/* スマホでは表をカードの形に並べ直す */
@media (max-width: 760px) {
  .main { padding: 12px; }
  .nav-top { padding: 8px 12px 2px; gap: 12px; }
  .nav .me { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu { padding: 2px 6px 0; }
  .card { padding: 14px; }
  .page-head h1 { font-size: 20px; }
  .summary, .two-col, .grid2, .grid3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi strong { font-size: 18px; }
  .calc-box { grid-template-columns: 1fr 1fr 1fr; }
  /* iPhoneで入力欄に触れたときに画面が拡大されないよう、16px にする */
  input, select, textarea { font-size: 16px; }
  table.list thead { display: none; }
  table.list, table.list tbody, table.list tr, table.list td { display: block; width: 100%; }
  table.list { border: 0; background: transparent; }
  table.list tr { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }
  /* 1行目(名前)は大きく、残りは「見出し:中身」を横に並べる */
  table.list td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 6.5em 1fr; gap: 8px; align-items: start; }
  table.list td::before { content: attr(data-label); font-size: 12px; color: var(--muted); font-weight: 600; padding-top: 2px; }
  /* 中身(金額の下の達成率など)は、すべて右の列にそろえる */
  table.list td > * { grid-column: 2; }
  table.list td > .badge, table.list td > .btn, table.list td > progress { justify-self: start; }
  table.list td.cell-title { display: block; font-size: 16px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
  table.list td.cell-title::before { content: none; }
  table.list td.rank { display: none; }
  .row-form { display: flex !important; flex-wrap: wrap; margin: 0 0 6px; }
  .row-form input { width: 100%; }
  .filter-row select { min-width: 0; width: 100%; }
  .filter-row label { flex: 1; }
}
