:root {
  --bg: #f4f6f9; --card: #fff; --text: #1f2328; --muted: #5f6b7a; --line: #d8dee6; --soft: #f6f8fa;
  --accent: #1f6feb; --accent-soft: #e8f0fe; --ok: #1a7f37; --late: #b35900; --ng: #cf222e; --info: #57606a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.7 "Yu Gothic UI", "Meiryo", system-ui, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 18px 0 6px; }
.lead { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--late); font-weight: bold; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 12px; background: #fff; }
code { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 13px; }

/* ---- ヘッダー ---- */
header.top { display: flex; align-items: center; gap: 20px; padding: 0 20px; min-height: 52px; flex-wrap: wrap;
  background: #1f2937; color: #fff; position: sticky; top: 0; z-index: 10; }
header.top .brand { font-weight: bold; font-size: 15px; color: #fff; text-decoration: none; white-space: nowrap; }
header.top nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; align-items: center; }
header.top nav a { color: #cbd5e1; text-decoration: none; padding: 6px 11px; border-radius: 6px; white-space: nowrap; }
header.top nav a.on, header.top nav a:hover { background: #374151; color: #fff; }
header.top nav .sep { width: 1px; height: 20px; background: #4b5563; margin: 0 6px; }
header.top .user { font-size: 13px; color: #cbd5e1; white-space: nowrap; }
header.top .user a { color: #93c5fd; margin-left: 10px; }
header.top a.help-link { background: #2563eb; color: #fff; }
header.top a.help-link:hover, header.top a.help-link.on { background: #1d4ed8; }

main { padding: 24px 20px 60px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---- カード・レイアウト ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; margin: 60px auto; }
.card.highlight { border-color: #93b4f5; box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.badge { font-size: 12px; font-weight: normal; background: #eef1f4; border-radius: 10px; padding: 2px 8px; color: var(--muted); }
.rules li { margin-bottom: 4px; }

/* ---- 入力 ---- */
input[type=text], input[type=search], input[type=date], input[type=number], input:not([type]) {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
input:focus, select:focus, button:focus-visible, .btn:focus-visible { outline: 2px solid #93b4f5; outline-offset: 1px; }
input[type=search] { min-width: 380px; }
input.mid { min-width: 260px; }
input.short { width: 90px; }
input.wide { min-width: 380px; }
select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
button, .btn { padding: 7px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft);
  font: inherit; cursor: pointer; color: var(--text); text-decoration: none; display: inline-block; line-height: 1.5; }
button:hover, .btn:hover { background: #eaeef2; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: bold; }
button.primary:hover, .btn.primary:hover { background: #1a5fd0; }
button.big, .btn.big { padding: 10px 28px; font-size: 15px; }
.ghost { background: transparent; }
.danger { color: var(--ng); }
form { margin: 0; }

/* ファイル選択（ドラッグ＆ドロップ） */
.drop { display: block; border: 2px dashed #b6c2d1; border-radius: var(--radius); padding: 18px; text-align: center;
  cursor: pointer; background: #fafbfd; transition: .15s; margin-bottom: 10px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input[type=file] { display: none; }
.drop .drop-title { font-weight: bold; }
.drop .drop-name { margin-top: 4px; color: var(--accent); font-weight: bold; min-height: 1.5em; }
.drop.chosen { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

/* ---- お知らせ ---- */
.flashes { margin-bottom: 14px; }
.flash { padding: 9px 36px 9px 14px; border-radius: 8px; margin-bottom: 6px; position: relative; }
.flash.ok { background: #dafbe1; color: #116329; }
.flash.error { background: #ffebe9; color: #a40e26; }
.flash.info { background: #eef1f4; color: var(--info); }
.flash.warnbox { background: #fff4e5; color: #8a4600; }
.flash ul { margin: 4px 0 0; }
.flash .close { position: absolute; right: 6px; top: 5px; border: none; background: transparent; font-size: 16px; padding: 0 6px; color: inherit; opacity: .6; }
.flash .close:hover { opacity: 1; background: transparent; }

/* 画面ごとの使い方（折りたたみ） */
details.help { background: #f0f6ff; border: 1px solid #c9dcfb; border-radius: var(--radius); padding: 8px 14px; margin: 8px 0 16px; }
details.help summary { cursor: pointer; font-weight: bold; color: #1d4ed8; }
details.help[open] summary { margin-bottom: 6px; }
details.help ol, details.help ul { margin: 4px 0; padding-left: 22px; }

/* ---- ステップ表示 ---- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0 20px; counter-reset: step; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; text-decoration: none; color: var(--text); position: relative; }
.step .n { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center;
  background: #e5e9ef; color: var(--muted); font-weight: bold; font-size: 13px; margin-right: 6px; }
.step .t { font-weight: bold; }
.step .s { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.step.done .n { background: var(--ok); color: #fff; }
.step.done .s { color: var(--ok); }
.step.todo { border-color: #93b4f5; box-shadow: 0 0 0 3px var(--accent-soft); }
.step.todo .n { background: var(--accent); color: #fff; }
.step.attn .s { color: var(--late); font-weight: bold; }
@media (max-width: 760px) { .steps { grid-template-columns: 1fr 1fr; } }

/* ---- 集計カード ---- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.stats > * { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px; min-width: 120px;
  color: var(--muted); font-size: 12px; text-decoration: none; }
.stats a:hover { border-color: var(--accent); }
.stats b { display: block; font-size: 24px; color: var(--text); }
.stats .ok b { color: var(--ok); } .stats .late b { color: var(--late); } .stats .ng b { color: var(--ng); }
.stats .sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 6px 0; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 12px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--accent); font-weight: bold; }

/* ---- 表 ---- */
.scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; border-bottom: 1px solid #edf0f3; text-align: left; white-space: nowrap; }
th { background: var(--soft); position: sticky; top: 0; font-size: 12px; color: var(--muted); z-index: 1; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f6f9ff; }
#prio td { border: none; padding: 3px 6px 3px 0; }
table.plain th { position: static; }
table.plain td, table.plain th { white-space: normal; vertical-align: top; }

.st { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.st-ok { background: #dafbe1; color: var(--ok); }
.st-late { background: #fff1e5; color: var(--late); }
.st-ng { background: #ffebe9; color: var(--ng); }
.st-info { background: #eef1f4; color: var(--info); }

.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; font-size: 13px; }
.pager .btn { padding: 3px 10px; }
.pager .disabled { color: #b0b7be; cursor: default; }
.pager form.inline { display: inline-flex; align-items: center; gap: 4px; }
.pager .pageno { width: 80px; padding: 3px 6px; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .btn { margin-top: 10px; }

table.tree td.tree-cell { font-variant-numeric: tabular-nums; }
table.tree .tree-line { white-space: pre; color: #8c959f; font-family: "MS Gothic", "Consolas", monospace; }
table.tree .toggle { padding: 0 5px; margin-right: 4px; font-size: 12px; line-height: 16px; min-width: 20px; }

/* ---- 処理中 ---- */
#busy { position: fixed; inset: 0; background: rgba(255,255,255,.75); display: none; align-items: center; justify-content: center; z-index: 100; }
#busy.on { display: flex; }
#busy .box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 32px; text-align: center; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
#busy .spinner { width: 36px; height: 36px; border: 4px solid #dbe4f3; border-top-color: var(--accent); border-radius: 50%;
  margin: 0 auto 10px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 使い方ページ ---- */
.help-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.help-toc { position: sticky; top: 72px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; }
.help-toc a { display: block; padding: 3px 0; text-decoration: none; }
.help-toc .sub { padding-left: 12px; }
.help-body section { scroll-margin-top: 70px; }
.help-body .card h2 { font-size: 18px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.help-body ol li, .help-body ul li { margin-bottom: 4px; }
.example { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-family: "Consolas", "MS Gothic", monospace;
  white-space: pre; overflow-x: auto; font-size: 13px; line-height: 1.6; }
.qa dt { font-weight: bold; margin-top: 12px; }
.qa dt::before { content: "Q. "; color: var(--accent); }
.qa dd { margin: 2px 0 0 0; padding-left: 22px; }
.tip { background: #fffbe6; border: 1px solid #f1df9b; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
@media (max-width: 900px) { .help-layout { grid-template-columns: 1fr; } .help-toc { position: static; } }
@media print { header.top, .help-toc, #busy { display: none !important; } .help-layout { display: block; } }

/* ---- フッター・規約 ---- */
.site-footer { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; padding: 18px 16px 28px; font-size: 13px; border-top: 1px solid var(--line); }
.site-footer a { color: var(--muted); }
.doc { max-width: 860px; margin: 0 auto; }
.doc h2 { font-size: 16px; margin-top: 22px; }
.doc li { margin-bottom: 4px; }
.hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical; }

/* ---- スマホ・タブレット ---- */
@media (max-width: 760px) {
  body { font-size: 14px; }
  main { padding: 14px 12px 40px; }
  h1 { font-size: 19px; }
  header.top { position: static; padding: 8px 12px; gap: 8px; }
  header.top .brand { width: 100%; }
  header.top nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  header.top nav .sep { display: none; }
  header.top .help-link { padding: 4px 10px; }
  .card { padding: 14px; }
  .card.narrow { margin: 16px auto; }
  .grid2 { grid-template-columns: 1fr; }
  input[type=search], input.wide, input.mid { min-width: 0; width: 100%; }
  .row > input[type=search], .row > input.wide, .row > input.mid { flex: 1 1 100%; }
  .row > span[style*="flex:1"] { display: none; }
  .stats > * { min-width: 0; flex: 1 1 40%; padding: 6px 10px; }
  .stats b { font-size: 20px; }
  .scroll { max-height: none; }
  th, td { padding: 5px 8px; }
  .steps { grid-template-columns: 1fr 1fr; gap: 8px; }
  .step { padding: 8px 10px; }
  .page-head { margin-bottom: 0; }
  .pager { font-size: 12px; }
  .pager .pageno { width: 60px; }
  button.big, .btn.big { width: 100%; }
  .drop { padding: 14px 10px; }
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; }
  .example { font-size: 11px; }
}
.help-body { min-width: 0; }
.help-body table.plain { display: block; overflow-x: auto; }
@media (max-width: 760px) { .help-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  header.top nav { overflow-x: visible; flex-wrap: wrap; gap: 4px; }
  header.top nav a { padding: 4px 8px; font-size: 13px; background: #2b3544; }
  header.top .user { margin-left: auto; }
}
@media (max-width: 760px) { header.top nav { flex: 1 1 100%; } }

/* ---- AI 分析 ---- */
.ai-report { line-height: 1.85; }
.ai-report h3 { font-size: 16px; margin: 20px 0 6px; padding-left: 8px; border-left: 4px solid var(--accent); }
.ai-report h4 { font-size: 15px; margin: 14px 0 4px; }
.ai-report ul, .ai-report ol { padding-left: 22px; margin: 4px 0 10px; }
.ai-report li { margin-bottom: 4px; }
.ai-report p { margin: 6px 0; }
.spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid #dbe4f3; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
button:disabled { opacity: .5; cursor: not-allowed; }
