/* 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;
  --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; }

/* ---------- 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);
}

/* ---------- 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); }

/* ---------- 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; }

/* モバイル: サイドバーはスライド式ドロワー（開閉は 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; }
}

/* ---------- MPA テンプレート移植ぶんの追加 ---------- */
[hidden] { display: none !important; } .appbar form { display: contents; }

/* ---------- 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; }
.btn { white-space: nowrap; } /* 「削除」等が縦に折り返して楕円化するのを防ぐ */

/* ---------- リンク化した要素のリセット（プロトは button だったため） ---------- */
a.hb-back, a.ptab, a.navitem, a.navsub__item, a.btn { text-decoration: none; }
.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; }
}
