:root {
  --bg: #eef1ef;
  --surface: #ffffff;
  --ink: #16232b;
  --ink-sub: #5b6b74;
  --line: #dbe2e0;
  --accent: #1d4f91;      /* 銀行の帳票ブルー */
  --accent-ink: #ffffff;
  --ok: #157a55;
  --ok-bg: #e2f2ea;
  --error: #b4362e;
  --error-bg: #fbe9e7;
  --warn: #8a5f00;
  --warn-bg: #fdf3d7;
  --radius: 10px;
  --mono: "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-size: 14.5px; line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ヘッダー */
.topbar {
  background: #12283f; color: #e8eef5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 54px;
}
.brand { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: 9px; }
/* ロゴのシンボル。SVGなので背景色や字形の指定は不要 */
.brand-mark { display: block; flex: 0 0 auto; border-radius: 7px; }
.brand span { display: inline-flex; align-items: baseline; }
.brand span b { color: #e8b931; font-weight: 700; }
.brand { margin-right: auto; }
.brand-sub { font-size: 11px; font-weight: 400; color: #9db2c6; margin-left: 2px; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: #cfdae6; font-size: 13.5px; }
.nav a:hover { color: #fff; text-decoration: none; }
.logout-form { margin-left: 18px; flex: 0 0 auto; }
.logout-form .link-btn { color: #9db2c6; font-size: 13px; }
.logout-form .link-btn:hover { color: #fff; text-decoration: none; }

.container { max-width: 1080px; margin: 0 auto; padding: 26px 22px 60px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 0 22px 30px; color: var(--ink-sub); font-size: 12px; }

/* 左メニュー（管理画面のみ）。項目が増えても縦に伸ばせるので上タブから移した。
   スタッフ側はスマホ主体なので上タブのまま。 */
/* 画面左端ぴったりだと親指が届きにくいので、内側に寄せてタップ領域も広めに取る */
.nav-toggle {
  display: none; background: none; border: 0; color: #cfdae6;
  font-size: 21px; line-height: 1; padding: 10px 14px; margin-left: 6px; cursor: pointer;
  min-width: 44px; min-height: 44px;
}
.nav-toggle:hover { color: #fff; }

.has-sidebar .shell { display: flex; align-items: flex-start; }
.sidebar {
  flex: 0 0 208px; align-self: stretch;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 0 40px; min-height: calc(100vh - 54px);
}
.side-group {
  padding: 0 18px; margin: 16px 0 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--ink-sub);
}
.side-group:first-child { margin-top: 0; }
.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; color: var(--ink); font-size: 13.5px;
  border-left: 3px solid transparent;
}
.side-link:hover { background: #f2f5f4; text-decoration: none; }
.side-link.is-current { background: #eaf0f6; border-left-color: var(--accent); font-weight: 700; color: var(--accent); }
.side-icon { width: 18px; text-align: center; font-size: 13px; }

/* サイドメニューぶん、本文の中央寄せ基準をずらす */
.has-sidebar .container { flex: 1 1 auto; min-width: 0; max-width: 1180px; margin: 0; }
.has-sidebar .foot { margin: 0; padding-left: 230px; }
.sidebar-backdrop { display: none; }

h1 { font-size: 21px; margin: 0 0 14px; }
h2 { font-size: 15.5px; margin: 26px 0 10px; color: var(--ink); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }

/* カード・テーブル */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 12px; color: var(--ink-sub); font-weight: 600; background: #f7f9f8; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
.r { text-align: right; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.strong { font-weight: 700; }
.sub, .sub-cell { color: var(--ink-sub); font-size: 12px; }
td .sub { display: block; margin-top: 2px; }
fieldset.no-border { border: 0; padding: 0; margin: 0; }
fieldset.no-border legend { padding: 0; }
.err { color: var(--error); }
.row-error td { background: #fff7f6; }
.row-muted td { color: var(--ink-sub); background: #fafbfa; }
.total-row td { background: #f7f9f8; font-weight: 600; }
.empty, .empty-cell { padding: 26px; text-align: center; color: var(--ink-sub); }

/* チップ・フラッシュ */
.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-error { background: var(--error-bg); color: var(--error); }
.chip-muted { background: #edf0ef; color: var(--ink-sub); }
.chip-warn { background: #fdf3e2; color: #a5661b; }
/* テストモードの帯。送信を伴う画面はどこからでも入れるので、全ページの先頭に固定で出す */
.testmode-bar {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 10px 15px; margin-bottom: 16px; font-size: 13px;
  background: #fff8e1; color: #7a5a00;
  border: 1px solid #e8cf8a; border-left: 4px solid #e8b931; border-radius: var(--radius);
}
.testmode-bar b { color: #5c4300; }

.flash { padding: 11px 15px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
ul.plain { margin: 0; padding-left: 18px; }

/* 出力バー */
.export-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 13px 18px; margin-bottom: 16px;
}
.stat { margin-right: 18px; color: var(--ink-sub); }
.stat b { color: var(--ink); font-size: 16px; }

/* フォーム */
.form-card { padding: 20px; }
.stack > * + * { margin-top: 14px; }
label { display: block; font-size: 12.5px; color: var(--ink-sub); font-weight: 600; }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--ink);
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type="file"] { padding: 6px; }
/* iOSは日付入力を中央寄せ＋固有幅で描くため、他の入力欄と頭を揃えつつ枠からはみ出させない。
   min-width:0 が無いと grid/flex の子として内容幅まで広がってしまう。 */
input[type="date"], input[type="month"] {
  text-align: left; min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none;
}
/* grid の子が内容幅で押し広げられるのを防ぐ */
.grid2 > *, .grid4 > * { min-width: 0; }
.hint { display: block; font-weight: 400; font-size: 12px; color: var(--ink-sub); margin-top: 5px; }
/* grid の隣の列にあるラベル付き入力と高さを合わせるための padding-top。
   単独で置くときは .check-inline で解除する */
.check-label { display: flex; align-items: center; gap: 8px; padding-top: 24px; }
.check-label.check-inline { padding-top: 0; }
.check-label input { width: auto; margin: 0; flex: 0 0 auto; }
.radio-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.radio-row .radio-label { min-width: 120px; color: #555; font-size: 14px; }
.radio-row .check-label { padding-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.align-top { align-items: start; }
.actions { display: flex; gap: 10px; }

/* ボタン */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: #173f74; }
.btn-disabled { opacity: .45; pointer-events: none; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.month-foot { margin-top: 10px; text-align: right; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px; }
.filter-bar select, .filter-bar input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
/* フリーワード欄は幅を取る（プルダウン3つを1本にまとめたぶん） */
.filter-search { flex: 1 1 320px; min-width: 240px; }

/* スタッフ管理の検索 */
.staff-search { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px; margin-bottom: 14px; }
.staff-search input {
  flex: 1 1 320px; min-width: 220px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
}
.nowrap { white-space: nowrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kv { margin: 0; }
.kv > div { display: flex; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.kv dt { color: var(--ink-sub); min-width: 80px; margin: 0; }
.kv dd { margin: 0; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 13px; cursor: pointer; padding: 0; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--error); }
.inline { display: inline; }

/* ログイン */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 360px; padding: 28px; }
.login-card.wide { width: 560px; max-width: 94vw; }
.login-card h1 { text-align: center; }

/* マイ報酬 */
.month-card { margin-bottom: 16px; }
.month-head { display: flex; align-items: baseline; justify-content: space-between; padding: 13px 16px 0; }
.month-head h2 { margin: 0; }
.month-total .num { font-size: 19px; }
.month-card table { margin-top: 8px; }

/* 稼働可能日（シフト）の提出カレンダー */
.month-tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.month-tab {
  padding: 7px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink-sub); font-size: 13.5px;
}
.month-tab:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.month-tab.is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.cal-card { padding: 16px 18px 18px; }
.cal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cal-title { margin: 0; font-size: 16px; }
.cal-status { font-size: 13px; color: var(--ok); font-weight: 600; }
.cal-status-sub { color: var(--ink-sub); font-weight: 400; }
.cal-status-none { color: var(--warn); }
.cal-hint { margin-bottom: 12px; }
.legend { margin-left: 12px; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.dot-weekday { background: #4aa06a; }
.dot-saturday { background: #e08a2e; }
.dot-holiday { background: #c94f45; }

.cal { table-layout: fixed; }
.cal th {
  text-align: center; font-size: 12px; color: var(--ink-sub);
  padding: 4px 0; border-bottom: 1px solid var(--line);
}
.cal th.is-saturday { color: #c2761f; }
.cal th.is-holiday { color: var(--error); }
.cal td.cal-cell { padding: 3px; border-bottom: none; }

/* チェックボックスは隠し、ラベル全体をタップ領域にする */
.day { display: block; cursor: pointer; }
.day input { position: absolute; opacity: 0; width: 0; height: 0; }
.day-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 46px; padding: 4px 2px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); transition: background .12s, border-color .12s;
}
.day-num { font-size: 15px; line-height: 1.2; }
.day-note { font-size: 9.5px; line-height: 1.2; color: var(--ink-sub); text-align: center; }
.day-weekday .day-num { color: var(--ink); }
.day-saturday .day-num { color: #c2761f; }
.day-holiday .day-num { color: var(--error); }
.day:hover .day-box { border-color: var(--accent); }

/* 選択中：色は曜日区分ごとに変える（フォームの🟢🟠🟥を踏襲） */
.day input:checked + .day-box { border-width: 2px; font-weight: 700; }
.day-weekday  input:checked + .day-box { background: #e3f1e8; border-color: #4aa06a; }
.day-saturday input:checked + .day-box { background: #fdefdc; border-color: #e08a2e; }
.day-holiday  input:checked + .day-box { background: #fbe6e4; border-color: #c94f45; }
.day input:focus-visible + .day-box { outline: 2px solid var(--accent); outline-offset: 1px; }

.cal-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 16px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.cal-bulk { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-submit { display: flex; align-items: center; gap: 12px; }
.cal-count { font-size: 13px; color: var(--ink-sub); }
.cal-count b { font-size: 16px; color: var(--ink); }

/* 月跨ぎの募集では、月初のマスだけ「9/1」と月を添える */
.day-mon { font-size: 10px; color: var(--ink-sub); }

/* 提出期限の帯。締切間近と締切後は色で気づけるようにする */
.cal-deadline {
  margin: 10px 0 0; padding: 9px 12px; border-radius: 8px;
  background: #eef3f1; color: var(--ink); font-size: 13px;
}
.cal-deadline.is-soon { background: #fdf3e2; color: #a5661b; }
.cal-deadline.is-closed { background: #f2f3f3; color: var(--ink-sub); }

/* シフト募集：対象者の選択 */
.target-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.target-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.target {
  display: flex; gap: 9px; align-items: flex-start; cursor: pointer;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
/* グローバルの input は width:100% なので、ここで解除しないと
   チェックボックスが行幅いっぱいを占めて氏名が右に押し出される */
.target input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }
.target:hover { border-color: var(--accent); }
.target:has(input:checked) { background: #eef3f1; border-color: var(--brand); }
.target.is-unlinked { background: #fafbfa; }
.target-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.target-name { font-size: 13.5px; font-weight: 600; }
.target-sub { font-size: 11.5px; color: var(--ink-sub); }

/* 送信前に見せるLINE本文のプレビュー */
.msg-preview {
  margin: 0; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fafbfa; font-size: 13px; line-height: 1.7; white-space: pre-wrap;
  font-family: inherit; color: var(--ink);
}

/* 空き状況（日付ごとの一覧） */
.avail-filter { padding: 16px 18px; margin-bottom: 18px; }
.avail-filter-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-top: 14px;
  padding-top: 13px; border-top: 1px solid var(--line);
}

.avail-day { padding: 14px 18px 16px; margin-bottom: 12px; border-left: 4px solid var(--line); }
.avail-day.day-saturday { border-left-color: #e08a2e; }
.avail-day.day-holiday { border-left-color: #c94f45; }
.avail-day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.avail-date { margin: 0; font-size: 15px; }
.avail-holiday { margin-left: 8px; font-size: 11.5px; font-weight: 400; color: var(--error); }
.avail-counts { display: inline-flex; gap: 7px; align-items: center; }

.avail-people {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px; margin-top: 12px;
}
.person {
  display: flex; gap: 10px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.person.is-assigned { background: #f7f8f8; color: var(--ink-sub); }
/* 職種の色帯。兼務している人は帯が複数本並ぶ */
.person-bars { display: inline-flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.wt-bar { display: block; width: 4px; height: 15px; border-radius: 2px; }
.wt-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.wt-a { background: #2f6f9f; }   /* クローザー等 */
.wt-b { background: #d08327; }   /* キャッチャー等 */
.wt-c { background: #4f9a6a; }
.wt-d { background: #8a5fa8; }
.wt-e { background: #b4645c; }
.wt-none { background: var(--line); }

.person-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.person-head { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
/* 案件地から探すので、氏名より駅を先・強めに出す */
.person-station { font-size: 13.5px; }
.person-name { font-size: 12.5px; color: var(--ink-sub); }
.person-sub { font-size: 11.5px; color: var(--ink-sub); }
.person-assigned { font-size: 11.5px; color: var(--ink-sub); margin-top: 2px; }
.person-action { flex: 0 0 auto; }

@media (max-width: 900px) {
  /* 狭い画面では左メニューを引き出し式に（☰ で開閉） */
  .has-sidebar .nav-toggle { display: block; }
  .has-sidebar .sidebar {
    position: fixed; top: 54px; left: 0; bottom: 0; z-index: 30;
    width: 232px; flex-basis: auto; min-height: 0; overflow-y: auto;
    transform: translateX(-100%); transition: transform .18s ease;
    box-shadow: 2px 0 14px rgba(0,0,0,.12);
  }
  .nav-open .sidebar { transform: none; }
  .nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 54px 0 0; z-index: 20; background: rgba(0,0,0,.35);
  }
  .has-sidebar .container { max-width: 100%; }
  .has-sidebar .foot { padding-left: 22px; }
}

@media (max-width: 760px) {
  /* 列を潰して「宇」「田」「川」と1文字ずつ折り返すより、横スクロールさせたほうが読める。
     .table-card は overflow-x:auto なので、中の表に最低幅を与えるとスクロールに切り替わる。 */
  .table-card table { min-width: 700px; }
  .table-card th, .table-card td { white-space: nowrap; }
  /* 明細名や備考など、元から折り返して読ませたいセルは対象外にする */
  .table-card .wrap, .table-card .wrap * { white-space: normal; }
  .table-card td .sub { white-space: nowrap; }

  .target-grid, .avail-people { grid-template-columns: 1fr; }
  .avail-filter-foot { flex-direction: column; align-items: stretch; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .cal-card { padding: 12px 8px 14px; }
  .cal td.cal-cell { padding: 2px; }
  .day-box { min-height: 42px; }
  .day-note { display: none; }  /* 幅が足りないので祝日名は省く（色で判別） */
  .legend { margin-left: 0; margin-right: 10px; }
  .cal-actions { flex-direction: column; align-items: stretch; }
  .cal-submit { justify-content: space-between; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .export-bar { flex-direction: column; align-items: stretch; text-align: center; }
  /* トップバーを2段に：上段=ブランド＋ログアウト / 下段=横スクロールのメニュー */
  .topbar { flex-wrap: wrap; height: auto; align-items: center; padding: 0; }
  .brand { order: 1; flex: 1 1 auto; padding: 11px 16px; white-space: nowrap; margin-right: 0; }
  .brand-sub { display: none; }
  .logout-form { order: 2; flex: 0 0 auto; margin-left: 0; padding: 0 16px; }
  .nav {
    order: 3; gap: 0; width: 100%; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-top: 1px solid rgba(255,255,255,.1);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; white-space: nowrap; padding: 12px 13px; font-size: 13.5px; }
}
