:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e2e5ea;
  --line-soft: #eef0f3;
  --text: #1c1f23;
  --muted: #6b7280;
  --accent: #1a56b8;
  --danger: #b3261e;
  --warn: #8a6d00;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── ヘッダー ───────────────────────── */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header .inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 18px;
}
header .brand { font-weight: 700; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
header nav { display: flex; gap: 14px; margin-left: 8px; }
header nav a { color: var(--muted); font-size: 13px; font-weight: 600; }
header nav a.on { color: var(--text); }
header .spacer { flex: 1; }
header .who { color: var(--muted); font-size: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 80px; }

/* ── 部品 ─────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.panel > h2 {
  font-size: 13px; letter-spacing: .04em; color: var(--muted);
  margin: 0 0 14px; font-weight: 700;
}
h1 { font-size: 21px; margin: 0 0 2px; }
.sub { color: var(--muted); font-size: 13px; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 13px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: #f3f5f8; text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #164a9e; }
button.danger { color: var(--danger); border-color: #eccfcc; }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 0; }

input[type=text], input[type=date], textarea, select {
  font: inherit; width: 100%; padding: 8px 11px;
  border: 1px solid #d5d9df; border-radius: 8px; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.65; }
label.f { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; }
label.f .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.pill {
  display: inline-block; font-size: 11px; font-weight: 700; line-height: 1.6;
  border-radius: 999px; padding: 1px 9px; border: 1px solid transparent; white-space: nowrap;
}
.chip {
  display: inline-block; font-size: 12px; border-radius: 6px;
  padding: 1px 8px; background: #f0f2f5; color: var(--muted); white-space: nowrap;
}
.overdue { color: var(--danger); font-weight: 700; }
.soon { color: var(--warn); font-weight: 700; }

/* ── 球持ちタブ ────────────────────── */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .tab {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-bottom: 3px solid transparent; border-radius: 10px 10px 0 0;
  padding: 10px 18px; cursor: pointer;
}
.tabs .tab:hover { background: #f3f5f8; }
.tabs .tab.on { border-color: var(--line); border-bottom-width: 3px; box-shadow: 0 1px 0 var(--panel); }
.tabs .tab .lbl { font-size: 13px; font-weight: 700; }
.tabs .tab .n { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tabs .tab .od { font-size: 11px; font-weight: 700; color: var(--danger); }

select.ballsel {
  width: auto; min-width: 92px; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
}
/* 一覧でその場で直せる欄。触れると分かる程度に控えめに枠を出す */
select.ownersel, input.duesel, select.stagesel {
  width: auto; max-width: 100%; font-size: 12px; padding: 3px 6px;
  border-color: transparent; background: transparent;
}
select.stagesel { color: var(--muted); margin-top: 1px; }
select.ownersel:hover, input.duesel:hover, select.stagesel:hover { border-color: #d5d9df; background: #fff; }
select.ownersel:focus, input.duesel:focus, select.stagesel:focus { border-color: var(--accent); background: #fff; }
input.duesel.over { color: var(--danger); font-weight: 700; }
input.duesel.soon { color: var(--warn); font-weight: 700; }

/* ── 絞り込み ────────────────────── */
.filters {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 14px; margin-bottom: 4px;
}
.filters .search { position: relative; display: flex; align-items: center; }
.filters .search .icon { position: absolute; left: 10px; stroke: var(--muted); pointer-events: none; }
.filters .search input {
  width: 320px; max-width: 46vw; padding-left: 32px; padding-right: 28px; border-radius: 999px;
}
.filters .search .clr {
  position: absolute; right: 4px; border: 0; background: none; color: var(--muted);
  font-size: 16px; line-height: 1; padding: 4px 6px; cursor: pointer;
}
.filters .opt { font-size: 12px; font-weight: 600; white-space: nowrap; }
.filters .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip-btn {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; display: inline-flex; gap: 6px; align-items: baseline;
}
.chip-btn .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-btn.on .n { color: #cddcf5; }
.chip-btn:disabled { opacity: .45; cursor: default; }
.chip-btn:disabled:hover { background: #fff; }

mark { background: #fff1a8; color: inherit; border-radius: 2px; padding: 0 1px; }

/* ── 一覧 ─────────────────────────── */
.summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.summary .cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; min-width: 132px; flex: 1;
}
.summary .cell .n { font-size: 24px; font-weight: 700; line-height: 1.2; }
.summary .cell .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.summary .cell.hot .n { color: var(--danger); }

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 700;
  padding: 8px 10px 9px; border-bottom: 1px solid var(--line);
  /* 件数が増えても、スクロール中に列の意味を見失わないようにする */
  position: sticky; top: 56px; background: var(--panel); z-index: 5;
}
table.list th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
table.list th[data-sort]:hover { color: var(--text); }
/* 並べ替え中の列だけ向きを出す。全列に矢印を置くと見出しが読みにくくなる */
table.list th[data-sort].on { color: var(--accent); }
table.list th[data-sort][data-dir="asc"]::after  { content: " ↑"; }
table.list th[data-sort][data-dir="desc"]::after { content: " ↓"; }
table.list td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list tr:hover td { background: #fafbfc; }
table.list td.name { font-weight: 600; }
table.list td .meta { font-weight: 400; color: var(--muted); font-size: 12px; }
table.list td .status { font-weight: 600; }
table.list .ball { border-left: 3px solid transparent; }

/* ── 詳細 ─────────────────────────── */
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.round { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.round > .head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #f8f9fb; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 13px;
}
.round > .body { padding: 14px; }
.qitem { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; margin-bottom: 10px; }
.qitem .ref { font-size: 12px; color: var(--muted); font-weight: 600; }
.qitem.fix { border-left-color: #d9822b; }

.tl { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.tl li { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.tl .t { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.copy {
  background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-size: 13px; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow: auto;
}
.copyrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0 6px; }
.copyrow .lbl { font-weight: 700; font-size: 13px; }

.msg {
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
  border: 1px solid #ffe08a; background: #fff8e1; color: var(--warn);
}
.msg.err { border-color: #eccfcc; background: #fdf1f0; color: var(--danger); }
.msg.ok { border-color: #b7dfba; background: #edf7ee; color: #1b5e20; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.icon { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.6;
        stroke-linecap: round; stroke-linejoin: round; flex: none; }
