/* ═══════════════════════════════════════════
   KOIN - 川本鋼材 業務プラットフォーム
   Google Material Design スタイル
═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&display=swap');

/* ── CSS変数（ライトテーマ） ── */
:root {
  --primary:        #1a73e8;
  --primary-dark:   #1557b0;
  --primary-light:  #e8f0fe;
  --surface:        #ffffff;
  --bg:             #f1f3f4;
  --text:           #202124;
  --text-sub:       #5f6368;
  --border:         #dadce0;
  --success:        #1e8e3e;
  --success-light:  #e6f4ea;
  --warning:        #f9ab00;
  --warning-light:  #fef7e0;
  --error:          #d93025;
  --error-light:    #fce8e6;
  --sidebar-w:      240px;
  --sidebar-min:    64px;
  --topbar-h:       56px;
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-2: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
}

/* ── リセット ── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Noto Sans JP', 'Meiryo', 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

/* ══════════════════════════════════════════
   サイドバー
══════════════════════════════════════════ */
#sidebar {
  display: flex;
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  z-index: 1000;
  transition: width .2s ease, transform .25s ease;
  overflow-x: hidden;
  overflow-y: auto;
}
#sidebar::-webkit-scrollbar { width: 0; }

/* ロゴ */
.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  gap: 12px;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1rem; font-weight: 700; font-style: italic;
  flex-shrink: 0;
}
/* 川本鋼材ロゴ (画像 + テキスト・縦並び) */
.sidebar-logo-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1;
}
.sidebar-logo-img {
  height: 24px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}
.sidebar-logo-text {
  font-family: 'Audiowide', 'Orbitron', 'Helvetica Neue', sans-serif;
  font-size: 1.35rem;
  font-weight: 400;
  letter-spacing: .22em;
  white-space: nowrap;
  background: linear-gradient(90deg, #0d3a8a 0%, #1a73e8 55%, #dc2548 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  line-height: 1;
  margin-left: 2px;
  margin-top: 4px;
}
.sidebar-logo-sub {
  font-size: 0.65rem;
  color: var(--text-sub);
  white-space: nowrap;
  letter-spacing: .25em;
  margin-top: 1px;
  font-weight: 500;
}

/* ナビ */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-section-label {
  padding: 16px 20px 4px;
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-sub);
  text-transform: uppercase; letter-spacing: .08em;
  white-space: nowrap;
}

/* ── ナビアイテム（横並び・サイドバー用に上書き） ── */
.koin-nav-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start;
  gap: 16px;
  padding: 10px 20px !important;
  margin: 1px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text) !important;
  font-size: 0.875rem !important;
  font-weight: 400;
  transition: background .15s;
  white-space: nowrap;
  min-width: unset;
  border-bottom: none !important;
  position: relative;
  cursor: pointer;
}
.koin-nav-item i {
  font-size: 1.2rem !important;
  display: flex !important;
  flex-shrink: 0;
  margin-bottom: 0 !important;
  color: var(--text-sub) !important;
  width: 22px;
  text-align: center;
}
.koin-nav-item span {
  font-size: 0.875rem !important;
  flex: 1;
}
.koin-nav-item:hover {
  background: var(--bg) !important;
  color: var(--text) !important;
  text-decoration: none;
}
.koin-nav-item.active {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  font-weight: 600;
}
.koin-nav-item.active i { color: var(--primary) !important; }

.koin-badge {
  position: static;
  background: var(--error);
  color: #fff;
  border-radius: 10px;
  min-width: 18px; height: 18px;
  font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  margin-left: auto;
}

/* ── アコーディオン セクションボタン ── */
.koin-nav-section-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: calc(100% - 16px);
  margin: 1px 8px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-sub);
  cursor: pointer;
  text-align: left;
  transition: background .15s;
  white-space: nowrap;
}
.koin-nav-section-btn i:first-child {
  font-size: 1.1rem;
  width: 22px;
  flex-shrink: 0;
  text-align: center;
}
.koin-nav-section-btn span {
  flex: 1;
}
.koin-nav-section-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.koin-nav-section-btn.expanded {
  color: var(--text);
}
.section-chevron {
  font-size: 0.7rem !important;
  transition: transform .2s;
  color: var(--text-sub) !important;
  width: auto !important;
}
.koin-nav-section-btn.expanded .section-chevron {
  transform: rotate(-180deg);
}

/* ── アコーディオン コンテンツ ── */
.koin-nav-section {
  overflow: hidden;
  max-height: 0;
  transition: max-height .25s ease;
}
.koin-nav-section.open {
  max-height: 800px;
}
.koin-nav-subhead {
  font-size: .7rem; font-weight: 600;
  color: #9aa0a6; letter-spacing: .05em;
  padding: 8px 12px 4px 28px; text-transform: uppercase;
}
body.dark-mode .koin-nav-subhead { color:#5f6368; }

/* ── サブアイテム（インデント） ── */
.koin-nav-sub {
  padding-left: 36px !important;
  font-size: 0.835rem !important;
  margin: 0px 8px !important;
  padding-top: 7px !important;
  padding-bottom: 7px !important;
}
.koin-nav-sub i {
  font-size: 1rem !important;
}

/* ユーザーセクション */
.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.875rem; font-weight: 600;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-size: 0.82rem; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.7rem; color: var(--text-sub);
}

/* ══════════════════════════════════════════
   メインコンテンツ
══════════════════════════════════════════ */
#main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .2s;
}

/* ── トップバー ── */
.koin-header {
  position: sticky;
  top: 0; z-index: 900;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
}
/* 旧ヘッダー要素は非表示 */
.koin-topbar  { display: none !important; }
.koin-icon-nav { display: none !important; }

.topbar-hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: 50%;
  color: var(--text-sub); font-size: 1.25rem;
}
.topbar-hamburger:hover { background: var(--bg); }

.topbar-spacer { flex: 1; }

.topbar-search { flex: 1; max-width: 480px; }
.topbar-search .input-group {
  background: var(--bg);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
.topbar-search .input-group:focus-within {
  background: var(--surface);
  border-color: var(--primary);
}
.topbar-search input {
  background: transparent !important;
  border: none; padding: 8px 16px; font-size: 0.875rem;
}
.topbar-search input:focus { box-shadow: none !important; }
.topbar-search .btn {
  background: transparent; border: none;
  color: var(--text-sub); padding: 8px 12px;
}

.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-sub); font-size: 1.1rem;
  text-decoration: none;
  transition: background .15s;
}
.topbar-icon-btn:hover { background: var(--bg); color: var(--text); }

.topbar-date { font-size: 0.8rem; color: var(--text-sub); }

/* ── コンテンツエリア ── */
#koin-content {
  flex: 1;
  padding: 24px;
}
.koin-page { }

/* ══════════════════════════════════════════
   ページタイトル
══════════════════════════════════════════ */
.page-title {
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 0;
  border-bottom: none;
}
.page-title i { color: var(--primary); }

/* ══════════════════════════════════════════
   カード
══════════════════════════════════════════ */
.koin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.koin-card-header {
  background: var(--surface);
  color: var(--text);
  padding: 12px 16px;
  font-size: 0.875rem; font-weight: 500;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.koin-card-header i { color: var(--primary); margin-right: 4px; }
.koin-card-header a { color: var(--primary); font-size: 0.78rem; }
.koin-card-header.green  { border-left: 3px solid var(--success); }
.koin-card-header.orange { border-left: 3px solid #fa7b17; }
.koin-card-header.gray   { border-left: 3px solid var(--text-sub); }

/* Bootstrap card override */
.card {
  border-radius: 8px !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.card-body { padding: 20px !important; }
.shadow-sm { box-shadow: var(--shadow-1) !important; }

/* stat-card */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stat-card .card-body { padding: 20px !important; }
.stat-value { font-size: 2rem; font-weight: 300; }
.stat-label { font-size: 0.75rem; color: var(--text-sub); margin-top: 4px; }

/* ══════════════════════════════════════════
   テーブル
══════════════════════════════════════════ */
.table-crm thead th {
  background: var(--bg);
  font-size: 0.75rem; font-weight: 500;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
  border-top: none;
  padding: 10px 12px;
  text-transform: uppercase; letter-spacing: .03em;
}
.table-crm tbody tr:hover { background: var(--primary-light); }
.table-crm td {
  vertical-align: middle;
  font-size: 0.875rem;
  padding: 10px 12px;
  border-color: var(--border);
}

/* ══════════════════════════════════════════
   ボタン
══════════════════════════════════════════ */
.btn { border-radius: 6px !important; font-weight: 500; }
.btn-xs { padding: .15rem .4rem; font-size: .75rem; }
.btn-primary {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-primary:hover {
  background: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}
.btn-outline-primary {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-outline-primary:hover {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}
.btn-outline-success { border-radius: 6px !important; }
.btn-outline-secondary { border-radius: 6px !important; }

/* ══════════════════════════════════════════
   フォーム
══════════════════════════════════════════ */
.form-control, .form-select {
  border-color: var(--border) !important;
  border-radius: 6px !important;
  font-size: 0.875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(26,115,232,.2) !important;
}
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--text-sub); }

/* ══════════════════════════════════════════
   KPIチップ（ダッシュボード）
══════════════════════════════════════════ */
.koin-kpi-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  min-width: 130px;
}
.koin-kpi-chip i { font-size: 1.35rem; }
.koin-kpi-val {
  font-size: 1.6rem; font-weight: 300; color: var(--text); line-height: 1;
}
.koin-kpi-lbl { font-size: 0.75rem; color: var(--text-sub); }

/* ══════════════════════════════════════════
   ダッシュボード 3カラム
══════════════════════════════════════════ */
.koin-dashboard {
  display: grid;
  grid-template-columns: 270px 1fr 230px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1300px) {
  .koin-dashboard { grid-template-columns: 1fr 1fr; }
  .koin-col-right { display: none; }
}
@media (max-width: 768px) {
  .koin-dashboard { grid-template-columns: 1fr; }
  .koin-col-right { display: block; }
}
.koin-col-left, .koin-col-center, .koin-col-right {
  display: flex; flex-direction: column; gap: 16px;
}

/* ══════════════════════════════════════════
   フェーズ・ステータスバッジ
══════════════════════════════════════════ */
.phase-badge {
  display: inline-block;
  padding: 3px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 500; white-space: nowrap;
}
.phase-0   { background: #f1f3f4; color: var(--text-sub); }
.phase-15  { background: #fef7e0; color: #b45309; }
.phase-30  { background: var(--primary-light); color: var(--primary-dark); }
.phase-50  { background: #e6f4ea; color: #137333; }
.phase-80  { background: #d2e3fc; color: var(--primary-dark); }
.phase-100 { background: var(--success); color: #fff; }

.status-active { background: var(--primary-light); color: var(--primary-dark); border-radius: 12px; padding: 3px 10px; font-size: 0.75rem; }
.status-won    { background: var(--success-light); color: var(--success); border-radius: 12px; padding: 3px 10px; font-size: 0.75rem; }
.status-lost   { background: var(--error-light); color: var(--error); border-radius: 12px; padding: 3px 10px; font-size: 0.75rem; }

/* ══════════════════════════════════════════
   カンバン
══════════════════════════════════════════ */
.kanban-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { min-width: 210px; width: 210px; flex-shrink: 0; }
.kanban-col-header {
  background: var(--bg); color: var(--text);
  border-radius: 8px 8px 0 0;
  padding: 10px 12px; font-size: 0.8rem; font-weight: 500;
  border: 1px solid var(--border); border-bottom: 2px solid var(--primary);
}
.kanban-cards {
  background: var(--bg); border-radius: 0 0 8px 8px;
  min-height: 100px; padding: 8px;
  border: 1px solid var(--border); border-top: none;
}
.kanban-card {
  background: var(--surface); border-radius: 6px;
  padding: 10px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow-1); font-size: 0.8rem;
  border-left: 3px solid var(--primary);
  transition: box-shadow .15s; cursor: pointer;
}
.kanban-card:hover { box-shadow: var(--shadow-2); }

/* ══════════════════════════════════════════
   優先度・カテゴリ
══════════════════════════════════════════ */
.priority-high   { border-left: 3px solid var(--error) !important; }
.priority-normal { border-left: 3px solid var(--primary) !important; }
.priority-low    { border-left: 3px solid var(--border) !important; }

.cat-visit    { background: var(--primary) !important; color: #fff !important; }
.cat-call     { background: var(--success) !important; color: #fff !important; }
.cat-meeting  { background: #fa7b17 !important; color: #fff !important; }
.cat-deadline { background: var(--error) !important; color: #fff !important; }
.cat-other    { background: var(--text-sub) !important; color: #fff !important; }

/* ══════════════════════════════════════════
   AI結果
══════════════════════════════════════════ */
.ai-result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 16px;
  white-space: pre-wrap; font-size: 0.875rem; line-height: 1.7;
  max-height: 500px; overflow-y: auto;
}

/* ══════════════════════════════════════════
   停滞アラート
══════════════════════════════════════════ */
.stale-item {
  border-left: 3px solid var(--warning);
  background: var(--warning-light);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px; margin-bottom: 6px;
}

/* ══════════════════════════════════════════
   サブタブ
══════════════════════════════════════════ */
.koin-subtabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.koin-subtab {
  padding: 10px 18px;
  font-size: 0.875rem; color: var(--text-sub);
  text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; font-weight: 500;
  transition: color .15s;
}
.koin-subtab:hover { color: var(--primary); }
.koin-subtab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ══════════════════════════════════════════
   在席バッジ
══════════════════════════════════════════ */
.presence-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
}
.presence-in    { background: var(--success); }
.presence-out   { background: var(--text-sub); }
.presence-other { background: var(--warning); }

/* ══════════════════════════════════════════
   タッチボタン（生産管理）
══════════════════════════════════════════ */
.touch-btn {
  min-height: 70px; font-size: 1rem;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; border-radius: 8px; touch-action: manipulation;
}
.touch-btn i { font-size: 1.6rem; }

/* ══════════════════════════════════════════
   アラート
══════════════════════════════════════════ */
.alert { border-radius: 8px; border: none; font-size: 0.875rem; }
.alert-success { background: var(--success-light); color: #137333; }
.alert-danger  { background: var(--error-light);   color: var(--error); }
.alert-warning { background: var(--warning-light); color: #b45309; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); }

/* ══════════════════════════════════════════
   バッジ
══════════════════════════════════════════ */
.badge { border-radius: 6px !important; font-weight: 500 !important; }

/* ══════════════════════════════════════════
   モバイルオーバーレイ
══════════════════════════════════════════ */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ══════════════════════════════════════════
   レスポンシブ
══════════════════════════════════════════ */
@media (max-width: 1100px) {
  #sidebar { width: var(--sidebar-min); }
  #sidebar .sidebar-logo-text,
  #sidebar .sidebar-logo-sub,
  #sidebar .koin-nav-item span,
  #sidebar .sidebar-section-label,
  #sidebar .sidebar-user-name,
  #sidebar .sidebar-user-role { display: none !important; }
  #sidebar .koin-nav-item {
    justify-content: center !important;
    padding: 12px 0 !important;
    margin: 1px 4px;
  }
  #sidebar .koin-badge { display: none; }
  #sidebar .sidebar-user { justify-content: center; padding: 12px 0; }
  #main-content { margin-left: var(--sidebar-min); }
}
@media (max-width: 768px) {
  /* ── サイドバー: 引き出し式に変更 ── */
  #sidebar {
    width: var(--sidebar-w);
    transform: translateX(-100%);
  }
  #sidebar.open { transform: translateX(0); box-shadow: 0 0 24px rgba(0,0,0,.18); }

  /* ── メインエリアのマージンをゼロに ── */
  #main-content { margin-left: 0; }

  /* ── トップバー ── */
  .topbar-hamburger { display: flex !important; }
  .koin-header { padding: 0 10px; gap: 6px; }
  .topbar-icon-btn { width: 38px; height: 38px; font-size: 1rem; }
  .topbar-search { display: none !important; }
  /* スマホでは日付も隠す（既にd-none d-lg-blockで隠れるがフォールバック） */
  .topbar-date { display: none !important; }

  /* ── コンテンツ余白 ── */
  #koin-content { padding: 12px 10px 80px 10px; } /* 下部はFABや下バーのため余白 */

  /* ── ページタイトル ── */
  .page-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
    gap: 6px;
  }

  /* ── カード: 余白を詰める ── */
  .card { border-radius: 8px !important; }
  .card-body { padding: 12px !important; }
  .koin-card-header { padding: 10px 12px; font-size: 0.82rem; }

  /* ── テーブル: 横スクロール保証 + フォント縮小 ── */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table { font-size: 0.8rem; }
  .table td, .table th { padding: 6px 8px !important; }
  /* table-responsive なしでも縦表示が破綻しないよう block表示で横スクロール */
  table.table:not(.table-responsive table) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── ボタン: タップしやすく ── */
  .btn            { min-height: 40px; }
  .btn-sm         { min-height: 36px; padding: 6px 12px; font-size: 0.82rem; }
  .btn-xs         { min-height: 32px; padding: 4px 10px; }
  .btn-group .btn { min-height: 36px; }

  /* ── フォーム要素（iOSでズーム発生を防ぐ font-size:16px） ── */
  .form-control, .form-select, input[type="text"], input[type="number"],
  input[type="date"], input[type="time"], input[type="email"],
  input[type="password"], input[type="search"], textarea {
    min-height: 44px;
    font-size: 16px !important;
  }
  textarea { min-height: 80px; }
  .input-group-text { font-size: 0.875rem; }

  /* ── モーダル: 画面の殆どを使う ── */
  .modal-dialog {
    margin: 8px;
    max-width: calc(100vw - 16px);
  }
  .modal-content { border-radius: 12px; }
  .modal-body { padding: 12px; }

  /* ── ドロップダウン: 全幅寄り ── */
  .dropdown-menu {
    max-width: calc(100vw - 24px);
    font-size: 0.9rem;
  }

  /* ── タブナビ: スクロール可・フォント縮小 ── */
  .nav-tabs, .nav-pills { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-link, .nav-pills .nav-link { white-space: nowrap; font-size: 0.85rem; padding: 8px 10px; }

  /* ── KPIチップ: ラップ許容 ── */
  .koin-kpi-chip { min-width: 0; flex: 0 0 auto; }

  /* ── Bootstrap gutters: スマホでは狭く ── */
  .container, .container-fluid { padding-left: 10px; padding-right: 10px; }
  .row                         { --bs-gutter-x: 12px; }

  /* ── 固定 sticky-top は Widget内ではマッチしがちなので解除 ── */
  .sf-widget .sticky-top,
  .card .sticky-top { position: static !important; }

  /* ── sfウィジェット: 余白と高さ調整 ── */
  .sf-widget { border-radius: 8px; }
  .sf-widget-body { padding: 10px 12px !important; }

  /* ── 見出し h1-h3 を控えめに ── */
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }
  h4 { font-size: 0.95rem; }

  /* ── バッジ: 読みやすいサイズを保ちつつ余白を詰める ── */
  .badge { font-size: 0.7rem; padding: 3px 7px; }

  /* ── ページャ: 親指で押しやすく ── */
  .pagination .page-link { min-height: 40px; min-width: 40px; display: flex; align-items: center; justify-content: center; }

  /* ── アラート: 余白を詰める ── */
  .alert { padding: 10px 12px; font-size: 0.85rem; }
}

/* ── 480px以下: さらなる圧縮（iPhone SE 幅対応） ── */
@media (max-width: 480px) {
  .koin-header { padding: 0 8px; }
  .topbar-icon-btn { width: 34px; height: 34px; }
  .page-title { font-size: 1rem; }
  .card-body { padding: 10px !important; }
  #koin-content { padding: 10px 8px 80px 8px; }
  /* ドロップダウン: 画面幅いっぱい */
  .dropdown-menu-end { min-width: 260px !important; max-width: calc(100vw - 16px); }
  /* モーダル: さらに余白詰め */
  .modal-dialog { margin: 4px; max-width: calc(100vw - 8px); }
  /* ボタンのラベルを折り返し許容 */
  .btn { white-space: normal; }
}

/* �����o�^�f���A�����X�g */
.sim-item {
  transition: background .15s;
}
.sim-item:hover {
  background: #f0f4ff;
}
.sim-item:last-child {
  border-bottom: none !important;
}

/* ══════════════════════════════════════════════
   改善提案書 (Kaizen Sheet) — 印刷対応フォーマット
   ============================================== */
.kaizen-sheet {
  max-width: 900px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #ccc;
  padding: 24px 28px;
  font-size: .88rem;
  line-height: 1.6;
}

.kaizen-header {
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.kaizen-company {
  font-size: .75rem;
  color: #555;
}
.kaizen-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
}
.kaizen-doc-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: .2em;
}
.kaizen-excellent-badge {
  background: #f9ab00;
  color: #fff;
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
}
.kaizen-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.kaizen-meta-table th,
.kaizen-meta-table td {
  padding: 3px 8px;
  border: 1px solid #ccc;
}
.kaizen-meta-table th {
  background: #f5f5f5;
  font-weight: 600;
  white-space: nowrap;
  width: 80px;
}

.kaizen-theme-box {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.kaizen-theme-text {
  font-size: 1.05rem;
  font-weight: 700;
}

.kaizen-section-label {
  font-weight: 700;
  font-size: .78rem;
  color: #555;
  letter-spacing: .05em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* 改善前後 2カラム */
.kaizen-comparison {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.kaizen-before,
.kaizen-after {
  flex: 1;
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
}
.kaizen-col-header {
  padding: 6px 10px;
  font-weight: 700;
  font-size: .82rem;
}
.before-header {
  background: #ffebee;
  color: #c62828;
  border-bottom: 1px solid #ffcdd2;
}
.after-header {
  background: #e8f5e9;
  color: #2e7d32;
  border-bottom: 1px solid #c8e6c9;
}
.kaizen-col-body {
  padding: 10px;
}
.kaizen-text-block {
  white-space: pre-wrap;
  min-height: 80px;
  font-size: .85rem;
}
.kaizen-arrow {
  display: flex;
  align-items: center;
  font-size: 1.8rem;
  color: #fa7b17;
  padding: 0 4px;
}
.kaizen-photo-block {
  margin-top: 10px;
  text-align: center;
}
.kaizen-photo {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}
.kaizen-photo-label {
  font-size: .72rem;
  color: #777;
  margin-top: 3px;
}
.kaizen-photo-placeholder {
  margin-top: 10px;
  padding: 20px;
  text-align: center;
  background: #fafafa;
  border: 1px dashed #ddd;
  border-radius: 4px;
}

.kaizen-section {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.kaizen-review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .83rem;
  margin-top: 4px;
}
.kaizen-review-table th,
.kaizen-review-table td {
  padding: 4px 8px;
  border: 1px solid #ddd;
}
.kaizen-review-table th {
  background: #f5f5f5;
  font-weight: 600;
  white-space: nowrap;
  width: 100px;
}

/* 承認欄 */
.kaizen-approval {
  display: flex;
  gap: 4px;
  margin: 12px 0 8px;
  border: 1px solid #ccc;
}
.approval-box {
  flex: 1;
  text-align: center;
  border-right: 1px solid #ccc;
}
.approval-box:last-child { border-right: none; }
.approval-label {
  background: #f5f5f5;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 0;
  border-bottom: 1px solid #ccc;
}
.approval-sign {
  min-height: 40px;
  padding: 6px 4px;
  font-size: .82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kaizen-footer {
  font-size: .72rem;
  color: #999;
  text-align: right;
  margin-top: 4px;
}

/* status badges in kaizen sheet */
.status-badge {
  padding: 1px 8px;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
}
.status-提案中      { background: #e0e0e0; color: #333; }
.status-採用審査中   { background: #b3e5fc; color: #01579b; }
.status-実施中      { background: #c8e6c9; color: #1b5e20; }
.status-完了        { background: #a5d6a7; color: #1b5e20; }
.status-却下        { background: #ffcdd2; color: #b71c1c; }

/* ── 印刷スタイル ── */
@media print {
  .no-print, .sidebar, nav, .btn, button,
  .modal, header { display: none !important; }
  body { font-size: 10pt; }
  .kaizen-sheet {
    border: none;
    padding: 0;
    max-width: 100%;
    box-shadow: none;
  }
  .kaizen-photo { max-height: 160px; }
  .kaizen-doc-title { font-size: 18pt; }
}

/* ── ナビ サブラベル（統合セクション内グループ名） ── */
.koin-nav-sub-label {
  font-size: .65rem;
  font-weight: 600;
  color: #9aa0a6;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 8px 16px 2px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}
.koin-nav-sub-label:first-child { border-top: none; margin-top: 0; }

/* ═══════════════════════════════════════════
   Salesforce風ゲージチャート
═══════════════════════════════════════════ */
.gauge-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 16px 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.gauge-title {
  font-weight: 600; font-size: .92rem; color: var(--text);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════
   Salesforce風 Path（ステージバー）
═══════════════════════════════════════════ */
.sf-path {
  display: flex; gap: 0; margin: 12px 0 20px; list-style: none; padding: 0;
}
.sf-path-step {
  flex: 1; position: relative;
  background: #eef2f7; color: #5f6368;
  padding: 10px 14px 10px 28px;
  font-size: .82rem; font-weight: 600;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%,
                     calc(100% - 14px) 100%, 0 100%, 14px 50%);
  text-align: center; cursor: pointer;
  transition: background .15s;
}
.sf-path-step:first-child { clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%); padding-left:14px; }
.sf-path-step:last-child  { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%); }
.sf-path-step.done    { background: #34a853; color: #fff; }
.sf-path-step.current {
  background: #1a73e8; color: #fff;
  box-shadow: 0 0 0 2px rgba(26,115,232,0.25);
}
.sf-path-step:hover:not(.current):not(.done) { background: #d8dde5; }
.sf-path-mark-btn {
  margin-left: 8px; padding: 8px 16px; border-radius: 6px;
  background: #1a73e8; color: #fff; border: none; font-weight: 600;
  font-size: .85rem;
  transition: background .15s;
}
.sf-path-mark-btn:hover { background: #1557b0; }

/* ═══════════════════════════════════════════
   フォームセクション（折りたたみ）
═══════════════════════════════════════════ */
.sf-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.sf-section-header {
  background: #f5f7fa;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.sf-section-header::before {
  content: '▼'; font-size: .7rem;
  transition: transform .15s;
}
.sf-section.collapsed .sf-section-header::before {
  transform: rotate(-90deg);
}
.sf-section-body { padding: 14px; }
.sf-section.collapsed .sf-section-body { display: none; }
body.dark-mode .sf-section-header { background:#1e1e1e; border-color:var(--border); }

/* 既存の card-header.bg-light を自動で折りたたみ対応 */
.card-header.bg-light.collapsible {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
}
.card-header.bg-light.collapsible::before {
  content: '▼'; font-size: .7rem; color:#5f6368;
  transition: transform .15s;
}
.card.collapsed > .card-header.bg-light.collapsible::before { transform: rotate(-90deg); }
.card.collapsed > .card-body { display: none; }

/* 必須マーク */
.sf-required::before {
  content: '*'; color: #e53935; margin-right: 2px; font-weight: bold;
}

/* ═══════════════════════════════════════════
   Intelligence View タブ
═══════════════════════════════════════════ */
.sf-intel-tabs {
  display: flex; gap: 24px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.sf-intel-tab {
  display: flex; flex-direction: column; align-items: flex-start;
  cursor: pointer; padding: 4px 0;
  border-bottom: 3px solid transparent;
  min-width: 80px;
}
.sf-intel-tab.active { border-bottom-color: #1a73e8; }
.sf-intel-tab-label { font-size: .72rem; color: var(--text-sub); }
.sf-intel-tab-count { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.sf-intel-tab.warn .sf-intel-tab-count { color: #e53935; }
.sf-intel-tab.ok   .sf-intel-tab-count { color: #1e8e3e; }

/* ═══════════════════════════════════════════
   関連サイドバー
═══════════════════════════════════════════ */
.sf-related-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.sf-related-header {
  padding: 10px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sf-related-body { padding: 10px 14px; font-size: .85rem; display:flex; flex-direction:column; gap:4px; }
.sf-related-item {
  display:block; padding:6px 8px; border-radius:4px;
  color:var(--text); text-decoration:none;
}
.sf-related-item:hover { background:#f1f3f4; color:#1a73e8; }
body.dark-mode .sf-related-item:hover { background:#2a2a2a; }

/* インラインエディット ホバー時に鉛筆表示 */
.sf-editable { border-bottom: 1px dashed transparent; padding: 0 2px; }
.sf-editable:hover { border-bottom-color: #1a73e8; background: rgba(26,115,232,.05); }
.sf-editable:hover::after { content:' ✏'; font-size:.75em; color:#1a73e8; }

/* ═══════════════════════════════════════════
   Chatter コメントフィード
═══════════════════════════════════════════ */
.sf-chatter { max-height: 480px; overflow-y: auto; padding: 8px; }
.sf-chatter-entry {
  display: flex; gap: 10px; padding: 10px;
  border-bottom: 1px solid var(--border);
}
.sf-chatter-entry:last-child { border-bottom: none; }
.sf-chatter-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #e8f0fe; color: #1a73e8;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.sf-chatter-content { flex: 1; }
.sf-chatter-meta {
  font-size: .76rem; color: var(--text-sub); margin-bottom: 3px;
}
.sf-chatter-body { font-size: .88rem; white-space: pre-wrap; }

/* ═══════════════════════════════════════════
   インラインエディット
═══════════════════════════════════════════ */
.sf-editable {
  padding: 4px 6px; border-radius: 4px; cursor: pointer;
  transition: background .15s;
}
.sf-editable:hover { background: var(--primary-light); }
.sf-editable .sf-edit-icon {
  opacity: 0; margin-left: 6px; font-size: .75rem; color: var(--primary);
  transition: opacity .15s;
}
.sf-editable:hover .sf-edit-icon { opacity: 1; }
.sf-editable input, .sf-editable select, .sf-editable textarea {
  width: 100%; border: 1px solid var(--primary);
  padding: 4px 6px; border-radius: 4px;
  font: inherit;
}

/* ═══════════════════════════════════════════
   🌙 ダークモード（body に class="dark-mode"）
═══════════════════════════════════════════ */
body.dark-mode {
  --primary:        #4d9fff;
  --primary-dark:   #1a73e8;
  --primary-light:  #1e3a5f;
  --surface:        #1e1e1e;
  --bg:             #121212;
  --text:           #e8eaed;
  --text-sub:       #9aa0a6;
  --border:         #3c4043;
  --success:        #34a853;
  --success-light:  #1e3a2a;
  --warning:        #fbbc04;
  --warning-light:  #3d3114;
  --error:          #ef5350;
  --error-light:    #3d1f1f;
}
body.dark-mode { background:var(--bg); color:var(--text); }
body.dark-mode .card,
body.dark-mode .modal-content,
body.dark-mode .dropdown-menu { background:var(--surface); color:var(--text); }
body.dark-mode .table { color:var(--text); }
body.dark-mode .table-light,
body.dark-mode .table-light > th,
body.dark-mode .table-light > td { background:#2a2a2a; color:var(--text); }
body.dark-mode .bg-light { background:#2a2a2a !important; color:var(--text); }
body.dark-mode .form-control,
body.dark-mode .form-select {
  background:#2a2a2a; color:var(--text); border-color:var(--border);
}
body.dark-mode .form-control::placeholder { color:#777; }
body.dark-mode .border,
body.dark-mode .border-bottom,
body.dark-mode .border-top { border-color:var(--border) !important; }
body.dark-mode a { color:var(--primary); }
body.dark-mode .text-muted { color:#9aa0a6 !important; }
body.dark-mode #sidebar { background:#171717; border-right:1px solid var(--border); }
body.dark-mode .table-warning { background:#3d3114 !important; }
body.dark-mode .table-danger  { background:#3d1f1f !important; }
body.dark-mode .table-success { background:#1e3a2a !important; }
body.dark-mode .badge.bg-light { color:#000; }

/* ═══════════════════════════════════════════
   通知バッジ（ナビ上）
═══════════════════════════════════════════ */
.koin-nav-badge {
  display: inline-block;
  background: var(--error);
  color: #fff;
  font-size: .66rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
  min-width: 18px;
  text-align: center;
}

/* ═══════════════════════════════════════════
   ローディングスピナー（グローバル）
═══════════════════════════════════════════ */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,0.65);
  display: none; align-items: center; justify-content: center;
  z-index: 9999;
}
.loading-overlay.show { display: flex; }
body.dark-mode .loading-overlay { background: rgba(0,0,0,0.55); }
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   商談フェーズバー
═══════════════════════════════════════════ */
.phase-bar {
  display: flex; gap: 4px; margin: 8px 0;
}
.phase-step {
  flex: 1; padding: 8px 6px; font-size: .72rem;
  text-align: center; font-weight: 600;
  background: #eef2f7; color: #9aa0a6;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
}
.phase-step:first-child {
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%);
}
.phase-step:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%);
}
.phase-step.done { background: var(--success); color: #fff; }
.phase-step.current {
  background: var(--primary); color: #fff;
  animation: pulse-current 2s infinite;
}
@keyframes pulse-current {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26,115,232,0.6); }
  50%      { box-shadow: 0 0 0 6px rgba(26,115,232,0); }
}

/* ═══════════════════════════════════════════
   検索結果ハイライト
═══════════════════════════════════════════ */
mark.search-hit {
  background: #fff3cd; color: #000;
  padding: 0 2px; border-radius: 2px;
}
body.dark-mode mark.search-hit { background:#665c1e; color:#fff; }

/* ═══════════════════════════════════════════
   モバイル: フローティング保存ボタン
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .mobile-fab {
    position: fixed; bottom: 18px; right: 18px;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-size: 1.4rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    border: none; z-index: 1040;
    text-decoration: none;
  }
  .mobile-fab:hover { background: var(--primary-dark); color:#fff; }
  /* 現場用大ボタン */
  .btn-field {
    min-height: 56px; font-size: 1rem; padding: 12px 20px;
  }
  .form-control, .form-select {
    min-height: 44px; font-size: 16px;
  }
  /* モバイルでテーブルが画面外にはみ出すのを防止 */
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { font-size: .82rem; }
  /* ボタングループの折返し */
  .btn-group, .btn-group-sm { flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════
   モバイル画面分類（PC専用画面で警告表示）
═══════════════════════════════════════════ */
.pc-only-warning { display: none; }
@media (max-width: 768px) {
  body.pc-only-screen .pc-only-warning {
    display: block !important;
    position: sticky; top: 0; z-index: 1050;
    background: #fff3cd; color: #664d03;
    padding: 10px 14px; border-bottom: 1px solid #ffe69c;
    font-size: .85rem; line-height: 1.4;
  }
  body.pc-only-screen .pc-only-warning::before {
    content: '⚠️ '; font-size: 1.1em;
  }
  /* PC専用画面のメインを少し縮小して警告を目立たせる */
  body.pc-only-screen #main-content {
    padding-top: 0;
  }
}

/* iPad中間サイズ最適化 */
@media (min-width: 769px) and (max-width: 1024px) {
  .topbar-search { max-width: 280px; }
  .table-crm { font-size: .82rem; }
}
