/* ゲンチョウPro v2 — ダッシュボードUI v2
   基盤 = maintenance.nextflow-app.com の実測トークン（2026-08-09 computed styleで採取）:
   sidebar #0b262c(252px) / primary #087f5b / bg #f4f7f6 / text #182b2f / heading #10333a
   card 白 border #dce5e3 radius14 二重ソフト影 / 状態ピル4色 / th=極小英大文字 #71827f
   モーション = ease-out 150-200ms・小さな移動のみ（emilkowalski/skills の原則） */

:root {
  --primary: #087f5b;
  --primary-deep: #06694b;
  --primary-soft: #dff7ed;
  --primary-soft-text: #087153;
  --info-soft: #e8f3f9;
  --info-text: #1e658b;
  --danger-soft: #fee9e7;
  --danger-text: #a43631;
  --neutral-soft: #edf1f0;
  --neutral-text: #657572;
  --warn: #b7791f;
  --warn-soft: #fdf3e3;
  --side-bg: #0b262c;
  --side-text: #bcd0cd;
  --side-text-dim: #779693;
  --side-active-bg: rgba(255, 255, 255, .08);
  --bg: #f4f7f6;
  --card: #ffffff;
  --text: #182b2f;
  --heading: #10333a;
  --muted: #71827f;
  --line: #dce5e3;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(8, 35, 38, .05), 0 4px 12px rgba(8, 35, 38, .04);
  --shadow-lift: 0 2px 4px rgba(8, 35, 38, .06), 0 8px 20px rgba(8, 35, 38, .07);
  --font: "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.65; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; color: var(--text); }

/* モーション原則 */
.btn, .nav-item, .kpi, .role-card, .list-row, .type-card, .label-chip, .photo-cell, .bn-item, .side-user-btn {
  transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out,
              transform .18s ease-out, box-shadow .18s ease-out;
}
.btn:active, .role-card:active, .type-card:active { transform: scale(.985); }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .role-card:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}

/* ===== 役割選択・ログインゲート ===== */
.role-gate { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px 60px; }
.role-gate-inner { width: 100%; max-width: 760px; }
.brand-block { text-align: center; margin-bottom: 6px; }
.brand-logo { font-size: 30px; font-weight: 700; letter-spacing: -.02em; color: var(--heading); }
.brand-logo span { color: var(--primary); }
.brand-sub { color: var(--muted); font-size: 12.5px; letter-spacing: .14em; margin-top: 2px; }
.role-gate-note { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 12px; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.role-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-align: left; box-shadow: var(--shadow); }
.role-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.role-card .rc-name { font-weight: 700; color: var(--heading); }
.role-card .rc-org { font-size: 12px; color: var(--primary); margin-top: 1px; font-weight: 600; }
.role-card .rc-desc { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.demo-badge-note { text-align: center; font-size: 11px; color: var(--muted); margin-top: 18px; }

/* ===== アプリ骨格（濃色サイドバー基盤） ===== */
.topbar { display: none; }
.layout { display: flex; min-height: 100vh; }
.sidenav {
  width: 252px; flex: none; background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: #fff; padding: 4px 10px 16px; cursor: pointer; }
.side-brand span { color: #35c48f; }
.side-brand-sub { font-size: 10.5px; font-weight: 600; letter-spacing: .18em; color: var(--side-text-dim); margin-top: 2px; }
.side-nav-items { flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm); color: var(--side-text); font-size: 13.5px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav-item.active { background: var(--side-active-bg); color: #fff; font-weight: 600; }
.nav-item .badge { margin-left: auto; }
.side-user { border-top: 1px solid rgba(255, 255, 255, .09); padding-top: 12px; }
.side-user-btn {
  width: 100%; text-align: left; background: none; border: 0; color: var(--side-text);
  font-size: 12px; line-height: 1.5; padding: 8px 10px; border-radius: var(--radius-sm);
}
.side-user-btn:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.main { flex: 1; padding: 28px 32px 48px; max-width: 1080px; min-width: 0; }

.bottomnav { display: none; }
.role-chip { display: none; }

/* ===== 見出し（実測: 24.8px/700/字間タイト・説明はミュート） ===== */
.page-title { font-size: 22px; font-weight: 700; color: var(--heading); letter-spacing: -.02em; margin-bottom: 4px; }
.page-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }

/* ===== カード（実測: 白・#dce5e3・radius14・二重ソフト影） ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card h3 { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .08em; text-transform: none; margin-bottom: 12px; }

/* ===== ボタン（実測: 緑CTA #087f5b・radius10・緑ソフト影） ===== */
.btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13.5px; font-weight: 500; }
.btn:hover { background: #f8faf9; border-color: #c7d4d1; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(8, 127, 91, .16); }
.btn-primary:hover { background: var(--primary-deep); }
.btn-primary:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ok { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-ok:hover { background: var(--primary-deep); }
.btn-warn { background: #fff; border-color: #eecfcb; color: var(--danger-text); }
.btn-warn:hover { background: var(--danger-soft); }
.btn-ghost { background: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--neutral-soft); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }

.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; background: #e5484d; color: #fff; }

/* 状態ピル（実測4色） */
.status-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.st-draft { background: var(--neutral-soft); color: var(--neutral-text); }
.st-submitted { background: var(--info-soft); color: var(--info-text); }
.st-returned { background: var(--danger-soft); color: var(--danger-text); }
.st-accepted { background: var(--primary-soft); color: var(--primary-soft-text); }

/* ===== KPIカード ===== */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; cursor: pointer; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: #c7d4d1; }
.kpi .kpi-num { font-size: 25px; font-weight: 700; color: var(--heading); line-height: 1.25; letter-spacing: -.02em; }
.kpi .kpi-label { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.kpi.k-warn .kpi-num { color: var(--danger-text); }
.kpi.k-ok .kpi-num { color: var(--primary); }
.kpi.k-accent .kpi-num { color: var(--info-text); }
.kpi .kpi-note { font-size: 11px; color: var(--danger-text); }

/* ===== リスト行 ===== */
.list-row { display: flex; align-items: center; gap: 10px; padding: 12px 6px; border-bottom: 1px solid #eef2f1; cursor: pointer; border-radius: 8px; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #f8faf9; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; color: var(--heading); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { font-size: 12px; color: var(--muted); }
.empty-note { color: var(--muted); font-size: 13px; padding: 20px 4px; text-align: center; }

/* テーブル見出し（実測: 極小・太字・字間・ミュート） */
table th { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; color: var(--muted); text-align: left; padding: 4px 6px; background: #f8faf9; }
table td { padding: 4px 6px; }

/* ===== フォーム ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .03em; margin-bottom: 5px; }
.form-group label .req { color: var(--danger-text); margin-left: 3px; }
.form-group input[type=text], .form-group input[type=email], .form-group input[type=password], .form-group input[type=number],
.form-group textarea, .form-group select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; background: #fff;
}
.form-group textarea { min-height: 76px; resize: vertical; }

.type-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.type-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: left; box-shadow: var(--shadow); }
.type-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.type-card .tc-name { font-weight: 700; color: var(--heading); }
.type-card .tc-labels { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ===== 写真ラベリング ===== */
.label-checklist { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.label-chip { font-size: 12px; font-weight: 500; padding: 4px 13px; border-radius: 20px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.label-chip.filled { background: var(--primary-soft); border-color: #bfe8d8; color: var(--primary-soft-text); }
.label-chip.missing { background: var(--danger-soft); border-color: #f3cdc8; color: var(--danger-text); }
.label-chip.selectable:hover { border-color: var(--primary); color: var(--primary); }
.label-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.photo-cell { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.photo-cell.unlabeled { border-color: #f3cdc8; }
.photo-thumb { height: 84px; background-size: cover; background-position: center; cursor: pointer; }
.photo-cell .pc-body { padding: 7px 9px; }
.photo-cell .pc-label { font-size: 11.5px; font-weight: 600; color: var(--heading); }
.photo-cell .pc-label.none { color: var(--danger-text); }
.photo-cell .pc-desc { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-cell input, .photo-cell select { width: 100%; border: 1px solid var(--line); border-radius: 6px; font-size: 11.5px; padding: 3px 6px; margin-top: 4px; }
.photo-cell.sel { outline: 2px solid var(--primary); }
.photo-add { display: flex; align-items: center; justify-content: center; min-height: 130px; border: 1.5px dashed #c2cfcb; border-radius: var(--radius-sm); color: var(--muted); font-size: 12.5px; background: none; }
.photo-add:hover { border-color: var(--primary); color: var(--primary); }
.bulk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; background: #f8faf9; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; margin: 10px 0; font-size: 12.5px; color: var(--muted); }

.warn-box { background: var(--danger-soft); border: 1px solid #f3cdc8; border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.5px; color: var(--danger-text); margin: 10px 0; }
.ok-box { background: var(--primary-soft); border: 1px solid #bfe8d8; border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.5px; color: var(--primary-soft-text); margin: 10px 0; }

/* ===== スレッド ===== */
.thread { margin-top: 4px; }
.thread-msg { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #e7edeb; }
.thread-msg:last-child { border-bottom: 0; }
.thread-avatar { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--info-soft); color: var(--info-text); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; }
.thread-msg.mine .thread-avatar { background: var(--primary-soft); color: var(--primary-soft-text); }
.thread-who { font-size: 11.5px; color: var(--muted); }
.thread-text { font-size: 13px; }
.thread-input { display: flex; gap: 8px; margin-top: 10px; }
.thread-input input { flex: 1; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; }

.hist-item { display: flex; gap: 10px; font-size: 12.5px; padding: 5px 0; color: var(--muted); }
.hist-item .h-act { color: var(--text); }
.provider-note { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }

/* ===== モバイルのメニューシート ===== */
.sheet-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; }
.sheet-panel {
  position: relative; width: 100%; background: var(--card);
  border-radius: 18px 18px 0 0; padding: 10px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(8, 35, 38, .18);
  animation: sheetUp .2s ease-out;
}
@keyframes sheetUp { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: #d6dedc; margin: 2px auto 12px; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; text-align: left; padding: 13px 10px; border-radius: var(--radius-sm); font-size: 14px; color: var(--text); }
.sheet-item:hover, .sheet-item:active { background: #f2f6f5; }
.sheet-item.active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.sheet-item .badge { margin-left: auto; }

/* ===== モーダル ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 30, 34, .55); }
.modal-body { position: relative; background: var(--card); border-radius: var(--radius); padding: 16px; max-width: 90vw; max-height: 86vh; overflow: auto; box-shadow: var(--shadow-lift); }
.photo-modal-img { width: min(640px, 80vw); height: min(420px, 50vh); background-size: contain; background-repeat: no-repeat; background-position: center; background-color: #f0f4f3; border-radius: var(--radius-sm); }
.photo-modal-cap { font-size: 13px; margin: 10px 0; }

/* ===== 報告書・見積書プレビュー（印刷=PDF保存。書類は白黒基調のまま） ===== */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 760px; }
.sheet h2 { font-size: 18px; letter-spacing: .1em; text-align: center; margin-bottom: 14px; font-weight: 600; color: #222; }
.sheet table.meta { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 12.5px; }
.sheet table.meta th, .sheet table.meta td { border: 1px solid #999; padding: 5px 8px; text-align: left; background: none; color: #222; font-size: 12.5px; letter-spacing: 0; }
.sheet table.meta th { background: #f2f3f5; width: 120px; font-weight: 600; }
.sheet .sheet-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .sp-cell { border: 1px solid #bbb; }
.sheet .sp-img { height: 150px; background-size: cover; background-position: center; }
.sheet .sp-cap { font-size: 11.5px; padding: 4px 8px; border-top: 1px solid #bbb; }
.sheet .sp-cap b { font-weight: 600; }

@media print {
  body { background: #fff; }
  .topbar, .sidenav, .bottomnav, .action-bar, .no-print { display: none !important; }
  .main { padding: 0; max-width: none; }
  .sheet { border: 0; padding: 0; max-width: none; box-shadow: none; }
  @page { margin: 14mm 12mm; }
}

/* ===== モバイル（サイドバー→下部ナビ・上部に細いブランドバー） ===== */
@media (max-width: 860px) {
  .topbar { display: flex; position: sticky; top: 0; z-index: 30; height: 50px; background: var(--side-bg); color: #fff; align-items: center; justify-content: space-between; padding: 0 16px; }
  .topbar-brand { font-size: 16px; font-weight: 700; color: #fff; cursor: pointer; }
  .topbar-brand span { color: #35c48f; }
  .role-chip { display: inline-block; background: rgba(255, 255, 255, .1); color: #e8f0ee; border: 0; border-radius: 20px; padding: 5px 12px; font-size: 11.5px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidenav { display: none; }
  .main { padding: 16px 14px 84px; }
  .bottomnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--card); border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(8, 35, 38, .06); }
  .bn-item { flex: 1; border: 0; background: none; padding: 7px 2px; font-size: 10.5px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; position: relative; }
  .bn-item.active { color: var(--primary); font-weight: 600; }
  .bn-item .bn-ic { font-size: 16px; line-height: 1; }
  .bn-item .badge { position: absolute; top: 0; right: 18%; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .sheet { padding: 14px; }
  .sheet .sheet-photos { grid-template-columns: 1fr; }
  .page-title { font-size: 19px; }
}
