/* =========================================================
   応募者管理アプリ スタイル
   ========================================================= */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1c2333;
  --muted: #6b7385;
  --line: #e2e6ef;
  --line-strong: #cfd5e3;
  --primary: #3257d6;
  --primary-dark: #2746ac;
  --primary-soft: #eaf0ff;
  --danger: #d23b3b;
  --danger-soft: #fdeaea;
  --warn: #b5790a;
  --ok: #1f9d57;
  --shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 8px 24px rgba(20, 30, 60, .06);
  --radius: 10px;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
h1, h2, h3 { margin: 0; font-weight: 700; }
button { font-family: inherit; }
a { color: var(--primary); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; white-space: nowrap; transition: .12s;
}
.btn:hover { background: #f5f7fc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef1f7; }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- ログイン ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #eaf0ff, #f4f6fb 60%);
}
.login-card {
  width: 340px; background: var(--panel); padding: 32px 28px;
  border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.login-title { font-size: 22px; text-align: center; color: var(--primary-dark); }
.login-sub { text-align: center; color: var(--muted); margin: 6px 0 20px; font-size: 13px; }
.login-error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: 4px 0 10px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; font-size: 14px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- アプリ枠 ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 18px; height: 56px;
}
.brand { font-size: 17px; font-weight: 800; color: var(--primary-dark); white-space: nowrap; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav .navbtn {
  border: none; background: transparent; padding: 7px 12px; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; position: relative;
}
.nav .navbtn:hover { background: #eef1f7; color: var(--ink); }
.nav .navbtn.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav .badge {
  position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: grid; place-items: center; font-weight: 700;
}
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { font-size: 13px; color: var(--muted); }
.user-chip b { color: var(--ink); }
.role-tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.role-admin { background: #fdeede; color: #9a6a00; }
.role-staff { background: #e7f0ff; color: #2746ac; }

main { padding: 16px 18px 60px; max-width: 1500px; margin: 0 auto; }

/* ---------- ツールバー / フィルタ ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.toolbar .sep { width: 1px; height: 24px; background: var(--line); }
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav .month-label { font-weight: 700; min-width: 120px; text-align: center; font-size: 15px; }
.mini-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.search-box { display: flex; align-items: center; gap: 6px; flex: 1 1 200px; min-width: 180px; }
.search-box input { flex: 1; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; }
select.ctl { padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 13px; background: #fff; }

/* マルチセレクト */
.ms { position: relative; }
.ms-btn {
  border: 1px solid var(--line-strong); background: #fff; border-radius: 8px;
  padding: 7px 10px; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.ms-btn .ms-count { background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; font-weight: 700; }
.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; min-width: 220px; max-height: 320px; overflow: auto;
}
.ms-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ms-item:hover { background: #f3f6fc; }
.ms-item input { accent-color: var(--primary); }

/* 媒体内訳チップ */
.breakdown { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.breakdown .bd-title { font-size: 12px; color: var(--muted); font-weight: 700; margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.chip .cnt { font-weight: 800; }

/* ---------- テーブル ---------- */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 240px); }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 2; background: #f7f9fd; text-align: left;
  padding: 9px 10px; border-bottom: 2px solid var(--line-strong); white-space: nowrap;
  font-size: 12px; color: var(--muted); font-weight: 700; cursor: default;
}
table.grid thead th.sortable { cursor: pointer; }
table.grid thead th.sortable:hover { color: var(--primary); }
table.grid thead th .arrow { color: var(--primary); margin-left: 2px; }
table.grid tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover { background: #f6f9ff; }
.cell-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-actions { text-align: right; }
.row-actions { display: inline-flex; gap: 4px; }
.empty-state { padding: 48px; text-align: center; color: var(--muted); }

/* グループ */
.group-head {
  background: #eef2fb; cursor: pointer; user-select: none;
}
.group-head td { font-weight: 700; color: var(--ink); padding: 10px; border-bottom: 1px solid var(--line-strong); }
.group-head .gcount { color: var(--primary-dark); margin-left: 6px; font-size: 12px; }
.group-head .gtoggle { display: inline-block; width: 16px; color: var(--muted); }

/* バッジ */
.badge-tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid transparent; white-space: nowrap;
}

/* ---------- カード / サマリー ---------- */
.section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.section h2 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section h2 .hint { font-size: 11px; color: var(--muted); font-weight: 600; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi .k-value { font-size: 28px; font-weight: 800; margin-top: 4px; }
.kpi .k-sub { font-size: 11px; color: var(--muted); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--primary); }

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 180px 1fr 56px; align-items: center; gap: 10px; }
.bar-row .bar-label { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef1f7; border-radius: 6px; height: 22px; overflow: hidden; cursor: pointer; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; min-width: 2px; transition: width .3s; }
.bar-row .bar-num { text-align: right; font-weight: 700; font-size: 13px; cursor: pointer; }
.bar-row .bar-num:hover { color: var(--primary); text-decoration: underline; }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.mini th { font-size: 12px; color: var(--muted); }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.mini td.linknum { cursor: pointer; color: var(--primary); font-weight: 700; }
table.mini td.linknum:hover { text-decoration: underline; }
.rate-pill { font-weight: 700; }

/* ---------- モーダル ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 28, 50, .45); z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow); width: min(760px, 100%);
  max-height: 92vh; display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 16px; }
.modal-head .x { margin-left: auto; border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.req-mark { color: var(--danger); margin-left: 3px; }
.field .help { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.audit-box { background: #f7f9fd; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--muted); margin-top: 14px; }
.audit-box b { color: var(--ink); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-right: auto; }

/* ---------- トースト ---------- */
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2333; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); animation: pop .2s; }
.toast.ok { background: #15623a; }
.toast.err { background: #9a2828; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.pii-note { font-size: 12px; color: var(--warn); background: #fff7e6; border: 1px solid #f0dca8; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t-label { font-weight: 600; }
.switch { position: relative; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cbd2e0; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.list-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.req-info { font-size: 11px; color: var(--muted); }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: var(--ink); }
.steps li { margin: 5px 0; }

/* 貼り付け→自動入力 */
.paste-box { background: #eef4ff; border: 1px solid #cdddff; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.paste-head { font-weight: 700; font-size: 13px; margin-bottom: 8px; color: var(--primary-dark); }
.paste-box textarea { width: 100%; min-height: 84px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: 13px; font-family: inherit; resize: vertical; background: #fff; }
.paste-box textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.paste-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.paste-status { font-size: 12px; color: var(--muted); flex: 1; }
