:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #cbd5e1;
  --text: #1e293b;
  --sub: #64748b;
  --primary: #1d4ed8;
  --primary-h: #1e40af;
  --shadow: rgba(0,0,0,0.07);
  --r: 10px;
  --rs: 6px;
}
[data-mode="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --sub: #94a3b8;
  --primary: #3b82f6;
  --primary-h: #2563eb;
  --shadow: rgba(0,0,0,0.3);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Header ── */
.hdr {
  background: linear-gradient(135deg, #1d4ed8 0%, #0891b2 100%);
  height: 58px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.brand-ic {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.18);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.brand-nm { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-vr {
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 600;
}
.mode-btn {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.mode-btn:hover { background: rgba(255,255,255,0.26); }

/* ── Layout ── */
.wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 22px 16px;
  display: grid;
  grid-template-columns: 430px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 820px) { .wrap { grid-template-columns: 1fr; } }

/* ── Panel ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.panel-hd {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
  background: var(--bg);
}
.panel-hd svg { color: var(--primary); flex-shrink: 0; }
.panel-bd { padding: 18px; }

/* ── Sections ── */
.sec + .sec { margin-top: 18px; }
.sec-ttl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sub);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Grid rows ── */
.row { display: grid; gap: 10px; }
.r2 { grid-template-columns: 1fr 1fr; }
.r3 { grid-template-columns: 1fr 1fr 1fr; }
.r4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.r5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.span2 { grid-column: span 2; }
@media (max-width: 600px) {
  .r2, .r3, .r4, .r5 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* ── Fields ── */
.f label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sub);
  margin-bottom: 5px;
}
.tag {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .04em;
}
.tv { background: #dbeafe; color: #1d4ed8; }
.tf { background: #f3e8ff; color: #7c3aed; }
.to { background: #d1fae5; color: #065f46; }
.tn { background: #e2e8f0; color: #94a3b8; }
[data-mode="dark"] .tv { background: #1e3a5f; color: #93c5fd; }
[data-mode="dark"] .tf { background: #3b0764; color: #c4b5fd; }
[data-mode="dark"] .to { background: #064e3b; color: #6ee7b7; }
[data-mode="dark"] .tn { background: #1e293b; color: #475569; }

.f input, .f select {
  width: 100%;
  height: 35px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: var(--rs);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.f input:focus, .f select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.14);
}
.f input::placeholder { color: var(--sub); opacity: .65; }

/* ── Buttons ── */
.btn-row { display: flex; gap: 8px; margin-top: 18px; align-items: center; }
.limit-w { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.limit-lbl { font-size: 11px; font-weight: 600; color: var(--sub); white-space: nowrap; }
.limit-inp { width: 70px; height: 40px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--rs); background: var(--bg); color: var(--text); font-size: 13px; font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; }
.limit-inp:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.14); }
.btn {
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: var(--rs);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .15s;
  font-family: inherit;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-p { background: var(--primary); color: #fff; flex: 1; }
.btn-p:hover { background: var(--primary-h); }
.btn-g {
  background: var(--bg);
  color: var(--sub);
  border: 1px solid var(--border);
}
.btn-g:hover { color: var(--text); border-color: var(--sub); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }

/* ── Result panel ── */
.res-panel { display: none; }
.res-panel.on { display: block; }

.res-bar {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg);
}
.res-count { display: flex; align-items: baseline; gap: 5px; }
.cnt-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.cnt-lbl { font-size: 12px; color: var(--sub); }
.res-acts { display: flex; gap: 6px; }

/* ── Table ── */
.tbl-w {
  overflow-x: auto;
  max-height: 540px;
  overflow-y: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg);
  padding: 7px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sub);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  text-align: left;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 7px 12px; vertical-align: middle; }
td.rn { color: var(--sub); font-size: 11px; width: 36px; text-align: center; }
td.rv { font-size: 13px; }
td.ra { width: 40px; text-align: center; }
.ty-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #dbeafe;
  color: #1d4ed8;
  white-space: nowrap;
  display: inline-block;
}
[data-mode="dark"] .ty-badge { background: #1e3a5f; color: #93c5fd; }
.sub-lbl { font-size: 11px; color: var(--sub); margin-top: 2px; }
.cpb {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 28px; height: 28px;
  cursor: pointer;
  color: var(--sub);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.cpb:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.cpb svg { width: 13px; height: 13px; }

/* ── Empty state ── */
.empty-st {
  padding: 52px 24px;
  text-align: center;
  color: var(--sub);
}
.empty-ic { margin-bottom: 14px; opacity: .35; }
.empty-tx { font-size: 13px; line-height: 1.8; }

/* ── Toast ── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #f1f5f9;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: all .25s;
  white-space: nowrap;
}
[data-mode="dark"] .toast { background: #f1f5f9; color: #1e293b; }
.toast.on { opacity: 1; transform: translateY(0); }

/* ── Toggle pills ── */
.sec-ttl-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sub);
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.tog-all { font-size: 10px; color: var(--sub); cursor: pointer; font-weight: 600; text-transform: none; letter-spacing: 0; }
.tog-all:hover { color: var(--text); }
.tog-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.tog-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer; font-size: 12px; font-weight: 600;
  background: var(--bg); color: var(--sub);
  user-select: none; transition: all .15s;
}
.tog-pill input { display: none; }
.tog-pill .td { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .4; transition: opacity .15s; }
.tog-pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.tog-pill.on .td { opacity: 1; }
