:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e2e4ea;
  --head: #eceef3;          /* カードの見出しの帯 */
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #5b4db1;       /* 基調の紫 */
  --primary-dark: #4a3d98;
  --primary-soft: #ece9f7;  /* メニューの帯・選んだ行 */
  --danger: #c0392b;
  --ok: #2f9e6b;
  --shadow: 0 1px 2px rgba(15,23,42,.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ヘッダー（白い帯） */
header.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 56px;
}
header.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
header.topbar .brand:hover { text-decoration: none; }
.brand-icon { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--primary); stroke-width: 2; }
.brand-name { font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; }
.topbar-right .who { color: var(--text); }
.topbar-right a, .topbar-right .logout button { color: var(--primary); text-decoration: underline; }
.topbar-right .logout { display: inline; margin: 0; }
.topbar-right .logout button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

/* メニュー（薄い紫の帯にタブ型のボタン） */
nav.menu { background: var(--primary-soft); border-bottom: 1px solid #dcd7f0; }
nav.menu .menu-inner { padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
nav.menu a {
  display: inline-flex; align-items: center; gap: 7px;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; white-space: nowrap;
}
nav.menu a:hover { border-color: var(--primary); text-decoration: none; }
nav.menu a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
nav.menu svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 1400px; margin: 16px 0; padding: 0 16px; }

/* ページの見出しは、カードの見出しと同じ灰色の帯にする */
h1 { font-size: 20px; margin: 0 0 16px; }
main > h1 {
  font-size: 16px; padding: 11px 16px;
  background: var(--head); border: 1px solid var(--border); border-radius: 8px;
}
h2 { font-size: 15px; margin: 24px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
/* カードの先頭の見出しは、カードの上端の帯にする */
.card > h2:first-child, .card > h3:first-child, .card > input[type=hidden]:first-child + h2 {
  margin: -18px -18px 14px !important; padding: 10px 18px;
  background: var(--head); border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0; font-size: 14px;
}

/* ボタン */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary { background: #e3e5ea; color: #1f2937; }
.btn.secondary:hover { background: #d5d8df; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* フォーム */
label { display: block; font-size: 13px; color: var(--text); margin: 12px 0 4px; font-weight: 600; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=time],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #d5d8df;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #c9c1ee; border-color: var(--primary); }
textarea { min-height: 72px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px){ .grid2, .grid3 { grid-template-columns: 1fr; } }

/* テーブル */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: #374151; font-size: 12.5px; background: #f1f2f6; font-weight: 700; }
tr:hover td { background: #f7f6fc; }

/* レベルのバッジ（淡い地に濃い文字。色は全画面で共通） */
.lv {
  display: inline-block; border-radius: 999px; padding: 2px 11px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  background: #eceef2; color: #4b5563;
}
.lv[data-lv="1"] { background: #e3ebfb; color: #2552b8; }
.lv[data-lv="2"] { background: #dcf3e7; color: #1d7a50; }
.lv[data-lv="3a"] { background: #fcefd2; color: #8a5a00; }
.lv[data-lv="3b"] { background: #fde3d6; color: #b2471a; }
.lv[data-lv="4"] { background: #fbdcdc; color: #a12b2b; }
.lv[data-lv="5"] { background: #f3d0d0; color: #7a1717; }
.lv[data-lv="クレーム"] { background: #ebe5fb; color: #5b3fb8; }
/* 車両事故（レベルなし。level は空文字。#74） */
.lv[data-lv=""], .lv[data-lv="vehicle"] { background: #d9f0f4; color: #0e5f73; }

/* ---------- ポータル ---------- */
.card > h2:first-child, .card > input[type=hidden]:first-child + h2 { display: flex; align-items: center; gap: 10px; }
.head-right { margin-left: auto; font-weight: 700; font-size: 13px; }
form.head-right { margin: -4px 0; }
.portal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--head); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 8px 16px; margin-bottom: 16px; }
.portal-head h1 { background: none; border: 0; padding: 0; margin: 0; font-size: 16px; }
.portal-filter { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-filter label { margin: 0; }
.portal-filter select { width: auto; padding: 6px 10px; }
.count-cards { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.count-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.count-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: #374151; }
.count-pair { display: flex; gap: 18px; }
.count-pair > a, .count-pair > div { display: grid; grid-template-columns: auto auto; align-items: baseline; color: var(--text); }
.count-pair > a:hover { text-decoration: none; opacity: .75; }
.count-when { grid-column: 1 / 3; font-size: 11.5px; color: var(--muted); }
.count-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.count-unit { font-size: 12px; margin-left: 2px; }
.count-card[data-lv="1"] .count-title, .count-card[data-lv="1"] .this .count-num { color: #2552b8; }
.count-card[data-lv="2"] .count-title, .count-card[data-lv="2"] .this .count-num { color: #1d7a50; }
.count-card[data-lv="3a"] .count-title, .count-card[data-lv="3a"] .this .count-num { color: #8a5a00; }
.count-card[data-lv="3b"] .count-title, .count-card[data-lv="3b"] .this .count-num { color: #b2471a; }
.count-card[data-lv="クレーム"] .count-title, .count-card[data-lv="クレーム"] .this .count-num { color: #5b3fb8; }
.count-card[data-lv="vehicle"] .count-title, .count-card[data-lv="vehicle"] .this .count-num { color: #0e5f73; }
.portal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.latest-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.latest-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.latest-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
ul.latest { margin: 0; padding-left: 18px; font-size: 13px; flex: 1; }
ul.latest li { margin: 3px 0; }
ul.latest a { color: var(--text); }
ul.latest .date { color: var(--muted); margin-right: 4px; }
.latest-foot { text-align: right; color: var(--muted); margin-top: 6px; }
.review-summary { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 8px; }
.review-summary > div { display: flex; align-items: baseline; gap: 8px; }
.review-summary strong { font-size: 22px; }
.review-summary strong.alert { color: var(--danger); }
.review-summary .diff { color: var(--muted); }
.review-types { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; }
.type-chip { background: var(--primary-soft); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.review-setting { margin-top: 10px; }
.review-setting form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
label.inline { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 400; }
a.waiting { display: flex; justify-content: space-between; align-items: baseline; background: #fff6e0;
  border-radius: 6px; padding: 10px 12px; color: #7a5300; font-weight: 700; }
a.waiting strong { font-size: 22px; }
a.waiting:hover { text-decoration: none; opacity: .85; }
a.waiting + a.waiting { margin-top: 8px; }
a.waiting.calm { background: #f3f4f6; color: var(--text); }
a.waiting.alert { background: #fde8e8; color: var(--danger); }
/* 承認の進捗（下書き → 申請中 → 差し戻し または 承認済み） */
.progress-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.progress-steps span { background: #f0f1f4; border-radius: 999px; padding: 3px 12px; }
.progress-steps span.on { background: #dfe8fb; color: #2450a8; font-weight: 700; }
.progress-tag { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; background: #f0f1f4; color: #4b5563; }
.progress-tag[data-progress="submitted"] { background: #dfe8fb; color: #2450a8; }
.progress-tag[data-progress="returned"] { background: #fde8e8; color: var(--danger); }
.progress-tag[data-progress="approved"] { background: #e3f4ec; color: #1f7a50; }
.approval-card .progress-steps { margin-bottom: 10px; }
.approval-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@media (max-width: 1100px) { .count-cards { grid-template-columns: repeat(3, 1fr); } .portal-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .count-cards { grid-template-columns: repeat(2, 1fr); } .latest-grid { grid-template-columns: 1fr; }
  .portal-filter { margin-left: 0; width: 100%; } .portal-filter select { flex: 1; width: auto !important; } }

/* ---------- 報告書の入力画面（左に項目名、右に入力） ---------- */
.form-sec { padding: 0; overflow: hidden; }
.form-sec > h2:first-child { margin: 0 !important; border-radius: 0; }
.frow { display: grid; grid-template-columns: 210px minmax(0, 1fr); border-top: 1px solid var(--border); }
.frow[hidden] { display: none; }
.form-sec > h2 + .frow { border-top: 0; }
.fl { background: #f6f7f9; padding: 12px 14px; font-weight: 700; font-size: 13.5px; border-right: 1px solid var(--border); }
.fv { padding: 10px 14px; min-width: 0; }
.fv.grid2, .fv.grid3 { gap: 8px 14px; }
.fv > label:first-child, .fv .grid2 label, .fv.grid2 label, .fv.grid3 label { margin-top: 0; }
.req { display: inline-block; margin-left: 6px; background: #c0392b; color: #fff; font-size: 11px;
  border-radius: 4px; padding: 0 6px; vertical-align: 1px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.hint.top { margin: 0 0 6px; }
.narrow { max-width: 340px; }
.inline-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.inline-fields > label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; }
.inline-fields input[type=date], .inline-fields input[type=time] { width: auto; }
.sublabel { font-size: 12.5px; color: var(--muted); margin-right: 8px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.choice-row .choice { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 400; font-size: 14px; cursor: pointer; }
.choice-row.pills .choice { border: 1px solid #d5d8df; border-radius: 999px; padding: 4px 12px; }
.choice-row.pills .choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice-row.tags .choice:nth-child(1) { background: #fcefd2; } .choice-row.tags .choice:nth-child(2) { background: #fbdcdc; }
.choice-row.tags .choice:nth-child(3) { background: #eceef2; } .choice-row.tags .choice:nth-child(4) { background: #dcf3e7; }
.choice-row.tags .choice { padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 13px; }
input[type=datetime-local] { padding: 8px 10px; border: 1px solid #d5d8df; border-radius: 6px; font-family: inherit; font-size: 14px; }
.level-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level-card { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-weight: 400; cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.level-card:has(input:checked) { border-color: var(--primary); background: #eef0fc; box-shadow: 0 0 0 1px var(--primary); }
.level-card input { margin-top: 4px; }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: #fff; border-top: 1px solid var(--border); margin: 0 -16px; padding: 10px 16px; }
.form-actions .muted { margin-right: auto; }
@media (max-width: 760px) {
  .frow { grid-template-columns: 1fr; }
  .fl { border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 12px; }
  .fv { padding: 10px 12px; }
  .level-cards { grid-template-columns: 1fr; }
}

/* ---------- 添付ファイル ---------- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 12px; }
.attach-item a { display: block; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #f6f7f9; }
.attach-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-pdf { display: flex; flex-direction: column; height: 100%; align-items: center; justify-content: center; font-weight: 700; color: var(--danger); font-size: 20px; }
.attach-pdf small { font-size: 11px; font-weight: 400; color: var(--muted); }
.attach-meta { margin-top: 4px; color: var(--muted); }
.attach-form { display: grid; gap: 8px; }
.attach-drop { display: flex; align-items: center; gap: 10px; border: 1.5px dashed var(--border); border-radius: 8px; padding: 12px; margin: 0; font-weight: 400; cursor: pointer; }
.attach-drop input { width: auto; }
.attach-drop span { color: var(--muted); font-size: 13px; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; font-size: inherit; text-decoration: underline; }
.danger-text { color: var(--danger); }

/* ---------- PDCAチェック ---------- */
.pdca-table tr.sel td { background: var(--primary-soft); }
.pdca-table tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.pdca-measure { display: block; font-weight: 600; }
.pdca-due.overdue { color: var(--danger); font-weight: 700; }
.pdca-due.soon { color: #9a5b00; font-weight: 700; }
.pdca-due.evaluate { color: #2450a8; font-weight: 700; }
.pdca-info { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.pdca-row { display: grid; grid-template-columns: 150px 1fr; border-top: 1px solid var(--border); }
.pdca-row:first-child { border-top: 0; }
.pdca-row .fl { background: #f6f7f9; padding: 9px 12px; font-weight: 600; font-size: 13px; }
.pdca-row .fv { padding: 9px 12px; font-size: 14px; }
.pre { white-space: pre-wrap; }
.tabs .cnt { font-weight: 700; margin-left: 2px; }
.nowrap { white-space: nowrap; }
.pdca-record summary { list-style: none; cursor: pointer; display: inline-block; }
.pdca-record summary::-webkit-details-marker { display: none; }
.pdca-record[open] summary { margin-bottom: 6px; }
.pdca-record form { display: grid; gap: 6px; min-width: 240px; }
.pdca-alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pdca-alerts a { display: block; padding: 7px 10px; border-radius: 6px; background: #f6f7f9; color: var(--text); font-size: 13px; }
.pdca-alerts a:hover { text-decoration: none; opacity: .85; }
.pdca-alerts .when { display: block; font-weight: 700; font-size: 12px; }
.pdca-alerts li.overdue a { background: #fde8e8; }
.pdca-alerts li.overdue .when { color: var(--danger); }
.pdca-alerts li.soon .when { color: #9a5b00; }
.pdca-alerts li.to_evaluate .when { color: #2450a8; }
.pdca-on-report { margin: 0; padding-left: 18px; }
.pdca-on-report li + li { margin-top: 4px; }
@media (max-width: 640px) { .pdca-row { grid-template-columns: 1fr; } }

/* ---------- 伏字の確認（左に一覧、右に公開前チェック） ---------- */
.review-tabs { flex-wrap: wrap; align-items: center; }
.review-tabs .cnt { font-weight: 700; margin-left: 2px; }
.tab-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.review-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.review-split > .card { margin-bottom: 0; }
.review-split.no-panel { grid-template-columns: 1fr; }
.review-rows tr.sel td { background: var(--primary-soft); }
.review-rows tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.nowrap { white-space: nowrap; }
.warn-text { color: #9a5b00; }
.need-fix { display: inline-block; background: #fde8e8; color: var(--danger); border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; }
.check-panel { position: sticky; top: 12px; }
.check-facts { display: grid; grid-template-columns: 70px 1fr; gap: 8px 10px; margin: 0 0 12px; font-size: 13px; align-items: center; }
.check-facts dt { color: var(--muted); }
.check-facts dt label { margin: 0; font-weight: 400; }
.check-facts dd { margin: 0; }
.check-facts dd select { margin-top: 4px; }
.check-facts dd.inline-fields { gap: 6px 8px; }
.check-sub { font-size: 13px; margin: 0 0 6px; }
.check-preview { background: #f6f7f9; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; max-height: 320px; overflow-y: auto; font-size: 13px; }
.check-preview .pv-item + .pv-item { margin-top: 8px; }
.pv-label { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.pv-text { white-space: pre-wrap; }
.check-list { margin: 12px 0 0; display: grid; gap: 6px; }
.check-list label { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; font-size: 13px; margin: 0; }
.check-list input { width: auto; margin-top: 3px; }
.check-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 14px; }
@media (max-width: 900px) {
  .review-split { grid-template-columns: 1fr; }
  .check-panel { position: static; order: -1; }
}

/* ---------- エリア別 ---------- */
.notice-flex { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.notice-flex a { font-weight: 700; text-decoration: underline; color: #7a5300; }
.area-block { margin-bottom: 18px; }
.area-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.area-head .rank { background: #1f2937; color: #fff; border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 1px 9px; }
.area-head .area-name { font-weight: 700; font-size: 16px; text-decoration: underline; }
.stack { display: flex; background: #eceef3; border-radius: 3px; overflow: hidden; }
.branch-rows { margin: 6px 0 0 18px; }
.branch-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 54px; align-items: center; gap: 10px; margin: 3px 0; font-size: 13px; }
.branch-row a { text-decoration: underline; }
.branch-row a.unknown { color: #8a5a00; font-weight: 700; }
.branch-row .cnt { text-align: right; }
.area-table tr.area-row td { background: #f6f7f9; font-weight: 700; }
.area-table td.indent { padding-left: 26px; }
.area-table a { color: var(--text); }
@media (max-width: 640px) { .branch-rows { margin-left: 0; } .branch-row { grid-template-columns: 96px minmax(0, 1fr) 44px; } }

/* ---------- 集計 ---------- */
.stats-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.stats-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.stats-form label { margin-top: 0; }
.stats-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; align-items: start; }
.pct-table td, .pct-table th { padding: 7px 8px; }
.pct-table a { color: var(--text); display: inline-flex; align-items: center; gap: 8px; }
.pct-table .dot, .legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; }
.chart a.col { color: inherit; }
.chart a.col:hover { text-decoration: none; opacity: .8; }
.num-table th, .num-table td { text-align: right; white-space: nowrap; }
.num-table th:first-child, .num-table td:first-child { text-align: left; }
.num-table tr.sum-row td { background: #f1f2f6; font-weight: 700; }
@media (max-width: 1000px) { .stats-grid { grid-template-columns: 1fr; } }

/* ---------- レポート一覧 ---------- */
.search-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-row input[type=text] { flex: 1 1 320px; width: auto; }
.search-actions { margin-left: auto; display: flex; gap: 8px; }
.search-detail { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px;
  background: #f6f7f9; border-radius: 6px; padding: 4px 12px 12px; margin-top: 10px; }
.search-detail[hidden] { display: none; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; }
.chips > .small { width: 100%; }
.chip { background: #eceef3; border-radius: 4px; padding: 2px 8px; font-size: 13px; color: var(--text); }
a.chip.removable:hover { background: #dfe2ea; text-decoration: none; }
.status { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.status.wait { background: #fff1d6; color: #8a5a00; }
.status.ok { background: #dcf3e7; color: #1d7a50; }
.list-table a.row-link { color: var(--text); display: block; }
.list-table td.ops { white-space: nowrap; }
.list-table td.ops a { display: inline-flex; padding: 4px; color: #4b5563; }
.list-table td.ops svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
@media (max-width: 640px) { .search-actions { margin-left: 0; width: 100%; } .search-actions .btn { flex: 1; text-align: center; } }

/* ---------- 閲覧確認 ---------- */
.read-card { border-left: 4px solid var(--primary); }
.read-form { display: grid; gap: 8px; justify-items: start; }
.read-form .btn[disabled] { opacity: .45; cursor: not-allowed; }
.unread-bar { margin-bottom: 12px; }
.unread-dot { display: inline-block; background: #fde8e8; color: var(--danger); border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 700; }
.read-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.read-split tr.sel td { background: var(--primary-soft); }
@media (max-width: 900px) { .read-split { grid-template-columns: 1fr; } }
/* ---------- 操作記録 ---------- */
.audit-filter { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px 12px; align-items: end; }
.audit-filter label { margin-top: 0; }
.audit-buttons { display: flex; gap: 8px; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ---------- ユーザー管理の一覧：検索・ページ分け（#66） ---------- */
.users-filter { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 4px 12px; align-items: end; margin-bottom: 10px; }
.users-filter label { margin-top: 0; }
.users-filter-buttons { display: flex; gap: 8px; }
.users-range { margin: 4px 0 6px; }
.users-pager { flex-wrap: wrap; }
.users-pager span[aria-current] { cursor: default; }
@media (max-width: 640px) {
  .users-filter { grid-template-columns: 1fr 1fr; }
  .users-filter-q, .users-filter-buttons { grid-column: 1 / -1; }
  .users-filter-buttons .btn { flex: 1; text-align: center; }
}

/* ---------- 2段階認証 ---------- */
.mfa-steps { padding-left: 20px; font-size: 13px; margin: 0 0 10px; }
.mfa-steps li + li { margin-top: 4px; }
.mfa-qr { display: flex; justify-content: center; margin: 8px 0; }
.mfa-qr svg { background: #fff; }
.mfa-secret { font-family: monospace; font-size: 15px; letter-spacing: 1px; word-break: break-all; background: #f6f7f9; padding: 6px 8px; border-radius: 4px; }
.mfa-codes { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px;
  font-family: monospace; font-size: 18px; letter-spacing: 1px; }

/* そのほかの丸いラベル（自動で伏せた語・順位など） */
.badge {
  display: inline-block;
  color: #fff;
  border-radius: 999px;
  padding: 2px 11px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* フラッシュ */
.flash { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok    { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* 統計カード */
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 150px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow); }
.stat-box .num { font-size: 28px; font-weight: 800; }
.stat-box .lbl { color: var(--muted); font-size: 13px; }

/* レベル別ミニバー */
.levelbar { display:flex; align-items:center; gap:8px; margin: 6px 0; font-size: 13px; }
.levelbar-link { display:flex; align-items:center; gap:8px; flex:1; text-decoration:none;
  color:inherit; padding:3px 6px; margin:-3px -6px; border-radius:7px; }
.levelbar-link:hover { background:var(--primary-soft); text-decoration:none; }
.levelbar .track { flex:1; background:#eceef3; border-radius:6px; height: 10px; overflow:hidden; }
.levelbar .fill { height:100%; border-radius:6px; }
.levelbar .cnt { width: 34px; text-align:right; font-weight:700; }

/* 集計グラフ（積み上げ棒） */
/* 高さは中身に合わせる（固定すると、いちばん高い棒の上の件数が切れる） */
.chart { display:flex; align-items:flex-end; gap: 14px; min-height: 240px; padding: 22px 4px 10px; overflow-x:auto; }
.chart .col { display:flex; flex-direction:column; align-items:center; gap:6px; min-width: 46px; }
.chart .bar { width: 34px; display:flex; flex-direction:column-reverse; border-radius:5px 5px 0 0; overflow:hidden; }
.chart .seg { width:100%; }
.chart .xlabel { font-size: 11px; color: var(--muted); text-align:center; white-space:nowrap; }
.chart .total { font-size: 12px; font-weight:700; }

.legend { display:flex; flex-wrap:wrap; gap: 12px; margin-top: 10px; }
.legend .item { display:flex; align-items:center; gap:6px; font-size:12.5px; color:var(--muted); }
.legend .dot { width:12px; height:12px; border-radius:3px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.tabs { display:flex; gap:8px; margin-bottom:14px; }
.tabs a { padding:7px 14px; border-radius:999px; background:#fff; border:1px solid var(--border); color:var(--text); font-size:13px; font-weight:600; }
.tabs a:hover { border-color: var(--primary); text-decoration:none; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color:#fff; }
.field-val { white-space: pre-wrap; }
.notice { background:#fff8e6; border:1px solid #f3dca0; color:#7a5300; padding:11px 15px; border-radius:8px; font-size:13px; margin-bottom:16px; }

/* スマホ・タブレット（パソコンの表示は変えない） */
@media (max-width: 900px) {
  header.topbar { height: auto; flex-wrap: wrap; gap: 4px 14px; padding: 10px 16px; }
  .brand-sub { display: none; }
  .topbar-right { margin-left: 0; flex-wrap: wrap; gap: 4px 14px; }
  .topbar-right .who { overflow-wrap: anywhere; }
  nav.menu .menu-inner { padding: 8px 16px; gap: 6px; }
  nav.menu a { padding: 6px 11px; font-size: 13px; }
  main { padding: 0 16px; }
  .grid2 > *, .grid3 > * { min-width: 0; }
  .field-val { overflow-wrap: anywhere; }

  input[type=month] {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-family: inherit;
    background: #fff;
  }
  /* iPhoneで入力時に画面が拡大されないよう16pxにする（インライン指定より優先） */
  input[type=text], input[type=search], input[type=password], input[type=date], input[type=time], input[type=month],
  select, textarea { font-size: 16px !important; }
  /* iPhoneの日付欄は標準の幅と高さで枠からはみ出すので揃える */
  input[type=date], input[type=time], input[type=month] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    width: 100% !important;
    min-width: 0;
    max-width: 100%;
    min-height: 42px;
  }
  input::-webkit-date-and-time-value { text-align: left; }
}

@media (max-width: 640px) {
  main { margin: 14px auto; padding: 0 16px; }
  .card { padding: 14px; }
  select { width: 100% !important; }
  form[style*="display:flex"] > div { flex: 1 1 100%; min-width: 0; }
  /* 表は表の中だけで横スクロールする */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  tbody { display: table; width: 100%; }
  th, td { padding: 9px 10px; white-space: nowrap; }
  /* 一覧では内容を折り返して見えるようにし、優先度の低い列を隠す */
  td.small:last-child { white-space: normal; min-width: 11em; }
  .hide-sp { display: none; }
  .detail-head { flex-wrap: wrap; margin-bottom: 12px; }
  .detail-head .spacer { display: none; }
  .levelbar .muted { display: none; }
  .tabs { flex-wrap: wrap; }
  .card > h2:first-child, .card > h3:first-child, .card > input[type=hidden]:first-child + h2 { margin: -14px -14px 12px !important; padding: 9px 14px; }
  .stat-box { min-width: 100%; }
}

/* ---------- 配布用の紙（ユーザー管理で発行した初期パスワード） ---------- */
.slips { display: none; }
@media print {
  @page { size: A4; margin: 8mm; }
  html, body { background: #fff !important; }
  /* 紙のある画面だけ、紙以外を隠す（報告書の印刷など、ほかの画面の印刷は隠さない。#115） */
  body:has(.slips) * { visibility: hidden; }
  /* 隠した部分が場所を取って白紙のページが増えないように、紙以外は消す */
  body:has(.slips) header, body:has(.slips) nav.menu, body:has(.slips) main > *:not(.slips) { display: none !important; }
  body:has(.slips) .slips, body:has(.slips) .slips * { visibility: visible; }
  .slips { display: block; position: absolute; left: 0; top: 0; width: 100%; }
  .slip { box-sizing: border-box; height: 93mm; overflow: hidden; padding: 5mm 8mm 3mm;
          border-bottom: 1px dashed #666; break-inside: avoid; page-break-inside: avoid;
          font-size: 10pt; line-height: 1.45; color: #000; }
  .slip:nth-child(3n) { border-bottom: none; break-after: page; page-break-after: always; }
  .slip-title { font-weight: 700; font-size: 12pt; margin-bottom: 1mm; }
  .slip-name { font-size: 11pt; margin-bottom: 2mm; }
  .slips table.slip-table { width: auto; border-collapse: collapse; margin: 0 0 2mm; }
  .slips .slip-table th, .slips .slip-table td { border: 1px solid #999; padding: 1mm 3mm; text-align: left;
          font-size: 10pt; background: none; color: #000; }
  .slips .slip-table th { width: 36mm; white-space: nowrap; font-weight: 600; }
  .slip-code { font-family: monospace; font-size: 13pt !important; letter-spacing: 1px; }
  .slip-steps { margin: 0 0 1mm 5mm; padding: 0; font-size: 9pt; line-height: 1.4; }
  .slip-foot { font-size: 8.5pt; }
}

/* 過去の事例を探す（#92） */
.portal-search { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; }
.portal-search input { flex: 1; min-width: 0; }
.portal-search label { margin: 0; white-space: nowrap; font-weight: 600; }
.snippet { margin-top: 4px; color: #444; line-height: 1.5; }
.snippet-label { display: inline-block; font-size: 11px; color: #555; background: #eef0f6; border-radius: 4px;
  padding: 0 6px; margin-right: 6px; }
.snippet mark, .similar-box mark { background: #fff1a8; padding: 0 1px; }
@media (max-width: 640px) { .portal-search { flex-wrap: wrap; } .portal-search label { width: 100%; } }

/* 書いている途中の似た事例（#93） */
.similar-box { margin: 12px 0 4px; padding: 12px 14px; border: 1px solid #d9dcef; border-radius: 8px; background: #f7f8fd; }
.similar-box h3 { margin: 0 0 4px; font-size: 14px; }
.similar-box ul { list-style: none; margin: 8px 0 0; padding: 0; }
.similar-box li { padding: 8px 0; border-top: 1px solid #e6e8f2; }
.similar-box li:first-child { border-top: 0; }
.similar-box a { text-decoration: none; color: inherit; }
.similar-box a:hover { text-decoration: underline; }
.similar-box .snippet { margin-top: 4px; color: #444; line-height: 1.5; font-size: 13px; }
.similar-box .snippet-label { display: inline-block; font-size: 11px; color: #555; background: #eef0f6;
  border-radius: 4px; padding: 0 6px; margin-right: 6px; }

/* 掲示板（#98） */
.board h2 { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.board .head-right { margin-left: auto; }
.board-note { background: #fff8e6; border: 1px solid #f1d58a; border-radius: 8px; padding: 10px 12px; margin: 6px 0 10px;
  white-space: pre-wrap; line-height: 1.6; }
.board-note-head { font-weight: 700; font-size: 12px; color: #8a6200; margin-bottom: 2px; white-space: normal; }
.board-summary p { margin: 2px 0; line-height: 1.7; }
.board-alert { background: #fdecec; border: 1px solid #f2b8b8; color: #8a1f1f; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.board-alert a { margin-left: 6px; }
.board-sub { font-size: 13px; margin: 14px 0 4px; }
.board-digest { list-style: none; margin: 0; padding: 0; }
.board-digest li { padding: 7px 0; border-top: 1px solid #eceef5; }
.board-digest li:first-child { border-top: 0; }
.board-digest a { text-decoration: none; color: inherit; }
.board-digest a:hover { text-decoration: underline; }
.board-edit { margin-top: 12px; }
.board-edit summary { cursor: pointer; font-size: 13px; color: #555; }

/* 必読の事例（#99） */
.must-card { border: 2px solid #e05a5a; }
.must-list { list-style: none; margin: 0; padding: 0; }
.must-list li { padding: 8px 0; border-top: 1px solid #f1e2e2; }
.must-list li:first-child { border-top: 0; }
.must-list li.done { opacity: .7; }
.must-list a { text-decoration: none; color: inherit; }
.must-list a:hover { text-decoration: underline; }
.must-mark { display: inline-block; font-size: 11px; border-radius: 4px; padding: 1px 6px; margin-right: 4px; font-weight: 700; }
.must-mark.todo { background: #e05a5a; color: #fff; }
.must-mark.done { background: #e3f4ea; color: #1f6b3a; }
.must-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #fdecec; border: 2px solid #e05a5a; border-radius: 8px; padding: 10px 14px; margin: 10px 0; }
.must-banner form { margin: 0; }
.must-stats summary, .must-set summary { cursor: pointer; font-size: 13px; }
