:root {
  /* ブランド色。ロゴ（eyecatch.jpg）から採色した。
     ティールが主役、イエローは差し色。黄は白地では読めないので、
     濃い地の上の線や印にだけ使い、文字色には使わない。 */
  --brand: #004353;
  --brand-dark: #00313d;
  --brand-tint: #e7eef0;
  --brand-yellow: #ffe800;

  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #16323a;
  --muted: #64777d;
  --line: #dfe5e7;
  --accent: var(--brand);
  --accent-ink: #ffffff;
  --danger: #c0362c;
  --ok-bg: #e8f5ee;
  --ok-ink: #1b6b40;
  --err-bg: #fdecea;
  --err-ink: #a3261d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); }

/* ---------- 公開フォーム ---------- */
.form-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

.form-wrap h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

.lead {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}

.field { margin-bottom: 22px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}

.req {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: 2px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 16px; /* iOS のズーム防止 */
  font-family: inherit;
  background: #fff;
  color: inherit;
}

.field input:focus {
  outline: 2px solid rgba(0, 67, 83, .32);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
}

.field.has-error input { border-color: var(--danger); }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 5px;
}

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn {
  display: inline-block;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 26px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--brand-dark); }

/* 押せないボタンは、押せないと見て分かるようにする */
.btn:disabled,
.btn:disabled:hover {
  background: #b7c4c8;
  color: #f2f6f7;
  cursor: not-allowed;
}

.btn-sub:disabled,
.btn-sub:disabled:hover {
  background: #f1f4f5;
  color: #9aa8ad;
  border-color: var(--line);
}
.btn-block { display: block; width: 100%; }

.btn-sub {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 500;
  padding: 6px 14px;
  font-size: 13px;
}

.btn-danger { background: none; border: 1px solid var(--line); color: var(--danger); }

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 22px;
  font-size: 14px;
}
.alert-ok  { background: var(--ok-bg);  color: var(--ok-ink); }
.alert-err { background: var(--err-bg); color: var(--err-ink); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

/* ---------- 管理画面 ---------- */
.admin-header {
  background: var(--brand);
  color: #fff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.admin-header .brand {
  font-weight: 700;
  font-size: 15px;
  padding: 14px 0;
  white-space: nowrap;
}

.admin-nav { display: flex; gap: 4px; flex: 1; }

.admin-nav a {
  color: #a8c3c9;
  text-decoration: none;
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 3px solid transparent;
}

.admin-nav a:hover { color: #fff; }
.admin-nav a.active { color: #fff; border-bottom-color: var(--brand-yellow); font-weight: 600; }

.admin-header .logout { font-size: 13px; display: flex; align-items: center; gap: 14px; }
.admin-header .logout a { color: #a8c3c9; }
.admin-header .logout .me { color: #fff; }

.admin-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px 80px; }

.page-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 { font-size: 20px; margin: 0; }
.count { color: var(--muted); font-size: 13px; }

.toolbar { margin-left: auto; display: flex; gap: 8px; }

.search-form { display: flex; gap: 6px; }

.search-form input[type="search"] {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  min-width: 220px;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: #f7f9fa;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--brand-tint); }

td.wrap { white-space: normal; min-width: 180px; }
td.num, th.num { text-align: right; color: var(--muted); }
td.actions { text-align: right; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 6px; }

.badge {
  display: inline-block;
  font-size: 12px;
  border-radius: 999px;
  padding: 2px 10px;
  background: #eef1f5;
  color: #4a5464;
}
.badge-new { background: var(--brand-tint); color: var(--brand); }

.pager {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  font-size: 14px;
}

.pager a, .pager span {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  text-decoration: none;
  color: var(--ink);
}

.pager .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager .disabled { color: #b6bdc7; background: #f4f5f7; }

.login-wrap { max-width: 380px; margin: 0 auto; padding: 80px 20px; }
.login-wrap h1 { font-size: 18px; margin: 0 0 20px; text-align: center; }


/* ---------- スタッフ管理 ---------- */
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: inherit;
}

.field select:disabled { background: #f2f4f6; color: var(--muted); }

.field .static-value {
  margin: 0;
  padding: 10px 0 0;
  font-weight: 600;
}

.form-narrow { max-width: 560px; }

.form-narrow .meta {
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin: 0 0 20px;
}

.add-panel { margin-top: 22px; }

.add-panel > summary {
  cursor: pointer;
  display: inline-block;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  user-select: none;
}

.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel > summary::before { content: "＋ "; color: var(--accent); }
.add-panel[open] > summary::before { content: "− "; }
.add-panel > summary:hover { border-color: var(--accent); color: var(--accent); }
.add-panel .panel { margin-top: 14px; max-width: 560px; }

tr.row-off td { color: var(--muted); background: #fbfbfc; }
tr.row-off strong { font-weight: 500; }
.off { color: var(--danger); }

td.actions .btn-sub { margin-left: 4px; }
td.actions form { display: inline; }

/* ---------- 承認ステータス ---------- */
.badge-pending  { background: #fdf1dd; color: #8a5a10; }
.badge-approved { background: #e3f3e9; color: #1b6b40; }

td .sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.btn-approve {
  border-color: #a9c6cd;
  color: var(--brand);
  font-weight: 600;
}

.btn-approve:hover { background: var(--brand-tint); }

.filter-tabs {
  display: flex;
  gap: 4px;
  margin: -6px 0 18px;
  flex-wrap: wrap;
}

.filter-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
}

.filter-tabs a:hover { border-color: var(--accent); color: var(--accent); }

.filter-tabs a.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.filter-tabs .n {
  font-size: 11px;
  color: var(--muted);
  background: #eef1f5;
  border-radius: 999px;
  padding: 0 7px;
}

.filter-tabs a.active .n { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- クライアント側 ---------- */
.client-header .brand { color: #fff; }

.panel-title {
  font-size: 14px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 20px;
  font-size: 14px;
}

.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 600; word-break: break-all; }

@media (max-width: 560px) {
  .detail { grid-template-columns: 1fr; gap: 2px 0; }
  .detail dd { margin-bottom: 10px; }
}

/* ---------- 確認ダイアログ ---------- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(28, 36, 48, .55);
  animation: confirm-fade .12s ease-out;
}

/* display:flex を指定しているので、hidden を明示的に効かせる */
.confirm-overlay[hidden] { display: none; }

@keyframes confirm-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.confirm-dialog {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(15, 22, 32, .28);
  width: 100%;
  max-width: 440px;
  padding: 26px 26px 20px;
  animation: confirm-pop .14s ease-out;
}

@keyframes confirm-pop {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.confirm-title {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.5;
}

.confirm-message {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.75;
  color: #45505f;
  white-space: pre-line;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.confirm-actions .btn {
  padding: 10px 22px;
  font-size: 14px;
}

.confirm-actions .btn-sub { font-weight: 500; }

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
  border: 0;
}

.is-modal-open { overflow: hidden; }

@media (max-width: 560px) {
  .confirm-dialog { padding: 22px 20px 18px; }
  .confirm-actions { flex-direction: column-reverse; }
  .confirm-actions .btn { width: 100%; }
}

/* アニメーションを控えたい設定の環境では動かさない */
@media (prefers-reduced-motion: reduce) {
  .confirm-overlay,
  .confirm-dialog { animation: none; }
}

/* ---------- トースト通知 ---------- */
.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(calc(100vw - 40px), 400px);
  pointer-events: none;
}

/* ヘッダーのある画面では、その下に出す */
.toast-stack--under-header { top: 68px; }

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 22, 32, .16);
  padding: 14px 42px 14px 16px;
  pointer-events: auto;
  animation: toast-in .22s cubic-bezier(.2, .8, .3, 1);
}

.toast-ok  { border-left-color: #2c9c62; }
.toast-err { border-left-color: var(--danger); }

.toast-body {
  position: relative;
  margin: 0;
  padding-left: 22px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  word-break: break-word;
}

/* 折り返した2行目以降も本文の頭に揃うよう、アイコンは絶対配置にする */
.toast-body::before {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 700;
}

.toast-ok  .toast-body::before { content: "✓"; color: #2c9c62; }
.toast-err .toast-body::before { content: "!"; color: var(--danger); left: 4px; }

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.toast-close:hover { background: #eef1f5; color: var(--ink); }

.toast.is-leaving { animation: toast-out .2s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateX(16px); }
}

@media (max-width: 560px) {
  .toast-stack,
  .toast-stack--under-header {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
    width: auto;
  }
  @keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.is-leaving { animation: none; }
}

/* 操作ボタンが増えても表からはみ出さないよう、折り返せるようにする */
td.actions {
  text-align: right;
  white-space: normal;
}

td.actions form {
  display: inline-block;
  margin: 2px 0 2px 6px;
}

td.actions .btn-sub { margin-left: 0; }

/* ---------- 同意書 ---------- */
.consent-wrap { max-width: 760px; }

.consent-body {
  margin: 0;
  padding: 20px;
  background: #fbfbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.consent-action { margin-top: 18px; text-align: center; }

.consent-lead {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 600;
}

.btn-lg { padding: 16px 26px; font-size: 16px; }

.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: 400;
}

.radio-row:hover { border-color: var(--accent); }
.radio-row input { margin-top: 3px; }
.radio-row a { font-size: 12px; margin-left: 10px; }

.badge-requested { background: #eef1f5; color: #4a5464; }
.badge-awaiting  { background: #fdf1dd; color: #8a5a10; }
.badge-agreed    { background: #e3f3e9; color: #1b6b40; }

.scope-note {
  margin: -6px 0 18px;
  padding: 11px 14px;
  background: #f1f4f8;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.8;
  color: #45505f;
}

.field textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.9;
  font-family: inherit;
  background: #fff;
  color: inherit;
  resize: vertical;
}

.field textarea.mono {
  font-family: "SFMono-Regular", Menlo, Consolas, "Noto Sans Mono", monospace;
  font-size: 13px;
}

.field .hint code {
  background: #eef1f5;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
}

/* ---------- 読むためのモーダル ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(10, 30, 36, .55);
  animation: confirm-fade .12s ease-out;
}

.modal-overlay[hidden] { display: none; }

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(10, 30, 36, .3);
  animation: confirm-pop .14s ease-out;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  flex: 1;
}

.modal-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.modal-close:hover { background: var(--brand-tint); color: var(--ink); }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-body .consent-body {
  background: none;
  border: 0;
  padding: 0;
}

.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  text-align: right;
}

/* 押せることが分かるように、リンクらしい見た目のボタン */
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover { color: var(--brand-dark); }

.preview-source { display: none; }

@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-dialog { animation: none; }
}

/* 対処すべきことがある知らせ。説明と、そこへ行くボタンを並べる */
.notice-action {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.notice-action > div { flex: 1; min-width: 240px; }
.notice-action .btn { white-space: nowrap; }
