:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #e3e7ec;
  --brand: #2456b8;
  --brand-ink: #ffffff;
  --danger: #c0392b;
  --warn: #a5610c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav a { color: var(--brand); text-decoration: none; }
.nav a:hover { text-decoration: underline; }
.nav .user { color: var(--muted); font-size: 0.9rem; }
.logout { margin: 0; }
.logout button {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 0.3rem 0.7rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem;
}
.logout button:hover { border-color: var(--muted); }

/* --- Layout --- */
.container { max-width: 1120px; margin: 1.5rem auto; padding: 0 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* --- Filter tabs（承認待ち／承認済み 絞り込み） --- */
.filter-tabs { display: flex; gap: 0.5rem; margin: 0 0 1rem; flex-wrap: wrap; }
.filter-tab {
  padding: 0.35rem 0.9rem; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: 0.9rem; background: var(--card);
}
.filter-tab:hover { border-color: var(--muted); }
.filter-tab.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* --- 月移動（前月/当月/次月・SPEC §13.1） --- */
.month-nav { display: flex; gap: 0.4rem; margin: 0.6rem 0 1rem; flex-wrap: wrap; }

/* --- ページ送り --- */
.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; flex-wrap: wrap; }

/* --- Actions / buttons --- */
.actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.button, button.primary, button.danger, button.warn, .primary {
  display: inline-block; text-decoration: none; cursor: pointer;
  padding: 0.55rem 1.1rem; border-radius: 8px;
  font-family: inherit; font-size: 0.95rem; line-height: 1.4;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.button:hover { border-color: var(--muted); }
.button.small { padding: 0.3rem 0.65rem; font-size: 0.85rem; border-radius: 6px; }

/* --- Admin: 行内フォーム --- */
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.inline-form input[type="text"], .inline-form input[type="email"], .inline-form input[type="search"], .inline-form select {
  padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; line-height: 1.4; background: #fff; color: var(--ink); box-sizing: border-box;
}
.inline-form .chk { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.85rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 0.6rem; }
.primary, button.primary {
  background: var(--brand); color: var(--brand-ink); border-color: var(--brand);
}
.primary:hover { filter: brightness(1.05); }

/* --- Forms --- */
.stack { display: flex; flex-direction: column; gap: 0.35rem; }
.stack label { font-weight: 600; font-size: 0.9rem; margin-top: 0.6rem; }
.stack input, .stack select, .stack textarea {
  padding: 0.55rem 0.65rem; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink); width: 100%;
}
.stack input:focus, .stack select:focus, .stack textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand);
}
.req { color: var(--danger); font-size: 0.7rem; font-weight: 600; vertical-align: middle; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 長文セル（操作履歴のコメント等）は折り返しを許可（横幅が狭くても table-wrap で横スクロール） */
td.wrap, th.wrap { white-space: normal; min-width: 16rem; }

/* --- Definition list (detail) --- */
.detail { display: grid; grid-template-columns: 8rem 1fr; gap: 0.4rem 1rem; margin: 1rem 0; }
.detail dt { color: var(--muted); font-size: 0.9rem; }
.detail dd { margin: 0; }

/* --- Badges (status) --- */
.badge {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; border: 1px solid transparent;
}
.s-submitted { background: #e7f0ff; color: #1b4a9c; }
.s-approved  { background: #e5f6ec; color: #1c7a45; }
.s-rejected  { background: #fdeaea; color: #b0281c; }
.s-returned  { background: #fdf1e3; color: #a5610c; }
.s-cancelled { background: #eef0f2; color: #64707c; }

.error {
  background: #fdeaea; color: #9b241a; border: 1px solid #f2c4bf;
  padding: 0.6rem 0.8rem; border-radius: 8px;
}
.notice {
  background: #e5f6ec; color: #1c7a45; border: 1px solid #b7e0c4;
  padding: 0.6rem 0.8rem; border-radius: 8px;
}

/* --- Sign in with Google（Google 公式ボタン gsi-material-button）--- */
/* 見出し・説明文・ボタンを中央寄せ（ボタンは inline-block なので text-align で中央化）。 */
.login-card { text-align: center; }
.login-card hr.sep { border: none; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.login-card .stack { text-align: left; margin-top: 0.5rem; }
.login-card .muted { margin-bottom: 1.1rem; }
.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  background-color: #fff;
  background-image: none;
  border: 1px solid #747775;
  border-radius: 4px;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: "Roboto", arial, sans-serif;
  font-size: 14px;
  height: 40px;
  letter-spacing: 0.25px;
  outline: none;
  overflow: hidden;
  padding: 0 12px;
  position: relative;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.218s, border-color 0.218s, box-shadow 0.218s;
  vertical-align: middle;
  white-space: nowrap;
  width: auto;
  max-width: 400px;
  min-width: min-content;
}
.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 12px;
  min-width: 20px;
  width: 20px;
}
.gsi-material-button .gsi-material-button-content-wrapper {
  align-items: center;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: space-between;
  position: relative;
  width: 100%;
}
.gsi-material-button .gsi-material-button-contents {
  flex-grow: 1;
  font-family: "Roboto", arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}
.gsi-material-button .gsi-material-button-state {
  transition: opacity 0.218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}
.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #303030;
  opacity: 0.12;
}
.gsi-material-button:not(:disabled):hover {
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.30), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}
.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #303030;
  opacity: 0.08;
}

/* --- Approval / rejection action（コメント欄1つ＋ボタン3つ・issue #5）--- */
.action-panel {
  margin: 1.25rem 0; padding: 1rem; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card);
}
.button.danger, button.danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.button.warn, button.warn {
  background: var(--warn); color: #fff; border-color: var(--warn);
}
.button.danger:hover, button.danger:hover,
.button.warn:hover, button.warn:hover { filter: brightness(1.05); }
/* コメント未入力の間、却下・差戻ボタンは薄く・押せない見た目にする（JS が disabled を付ける・issue #5）。 */
.action-panel button:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

/* --- Footer --- */
.foot { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.5rem 1rem 2.5rem; }
.devtag {
  background: #333; color: #fff; border-radius: 4px; padding: 0.05rem 0.4rem;
  font-size: 0.7rem; margin-left: 0.4rem;
}

/* --- ページ番号（前へ, 1, 2, …, n, 次へ・SPEC §13.1） --- */
.pager-nums { display: inline-flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }
.pager-num {
  display: inline-block; min-width: 2rem; text-align: center;
  padding: 0.3rem 0.5rem; border: 1px solid var(--line); border-radius: 6px;
  text-decoration: none; color: var(--ink); background: var(--card); font-size: 0.9rem;
}
.pager-num:hover { border-color: var(--muted); }
.pager-num.current { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pager-gap { padding: 0 0.15rem; color: var(--muted); }

/* --- 管理メニュー（プルダウン・SPEC §13.1） ---
   details/summary で組み JS を使わない。summary の既定の三角マーカーは消して自前の▾を出す。 */
.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; color: var(--brand);
  padding: 0.1rem 0; user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: " ▾"; font-size: 0.75em; }
.menu > summary:hover { text-decoration: underline; }
.menu[open] > summary { text-decoration: underline; }
.menu-list {
  position: absolute; right: 0; top: 100%; z-index: 20; margin: 0.35rem 0 0; padding: 0.3rem;
  list-style: none; min-width: 11rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(28, 36, 48, 0.12);
}
.menu-list li { margin: 0; }
.menu-list a {
  display: block; padding: 0.45rem 0.7rem; border-radius: 6px;
  color: var(--ink); text-decoration: none; font-size: 0.92rem; white-space: nowrap;
}
.menu-list a:hover { background: var(--bg); text-decoration: none; }

/* --- 承認待ち一覧(全期間) ショートカット（SPEC §13.1, issue #4） ---
   検索フォーム（inline-flex・wrap）の末尾に置き、行の右端へ寄せる（＝2段目の右側）。 */
.inline-form .list-shortcut { margin-left: auto; }

/* --- 操作履歴: その時の申請内容（ホバー＆クリックで表示・SPEC §13.1, issue #4） ---
   ⓘ にホバー、またはクリック/フォーカスすると内容をポップオーバー表示する。JS は使わず
   :hover と :focus-within で出す。ポップオーバーが表に切られないよう、この履歴表の
   table-wrap は overflow を可視にする（.snap-visible）。 */
.table-wrap.snap-visible { overflow: visible; }
.has-snapshot { position: relative; }
.snapshot-trigger {
  background: none; border: 0; margin: 0; padding: 0 0 0 0.2rem;
  font-size: 1em; line-height: 1; cursor: pointer; vertical-align: baseline;
  color: var(--brand);
}
.snapshot-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.snapshot-pop {
  position: absolute; top: calc(100% + 0.3rem); left: 0; z-index: 30;
  display: none; width: max-content; max-width: 20rem; text-align: left;
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(28, 36, 48, 0.16);
  padding: 0.55rem 0.7rem; white-space: normal; font-weight: 400;
}
.has-snapshot:hover .snapshot-pop,
.has-snapshot:focus-within .snapshot-pop { display: block; }
.snapshot-pop-title { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
.snapshot-row { display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.05rem 0.6rem; font-size: 0.86rem; }
.snapshot-row > span:first-child { color: var(--muted); }
