/* 物撮りドットコム 注文システム 管理画面CSS（~/dev共通規約: em単位 / min(92%,80em) / Ubuntu+Noto Sans JP） */
:root {
    --ink: #1a1a1a;
    --muted: #6b6b6b;
    --line: #e5e5e5;
    --bg: #f5f4f2;
    --card: #ffffff;
    --brand: #1a1a1a;
    --accent: #2563eb;
    --danger: #c0392b;
    --ok: #15803d;
    --warn: #b45309;
    --info: #1d4ed8;
}
* { box-sizing: border-box; }
body {
    font-size: clamp(0px, calc(100vw / 80), 16px);
    font-family: 'Ubuntu', 'Noto Sans JP', sans-serif;
    color: var(--ink);
    line-height: 1.6;
    margin: 0;
    background: var(--bg);
}
@media (max-width: 769px) { body { font-size: clamp(0px, calc(100vw / 25), 14px); } }

a { color: var(--accent); }
.container { width: min(94%, 80em); margin: 0 auto; }

/* ヘッダー / ナビ */
.admin-header { background: var(--ink); color: #fff; }
/* ヘッダーは全幅（100vw相当）。中身の80em制限を外し、左右に余白だけ確保する。 */
.admin-header .container { width: 100%; max-width: none; display: flex; align-items: center; justify-content: space-between; gap: 1em; padding: 0.9em 1.5em; flex-wrap: wrap; }
.admin-brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.125em; }
.admin-brand small { color: #9ca3af; font-weight: 400; margin-left: 0.5em; font-size: 0.75em; }
.admin-nav { display: flex; align-items: center; gap: 0.25em; flex-wrap: wrap; }
.admin-nav a { color: #d1d5db; text-decoration: none; padding: 0.4em 0.8em; border-radius: 0.375em; font-size: 0.9375em; }
.admin-nav a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.admin-nav a.is-active { background: #fff; color: var(--ink); font-weight: 700; }
.admin-nav .badge-count { display: inline-block; min-width: 1.4em; text-align: center; background: var(--danger); color: #fff; border-radius: 1em; font-size: 0.75em; padding: 0 0.4em; margin-left: 0.3em; }

/* メイン */
main { padding: 2em 0 4em; }
h1 { font-size: 1.5em; margin: 0 0 1em; }
h2 { font-size: 1.1875em; margin: 1.5em 0 0.75em; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1em; margin-bottom: 1.5em; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

/* フラッシュ / エラー */
.flash { background: #ecfdf5; border: 0.0625em solid #a7f3d0; color: var(--ok); padding: 0.8em 1em; border-radius: 0.5em; margin-bottom: 1em; }
.errors { background: #fef2f2; border: 0.0625em solid #fecaca; color: var(--danger); padding: 0.8em 1em; border-radius: 0.5em; margin-bottom: 1em; }
.errors ul { margin: 0; padding-left: 1.2em; }

/* トースト通知（フラッシュ/エラーを右上に表示・自動消滅） */
.toast-container { position: fixed; top: 1em; right: 1em; z-index: 1000; display: flex; flex-direction: column; gap: 0.6em; width: min(92%, 26em); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 0.75em; padding: 0.85em 1em; border-radius: 0.5em; background: #fff; border-left: 0.25em solid currentColor; box-shadow: 0 0.5em 1.5em rgba(0,0,0,0.18); font-size: 0.9375em; line-height: 1.5; animation: toast-in 0.28s ease-out; }
.toast--success { color: var(--ok); background: #ecfdf5; }
.toast--error { color: var(--danger); background: #fef2f2; }
.toast-body { flex: 1; color: #1a1a1a; word-break: break-word; }
.toast-close { pointer-events: auto; flex-shrink: 0; background: none; border: 0; color: inherit; font-size: 1.25em; line-height: 1; cursor: pointer; padding: 0 0.1em; opacity: 0.55; }
.toast-close:hover { opacity: 1; }
.toast.is-hiding { animation: toast-out 0.35s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(1.2em); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(1.2em); } }
@media (max-width: 769px) { .toast-container { left: 1em; right: 1em; width: auto; } }

/* カード */
.card { background: var(--card); border: 0.0625em solid var(--line); border-radius: 0.625em; padding: 1.5em; margin-bottom: 1.25em; }
.card h2:first-child { margin-top: 0; }

/* 統計 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1em; margin-bottom: 1.5em; }
@media (max-width: 769px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 0.0625em solid var(--line); border-radius: 0.625em; padding: 1.25em; }
.stat__label { color: var(--muted); font-size: 0.8125em; margin: 0 0 0.4em; }
.stat__value { font-size: 1.625em; font-weight: 700; letter-spacing: 0.01em; }
.stat__sub { color: var(--muted); font-size: 0.8125em; margin-top: 0.3em; }

/* テーブル */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); }
table.data th, table.data td { text-align: left; padding: 0.75em 0.9em; border-bottom: 0.0625em solid var(--line); vertical-align: middle; white-space: nowrap; }
table.data th { background: #fafafa; font-size: 0.8125em; color: var(--muted); font-weight: 500; }
table.data tr:hover td { background: #fafafa; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .wrap { white-space: normal; }

/* バッジ */
.badge { display: inline-block; padding: 0.15em 0.6em; border-radius: 1em; font-size: 0.8125em; font-weight: 500; white-space: nowrap; }
.badge--gray { background: #f3f4f6; color: #4b5563; }
.badge--info { background: #dbeafe; color: var(--info); }
.badge--primary { background: #ede9fe; color: #6d28d9; }
.badge--warning { background: #fef3c7; color: var(--warn); }
.badge--success { background: #dcfce7; color: var(--ok); }
.badge--danger { background: #fee2e2; color: var(--danger); }

/* ボタン */
.btn { display: inline-block; padding: 0.6em 1.1em; border-radius: 0.5em; border: 0.0625em solid transparent; font-size: 0.9375em; font-weight: 700; cursor: pointer; text-decoration: none; line-height: 1.2; font-family: inherit; }
.btn--primary { background: var(--ink); color: #fff; }
.btn--accent { background: var(--accent); color: #fff; }
.btn--ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn--danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn--sm { padding: 0.35em 0.7em; font-size: 0.8125em; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.inline-form { display: inline; }

/* フォーム */
.field { margin-bottom: 1em; }
.field label { display: block; font-size: 0.875em; font-weight: 500; margin-bottom: 0.35em; }
.field .req { color: var(--danger); margin-left: 0.25em; }
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number],
.field input[type=date], .field input[type=file], .field textarea, .field select {
    width: 100%; padding: 0.6em; border: 0.0625em solid var(--line); border-radius: 0.5em; font-size: 1em; font-family: inherit; background: #fff;
}
.field textarea { min-height: 6em; resize: vertical; }
.field .hint { color: var(--muted); font-size: 0.8125em; margin-top: 0.25em; }
.field .err { color: var(--danger); font-size: 0.8125em; margin-top: 0.25em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25em; }
@media (max-width: 769px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .col-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75em; margin-top: 1.25em; align-items: center; }

/* 定義リスト（詳細表示） */
.dl { display: grid; grid-template-columns: 8em 1fr; gap: 0.5em 1em; }
.dl dt { color: var(--muted); font-size: 0.875em; }
.dl dd { margin: 0; }

/* 合計行 */
.totals { margin-left: auto; max-width: 22em; }
.totals .row { display: flex; justify-content: space-between; padding: 0.35em 0; }
.totals .row--grand { font-size: 1.1875em; font-weight: 700; border-top: 0.125em solid var(--ink); margin-top: 0.4em; padding-top: 0.6em; }

/* レイアウト補助 */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.25em; align-items: start; }
@media (max-width: 769px) { .grid-2 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.thumb { width: 3.5em; height: 2.33em; object-fit: cover; border-radius: 0.375em; border: 0.0625em solid var(--line); }
.pagination { display: flex; gap: 0.4em; margin-top: 1.25em; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 0.4em 0.7em; border: 0.0625em solid var(--line); border-radius: 0.375em; background: #fff; text-decoration: none; font-size: 0.875em; }
.pagination .active span { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ログイン */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2em; }
.login-card { background: var(--card); border: 0.0625em solid var(--line); border-radius: 0.75em; padding: 2.5em; width: min(100%, 24em); }
.login-card h1 { font-size: 1.25em; text-align: center; margin-bottom: 1.5em; }

/* ===== メールボックス（/admin/mail・shirohori.comから移植） ===== */
.mailbox-page { width: 100vw; margin-left: calc(50% - 50vw); padding: 0 2em; }
.mailbox { display: grid; grid-template-columns: 26em 22em 1fr; gap: 1em; align-items: start; }
.mailbox-pane { border: 0.0625em solid var(--line); border-radius: 0.5em; background: #fff; overflow: hidden; }
.mailbox-pane > h2 { font-size: 1em; margin: 0; padding: 0.75em 1em; background: #fafaf9; border-bottom: 0.0625em solid var(--line); }
.mailbox-body { padding: 1em; }
.mailbox-body textarea { min-height: 18em; font-size: 0.8125em; }
.mailbox-filter { display: flex; flex-wrap: wrap; gap: 0.5em; padding: 0.75em 1em; border-bottom: 0.0625em solid var(--line); }
.mailbox-filter select, .mailbox-filter input { padding: 0.375em 0.5em; border: 0.0625em solid var(--line); border-radius: 0.375em; font-family: inherit; font-size: 0.875em; }
.mailbox-filter input { flex: 1; min-width: 8em; }
.mailbox-list { max-height: 40em; overflow-y: auto; }
.mail-item { display: block; padding: 0.75em 1em; border-bottom: 0.0625em solid #f0efed; color: inherit; text-decoration: none; }
.mail-item:hover { background: #fafaf9; text-decoration: none; }
.mail-item.is-active { background: #fff7ed; box-shadow: inset 0.1875em 0 0 var(--warn); }
.mail-meta { display: flex; justify-content: space-between; align-items: center; gap: 0.5em; margin-bottom: 0.375em; }
.mail-meta > span:last-child { font-size: 0.75em; color: var(--muted); white-space: nowrap; }
.mail-dot { color: var(--danger); margin-right: 0.25em; }
.mail-party { font-size: 0.8125em; color: #57534e; margin-bottom: 0.125em; word-break: break-all; }
.mail-subject { font-size: 0.875em; }
.mail-item.is-unread .mail-subject { font-weight: 700; }
.mail-detail-body { white-space: pre-wrap; font-size: 0.875em; line-height: 1.7; word-break: break-word; }
.mail-assignee { font-size: 0.75em; color: #57534e; margin-top: 0.25em; }
.mail-detail-status { margin-top: 1em; font-size: 0.875em; }
.mailbox-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5em; padding: 0.5em 1em; background: #fafaf9; border-bottom: 0.0625em solid var(--line); }
.mailbox-pane-head h2 { margin: 0; padding: 0; background: none; border: 0; font-size: 1em; display: flex; align-items: center; gap: 0.5em; }
.mailbox-refresh { display: inline-flex; align-items: center; justify-content: center; border: none; background: none; color: #57534e; cursor: pointer; padding: 0.3em; border-radius: 0.25em; line-height: 0; }
.mailbox-refresh:hover { background: #efedeb; color: var(--ink); }
@media (max-width: 769px) {
    .mailbox-page { padding: 0 1em; }
    .mailbox { grid-template-columns: 1fr; }
    .mailbox-list { max-height: 26em; }
}

/* 新規作成のゲート: 送信元を選ぶまで入力フォームを出さない */
.compose-gate { padding: 1.25em; border: 0.125em dashed var(--line); border-radius: 0.5em; background: #fafaf9; text-align: center; }
.compose-gate__lead { margin: 0 0 1em; font-size: 0.875em; color: #57534e; }
.compose-gate .field { text-align: left; margin-bottom: 1em; }
.compose-gate select { width: 100%; }
/* 選択後に表示する「送信元: ○○ [変更]」行 */
.mailbox-from-fixed { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; margin: 0; font-size: 0.875em; }

/* スタッフ管理 */
.staff-tenants { display: flex; flex-wrap: wrap; gap: 0.5em 1.25em; }
.staff-check { display: inline-flex; align-items: center; gap: 0.4em; font-size: 0.9375em; font-weight: 400; }
.staff-check input { width: auto; }
.staff-actions { display: flex; gap: 0.5em; align-items: center; white-space: nowrap; }
.staff-edit-row > td { background: #fafafa; }

/* 添付ファイル */
.mail-clip { vertical-align: -0.125em; color: #57534e; margin-right: 0.125em; }
.mail-attachments { margin-top: 1em; padding-top: 0.75em; border-top: 0.0625em dashed var(--line); font-size: 0.875em; }
.mail-attachments__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375em; }
.mail-attachments__link { display: inline-flex; align-items: center; gap: 0.3em; word-break: break-all; }

/* メール詳細ヘッダの操作ボタン（全員に返信/返信/アーカイブ） */
.mail-detail-actions { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }
