/* ===== リセット & ベース ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0078d4;
  --primary-dark: #005a9e;
  --primary-light: #deecf9;
  --accent: #00b0f0;
  --bg: #f3f5f7;
  --card-bg: #ffffff;
  --text: #323130;
  --text-light: #605e5c;
  --border: #e1dfdd;
  --danger: #d13438;
  --success: #107c10;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --header-h: 40px;
  --nav-h: 60px;
  --bottom-bar-h: 110px;
}

html { font-size: 16px; }
body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ===== モジュール選択ダッシュボード ===== */
.module-dashboard {
  position: fixed; inset: 0; z-index: 400;
  background: linear-gradient(135deg, #f3f5f7 0%, #e8eef5 100%);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.module-dashboard.hidden { display: none; }

.dashboard-header {
  background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
  color: #fff;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.dashboard-brand {
  display: flex; align-items: center; gap: 14px;
}
.dashboard-brand-title { font-size: 1.05rem; font-weight: 700; }
.dashboard-brand-sub { font-size: .72rem; opacity: .85; margin-top: 2px; }
.dashboard-user {
  display: flex; align-items: center; gap: 12px;
  font-size: .85rem;
}

.dashboard-main {
  flex: 1;
  padding: 48px 24px;
  max-width: 1100px; width: 100%;
  margin: 0 auto;
}
.dashboard-greeting {
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  margin-bottom: 4px;
}
.dashboard-subtitle {
  font-size: .9rem; color: var(--text-light); margin-bottom: 32px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.module-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
  cursor: pointer;
  transition: all .25s;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,120,212,.18);
  border-color: var(--primary);
}
.module-card.disabled {
  opacity: .55;
  cursor: not-allowed;
}
.module-card.disabled:hover {
  transform: none; box-shadow: 0 4px 16px rgba(0,0,0,.06);
  border-color: transparent;
}

.module-card-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  background: var(--primary-light);
}
.module-card-icon svg { stroke: var(--primary); }
.module-card.disabled .module-card-icon { background: #f0f0f0; }
.module-card.disabled .module-card-icon svg { stroke: #aaa; }

.module-card-title {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  margin-bottom: 6px;
}
.module-card-desc {
  font-size: .82rem; color: var(--text-light); line-height: 1.5;
}
.module-card-badge {
  position: absolute; top: 14px; right: 14px;
  font-size: .65rem; font-weight: 700;
  padding: 3px 10px; border-radius: 10px;
  background: #e8f5e9; color: #2e7d32;
}
.module-card-badge-coming {
  background: #fff3e0; color: #e65100;
}
.module-card-badge-locked {
  background: #f5f5f5; color: #888;
}

@media (max-width: 600px) {
  .dashboard-main { padding: 24px 16px; }
  .dashboard-greeting { font-size: 1.2rem; }
  .module-grid { grid-template-columns: 1fr; gap: 14px; }
  .module-card { padding: 22px 18px; }
}

/* ===== ユーザー管理モジュール (独立画面) ===== */
.user-mgmt-screen {
  position: fixed; inset: 0; z-index: 400;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.user-mgmt-screen.hidden { display: none; }

.user-mgmt-body {
  flex: 1; display: flex; min-height: 0;
}
.user-mgmt-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}
.user-mgmt-sidebar-section { padding: 0 8px; }
.user-mgmt-sidebar-title {
  font-size: .68rem; font-weight: 700;
  color: var(--text-light); text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 12px 6px;
}
.user-mgmt-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 2px 0;
  border-radius: 8px; text-decoration: none;
  color: var(--text); font-size: .88rem; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.user-mgmt-link:hover { background: var(--bg); }
.user-mgmt-link.active {
  background: var(--primary-light); color: var(--primary); font-weight: 600;
}
.user-mgmt-link svg { stroke: currentColor; flex-shrink: 0; }

.user-mgmt-main {
  flex: 1; min-width: 0;
  overflow-y: auto;
  padding: 24px 28px;
}
.um-view { display: none; }
.um-view.active { display: block; }
.um-view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.um-view-header h2 {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
}

@media (max-width: 767px) {
  .user-mgmt-body { flex-direction: column; }
  .user-mgmt-sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    padding: 8px;
  }
  .user-mgmt-sidebar-section {
    display: flex; gap: 4px; overflow-x: auto;
  }
  .user-mgmt-sidebar-title { display: none; }
  .user-mgmt-link {
    padding: 8px 12px; white-space: nowrap; margin: 0;
    font-size: .8rem;
  }
  .user-mgmt-main { padding: 16px; }
}

/* ===== ログイン画面 ===== */
.login-screen {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(135deg, #0078d4 0%, #005a9e 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: 20px;
  padding: 36px 28px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-logo-img {
  display: block; margin: 0 auto 12px;
  width: 140px; max-width: 60%; height: auto;
}
.login-tagline {
  font-size: .82rem; color: var(--text-light); font-weight: 500;
  margin-top: 4px; margin-bottom: 22px;
  letter-spacing: .04em;
}
.dashboard-brand-logo {
  height: 44px; width: auto; display: block;
  background: #fff; padding: 6px 10px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.login-title {
  font-size: 1.15rem; font-weight: 700; color: var(--text);
  margin-bottom: 4px; letter-spacing: .01em;
}
.login-subtitle {
  font-size: .85rem; color: var(--text-light); margin-bottom: 24px;
}
.login-field {
  text-align: left; margin-bottom: 16px;
}
.login-field label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--text-light); margin-bottom: 4px;
}
.login-field input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  font-size: .95rem; font-family: inherit;
  transition: border-color .2s;
}
.login-field input:focus { outline: none; border-color: var(--primary); }
.login-error {
  color: var(--danger); font-size: .82rem;
  margin-bottom: 12px; text-align: left;
}
.login-btn {
  width: 100%; padding: 14px;
  background: var(--primary); color: #fff; border: none;
  border-radius: 12px; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: background .2s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:active { transform: scale(.98); }
.login-link-btn {
  background: none; border: none; color: var(--primary);
  font-size: .8rem; cursor: pointer; padding: 4px;
  text-decoration: underline;
}

/* ===== ヘッダー ===== */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; padding: 0 16px;
  box-shadow: var(--shadow);
}
.header h1 { font-size: .85rem; font-weight: 600; flex: 1; }
.header-back-btn {
  background: rgba(255,255,255,.15); border: none;
  border-radius: 6px; padding: 5px 8px; margin-right: 10px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.header-back-btn:hover { background: rgba(255,255,255,.3); }

.header-user {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.header-user-name {
  font-size: .72rem; color: rgba(255,255,255,.9);
  white-space: nowrap; max-width: 100px;
  overflow: hidden; text-overflow: ellipsis;
}
.header-admin-btn, .header-logout-btn {
  background: rgba(255,255,255,.15); border: none;
  border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
}
.header-admin-btn:hover, .header-logout-btn:hover { background: rgba(255,255,255,.3); }

/* ユーザーカード */
.user-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; flex-shrink: 0; color: #fff;
}
.user-avatar-admin { background: #e65100; }
.user-avatar-user { background: var(--primary); }
.user-info { flex: 1; min-width: 0; }
.user-info-name { font-weight: 600; font-size: .9rem; }
.user-info-email { font-size: .75rem; color: var(--text-light); }
.user-info-role {
  display: inline-block; font-size: .65rem; font-weight: 600;
  padding: 1px 8px; border-radius: 8px; margin-top: 2px;
}
.role-admin { background: #fff3e0; color: #e65100; }
.role-user { background: var(--primary-light); color: var(--primary); }
.user-actions { display: flex; gap: 6px; }
.user-edit-btn, .user-delete-btn {
  background: none; border: none; cursor: pointer; padding: 6px;
  border-radius: 6px; transition: background .15s;
}
.user-edit-btn:hover { background: var(--bg); }
.user-delete-btn:hover { background: #fde8e8; }
.user-edit-btn svg { stroke: var(--text-light); }
.user-delete-btn svg { stroke: var(--danger); }

/* 管理画面タブ */
.admin-tabs {
  display: flex; gap: 0; margin: 0 12px 12px;
  border-radius: 10px; overflow: hidden;
  border: 1.5px solid var(--primary);
}
.admin-tab {
  flex: 1; padding: 10px; border: none;
  background: var(--card-bg); color: var(--primary);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: all .2s;
}
.admin-tab.active { background: var(--primary); color: #fff; }
.admin-view { display: none; }
.admin-view.active { display: block; }

/* 事務所マスタ ツリー */
.tenant-node {
  background: var(--card-bg); border-radius: 10px;
  margin-bottom: 6px; box-shadow: var(--shadow);
}
.tenant-node-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.tenant-node-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tenant-icon-party { background: #c62828; }
.tenant-icon-prefecture { background: #2e7d32; }
.tenant-icon-city { background: #1565c0; }
.tenant-icon-office { background: #6a1b9a; }
.tenant-icon-other { background: #757575; }
.tenant-node-info { flex: 1; min-width: 0; }
.tenant-node-name { font-weight: 600; font-size: .92rem; }
.tenant-node-meta {
  font-size: .7rem; color: var(--text-light);
  display: flex; gap: 8px; margin-top: 2px;
}
.tenant-node-meta .badge {
  padding: 1px 6px; border-radius: 8px; background: var(--bg);
}
.tenant-node-actions { display: flex; gap: 4px; }
.tenant-children { padding-left: 24px; border-left: 2px solid var(--border); margin-left: 26px; }

.tenant-toggle-icon {
  font-size: .85rem; color: var(--text-light);
  width: 14px; flex-shrink: 0;
  transition: transform .2s;
}
.tenant-node-header {
  cursor: pointer;
}
.tenant-node-header:hover { background: var(--bg); }

.tenant-users-list {
  background: #fafbfc;
  border-top: 1px solid var(--border);
  padding: 10px 16px 14px;
}
.tenant-user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid #eee;
  font-size: .82rem;
}
.tenant-user-row:last-of-type { border-bottom: none; }
.tenant-user-name {
  font-weight: 600; min-width: 100px;
}
.tenant-user-email {
  color: var(--text-light); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tenant-user-empty {
  font-size: .8rem; color: #aaa; text-align: center;
  padding: 12px 0;
}
.tenant-user-add-btn {
  margin-top: 8px; font-size: .75rem !important;
  padding: 6px 12px !important;
  display: block; width: 100%;
}

/* ログイン履歴 */
.log-item {
  background: var(--card-bg); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 6px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
}
.log-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.log-info { flex: 1; min-width: 0; }
.log-name { font-weight: 600; font-size: .88rem; }
.log-email { font-size: .72rem; color: var(--text-light); }
.log-meta {
  text-align: right; flex-shrink: 0;
}
.log-date { font-size: .75rem; color: var(--text); font-weight: 500; }
.log-time { font-size: .68rem; color: var(--text-light); }
.log-device { font-size: .6rem; color: var(--text-light); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }

/* ===== ボトムナビ (モバイル) ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; background: none; border: none;
  color: var(--text-light); font-size: .65rem; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; transition: all .2s;
}
.nav-item .nav-icon { font-size: 1.4rem; }
.nav-item.active { color: var(--primary); font-weight: 600; }

/* ===== メインコンテンツ ===== */
.main {
  padding-top: calc(var(--header-h) + 4px);
  padding-bottom: calc(var(--nav-h) + var(--bottom-bar-h) + 8px);
  padding-left: 0; padding-right: 0;
  max-width: 960px; margin: 0 auto;
}

/* ===== ページ表示制御 ===== */
.page { display: none; }
.page.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== リストコンテナ (カード一覧 + あいうえおインデックス) ===== */
.list-container {
  display: flex;
  position: relative;
}
.list-container .card-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  min-width: 0;
}

/* ===== 名刺カード一覧 (Power Apps風) ===== */
.card-item {
  background: var(--card-bg);
  padding: 14px 16px;
  cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  position: relative;
}
.card-item:first-child { border-top: 1px solid var(--border); }
.card-item:hover { background: #f8f8fa; }
.card-item:active { background: #eef1f5; }

.card-info { flex: 1; min-width: 0; }
.card-info .card-name {
  font-weight: 500; font-size: 1.15rem; color: var(--primary);
  line-height: 1.3; margin-bottom: 2px;
}
.card-info .card-company {
  font-size: .88rem; color: var(--text); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-info .card-dept {
  font-size: .8rem; color: var(--text-light); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-right {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 8px; flex-shrink: 0;
}
.card-date { font-size: .75rem; color: var(--text-light); white-space: nowrap; }

/* 電話・メール・住所アクションボタン */
.card-actions {
  display: flex; gap: 6px; align-items: center;
}
.action-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
  text-decoration: none;
}
.action-btn:active { transform: scale(.9); }

.action-btn-phone {
  background: #f5f5f5; color: #555;
}
.action-btn-phone:hover { background: #e8e8e8; }
.action-btn-phone svg { stroke: #555; }

.action-btn-mail {
  background: #f5f5f5; color: #555;
}
.action-btn-mail:hover { background: #e8e8e8; }
.action-btn-mail svg { stroke: #555; }

.action-btn-map {
  background: #f5f5f5; color: #555;
}
.action-btn-map:hover { background: #e8e8e8; }
.action-btn-map svg { stroke: #555; }

/* ===== かな行フィルター (横スクロール) ===== */
.kana-row-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  background: var(--bg);
}
.kana-row-bar::-webkit-scrollbar { display: none; }

.kana-row-btn {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.kana-row-btn:active { transform: scale(.95); }
.kana-row-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.kana-row-btn:not(.active):hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== ボトム固定: ソートタブ + キーワード検索 ===== */
.list-bottom-bar {
  position: fixed;
  bottom: var(--nav-h);
  left: 0; right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 90;
  padding: 6px 12px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0));
}

.sort-tabs {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.sort-tab {
  flex: 1;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text-light);
  font-size: .78rem; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  transition: all .2s;
  white-space: nowrap;
}
.sort-tab.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.sort-tab.active svg { stroke: #fff; }
.sort-tab:not(.active):hover { background: var(--bg); }

.keyword-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 14px;
}
.keyword-icon { flex-shrink: 0; }
.keyword-search input {
  flex: 1; border: none; background: transparent;
  font-size: .92rem; outline: none; font-family: inherit;
  min-width: 0;
}
.keyword-search input::placeholder { color: #aaa; }
.keyword-clear {
  background: #999; color: #fff; border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: .7rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.keyword-go {
  background: var(--primary); color: #fff; border: none; border-radius: 16px;
  padding: 4px 14px; font-size: .8rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
}

/* ===== 音声入力ボタン ===== */
.voice-btn {
  padding: 8px 14px; border-radius: 10px;
  background: rgba(255,255,255,.25); border: 1.5px solid rgba(255,255,255,.5);
  cursor: pointer;
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0; transition: all .2s;
  font-size: 1rem; line-height: 1;
  color: #fff;
}
.voice-btn:hover { background: rgba(255,255,255,.4); border-color: #fff; }
.voice-btn:active { transform: scale(.95); }
.voice-label {
  font-size: .7rem; font-weight: 600; color: #fff;
}
.voice-btn.recording {
  background: #e53935; animation: pulse 1s infinite;
}
.voice-btn.recording svg { stroke: #fff; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,.4); }
  50% { box-shadow: 0 0 0 10px rgba(229,57,53,0); }
}

/* ===== 検索候補チップ ===== */
.search-suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 12px 4px;
}
.suggestion-chip {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 16px;
  font-size: .82rem; color: var(--text); cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.suggestion-chip:hover {
  background: var(--primary-light); border-color: var(--primary); color: var(--primary);
}
.suggestion-chip:active { transform: scale(.95); }

/* ===== グループヘッダー ===== */
.card-group-header {
  position: sticky;
  top: calc(var(--header-h) + 56px); /* ヘッダー + かな行バーの高さ */
  z-index: 20;
  background: var(--primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  padding: 6px 16px;
  letter-spacing: .03em;
  margin: 0 -1px; /* 隙間防止 */
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center; padding: 48px 16px; color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ===== AI検索セクション ===== */
.ai-search {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius); padding: 16px;
  margin: 0 12px 16px; color: #fff;
}
.ai-search h3 { font-size: .9rem; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

.search-bar { display: flex; gap: 8px; }
.search-bar input {
  flex: 1; padding: 12px 16px; border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius); font-size: .95rem;
  background: rgba(255,255,255,.15); color: #fff; transition: border-color .2s;
}
.search-bar input::placeholder { color: rgba(255,255,255,.6); }
.search-bar input:focus { outline: none; border-color: rgba(255,255,255,.6); }
.search-bar button {
  padding: 0 20px; background: rgba(255,255,255,.25); color: #fff;
  border: none; border-radius: var(--radius); font-size: .9rem;
  cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: background .2s;
}
.search-bar button:hover { background: rgba(255,255,255,.35); }

.ai-answer {
  margin-top: 12px; padding: 12px; background: rgba(255,255,255,.12);
  border-radius: 8px; font-size: .9rem; line-height: 1.5;
  display: none;
}
.ai-answer.visible { display: block; }

.ai-result-list { padding: 0 12px; }

.search-examples {
  margin: 16px 12px; padding: 12px; background: var(--card-bg);
  border-radius: var(--radius); font-size: .82rem; color: var(--text-light);
}
.search-examples ul { margin-top: 6px; padding-left: 18px; line-height: 1.8; }

/* ===== 名刺詳細 (Power Apps風) ===== */
#page-detail {
  padding-bottom: 64px;
}
.detail-body {
  background: var(--card-bg);
  border-radius: var(--radius);
  margin: 8px;
  padding: 20px 18px;
  box-shadow: var(--shadow);
}

/* 読み（携帯：漢字の上、PC：横） */
.d-reading-above {
  font-size: .78rem; color: #4caf50; font-weight: 600;
  margin-bottom: 2px;
}
.d-reading-inline {
  font-size: .85rem; color: #4caf50; font-weight: 600;
  display: none;
}
@media (min-width: 768px) {
  .d-reading-above { display: none; }
  .d-reading-inline { display: inline; }
}

/* 名前行 */
.d-name-row {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 2px;
}
.d-name {
  font-size: 1.4rem; font-weight: 800; color: var(--text);
  letter-spacing: .02em;
}

/* 会社名 */
.d-company {
  font-size: 1rem; color: #555; font-weight: 600;
  margin-bottom: 4px;
}

/* 住所セクション */
.d-address-section {
  margin-bottom: 16px;
}
.d-postal {
  font-size: .9rem; color: var(--text); font-weight: 600;
  margin-bottom: 2px;
}
.d-address-row {
  display: flex; align-items: center; gap: 8px;
}
.d-address-text {
  font-size: .95rem; color: var(--text); flex: 1;
}
.d-map-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; background: none; border: none; padding: 0;
  text-decoration: none;
}
.d-map-btn svg { stroke: var(--primary); }

/* キーマン */
.d-keyman-btn {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 14px; border-radius: 20px;
  border: 1.5px solid #ddd; background: var(--card-bg);
  color: var(--text-light); font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: all .2s;
}
.d-keyman-btn:active { transform: scale(.95); }
.d-keyman-btn.active {
  border-color: #f0d060; background: #fef9e7; color: #b8860b;
}
.d-keyman-star { font-size: 1rem; }

/* 組織リンク */
.d-org-link {
  display: inline-block;
  font-size: .8rem; color: var(--primary); font-weight: 600;
  cursor: pointer; padding: 2px 0;
  margin-bottom: 14px;
  transition: opacity .15s;
}
.d-org-link:hover { opacity: .7; }
.d-org-link:active { opacity: .5; }

/* 区切り線 */
.d-divider {
  border: none; border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* ラベル: 値 行 */
.d-field {
  display: flex; align-items: baseline; gap: 12px;
  padding: 5px 0; font-size: .92rem;
}
.d-label {
  color: var(--primary); font-weight: 700;
  font-size: .82rem; min-width: 56px; flex-shrink: 0;
}
.d-value {
  color: var(--text); font-size: .95rem; word-break: break-all;
}
.d-value a {
  color: var(--text); text-decoration: none;
}

/* TEL / 携帯 ボックス */
.d-phone-row {
  display: flex; gap: 16px; margin-top: 10px;
}
.d-phone-box {
  flex: 1;
}
.d-phone-label {
  display: inline-block;
  padding: 3px 14px;
  border: 1.5px solid var(--primary);
  border-radius: 4px;
  color: var(--primary);
  font-size: .78rem; font-weight: 700;
  margin-bottom: 4px;
}
.d-phone-number {
  font-size: 1rem; font-weight: 600; color: var(--text);
}
.d-phone-number a {
  color: var(--text); text-decoration: none;
}

/* FAXラベル（枠なし、TELの枠左端と揃え） */
.d-phone-label-plain {
  display: inline-block;
  color: var(--primary);
  font-size: .78rem; font-weight: 700;
  margin-bottom: 4px;
  /* TELの border(1.5px) + padding(14px) = 15.5px 分ずらしてテキスト位置を揃える */
  margin-left: 0;
  padding-left: 0;
}

/* 名刺画像 */
.d-photo-section {
  margin-top: 18px;
}
.d-photo {
  width: 100%; border-radius: 10px;
  border: 3px solid var(--primary-light);
  box-shadow: var(--shadow);
}

/* 自社担当カード */
.d-owners-card {
  margin-top: 16px; padding: 12px 14px;
  background: #e8f5e9; border-radius: 10px;
  border: 1px solid #c8e6c9;
}
.d-owners-title {
  font-size: .78rem; font-weight: 700; color: #2e7d32;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.d-owners-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.d-owner-chip {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 12px;
  padding: 8px 12px 8px 8px;
  font-size: .85rem; font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.d-owner-info {
  display: flex; flex-direction: column;
}
.d-owner-name { font-weight: 600; font-size: .85rem; }
.d-owner-date { font-size: .68rem; color: var(--text-light); margin-top: 1px; }
.d-owner-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #2e7d32; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}

/* 交換情報・メモ */
.d-notes-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.d-notes-section .d-field {
  align-items: flex-start;
}

/* 詳細ボトムバー */
.detail-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: 54px;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 90;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.detail-bar-btn {
  background: none; border: none;
  color: var(--primary); cursor: pointer;
  padding: 8px 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  text-decoration: none;
}
.detail-bar-btn:hover { background: var(--primary-light); }
.detail-bar-btn:active { transform: scale(.92); }
.detail-bar-btn svg { stroke: var(--primary); }

/* 非表示制御 */
#detailBottomBar { display: none; }
#page-detail.active ~ .bottom-nav { display: none; }

/* フォーム用ヘッダー */
.detail-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
  padding: 0 16px;
}
.back-btn {
  background: none; border: none; font-size: 1.5rem; cursor: pointer;
  color: var(--primary); padding: 4px;
}
.detail-actions { margin-left: auto; display: flex; gap: 8px; }

.detail-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin: 0 12px;
}

.photo-preview {
  max-width: 100%; border-radius: 8px; margin-top: 12px;
  box-shadow: var(--shadow);
}

/* ===== フォーム ===== */
.camera-section {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; margin: 0 12px 16px; box-shadow: var(--shadow);
  text-align: center;
}
.camera-section h3 { font-size: .95rem; margin-bottom: 12px; }

/* 表面・裏面アップロード */
.photo-upload-row {
  display: flex; gap: 10px; margin-bottom: 8px;
}
.photo-upload-box {
  flex: 1; position: relative;
  border: 2px dashed var(--border); border-radius: 10px;
  overflow: hidden; cursor: pointer;
  min-height: 120px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: border-color .2s;
  background: var(--bg);
}
.photo-upload-box:hover { border-color: var(--primary); }
.photo-upload-box.has-photo { border-style: solid; border-color: var(--primary); }

.photo-upload-label {
  position: absolute; top: 6px; left: 8px;
  font-size: .7rem; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 2px 8px; border-radius: 4px;
  z-index: 2;
}
.photo-upload-preview {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 8px;
}
.photo-upload-placeholder {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; color: #aaa; font-size: .75rem; padding: 16px;
}

.ocr-status {
  margin-top: 8px; font-size: .85rem; color: var(--primary);
  display: none;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: .82rem; font-weight: 600;
  color: var(--text-light); margin-bottom: 4px;
}
.form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .95rem; font-family: inherit;
  background: var(--card-bg); color: var(--text);
  transition: border-color .2s; appearance: auto;
}
.form-group select:focus { outline: none; border-color: var(--primary); }
.form-group input, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .95rem; font-family: inherit;
  transition: border-color .2s;
}
.form-group input:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== ボタン ===== */
.btn {
  padding: 10px 24px; border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 600; cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a4262c; }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== FAB ===== */
.fab {
  position: fixed; bottom: calc(var(--nav-h) + var(--bottom-bar-h) + 12px); right: 28px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 1.6rem; cursor: pointer; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s, background .2s; z-index: 50;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.05); }

/* ===== ローディング ===== */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; display: none;
}
.loading-overlay.visible { display: flex; }
.loading-box {
  background: var(--card-bg); padding: 24px 32px; border-radius: var(--radius);
  text-align: center; box-shadow: var(--shadow-lg);
}
.loading-box .spinner { border-color: var(--primary-light); border-top-color: var(--primary); width: 36px; height: 36px; }
.loading-box p { margin-top: 12px; font-size: .9rem; }

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 300; padding: 16px;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; max-width: 400px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin-bottom: 12px; }
.modal p { font-size: .9rem; color: var(--text-light); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ===== PC (768px+) ===== */
/* ===== PC サイドバーレイアウト (768px+) ===== */
@media (min-width: 768px) {
  :root { --nav-h: 0px; --bottom-bar-h: 0px; --header-h: 52px; --sidebar-w: 220px; }
  .bottom-nav { display: none; }
  .fab { display: none; }

  /* ソートタブ+検索を最上部に固定 */
  .list-bottom-bar {
    position: sticky; top: var(--header-h);
    z-index: 40; border-top: none;
    padding: 10px 0; background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  .header { padding: 0 24px; }
  .header h1 { font-size: 1.2rem; }
  .header-user-name { font-size: .85rem; max-width: 200px; }
  .header-logout-btn { width: 32px; height: 32px; }
  .header-admin-btn { width: 32px; height: 32px; }

  /* ヘッダー内トップナビは非表示（サイドバーに移行） */
  .pc-nav { display: none !important; }

  /* サイドバー */
  .pc-sidebar {
    display: flex !important;
    position: fixed; left: 0; top: var(--header-h);
    width: var(--sidebar-w); height: calc(100dvh - var(--header-h));
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    flex-direction: column;
    padding: 16px 0;
    z-index: 80;
    overflow-y: auto;
  }
  .sidebar-section {
    padding: 0 16px; margin-bottom: 16px;
  }
  .sidebar-section-title {
    font-size: .68rem; font-weight: 700; color: var(--text-light);
    text-transform: uppercase; letter-spacing: .05em;
    padding: 0 0 6px; margin-bottom: 4px;
  }
  .sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; margin: 2px 8px;
    border-radius: 10px; text-decoration: none;
    color: var(--text); font-size: .88rem; font-weight: 500;
    transition: all .15s; cursor: pointer;
  }
  .sidebar-link:hover { background: var(--bg); }
  .sidebar-link.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
  .sidebar-link .sidebar-icon { font-size: 1.1rem; width: 24px; text-align: center; }

  /* メインをサイドバー分オフセット */
  .main {
    margin-left: var(--sidebar-w);
    padding: calc(var(--header-h) + 20px) 28px 28px;
    max-width: none;
  }

  /* 一覧: 3列カード */
  .list-container .card-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .card-group-header {
    grid-column: 1 / -1;
    top: calc(var(--header-h) + 56px);
  }
  .card-item {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }
  .card-item .card-info { margin-bottom: 8px; }
  .card-item .card-right {
    flex-direction: row; justify-content: space-between; align-items: center;
  }
  /* 名刺画像プレビュー（PC用） */
  .card-thumb {
    width: 100%; height: 120px; object-fit: cover;
    border-radius: 8px; margin-bottom: 10px;
    background: #f0f0f0; display: block;
  }

  .form-row { grid-template-columns: 1fr 1fr 1fr; }
  .detail-card, .camera-section, .ai-search, .detail-header { margin: 0; }

  .detail-body { margin: 0; max-width: none; }
  .detail-bottom-bar { left: var(--sidebar-w); }
}

/* ズームバーはモバイルでは非表示 */
.d-photo-zoom-bar { display: none; }

/* ===== 詳細画面レイアウト (モバイルファースト) ===== */
.d-pc-left .d-photo-label { font-size: .7rem; color: var(--text-light); font-weight: 600; margin-bottom: 2px; }
.d-photo-label { font-size: .7rem; color: var(--text-light); font-weight: 600; margin-bottom: 4px; }

/* PC: 2カラム + リサイズ可能な画像 */
@media (min-width: 768px) {
  .d-pc-layout {
    display: flex; gap: 20px; align-items: flex-start;
  }
  .d-pc-left {
    width: 300px; flex-shrink: 0;
    position: sticky; top: calc(var(--header-h) + 16px);
  }
  .d-pc-left .d-photo {
    width: 100%; border-radius: 10px; border: 2px solid var(--primary-light); margin-top: 4px;
  }
  .d-pc-right { flex: 1; min-width: 0; }
  .d-info-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 4px 16px; margin-bottom: 12px;
  }
  .d-info-grid .d-field { padding: 4px 0; }

  .d-resize-handle { display: none; }

  /* 画像拡大縮小ボタン */
  .d-photo-zoom-bar {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px; justify-content: center;
  }
  .d-photo-zoom-btn {
    width: 30px; height: 30px; border-radius: 50%;
    border: 1.5px solid var(--border); background: var(--card-bg);
    cursor: pointer; font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    color: var(--text); transition: all .15s;
    user-select: none; -webkit-user-select: none;
  }
  .d-photo-zoom-btn:hover { border-color: var(--primary); color: var(--primary); }
  .d-photo-zoom-btn:active { transform: scale(.9); }
  .d-photo-zoom-label {
    font-size: .72rem; color: var(--text-light); min-width: 36px; text-align: center;
  }
  .d-pc-left {
    user-select: none; -webkit-user-select: none;
  }
}

/* モバイル: 画像を最下段、ソートバー修正 */
@media (max-width: 767px) {
  .d-pc-layout { display: flex; flex-direction: column; }
  .d-pc-left { order: 99; margin-top: 16px; }
  .d-pc-right { order: 1; }
  .d-resize-handle { display: none; }
  .card-thumb { display: none !important; }
}

/* PC サイドバー非表示 (モバイル) */
.pc-sidebar { display: none; }
/* PC ナビ非表示 (モバイル) */
.pc-nav { display: none; }

/* ===== 人脈管理 ===== */
#netTree { padding: 0 12px 12px; }

/* 組織ツリー: 会社カード */
.org-company {
  background: var(--card-bg); border-radius: var(--radius);
  margin-bottom: 10px; box-shadow: var(--shadow);
  overflow: hidden;
}
.org-company-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; cursor: pointer;
  transition: background .15s;
}
.org-company-header:active { background: #f5f5f5; }
.org-company-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700; flex-shrink: 0;
}
.org-company-info { flex: 1; min-width: 0; }
.org-company-name {
  font-weight: 600; font-size: .95rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.org-company-meta {
  font-size: .75rem; color: var(--text-light); margin-top: 2px;
  display: flex; gap: 8px;
}
.org-company-meta .key-badge {
  color: #e6a700; font-weight: 700;
}
.org-chevron {
  font-size: 1rem; color: var(--text-light);
  transition: transform .2s; flex-shrink: 0;
}
.org-company.open .org-chevron { transform: rotate(90deg); }

/* 部署・人 */
.org-body { display: none; padding: 0 16px 12px 16px; }
.org-company.open .org-body { display: block; }

.org-dept {
  margin-top: 8px;
}
.org-dept-name {
  font-size: .78rem; font-weight: 700; color: var(--primary);
  padding: 4px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.org-person {
  display: flex; flex-direction: column;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer; transition: background .15s;
  gap: 3px;
}
.org-person:last-child { border-bottom: none; }
.org-person:active { background: #f5f5f5; }

.org-person-top {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.org-person-owners {
  display: flex; gap: 3px; margin-left: auto;
}
.org-person-name {
  font-size: .9rem; font-weight: 500;
}
.org-person-key {
  font-size: .65rem; color: #e6a700; font-weight: 700;
  background: #fef9e7; border: 1px solid #f0d060;
  border-radius: 4px; padding: 1px 6px;
  white-space: nowrap;
}

.org-person-bottom {
  display: flex; align-items: center; gap: 6px;
}
.org-person-position {
  font-size: .72rem; color: var(--text-light);
  white-space: nowrap;
}
.org-person-owner {
  font-size: .6rem; color: var(--card-bg);
  background: var(--text-light); border-radius: 8px;
  padding: 1px 5px; white-space: nowrap;
}

/* 会社詳細ヘッダー */
.org-detail-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 12px;
  position: sticky; top: var(--header-h); z-index: 30;
  background: var(--bg);
}
.org-fullscreen-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border: 1.5px solid var(--primary);
  background: var(--card-bg); color: var(--primary);
  border-radius: 6px; cursor: pointer;
  font-size: .72rem; font-weight: 600;
}
.org-fullscreen-btn:hover { background: var(--primary-light); }

/* フルスクリーンモーダル */
.org-fullscreen-modal {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.org-fullscreen-modal.hidden { display: none; }
.org-fullscreen-modal > .org-fullscreen-inner,
.org-fullscreen-modal {
  --inner-w: 95vw; --inner-h: 92vh;
}
.org-fullscreen-modal::before {
  content: '';
}
.org-fullscreen-header {
  position: absolute; top: 4vh; left: 2.5vw; right: 2.5vw;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  background: var(--card-bg);
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.org-fullscreen-header h3 { font-size: 1.05rem; font-weight: 700; }
.org-fullscreen-close {
  background: none; border: none; font-size: 1.4rem;
  cursor: pointer; color: var(--text-light);
  padding: 4px 12px; border-radius: 6px;
}
.org-fullscreen-close:hover { background: var(--bg); color: var(--text); }

.org-fullscreen-body {
  position: absolute; top: calc(4vh + 56px); left: 2.5vw; right: 2.5vw; bottom: 4vh;
  display: flex; gap: 0;
  background: var(--card-bg);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.org-fullscreen-graph {
  flex: 1; min-width: 0;
  background: #1a1a2e;
  position: relative;
  border-right: 1px solid var(--border);
}
.org-fullscreen-graph svg { width: 100%; height: 100%; display: block; }
.org-fullscreen-side {
  width: 380px; flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 20px;
  background: #fafafa;
}
.org-fullscreen-empty {
  text-align: center; color: var(--text-light);
  padding: 40px 16px; font-size: .85rem;
}
.org-detail-title { flex: 1; min-width: 0; }
.org-detail-title .odt-name {
  font-size: 1.05rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.org-detail-title .odt-meta {
  font-size: .75rem; color: var(--text-light);
  display: flex; gap: 8px; margin-top: 2px;
}
.odt-meta .key-badge { color: #e6a700; font-weight: 700; }

#orgDetailBody { padding: 0 12px 12px; }
#orgDetailBody .org-dept {
  background: var(--card-bg); border-radius: var(--radius);
  margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden;
}
#orgDetailBody .org-dept-name {
  padding: 10px 14px 6px; border-bottom: none; font-size: .85rem;
}
#orgDetailBody .org-person { padding: 8px 14px; }

/* ネットワークグラフ */
#graphContainer {
  width: 100%;
  height: 420px;
  background: #1a1a2e;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
#graphContainer svg {
  width: 100%; display: block;
}
.graph-tooltip {
  position: absolute; pointer-events: none;
  background: rgba(0,0,0,.85); color: #fff;
  padding: 6px 10px; border-radius: 6px;
  font-size: .75rem; line-height: 1.4;
  display: none; z-index: 10;
  max-width: 200px;
}
.graph-options {
  position: absolute; top: 10px; right: 10px; z-index: 5;
}
.graph-toggle-inline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: rgba(255,255,255,.95);
  border: 1px solid var(--border); border-radius: 18px;
  font-size: .75rem; font-weight: 600; color: var(--text);
  cursor: pointer; user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.graph-toggle-inline input { width: auto; cursor: pointer; margin: 0; }
.graph-toggle-inline:hover { border-color: var(--primary); }

.graph-legend {
  position: absolute; bottom: 10px; left: 10px;
  background: rgba(0,0,0,.6); border-radius: 8px;
  padding: 8px 12px; font-size: .65rem; color: #ccc;
  display: flex; flex-direction: column; gap: 4px;
}
.graph-legend-item {
  display: flex; align-items: center; gap: 6px;
}
.graph-legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* グラフフィルター */
.graph-filters {
  padding: 0 12px 16px;
}
.graph-filter-section {
  margin-bottom: 8px;
}
.graph-filter-label {
  font-size: .72rem; font-weight: 700;
  color: var(--text-light); margin-bottom: 5px;
}
.graph-filter-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.graph-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border: 1.5px solid var(--border);
  border-radius: 20px; background: var(--card-bg);
  font-size: .8rem; font-weight: 600; color: var(--text);
  cursor: pointer; user-select: none;
}
.graph-toggle input { width: auto; cursor: pointer; }
.graph-toggle:hover { border-color: var(--primary); }
.graph-chip-all, .graph-chip {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text);
  font-size: .78rem; font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  user-select: none; -webkit-user-select: none;
}
.graph-chip-all {
  border-color: var(--primary); color: var(--primary); font-weight: 600;
}
.graph-chip:active { transform: scale(.95); }
.chip-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 3px;
  border: 1.5px solid rgba(255,255,255,.6);
  background: rgba(255,255,255,.2);
  font-size: .7rem; line-height: 1;
  margin-right: 2px; vertical-align: -2px;
}
.graph-chip:not(.active-owner):not(.active-dept) .chip-check {
  border-color: #bbb;
  background: #fff;
  color: transparent;
}
.graph-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.graph-chip.active-owner {
  background: #0288d1;
  color: #fff;
  border-color: #0288d1;
}
.graph-chip.active-dept {
  background: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}

/* コネクション */
.conn-company {
  background: var(--card-bg); border-radius: var(--radius);
  margin-bottom: 10px; box-shadow: var(--shadow); overflow: hidden;
}
.conn-company-header {
  padding: 14px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s;
}
.conn-company-header:active { background: #f5f5f5; }
.conn-company-name { font-weight: 600; font-size: .95rem; flex: 1; }
.conn-badges {
  display: flex; gap: 4px;
}
.conn-badge {
  font-size: .7rem; padding: 2px 8px; border-radius: 10px;
  font-weight: 600;
}
.conn-badge-people { background: var(--primary-light); color: var(--primary); }
.conn-badge-owners { background: #e8f5e9; color: #2e7d32; }

.conn-body { display: none; padding: 0 16px 12px; }
.conn-company.open .conn-body { display: block; }
.conn-company.open .org-chevron { transform: rotate(90deg); }

.conn-owner-group { margin-top: 8px; }
.conn-owner-name {
  font-size: .8rem; font-weight: 700; color: #2e7d32;
  padding: 4px 0; display: flex; align-items: center; gap: 6px;
}
.conn-owner-name::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #2e7d32; flex-shrink: 0;
}
.conn-person {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0 5px 16px; font-size: .85rem;
  border-bottom: 1px solid #f5f5f5;
}
.conn-person:last-child { border-bottom: none; }
.conn-person-name { flex: 1; }
.conn-person-dept { font-size: .72rem; color: var(--text-light); }
.conn-person-key { font-size: .75rem; color: #e6a700; }

/* ===== PDF一括登録 ===== */
.bulk-dropzone {
  border: 2.5px dashed var(--border);
  border-radius: 16px; padding: 32px 16px;
  text-align: center; cursor: pointer;
  transition: all .2s; background: var(--card-bg);
}
.bulk-dropzone:hover, .bulk-dropzone.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.bulk-dropzone-inner p {
  font-size: .88rem; color: var(--text-light); margin-top: 8px; line-height: 1.6;
}

.bulk-file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--card-bg);
  border-radius: 10px; margin-bottom: 6px;
  box-shadow: var(--shadow);
}
.bulk-file-icon { font-size: 1.3rem; }
.bulk-file-info { flex: 1; min-width: 0; }
.bulk-file-name { font-size: .85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-file-size { font-size: .7rem; color: var(--text-light); }
.bulk-file-status { font-size: .72rem; font-weight: 600; }
.bulk-file-remove {
  background: none; border: none; color: var(--danger);
  cursor: pointer; font-size: 1.1rem; padding: 4px;
}

/* OCRプログレス (画面上部固定) */
.bulk-progress {
  position: fixed; top: var(--header-h); left: 0; right: 0;
  z-index: 200; margin: 0; padding: 14px 24px;
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  border-bottom: 2px solid var(--primary);
}
@media (min-width: 768px) {
  .bulk-progress { left: var(--sidebar-w); }
}
.bulk-progress-bar-wrap {
  height: 8px; background: #e0e0e0; border-radius: 4px;
  overflow: hidden; margin: 10px 0;
}
.bulk-progress-bar {
  height: 100%; background: var(--primary); border-radius: 4px;
  transition: width .3s ease;
}
.bulk-progress-text {
  display: flex; justify-content: space-between;
  font-size: .8rem; color: var(--text-light);
}
.bulk-progress-current {
  text-align: center; margin-top: 8px;
  font-size: .82rem; color: var(--text);
}
.bulk-progress-current .spinner {
  border-color: var(--primary-light); border-top-color: var(--primary);
  width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px;
}

/* 一括確認カード */
.bulk-review-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.bulk-review-card-number {
  font-size: .7rem; font-weight: 700; color: var(--primary);
  margin-bottom: 8px;
}
/* 確認画面トップバー */
.bulk-review-top-bar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg); padding: 10px 0;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); margin-bottom: 12px;
}

/* 確認画面2列グリッド (PC) */
.bulk-review-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 768px) {
  .bulk-review-grid { grid-template-columns: 1fr 1fr; }
}

.bulk-review-body {
  display: flex; flex-direction: column; gap: 10px;
}
.bulk-review-images {
  display: flex; gap: 8px;
  width: 100%;
}
.bulk-review-img-wrap {
  position: relative;
}
.bulk-review-img-label {
  position: absolute; top: 4px; left: 4px;
  font-size: .6rem; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.5); padding: 1px 6px; border-radius: 4px;
}
.bulk-review-img-wrap {
  flex: 1; position: relative;
}
.bulk-review-img {
  width: 100%; border-radius: 8px; border: 1px solid var(--border);
  display: block;
}
/* リサイズ可能な画像コンテナ */
.bulk-review-images-resizable {
  resize: vertical; overflow: hidden;
  min-height: 80px; max-height: 600px;
  padding-bottom: 4px;
  border-bottom: 2px dashed var(--border);
  cursor: ns-resize;
}
.bulk-review-images-resizable .bulk-review-img {
  height: 100%; width: auto; max-width: 100%;
  object-fit: contain;
}
.bulk-review-resize-hint {
  font-size: .65rem; color: #aaa; text-align: center;
  margin-top: 2px;
}
.bulk-review-form { flex: 1; min-width: 0; }
.bulk-review-name-row {
  font-size: 1rem; font-weight: 700; margin-bottom: 4px;
}
.bulk-review-company-row {
  font-size: .82rem; color: var(--text-light); margin-bottom: 10px;
}
.bulk-review-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px;
  font-size: .8rem;
}
.bulk-review-field label {
  font-size: .7rem; color: var(--text-light); font-weight: 600;
  display: block; margin-bottom: 2px;
}
.bulk-review-field input {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 6px; font-size: .82rem; font-family: inherit;
  transition: border-color .2s;
}
.bulk-review-field input:focus { outline: none; border-color: var(--primary); }

/* 重複警告バナー */
.bulk-duplicate-warn {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; margin-bottom: 10px;
  background: #fff8e1; border: 1.5px solid #ffb300;
  border-radius: 8px;
}
.bulk-duplicate-icon {
  font-size: 1.2rem; flex-shrink: 0; line-height: 1;
}
.bulk-duplicate-text {
  font-size: .8rem; color: #5d4037; line-height: 1.5;
}
.bulk-duplicate-text strong {
  color: #e65100; font-size: .82rem;
}
.bulk-duplicate-action {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; font-size: .78rem; font-weight: 600;
  color: var(--primary); cursor: pointer;
}
.bulk-duplicate-action input { width: auto; cursor: pointer; }

/* モバイルでは画像を縦積み */
@media (max-width: 767px) {
  .bulk-review-images { flex-direction: column; }
}

/* ===== ユーティリティ ===== */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.hidden { display: none !important; }
