:root {
  --bg: #f4f6f8;
  --paper: #ffffff;
  --ink: #1f2933;
  --muted: #6b7a88;
  --line: #d9e0e7;
  --brand: #1f5fa8;
  --brand-ink: #ffffff;
  --accent: #e8f1fb;
  --self: #fff7e0;
  --evaluator: #e9f5ec;
  --danger: #b42318;
  --ok: #1a7f4b;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--brand); }
button { font: inherit; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; height: 48px;
  background: var(--brand); color: var(--brand-ink);
  position: sticky; top: 0; z-index: 10;
}
.brand { color: var(--brand-ink); font-weight: 700; text-decoration: none; font-size: 15px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--brand-ink); text-decoration: none; padding: 4px 10px; border-radius: 4px; opacity: .85; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.18); opacity: 1; }
.user { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.user button { background: transparent; color: var(--brand-ink); border: 1px solid rgba(255,255,255,.5); border-radius: 4px; padding: 3px 8px; cursor: pointer; }

.app { max-width: 1280px; margin: 0 auto; padding: 16px; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; color: var(--muted); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 15px; }
.section-title .badge { font-weight: 400; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--accent); color: var(--brand); }
.badge.warn { background: #fdecc8; color: #8a5a00; }
.badge.ok { background: #d8f0e1; color: var(--ok); }
.badge.muted { background: #eef1f4; color: var(--muted); }
.badge.danger { background: #fde2df; color: var(--danger); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .cell input, .cell select, .inline input {
  font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 72px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: #f3f5f7; color: #4a5560; }
.grow { flex: 1; min-width: 240px; }

.btn { padding: 7px 14px; border-radius: 4px; border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
.btn:hover { background: #f3f5f7; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #184c86; }
.btn.danger { color: var(--danger); border-color: #f0b8b3; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

table { border-collapse: collapse; width: 100%; background: #fff; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
th { background: #f0f3f6; font-weight: 600; font-size: 12px; white-space: nowrap; }
td.num, th.num { text-align: center; width: 64px; }
td.cell { padding: 2px; text-align: center; }
td.cell select, td.cell input { width: 56px; text-align: center; padding: 4px; }
th.self, td.self-h { background: var(--self); }
th.eval, td.eval-h { background: var(--evaluator); }
td.cell.self { background: #fffaf0; }
td.cell.eval { background: #f3faf5; }
td.text { min-width: 280px; }
td.cat { white-space: nowrap; font-weight: 600; background: #fafbfc; }
tr.total td { font-weight: 700; background: #f7f9fb; }
.table-wrap { overflow-x: auto; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent); }
tr.mine td { background: #fffbe6; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.result { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.result .stat { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fafbfc; }
.result .stat .label { font-size: 12px; color: var(--muted); }
.result .stat .value { font-size: 20px; font-weight: 700; }
.result .stat.final { background: var(--accent); border-color: #b9d1ec; }

.round { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fff; }
.round.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--accent); }
.round h4 { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 8px; }
.steps span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f4; color: var(--muted); }
.steps span.done { background: #d8f0e1; color: var(--ok); }
.steps span.now { background: var(--brand); color: #fff; }
.note { font-size: 12px; color: var(--muted); }
.pre { white-space: pre-wrap; word-break: break-word; min-height: 1.5em; }
.error { color: var(--danger); }
.ok { color: var(--ok); }

.login { max-width: 380px; margin: 60px auto; }
.login .field { margin-bottom: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #1f2933; color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 100; max-width: 90vw;
}
.toast.error { background: var(--danger); }
.toast[hidden] { display: none; }

.guide { font-size: 12px; }
.guide th, .guide td { padding: 3px 6px; text-align: center; }

ul.tree, ul.tree ul { list-style: none; margin: 0; padding-left: 18px; }
ul.tree li { padding: 2px 0; }
.tree .btn { margin-left: 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
