/* Report Agent 画面スタイル（色・タイポグラフィは Safie デザインシステム準拠） */

:root {
  --font-sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;

  /* brand */
  --accent-primary: #156ce6;
  --accent-secondary: #3b89f7;
  --accent-tertiary: #e1ecfc;
  --accent-quaternary: #e1ecfc;

  /* surface */
  --bg-base: #f2f5fa;
  --surface-base: #ffffff;
  --surface-neutral-2: #e9e9e9;
  --surface-neutral-3: #f6f6f6;
  --surface-alpha-3: rgba(0, 0, 0, 0.38);
  --surface-alpha-4: rgba(0, 0, 0, 0.12);
  --surface-destructive: #f9dede;

  /* label */
  --label-base: #000000;
  --label-alpha-primary: rgba(0, 0, 0, 0.87);
  --label-alpha-secondary: rgba(0, 0, 0, 0.6);
  --label-alpha-tertiary: rgba(0, 0, 0, 0.38);
  --label-white: #ffffff;
  --label-accent: #156ce6;
  --label-destructive: #dd0000;

  /* border */
  --border-neutral: #9e9e9e;
  --border-neutral-light: #e9e9e9;   /* --border/neutral/tertiary (Safie) */
  --border-neutral-secondary: #c6c6c6;
  --border-accent: #156ce6;
  --border-destructive: #dd0000;

  /* radius */
  --radius-input: 4px;
  --radius-card: 8px;
  --radius-button-md: 16px;
  --radius-button-lg: 24px;

  /* status hues (prototype-only, derived from brand palette) */
  --status-warning: #b8860b;
  --status-warning-bg: #fbf1d8;
  --status-todo: #0f4da7; /* 未完了バッジの塗り（Safie primitive/blue-80） */
  --badge-mine: #1b6e3a; /* 安全指摘の「あなたの修正」バッジ */
  --badge-mine-bg: #dff3e6;
  --object-orange: #eb8022; /* Beta バッジの塗り */

  --sidebar-w: 240px;
  --topbar-h: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  letter-spacing: 0;
  color: var(--label-alpha-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--label-accent); text-decoration: none; }

/* ---------- Layout (Safie chrome: full-width header over sidebar+content) ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app__body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; flex: 1; min-height: 0; }
/* ハンバーガーで畳んだときはアイコンだけのレールにする（ラベルとセクション見出しを落とす） */
.app__body.nav-collapsed { grid-template-columns: 66px 1fr; }
.app__body.nav-collapsed .nav { padding-top: 8px; }
.app__body.nav-collapsed .nav__sec { display: none; }
.app__body.nav-collapsed .navitem { justify-content: center; padding: 4px 12px; }
.app__body.nav-collapsed .navitem__label { display: none; }
.app__body.nav-collapsed .navsub { display: none; }
.app__body.nav-collapsed .navitem:hover { background: none; }
.app__body.nav-collapsed .navitem.is-active { background: none; }
.app__body.nav-collapsed .navitem__icon { width: 40px; height: 40px; border-radius: var(--radius-card); }
.app__body.nav-collapsed .navitem:hover .navitem__icon { background: var(--bg-base); }
.app__body.nav-collapsed .navitem.is-active .navitem__icon { background: var(--accent-quaternary); }

/* ---------- App header (Safie Navigation / Header) ---------- */
.appbar {
  height: var(--topbar-h);
  background: var(--surface-base);
  border-bottom: 1px solid var(--border-neutral-light);
  display: flex; align-items: center; justify-content: space-between;
  padding-left: 16px;
  position: sticky; top: 0; z-index: 30;
}
.appbar__left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.appbar__brand {
  margin-left: 4px;
  font-size: 18px; font-weight: 700; color: var(--label-alpha-primary);
}
/* アカウント: アバターのボタンでメニューを開閉する（開閉は app.js） */
.appbar__right { position: relative; display: flex; align-items: center; padding-right: 16px; }
.acct-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; border: none; background: none; color: var(--label-alpha-secondary);
}
.acct-btn:hover { background: var(--bg-base); }
.acct-menu {
  position: absolute; top: calc(100% + 4px); right: 16px; z-index: 40;
  width: 280px; padding: 20px;
  background: var(--surface-base); border: 1px solid var(--border-neutral-light);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}
.acct-menu__avatar { display: grid; place-items: center; color: var(--border-neutral-secondary); }
.acct-menu__logout {
  width: 100%; height: 44px; margin-top: 16px;
  border: none; border-radius: var(--radius-button-lg);
  background: var(--accent-primary); color: var(--label-white);
  font-family: inherit; font-size: 14px; font-weight: 700;
}
.acct-menu__logout:hover { background: var(--accent-secondary); }
.hmb {
  width: 32px; height: 32px; border-radius: var(--radius-input);
  display: grid; place-items: center; border: none; background: none;
  color: var(--label-alpha-secondary);
}
.hmb:hover { background: var(--bg-base); }

/* ---------- Sidebar (Safie Navigation / Element_open) ---------- */
.sidebar {
  background: var(--surface-base);
  border-right: 1px solid var(--border-neutral-light);
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
}
.nav { flex: 1; overflow-y: auto; padding-bottom: 8px; }
.nav__sec { font-size: 11px; font-weight: 700; color: var(--label-alpha-tertiary);
  padding: 16px 24px 6px; letter-spacing: .02em; }
.navitem {
  display: flex; align-items: center; gap: 4px;
  width: 100%; min-height: 48px;
  padding: 12px 16px 12px 24px;
  border: none; background: var(--surface-base);
  font-size: 14px; line-height: 21px; font-weight: 400;
  color: var(--label-alpha-secondary);
  text-align: left;
}
.navitem:hover { background: var(--bg-base); }
.navitem.is-active { background: var(--accent-quaternary); color: var(--label-accent); font-weight: 700; }
.navitem.is-active .navitem__icon { color: var(--label-accent); }
/* 選択中は塗りのアイコン、それ以外は線画 */
.navitem__icon .ic-fill { display: none; }
.navitem.is-active .navitem__icon .ic-outline { display: none; }
.navitem.is-active .navitem__icon .ic-fill { display: inline-block; }
.navitem__icon { width: 24px; height: 24px; flex: none; display: grid; place-items: center; color: var(--label-alpha-secondary); }
.navitem__label { flex: 1; min-width: 0; }
.navitem__star { width: 32px; height: 32px; border-radius: var(--radius-input); display: grid; place-items: center;
  color: var(--label-alpha-tertiary); flex: none; }
.navitem.is-active .navitem__star { color: var(--accent-primary); }
/* 親の項目の下に、親のラベルの左端に揃えて並べる */
.navsub { display: flex; flex-direction: column; padding-bottom: 4px; }
.navsub__item { padding: 8px 16px 8px 52px; font-size: 13px; line-height: 20px; color: var(--label-alpha-secondary); }
.navsub__item:hover { background: var(--bg-base); }
.navsub__item.is-active { color: var(--label-accent); font-weight: 700; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.headingbar {
  height: var(--topbar-h);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-neutral-light);
  display: flex; align-items: center; gap: 8px;
  padding: 0 24px;
  position: sticky; top: var(--topbar-h); z-index: 20;
}
.hb-back { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--radius-input); color: var(--label-alpha-secondary); }
.hb-back:hover { background: var(--surface-base); color: var(--label-accent); }
.hb-title { font-size: 16px; line-height: 24px; font-weight: 700; color: var(--label-alpha-primary); margin: 0; }
.content { padding: 24px; }
.page { display: none; }
.page.is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 6px 16px;
  border-radius: var(--radius-button-md);
  font-size: 14px; line-height: 21px; font-weight: 700;
  border: 1px solid transparent;
  background: var(--accent-primary); color: var(--label-white);
  transition: background .12s ease;
}
.btn:hover { background: var(--accent-secondary); }
.btn:disabled { background: var(--surface-neutral-2); color: var(--label-alpha-tertiary); cursor: not-allowed; }
.btn--lg { height: 40px; padding: 8px 16px; font-size: 16px; line-height: 24px; border-radius: var(--radius-button-lg); }
.btn--sm { height: 24px; padding: 4px 12px; font-size: 12px; line-height: 18px; border-radius: 12px; }
.btn--ghost { background: transparent; color: var(--label-accent); border-color: var(--border-accent); }
.btn--ghost:hover { background: var(--accent-tertiary); }
.btn--neutral { background: transparent; color: var(--label-alpha-primary); border-color: var(--border-neutral); }
.btn--neutral:not(:disabled):hover { background: var(--bg-base); }
.btn--danger { background: transparent; color: var(--label-destructive); border-color: var(--border-destructive); }
.btn--danger:hover { background: var(--surface-destructive); }
.btn svg { flex: none; }
/* PC では capture 付きの入力欄も通常のファイル選択になるため、撮影ボタンはタッチ操作の端末だけに出す */
.btn-capture { display: none; }
@media (pointer: coarse) { .btn-capture { display: inline-flex; } }


/* ---------- Cards ---------- */
.card {
  background: var(--surface-base);
  border: 1px solid var(--border-neutral-light);
  border-radius: var(--radius-card);
}
.card--pad { padding: 20px 24px; }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field > label, .field > span { font-size: 12px; line-height: 18px; color: var(--label-alpha-secondary); }
/* 変更できない値の表示。入力欄と枠を揃えつつ、無効化された入力に見えるよう灰背景＋二次色にする */
.readonly-value {
  min-height: 40px; display: flex; align-items: center;
  background: var(--surface-neutral-2); border: 1px solid var(--border-neutral);
  border-radius: var(--radius-input); padding: 4px 12px;
  font-size: 14px; line-height: 21px; color: var(--label-alpha-secondary); word-break: break-all;
}
.input, .select, .textarea {
  height: 40px; background: var(--surface-base);
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input);
  padding: 4px 12px; font-size: 14px; line-height: 21px; color: var(--label-alpha-primary);
  font-family: inherit; width: 100%;
}
.textarea { height: auto; min-height: 72px; padding: 8px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-accent); box-shadow: 0 0 0 2px var(--accent-tertiary); }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--label-alpha-tertiary); }
.search .input { padding-left: 36px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---------- Tags / badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 10px; border-radius: 11px;
  font-size: 12px; font-weight: 700; line-height: 18px;
  white-space: nowrap;
}
.badge--accent { background: var(--accent-tertiary); color: var(--label-accent); }
.badge--beta { background: var(--object-orange); color: var(--label-white); border-radius: var(--radius-input); }
.badge--warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge--danger { background: var(--surface-destructive); color: var(--label-destructive); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--radius-input);
  font-size: 12px; font-weight: 500;
  background: var(--surface-base); color: var(--label-alpha-primary);
  border: 1px solid var(--border-neutral-light);
}

/* 記録の対応ステータス。未完了を塗りで目立たせ、完了は落ち着かせる */
.rd-status {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; padding: 1px 6px; border-radius: 3px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.rd-status--open { background: var(--status-todo); color: var(--label-white); }
.rd-status--done { background: var(--surface-alpha-4); color: var(--label-alpha-primary); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 14px; font-weight: 700; color: var(--label-alpha-primary);
  padding: 12px 16px; border-bottom: 1px solid var(--border-neutral-light); white-space: nowrap;
}
.tbl td { padding: 24px 16px; border-bottom: 1px solid var(--border-neutral-light); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { color: var(--label-alpha-secondary); font-variant-numeric: tabular-nums; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 16px; }
.thumb-svg { width: 100%; height: 100%; object-fit: cover; display: block; }
/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { padding: 16px 20px; }
.stat__label { font-size: 12px; color: var(--label-alpha-secondary); }
.stat__value { font-size: 32px; line-height: 48px; font-weight: 700; }
.stat__value small { font-size: 14px; font-weight: 400; color: var(--label-alpha-secondary); }

/* ---------- Report detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.report-meta { display: flex; flex-wrap: wrap; gap: 20px 32px; }
.report-meta > div { font-size: 14px; }
.report-meta .k { font-size: 12px; color: var(--label-alpha-secondary); margin-bottom: 2px; }
.report-meta .v { font-weight: 500; }

.event { border-bottom: 1px solid var(--border-neutral-light); padding: 20px 24px; }
.event:last-child { border-bottom: none; }
.event__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.event__no { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-primary);
  color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none; }
.event__time { font-size: 13px; color: var(--label-alpha-secondary); font-variant-numeric: tabular-nums; }
.event__body { display: grid; grid-template-columns: 180px 1fr; gap: 16px; }
.event__snap { border-radius: var(--radius-input); overflow: hidden; background: #0d1b2a; aspect-ratio: 4/3; position: relative; }
.event__snap .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; }
.event__snap--error { background: var(--surface-destructive); display: grid; place-items: center; }
.snap-error { color: var(--label-destructive); font-size: 12px; text-align: center; line-height: 1.5; font-weight: 700; }
.prop-section-label { font-size: 11px; font-weight: 700; color: var(--label-alpha-tertiary); letter-spacing: .02em; margin-bottom: 6px; }

/* ---------- Detail: pattern (表示切り替え) tabs ---------- */
.pattern-tabs { display: flex; gap: 4px; }
.ptab {
  height: 28px; padding: 0 14px; border-radius: 14px; border: none; background: none;
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--label-alpha-secondary);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.ptab:hover { background: var(--bg-base); }
.ptab.is-active { background: var(--accent-tertiary); color: var(--label-accent); }
.ptab .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.event__fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.event__fields .field { margin: 0; }
.event__fields .full { grid-column: 1 / -1; }
.transcript {
  background: var(--bg-base); border-radius: var(--radius-input);
  padding: 12px 14px; font-size: 13px; color: var(--label-alpha-secondary);
  margin-top: 12px; line-height: 1.7;
}
.transcript b { color: var(--label-alpha-primary); }

.side-panel { position: sticky; top: calc(var(--topbar-h) + 28px); }
.side-panel h3 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.side-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; }
.side-row svg { color: var(--label-alpha-secondary); flex: none; }

/* ---------- Recording ---------- */
.record-layout { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.phone {
  width: 100%; max-width: 360px; margin: 0 auto;
  background: #111; border-radius: 28px; padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.phone__screen { background: var(--bg-base); border-radius: 18px; overflow: hidden; }
.phone__cam { height: 200px; background: #0d1b2a; position: relative; }
.phone__cam .rec-dot { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 6px;
  color: #fff; font-size: 12px; font-weight: 700; }
.phone__cam .rec-dot .dot { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }
.phone__body { padding: 16px; }
.phone__fmt { font-size: 12px; color: var(--label-alpha-secondary); }
.phone__timer { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0 12px; }
.live-feed { display: flex; flex-direction: column; gap: 10px; max-height: 220px; overflow-y: auto; }
.live-line { background: var(--surface-base); border-radius: var(--radius-input); padding: 10px 12px; font-size: 13px;
  border-left: 3px solid var(--accent-primary); animation: fade .25s ease; }
.live-line .t { font-size: 11px; color: var(--label-alpha-tertiary); }
.live-line.flag { border-left-color: var(--label-destructive); background: #fff7f7; }

.bonx-hint { display: flex; gap: 14px; align-items: flex-start; }
.bonx-hint .ico { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-tertiary);
  color: var(--label-accent); display: grid; place-items: center; flex: none; }
.bonx-hint b { display: block; font-size: 14px; margin-bottom: 2px; }
.bonx-hint span { font-size: 13px; color: var(--label-alpha-secondary); }

.fmt-picker { display: grid; gap: 10px; }
.fmt-option {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card);
  background: var(--surface-base); cursor: pointer; text-align: left; width: 100%;
}
.fmt-option:hover { border-color: var(--accent-primary); }
.fmt-option.is-sel { border-color: var(--accent-primary); background: var(--accent-tertiary); }
.fmt-option .ico { width: 38px; height: 38px; border-radius: 8px; background: var(--bg-base);
  display: grid; place-items: center; color: var(--label-accent); flex: none; }
.fmt-option .t b { font-size: 14px; display: block; }
.fmt-option .t span { font-size: 12px; color: var(--label-alpha-secondary); }
.fmt-option .check { margin-left: auto; color: var(--accent-primary); opacity: 0; }
.fmt-option.is-sel .check { opacity: 1; }

/* ---------- Format management ---------- */
.field-row {
  display: grid; grid-template-columns: 24px 1.4fr 1fr 2fr 32px;
  gap: 12px; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--border-neutral-light);
}
.field-row:last-child { border-bottom: none; }
.field-row .handle { color: var(--label-alpha-tertiary); cursor: grab; display: grid; place-items: center; }
.field-row .del { color: var(--label-alpha-tertiary); }
.field-row .del:hover { color: var(--label-destructive); }
.field-head { font-size: 12px; font-weight: 700; color: var(--label-alpha-secondary); }
.baseprop-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-neutral-light); }
.baseprop-row:last-child { border-bottom: none; }
.baseprop-row .lock { color: var(--label-alpha-tertiary); display: grid; place-items: center; flex: none; }
.baseprop-row .bp-name { font-weight: 700; font-size: 14px; width: 140px; flex: none; }
.baseprop-row .bp-desc { font-size: 13px; color: var(--label-alpha-secondary); flex: 1; }

/* ---------- Devices ---------- */
.link-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.link-arrow { color: var(--label-alpha-tertiary); }
.cam-cell { display: flex; align-items: center; gap: 10px; }
.cam-thumb { width: 56px; height: 38px; border-radius: 4px; background: #0d1b2a; flex: none; overflow: hidden; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: var(--surface-alpha-3); display: none; place-items: center; z-index: 50; padding: 24px; }
.modal-bg.is-open { display: grid; }
.modal { background: var(--surface-base); border-radius: var(--radius-card); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-neutral-light); }
.modal__head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal__close {
  width: 32px; height: 32px; border: none; background: none; border-radius: var(--radius-input);
  color: var(--label-alpha-secondary); font-size: 15px;
}
.modal__close:hover { background: var(--bg-base); color: var(--label-alpha-primary); }
.modal__body { padding: 24px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--border-neutral-light); }

/* ---------- Snackbar（画面上部・操作結果の通知） ---------- */
.toast {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%) translateY(-140%);
  width: min(640px, calc(100vw - 24px));
  background: var(--accent-primary); color: var(--label-white);
  padding: 12px 16px 12px 24px; border-radius: var(--radius-input);
  font-size: 16px; font-weight: 700; line-height: 24px; box-shadow: 0 8px 28px rgba(0, 0, 0, .24);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast__close {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border: none; border-radius: var(--radius-input); background: none; color: inherit;
}
.toast__close:hover { background: rgba(255, 255, 255, .18); }

/* ---------- Helpers ---------- */
.muted { color: var(--label-alpha-secondary); }
.row { display: flex; align-items: center; gap: 10px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.divider { height: 1px; background: var(--border-neutral-light); margin: 16px 0; }
.empty { text-align: center; padding: 48px; color: var(--label-alpha-secondary); font-size: 14px; }
.empty__ico {
  width: 96px; height: 96px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px dashed var(--border-neutral); color: var(--label-alpha-tertiary);
}

/* ---------- 必須バッジ・入力エラー ---------- */
.req {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 4px;
  border: 1px solid var(--border-destructive); border-radius: var(--radius-input); color: var(--label-destructive);
  font-size: 11px; font-weight: 700; line-height: 18px;
}
.field-err { color: var(--label-destructive); font-size: 12px; line-height: 18px; }
.input.is-invalid, .select.is-invalid { border-color: var(--border-destructive); }

/* ---------- Login ---------- */
.app.is-hidden { display: none; }
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-base);
}
.login-screen.is-hidden { display: none; }
.login-card { width: 100%; max-width: 320px; padding: 24px; text-align: center; }
.login-mark {
  width: 48px; height: 48px; border-radius: var(--radius-input); margin: 0 auto 16px;
  background: var(--accent-tertiary); color: var(--label-accent); display: grid; place-items: center;
}
.login-logo { font-size: 20px; font-weight: 700; color: var(--label-alpha-primary); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--label-alpha-secondary); margin-bottom: 28px; line-height: 1.6; }
.login-btn { width: 100%; justify-content: center; }
.login-note { margin-top: 18px; font-size: 12px; color: var(--label-alpha-tertiary); line-height: 1.6; }
/* ロゴ下端から見出しまでは Figma 45px。行間が乗る分を引いて 39px */
.safie-logo { display: block; width: 132px; height: auto; margin: 0 auto 39px; }
/* .login-card / .app-title / .login-btn は 404 画面と共用のため、ログイン画面の寸法は modifier に閉じる。
   見出しからボタンまでは Figma 34px（ここも行間の分を引く）、ボタン幅は Figma 240px */
.login-card--signin .app-title { margin-bottom: 33px; }
.login-card--signin .login-btn { width: 240px; }
/* カードを残り領域の中央に、フッターを下端に置く */
.login-screen--signin { flex-direction: column; align-items: stretch; justify-content: flex-start; }
.login-screen--signin .login-card { margin: auto; }
.login-footer {
  padding: 20px 16px; border-top: 1px solid var(--border-neutral-light);
  text-align: center; font-size: 13px; color: var(--label-alpha-secondary);
}
/* ---------- OAuth-style ログイン / ユーザー認証 ---------- */
#authScreen { align-items: flex-start; overflow-y: auto; padding: 32px 16px; }
.app-title { font-size: 18px; font-weight: 700; color: var(--label-alpha-primary); margin-bottom: 28px; }
.auth-card { width: 100%; max-width: 600px; background: var(--surface-base); border-radius: var(--radius-card); box-shadow: 0 20px 60px rgba(0,0,0,.12); padding: 40px; }
.auth-title { text-align: center; font-size: 28px; font-weight: 800; color: var(--label-alpha-primary); margin: 0 0 24px; }
.auth-box { background: var(--bg-base); border-radius: 8px; padding: 20px 24px; margin-bottom: 20px; font-size: 14px; color: var(--label-alpha-secondary); line-height: 1.9; }
.auth-box p { margin: 0 0 8px; }
.auth-kv { color: var(--label-alpha-secondary); }
.auth-perms { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; margin-top: 14px; }
.auth-perm { display: flex; align-items: center; gap: 10px; color: var(--label-accent); font-size: 14px; }
.auth-perm svg { flex: none; }
.auth-desc { font-size: 14px; color: var(--label-alpha-primary); line-height: 1.8; margin: 20px 0; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; color: var(--label-alpha-secondary); margin-bottom: 6px; }
.auth-field .input { width: 100%; box-sizing: border-box; }
.btn--teal { background: #17a2a2; color: #fff; width: 100%; justify-content: center; margin-top: 4px; }
.btn--teal:hover { background: #149191; }
.auth-or { text-align: center; color: var(--label-alpha-secondary); font-size: 13px; margin: 16px 0; }
.btn--teal-outline { background: transparent; color: #17a2a2; border: 1px solid #17a2a2; width: 100%; justify-content: center; }
.btn--teal-outline:hover { background: rgba(23,162,162,.06); }

/* ---------- Toast variants ---------- */
.toast--error { background: var(--label-destructive); }
.toast a.retry { color: #fff; text-decoration: underline; font-weight: 700; margin-left: 4px; }

/* ---------- Help tooltip (Safie icon system: outline info icon) ---------- */
.help-icon {
  position: relative; display: inline-flex; align-items: center; flex: none;
  color: var(--label-alpha-tertiary); cursor: help;
}
.help-icon:hover { color: var(--label-accent); }
.help-icon .help-tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--label-alpha-primary); color: #fff; font-size: 12px; font-weight: 400;
  line-height: 1.5; padding: 8px 12px; border-radius: var(--radius-input);
  width: max-content; max-width: 240px; white-space: normal;
  opacity: 0; visibility: hidden; transition: opacity .15s ease; z-index: 40;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); pointer-events: none;
}
.help-icon .help-tip::after {
  content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--label-alpha-primary);
}
.help-icon:hover .help-tip { opacity: 1; visibility: visible; }

/* ---------- Secret / key display ---------- */
.secret-box { display: flex; align-items: center; gap: 8px; background: var(--bg-base);
  border: 1px solid var(--border-neutral-light); border-radius: var(--radius-input); padding: 6px 8px 6px 12px; margin-top: 10px; }
.secret-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--label-alpha-primary); }

/* ---------- 期間指定カレンダー（app.js が生成） ---------- */
.cal-scrim { position: fixed; inset: 0; z-index: 55; }
.cal-pop {
  position: absolute; z-index: 56; width: min(592px, calc(100vw - 24px));
  background: var(--surface-base); border: 1px solid var(--border-neutral-light);
  border-radius: var(--radius-card); box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  padding: 16px; max-height: calc(100vh - 24px); overflow-y: auto;
}
.cal-months { display: flex; gap: 24px; }
.cal-month { flex: 1; min-width: 0; }
.cal-mhead { display: flex; align-items: center; justify-content: space-between; height: 32px; margin-bottom: 8px; }
.cal-mhead b { font-size: 14px; font-weight: 700; }
/* 送れない向き（左の月の次・当月より先）は空の枠を置き、左右の月見出しの位置をそろえる */
.cal-nav {
  width: 28px; height: 28px; display: grid; place-items: center; flex: none;
  border: none; background: none; border-radius: var(--radius-input); color: var(--label-alpha-secondary);
}
button.cal-nav:hover { background: var(--bg-base); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: 12px; line-height: 28px; color: var(--label-alpha-secondary); }
.cal-wd--sun { color: var(--label-destructive); }
.cal-wd--sat { color: var(--label-accent); }
.cal-day {
  height: 28px; border: none; background: none; border-radius: 50%;
  font-size: 13px; color: var(--label-alpha-primary); font-family: inherit;
}
.cal-day:hover { background: var(--bg-base); }
.cal-day--sun { color: var(--label-destructive); }
.cal-day--sat { color: var(--label-accent); }
.cal-day--range { background: var(--accent-tertiary); border-radius: 0; }
.cal-day.is-sel { background: var(--accent-primary); color: var(--label-white); border-radius: 50%; }
.cal-day:disabled { color: var(--label-alpha-tertiary); background: none; cursor: default; }
.cal-presets { display: flex; gap: 8px; flex-wrap: wrap; padding: 16px 0 12px; }
.cal-preset {
  height: 32px; padding: 0 8px; border: none; background: none; border-radius: var(--radius-input);
  font-size: 14px; font-family: inherit; color: var(--label-alpha-primary);
}
.cal-preset:hover { background: var(--accent-tertiary); color: var(--label-accent); }
.cal-times { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-bottom: 16px; }
.cal-time { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--label-alpha-secondary); }
.cal-time input {
  height: 40px; padding: 4px 12px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input); color: var(--label-alpha-primary);
}
.cal-foot { display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border-neutral-light); padding-top: 16px; }

@media (max-width: 1080px) {
  .detail-grid, .record-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
/* モバイル: サイドバーはスライド式ドロワー（開閉は app.js が nav-open を付け外しする） */
.nav-scrim { display: none; }
@media (max-width: 720px) {
  .app__body { grid-template-columns: 1fr; }
  .app__body.nav-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0;
    width: 264px; max-width: 84vw; z-index: 45;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
    height: auto;
  }
  .app__body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(0, 0, 0, .38); z-index: 44;
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .app__body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .modal-bg { padding: 12px; }
  .modal__body, .modal__head, .modal__foot { padding-left: 16px; padding-right: 16px; }
}

/* ---------- MPA テンプレート移植ぶんの追加 ---------- */
[hidden] { display: none !important; } /* .btn 等の display 指定に UA の [hidden] が負けるのを防ぐ */
a.navitem { text-decoration: none; }
.appbar form { display: contents; }
.snap-zoom { cursor: zoom-in; }
.toolbar form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- MPA 画面部品の追加 ---------- */
.login-notice { border: 1px solid var(--border-neutral-light); background: var(--bg-base); color: var(--label-alpha-secondary); border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.login-error { border: 1px solid var(--border-destructive, #d64545); background: var(--surface-destructive, #fdecec); color: var(--label-destructive, #b03030); border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.rd-tabs { flex-wrap: wrap; margin-bottom: 8px; }
/* タブが1つのときは中身が空になるので余白を出さない */
.rd-tabs:empty { display: none; }
.rd-tabs .ptab { margin-bottom: 4px; text-decoration: none; }
.btn { white-space: nowrap; } /* 「削除」等が縦に折り返して楕円化するのを防ぐ */
/* URLサジェストはラベルが長い（設定名入り）ため折返しを許可し、モーダルからのはみ出しを防ぐ */
.btn[data-whfill], .btn.js-issued-fill { white-space: normal; height: auto; min-height: 28px; padding-top: 4px; padding-bottom: 4px; text-align: left; }
.modal__foot form { display: contents; }

/* ---------- 帳票: ツールバー ---------- */
.rd-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin-bottom: 8px; flex-wrap: wrap; }
.rd-toolbar__right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rd-notice { margin: 0 0 8px; font-size: 13px; line-height: 1.6; color: var(--label-alpha-secondary); }
.rd-count { font-size: 14px; color: var(--label-alpha-primary); }
.rd-pager { display: flex; align-items: center; gap: 4px; }
.rd-navbtn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input);
  background: var(--surface-base); color: var(--label-alpha-primary);
}
.rd-navbtn:hover { background: var(--bg-base); }
.rd-navbtn.is-disabled { background: var(--surface-neutral-2); color: var(--label-alpha-tertiary); border-color: var(--border-neutral-light); }
.rd-pageind {
  width: 140px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input);
  font-size: 16px; color: var(--label-alpha-secondary);
}

/* ---------- 帳票詳細: 記録リスト ----------
   固定列と可変列の最小幅の合計を下回る幅では横スクロールにする
   （縮み切らせると操作ボタンが枠外に出て押せなくなる） */
.rd-list {
  border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card);
  background: var(--surface-base); overflow-x: auto; overflow-y: hidden;
}
.rd-hrow, .rd-row { display: flex; align-items: center; border-bottom: 1px solid var(--border-neutral-light); }
.rd-hrow { min-height: 45px; padding: 0 24px; }
.rd-row { min-height: 88px; padding: 16px 24px; }
.rd-row:last-child { border-bottom: none; }
.rd-hrow > div { font-size: 14px; font-weight: 700; color: var(--label-alpha-primary); white-space: nowrap; }
.rd-c-no { width: 28px; flex: none; padding-right: 8px; font-size: 14px; color: var(--label-alpha-primary); }
.rd-c-date { width: 118px; flex: none; padding: 0 16px; font-size: 14px; line-height: 21px; }
.rd-c-date a { white-space: nowrap; }
.rd-c-date .rd-ymd { display: block; }
.rd-c-date svg { vertical-align: -1px; margin-left: 2px; }
.rd-c-photo { width: 147px; flex: none; padding: 0 16px; }
/* 安全指摘から複数の指摘を登録した要約は「1. …\n2. …」の複数行になるため改行を保つ */
.rd-c-sum { flex: 2 1 0; min-width: 120px; padding: 0 16px; font-size: 14px; line-height: 21px; word-break: break-word; white-space: pre-line; }
.rd-c-sum a { white-space: nowrap; margin-left: 4px; }
/* メールアドレスは1行に収まらないので、途中で折り返して全体を見せる */
.rd-c-worker { width: 165px; flex: none; padding: 0 16px; font-size: 14px; line-height: 21px; overflow-wrap: anywhere; }
.rd-c-status { width: 102px; flex: none; padding: 0 16px; }
.rd-c-done { width: 120px; flex: none; padding: 0 16px; font-size: 14px; }
.rd-c-photos { width: 150px; flex: none; padding: 0 16px; }
.rd-c-comment { flex: 1 1 0; min-width: 80px; padding: 0 16px; font-size: 14px; }
.rd-c-prop { width: 110px; flex: none; padding: 0 16px; font-size: 14px; }
.rd-c-act { width: 72px; flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.rd-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.rd-sort:hover { color: var(--label-accent); }
.rd-thumb { width: 115px; height: 64px; border-radius: var(--radius-input); overflow: hidden; background: #0d1b2a; }
.rd-thumb--none {
  display: grid; place-items: center; text-align: center;
  background: var(--surface-neutral-2); color: var(--label-alpha-secondary); font-size: 12px; padding: 4px;
}
/* コメントは行の高さを揃えるため3行までにして、全文は編集ダイアログで見せる */
.rd-comment {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; white-space: pre-wrap; word-break: break-word; line-height: 21px;
}
.rd-photos { display: flex; flex-wrap: wrap; gap: 4px; }
/* サムネイルはキーボードでも開けるようボタンにする（見た目は画像だけ） */
.rd-photo-btn { display: block; padding: 0; border: none; background: none; cursor: zoom-in; }
.rd-photo-btn:focus-visible { outline: 2px solid var(--accent-secondary); outline-offset: 2px; }
.rd-photo { display: block; width: 56px; height: 40px; object-fit: cover; border-radius: 4px; background: #0d1b2a; }
.ph-drop {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 24px 16px; border: 1px dashed var(--border-accent); border-radius: var(--radius-input);
  color: var(--label-alpha-tertiary); text-align: center;
}
.ph-drop.is-over { background: var(--accent-tertiary); }
.ph-drop p { margin: 0; }
.ph-drop__drag { font-size: 14px; color: var(--label-alpha-primary); }
.ph-drop__or { font-size: 12px; }
.ph-drop__note { font-size: 12px; color: var(--label-alpha-secondary); }
.ph-updated { margin: 0; font-size: 12px; color: var(--label-alpha-secondary); }
.ph-list { display: flex; flex-wrap: wrap; gap: 12px; }
.ph-list:empty { display: none; }
.ph-item { position: relative; width: 144px; height: 81px; }
.ph-item img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; background: #0d1b2a; }
.ph-del {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: var(--radius-input); border: none;
  background: var(--label-alpha-primary); color: var(--label-white); font-size: 12px; display: grid; place-items: center;
}
.rd-act {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: none; border-radius: var(--radius-input); background: none; color: var(--label-alpha-secondary);
}
.rd-act:hover { background: var(--bg-base); color: var(--label-alpha-primary); }
.rd-act--del:hover { color: var(--label-destructive); }

/* ---------- 帳票設定 ---------- */
.page-desc { font-size: 14px; line-height: 1.5; color: var(--label-alpha-secondary); margin: 0 0 24px; }
/* 押せないボタンの理由をホバーで出す。帳票作成ボタンと Excel 出力ボタンで共用する */
.tip-wrap { position: relative; }
.tip {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  padding: 6px 10px; border-radius: var(--radius-input); white-space: nowrap;
  background: var(--label-alpha-primary); color: var(--label-white); font-size: 12px; line-height: 18px;
  opacity: 0; visibility: hidden; transition: opacity .12s ease;
  pointer-events: none;  /* 表示中に下の本文を選べなくする副作用を避ける */
}
.tip-wrap.is-locked:hover .tip { opacity: 1; visibility: visible; }
/* 見出しバー右端のボタン（帳票作成・帳票ダウンロード） */
.hb-create, .hb-action { margin-left: auto; }
.hb-create .btn--ghost, .hb-action .btn--ghost { background: var(--surface-base); }
.hb-create .btn--ghost:disabled, .hb-action .btn--ghost:disabled { background: var(--surface-neutral-2); color: var(--label-alpha-tertiary); border-color: var(--surface-neutral-2); }
.wh-card { margin-bottom: 24px; }
.wh-card__title { font-size: 18px; font-weight: 700; line-height: 1.4; }
.wh-card__desc { font-size: 14px; line-height: 1.5; color: var(--label-alpha-secondary); margin: 16px 0 24px; }
.wh-row { display: flex; align-items: center; gap: 8px; }
.wh-row .input { flex: 1; min-width: 0; margin-right: 16px; }
.wh-abtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  height: 32px; padding: 6px 8px; border: 1px solid var(--border-neutral); border-radius: var(--radius-input);
  background: var(--surface-base); font-family: inherit; font-size: 14px; line-height: 20px;
  color: var(--label-alpha-secondary);
}
.wh-abtn:hover { background: var(--bg-base); }
.wh-abtn:disabled { color: var(--label-alpha-tertiary); background: var(--surface-neutral-3); border-color: var(--border-neutral-secondary); cursor: not-allowed; }
.wh-used { font-size: 12px; line-height: 1.6; color: var(--label-alpha-secondary); margin: 6px 0 16px; }
.wh-note { font-size: 12px; line-height: 1.6; color: var(--label-alpha-secondary); margin: 12px 0 0; }
.wh-note--warn { color: var(--label-destructive); }
.wh-card__desc + .wh-note--warn { margin: 0 0 24px; }  /* 直後に URL の入力欄が続く */
/* 名前は折り返さず省略する（折り返すと下のシリアルと段が混ざる）。上限を置かないと auto レイアウトの
   列が全文の幅まで広がって省略が発火しないため、メールの折り返し幅と併せて他の列を押し出さない値にする */
.dev-cam__name { font-size: 14px; line-height: 21px; color: var(--label-alpha-primary);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-cam__serial { font-size: 12px; line-height: 18px; color: var(--label-alpha-secondary); }
.dev-email { max-width: 280px; word-break: break-all; }
.tbl-empty-row td { padding: 0; }  /* 中身の .empty が余白を持つ */
.field-hint { font-size: 12px; line-height: 1.6; color: var(--label-alpha-secondary); margin: 6px 0 0; }
.modal-warn { font-size: 13px; line-height: 1.7; color: var(--label-destructive); margin: 8px 0 0; }

/* ---------- リンク化した要素のリセット（プロトは button だったため） ---------- */
a.hb-back, a.ptab, a.navitem, a.navsub__item, a.btn { text-decoration: none; }
.ptab { white-space: nowrap; } /* タブ内で文字が縦に折り返して重なるのを防ぐ */
.hb-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* headingbar は固定高のため */

/* ---------- 狭幅（スマホ・半画面）対応の補強 ---------- */
@media (max-width: 720px) {
  .content { padding: 16px 12px; }
  .appbar, .headingbar { padding-left: 12px; padding-right: 12px; }
  .appbar__right { padding-right: 4px; }
  .acct-menu { right: 4px; }
  .pattern-tabs { flex-wrap: wrap; }
  /* 見出しの横にボタンを置く幅がないので下に落とす（見出しが1文字ずつ折り返すのを防ぐ） */
  .wh-card > .row { flex-wrap: wrap; }
  .wh-card > .row .btn { width: 100%; justify-content: center; }
  .rd-toolbar { position: relative; }
  /* 折り返すとボタンが左端に来るため、吹き出しの起点をツールバーに移して画面外へ出さない */
  .rd-toolbar .tip-wrap { position: static; }
  .rd-toolbar .tip { max-width: 100%; white-space: normal; }

  /* 記録リストは1件1カード。列は order で積み直し、消えるヘッダのぶんは data-label で補う */
  .rd-hrow { display: none; }
  .rd-list { border: none; background: none; overflow: visible; }
  .rd-c-sum, .rd-c-comment { min-width: 0; }
  .rd-row {
    display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px;
    padding: 16px; margin-bottom: 12px;
    background: var(--surface-base); border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card);
  }
  .rd-row:last-child { border-bottom: 1px solid var(--border-neutral-light); margin-bottom: 0; }
  /* セレクタは .rd-row > .rd-c-* にそろえる（.rd-row > div だけだと個別指定が詳細度で負ける） */
  .rd-row > div { width: 100%; flex: none; padding: 0; }
  /* 番号・日時・ステータスは1行に収め、日付と時刻も横に並べる */
  .rd-row > .rd-c-no { order: 1; width: auto; }
  .rd-row > .rd-c-date { order: 2; width: auto; flex: 1 0 auto; }
  .rd-c-date .rd-ymd { display: inline; margin-right: 4px; }
  .rd-row > .rd-c-status { order: 3; width: auto; }
  .rd-row > .rd-c-photo { order: 4; }
  .rd-row > .rd-c-sum { order: 5; }
  .rd-row > .rd-c-worker { order: 6; width: 100%; }
  .rd-row > .rd-c-done { order: 7; }
  .rd-row > .rd-c-photos { order: 8; }
  /* 添付の無い行は「-」だけの行を作らず畳む */
  .rd-row > .rd-c-photos.is-empty { display: none; }
  .rd-row > .rd-c-comment { order: 9; }
  .rd-row > .rd-c-prop { order: 10; }
  .rd-row > .rd-c-act { order: 11; justify-content: flex-end; }
  .rd-row > .rd-c-worker, .rd-row > .rd-c-done, .rd-row > .rd-c-photos, .rd-row > .rd-c-comment,
  .rd-row > .rd-c-prop {
    display: flex; align-items: baseline; gap: 4px;
  }
  .rd-c-worker::before, .rd-c-done::before, .rd-c-photos::before, .rd-c-comment::before, .rd-c-prop::before {
    content: attr(data-label) "："; flex: none; color: var(--label-alpha-secondary); font-size: 12px;
  }
  /* 狭い画面はドラッグ&ドロップができないので、枠はボタンと注記だけにする */
  .ph-drop { padding: 16px; }
  .ph-drop > svg, .ph-drop__drag, .ph-drop__or { display: none; }
  .rd-thumb { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .rd-thumb--none { min-height: 88px; }
  .rd-comment { -webkit-line-clamp: 6; }
  .cal-months { flex-direction: column; gap: 12px; }
}

/* ---------- 安全指摘（GET /safety） ----------
   チャット風の1画面。左が写真の送信と AI の指摘、右が参照情報（現場の記録・ルール）。
   狭幅では右レールをチャットの下に落とす */
.sf-setting { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.sf-setting__label { font-size: 12px; line-height: 18px; color: var(--label-alpha-secondary); }
.sf-setting__select { max-width: 640px; }
.sf-setting__help { font-size: 12px; }
.sf-nosetting { margin-bottom: 16px; font-size: 14px; }
.sf-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.sf-chat { display: flex; flex-direction: column; min-height: 560px; }
.sf-log { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.sf-empty { margin: auto; text-align: center; color: var(--label-alpha-secondary); max-width: 34em; padding: 24px 0; }
.sf-empty h2 { font-size: 16px; margin: 0 0 6px; color: var(--label-alpha-primary); text-wrap: balance; }
.sf-empty p { margin: 0; font-size: 13px; line-height: 1.7; }
.sf-msg { display: flex; gap: 10px; max-width: 92%; }
.sf-msg--user { align-self: flex-end; flex-direction: row-reverse; }
.sf-msg__who {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--accent-tertiary); color: var(--label-accent);
}
.sf-msg--user .sf-msg__who { background: var(--surface-neutral-3); color: var(--label-alpha-secondary); border: 1px solid var(--border-neutral-light); }
.sf-bubble {
  background: var(--surface-neutral-3); border: 1px solid var(--border-neutral-light);
  border-radius: var(--radius-card); padding: 12px 14px; min-width: 0; font-size: 14px; line-height: 1.6;
}
.sf-msg--ai .sf-bubble { width: 100%; }
.sf-msg--user .sf-bubble { background: var(--accent-primary); color: var(--label-white); border-color: transparent; }
.sf-bubble__meta { font-size: 11px; color: var(--label-alpha-tertiary); margin-top: 6px; }
.sf-msg--user .sf-bubble__meta { color: rgba(255, 255, 255, .75); }
.sf-photo { display: block; width: 260px; max-width: 100%; max-height: 200px; object-fit: cover; border-radius: 6px; background: #0d1b2a; cursor: zoom-in; }
.sf-thinking { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.sf-thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--label-alpha-tertiary); animation: sf-blink 1.2s infinite; }
.sf-thinking i:nth-child(2) { animation-delay: .2s; }
.sf-thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes sf-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sf-thinking i { animation: none; opacity: .6; } }
.sf-report { white-space: pre-wrap; word-break: break-word; margin: 0 0 10px; }
.sf-findings { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sf-finding {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  padding: 8px 10px; border: 1px solid var(--border-neutral-light); border-radius: 6px; background: var(--surface-base);
}
.sf-finding--primary .sf-finding__text { font-weight: 700; }
.sf-finding__body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sf-finding__text { min-width: 0; word-break: break-word; }
.sf-more { margin-top: 10px; font-size: 13px; }
.sf-more > summary { cursor: pointer; color: var(--label-accent); font-weight: 700; font-size: 12px; list-style: none; }
.sf-more > summary::-webkit-details-marker { display: none; }
.sf-more > summary::before { content: "▸ "; }
.sf-more[open] > summary::before { content: "▾ "; }
.sf-more > .sf-findings, .sf-more > .sf-report { margin-top: 8px; }
.sf-laws { display: flex; flex-wrap: wrap; gap: 4px; }
.sf-law {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px;
  border: 1px solid var(--border-neutral-light); background: var(--surface-base); font-size: 11px; font-weight: 500;
  color: var(--label-alpha-secondary); text-decoration: none; white-space: nowrap;
}
.sf-law::before { content: "§"; font-weight: 700; }
.sf-law:hover { border-color: var(--accent-primary); color: var(--label-accent); }
.sf-risk { flex: none; text-align: center; border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700; line-height: 1.3; }
.sf-risk small { display: block; font-weight: 500; font-size: 10px; opacity: .85; }
.sf-risk--high { background: var(--surface-destructive); color: var(--label-destructive); }
.sf-risk--mid { background: var(--status-warning-bg); color: var(--status-warning); }
.sf-risk--low { background: var(--surface-neutral-2); color: var(--label-alpha-secondary); }
.sf-refs {
  margin-top: 10px; padding: 8px 10px; border-radius: 6px; background: var(--accent-tertiary); color: var(--label-accent);
  font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.sf-refs button { background: none; border: none; color: inherit; text-decoration: underline; font-size: 12px; font-weight: 700; padding: 0; }
.sf-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.sf-actions .btn--sm { height: 28px; padding: 4px 12px; font-size: 13px; border-radius: 14px; }
.sf-state { margin-top: 10px; font-size: 13px; color: var(--label-alpha-secondary); }
.sf-state a { font-weight: 700; }
.sf-fail { color: var(--label-destructive); }
.sf-feedback { margin-top: 12px; padding: 12px; border: 1px solid var(--border-neutral-light); border-radius: 6px; background: var(--surface-base); }
.sf-feedback .textarea { min-height: 84px; }
.sf-feedback__count { display: block; text-align: right; font-size: 12px; color: var(--label-alpha-secondary); margin-top: 4px; }
.sf-register { margin-top: 10px; padding: 10px 12px; border-radius: 6px; background: var(--bg-base); font-size: 13px; }
.sf-register__label { font-size: 11px; font-weight: 700; color: var(--label-alpha-tertiary); margin-bottom: 4px; }
.sf-register__text { white-space: pre-wrap; word-break: break-word; }
.sf-register__text:empty::before { content: "（登録する指摘を選ぶと、ここに登録される文が出ます）"; color: var(--label-alpha-tertiary); }
.sf-edit__title { font-size: 13px; font-weight: 700; }
.sf-edit__help { margin: 2px 0 8px; font-size: 12px; color: var(--label-alpha-secondary); }
.sf-edit__rows { display: flex; flex-direction: column; gap: 8px; }
.sf-edit__row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--border-neutral-light); border-radius: 6px; background: var(--bg-base); }
.sf-edit__row input[type="checkbox"] { margin-top: 10px; width: 16px; height: 16px; flex: none; }
/* 行の本文は残り幅いっぱいに広げる。広げないと本文の幅が中身（法令タグの有無）で決まり、行ごとにテキストボックスの幅が変わる */
.sf-edit__row .sf-finding__body { flex: 1 1 auto; }
.sf-feedback .sf-edit__text { display: block; width: 100%; min-height: 48px; font-size: 13px; }
.sf-edit__add { margin-top: 8px; }
.sf-notice { margin: 8px 0 0; font-size: 12px; line-height: 1.7; color: var(--label-alpha-secondary); }
.sf-composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border-neutral-light); align-items: center; flex-wrap: wrap; }
.sf-composer .sf-hint { flex: 1; min-width: 160px; height: 36px; }
.sf-preview { position: relative; width: 56px; height: 40px; flex: none; }
.sf-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; display: block; }
.sf-preview__clear {
  position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%; border: none;
  background: var(--label-alpha-primary); color: var(--label-white); font-size: 11px; display: grid; place-items: center;
}
.sf-rail { position: sticky; top: calc(var(--topbar-h) * 2 + 16px); }
.sf-rail__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border-neutral-light); }
.sf-rail__head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.sf-rail__for { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-tabs { display: flex; border-bottom: 1px solid var(--border-neutral-light); }
.sf-tab { flex: 1; height: 40px; background: none; border: none; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 700; color: var(--label-alpha-secondary); }
.sf-tab.is-active { color: var(--label-accent); border-bottom-color: var(--accent-primary); }
.sf-rail__body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 240px; max-height: calc(100vh - var(--topbar-h) * 2 - 140px); overflow-y: auto; }
.sf-rail__empty { color: var(--label-alpha-tertiary); font-size: 13px; text-align: center; padding: 40px 12px; }
.sf-case { border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card); padding: 10px; display: grid; grid-template-columns: 84px 1fr; gap: 10px; background: var(--surface-neutral-3); }
.sf-case__thumb { width: 84px; height: 56px; border-radius: 4px; background: #0d1b2a; overflow: hidden; }
.sf-case__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.sf-case__thumb--none { display: grid; place-items: center; font-size: 11px; color: var(--label-alpha-secondary); background: var(--surface-neutral-2); }
.sf-case__body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sf-case__top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sf-case__when { font-size: 11px; color: var(--label-alpha-tertiary); font-variant-numeric: tabular-nums; }
.sf-case__text { font-size: 13px; line-height: 1.5; word-break: break-word; }
.sf-case__foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.sf-case__link { font-size: 12px; font-weight: 700; }
.sf-rule { border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card); padding: 10px 12px; background: var(--surface-neutral-3); font-size: 13px; line-height: 1.6; }
.sf-rule__title { font-weight: 700; margin: 6px 0 2px; }
.sf-rule__src { font-size: 11px; color: var(--label-alpha-tertiary); margin-top: 6px; word-break: break-all; }
.badge--mine { background: var(--badge-mine-bg); color: var(--badge-mine); }
.rd-safety { height: 20px; padding: 0 8px; font-size: 11px; vertical-align: 2px; }
@media (max-width: 980px) {
  .sf-layout { grid-template-columns: 1fr; }
  .sf-rail { position: static; }
  .sf-rail__body { max-height: none; }
}
@media (max-width: 720px) {
  .sf-msg { max-width: 100%; }
  .sf-finding { flex-direction: column; align-items: flex-start; gap: 6px; }
  .sf-chat { min-height: 420px; }
  .sf-composer .btn[type="submit"] { flex: 1; justify-content: center; }
}
.sf-text { white-space: pre-wrap; word-break: break-word; }

/* ---------- 帳票: 絞り込みカード ---------- */
.rf-card {
  position: relative;
  border: 1px solid var(--border-neutral-light); border-radius: var(--radius-card);
  background: var(--surface-base); padding: 16px; margin-bottom: 8px;
}
/* 期間は「YYYY-MM-DD HH:MM – YYYY-MM-DD HH:MM」が1行で収まる幅に固定し、残りを3項目で分ける */
.rf-fields { display: grid; grid-template-columns: 320px repeat(3, minmax(160px, 1fr)); gap: 12px 16px; }
.rf-field { min-width: 0; }
.rf-field__label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 700; color: var(--label-alpha-primary); }
.rf-foot { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 12px; }
.rf-reset { font-size: 13px; }
/* 畳んだ条件を開くボタン。狭い画面でだけ出す */
.rf-fold { display: none; }
.rf-dd { position: relative; }
.rf-ddbtn {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
  height: 28px; padding: 0 10px; border-radius: var(--radius-input);
  border: 1px solid var(--border-neutral); background: var(--surface-base);
  color: var(--label-alpha-primary); font-size: 13px;
}
.rf-ddbtn svg { flex: none; }
.rf-ddbtn:hover { background: var(--bg-base); }
.rf-ddbtn__value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-ddbtn--span { justify-content: flex-start; gap: 8px; }
/* select の矢印を他のドロップダウンと同じ SVG にそろえる（既定の矢印は appearance: none で消す） */
.rf-sel { position: relative; }
.rf-sel svg { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); pointer-events: none; }
.rf-selbox {
  width: 100%; height: 28px; padding: 0 26px 0 10px; appearance: none;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input);
  background: var(--surface-base); color: var(--label-alpha-primary); font-family: inherit; font-size: 13px;
}
.rf-selbox:hover { background: var(--bg-base); }
.rf-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; min-width: 340px; max-width: 90vw;
  max-height: 320px; overflow-y: auto; padding: 6px;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-card);
  background: var(--surface-base); box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.rf-menu__empty { margin: 8px; font-size: 13px; }
.rf-menu__foot { display: flex; justify-content: flex-end; margin-top: 4px; padding: 8px 8px 2px; border-top: 1px solid var(--border-neutral-light); }
.rf-option { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius-input); cursor: pointer; }
.rf-option:hover { background: var(--bg-base); }
.rf-option input { width: 16px; height: 16px; flex: none; accent-color: var(--accent-primary); }
.rf-option__name { flex: 1; min-width: 0; }
.rf-option__name b { display: block; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-option__name small { color: var(--label-alpha-tertiary); font-size: 12px; }
.rf-count {
  flex: none; padding: 2px 8px; border-radius: var(--radius-button-md); white-space: nowrap;
  background: var(--status-warning-bg); color: var(--status-warning); font-size: 12px;
}
.rf-count.is-zero { background: var(--surface-neutral-2); color: var(--label-alpha-tertiary); }
.rf-kwbox { display: flex; }
.rf-kw {
  height: 28px; min-width: 0; flex: 1; padding: 0 10px;
  border: 1px solid var(--border-neutral); border-radius: var(--radius-input) 0 0 var(--radius-input);
  background: var(--surface-base); color: var(--label-alpha-primary); font-size: 13px;
}
.rf-kwbtn {
  display: grid; place-items: center; width: 34px; height: 28px; flex: none; margin-left: -1px;
  border: 1px solid var(--border-neutral); border-radius: 0 var(--radius-input) var(--radius-input) 0;
  background: var(--surface-base); color: var(--label-alpha-secondary);
}
.rf-kwbtn:hover { background: var(--bg-base); color: var(--label-accent); }
.rf-badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-button-md); background: var(--accent-primary); color: var(--label-white);
  font-size: 11px; font-weight: 700;
}

@media (max-width: 1080px) {
  .rf-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .rf-fields { grid-template-columns: 1fr; }
  .rf-menu { min-width: 240px; max-width: 80vw; }
  .rf-fold {
    position: absolute; top: 12px; right: 12px; display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 6px; border: 0; border-radius: var(--radius-input);
    background: transparent; color: var(--label-alpha-secondary);
  }
  .rf-card:not(.is-open) .rf-field--fold, .rf-card:not(.is-open) .rf-foot { display: none; }
  .rf-card.is-open .rf-fold svg { transform: rotate(180deg); }
}
