/* カスタムスタイル */

/* 帳票フィールド用フォント（プレビューとPDF出力で同一フォントを使い折り返しを一致させる）
   IPAex明朝(TrueType)を使用: pdf-libのサブセット化が確実でグリフ欠落が起きないため */
@font-face {
  font-family: 'ReportJpFont';
  src: url('/fonts/ipaexm.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
/* ゴシック体（フィールドでゴシックを選んだ時用・プレビューとPDFで一致） */
@font-face {
  font-family: 'ReportJpFontGothic';
  src: url('/fonts/ipaexg.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* tailwind.css ビルド漏れ対策（2026-04-23）: grid-cols-8 が欠落していたためここで補完 */
.grid-cols-8 { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.col-span-8 { grid-column: span 8 / span 8; }

/* ============================================================
   デザイントークン（G1: CSS変数化の足場）
   ※ 後続フェーズで既存の色値を段階的にこれらに置換する予定。
      現時点では定義のみ。既存コードの変更はしない。
   ============================================================ */
:root {
  --brand: #16a34a;
  --brand-2: #84cc16;
  --brand-dark: #14532d;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --info: #2563eb;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border: #e5e7eb;
  --text: #1e293b;
  --text-muted: #64748b;
}

* {
  box-sizing: border-box;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ============================================================
   Myメモ（個人ToDo）フローティングパネル
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Kosugi+Maru&display=swap');

#myMemoRoot {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  font-family: 'Kosugi Maru', sans-serif;
}
.mymemo-closed-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 9999px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.15s;
  color: #78350f;
  font-family: 'Kosugi Maru', sans-serif;
  font-size: 12px;
  font-weight: 700;
}
.mymemo-closed-btn:hover {
  background: #fde68a;
  box-shadow: 0 5px 12px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}
.mymemo-closed-btn .mymemo-icon { font-size: 14px; line-height: 1; }
.mymemo-closed-btn .mymemo-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #d97706; color: #fff;
  border-radius: 9999px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

.mymemo-panel {
  width: 340px;
  background: #fffbeb;
  border: 1px solid #b45309;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25), 0 8px 20px rgba(0,0,0,0.15);
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
  max-height: calc(100vh - 40px);
}
.mymemo-resize-handle {
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
  cursor: ns-resize;
  background: transparent;
  z-index: 5;
}
.mymemo-resize-handle:hover { background: rgba(180,83,9,0.15); }
.mymemo-resize-handle::before {
  content: '';
  position: absolute; top: 2px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 2px; background: rgba(180,83,9,0.3); border-radius: 2px;
}
.mymemo-resize-handle:hover::before { background: #b45309; }
@keyframes mymemoSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.mymemo-header {
  padding: 10px 14px;
  background: #f59e0b;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.mymemo-header:active { cursor: grabbing; }
.mymemo-title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 14px; letter-spacing: 0.05em;
}
.mymemo-back {
  background: transparent; border: none; color: #fff; cursor: pointer;
  font-size: 16px; padding: 0 4px;
}
.mymemo-close {
  background: transparent; border: none; color: rgba(255,255,255,0.8); cursor: pointer;
  font-size: 18px; line-height: 1;
}
.mymemo-close:hover { color: #fff; }

.mymemo-tabs {
  display: flex; background: #fef3c7;
  border-bottom: 1px solid #fcd34d;
  flex-shrink: 0;
}
.mymemo-tab {
  flex: 1; padding: 8px 4px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: #a16207;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.mymemo-tab:hover { background: rgba(255,255,255,0.4); }
.mymemo-tab.active {
  color: #78350f; font-weight: 700;
  border-bottom-color: #b45309;
  background: #fffbeb;
}

.mymemo-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 8px;
  background-image:
    linear-gradient(rgba(146,64,14,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(146,64,14,0.05) 1px, transparent 1px);
  background-size: 16px 16px;
}
.mymemo-empty {
  text-align: center; padding: 32px 12px;
  color: #a16207; font-size: 13px;
}

.mymemo-item {
  background: #fff;
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
  border-radius: 4px;
  padding: 7px 8px;
  margin-bottom: 6px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.15s;
}
.mymemo-item:last-child { margin-bottom: 0; }
.mymemo-item:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.mymemo-item-done {
  background: #f3f4f6;
  border-color: #d1d5db;
  border-left-color: #9ca3af;
  color: #6b7280;
}
.mymemo-item-done .mymemo-item-content-main,
.mymemo-item-done .mymemo-due,
.mymemo-item-done .mymemo-customer-link {
  color: #6b7280 !important;
}
.mymemo-item-done .mymemo-due { background: #e5e7eb; }

.mymemo-item-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 3px;
}
.mymemo-item-head-left { flex: 1; min-width: 0; }
.mymemo-item-body-row {
  display: flex; align-items: flex-start; gap: 6px;
}
.mymemo-item-content-main {
  flex: 1; min-width: 0;
  font-weight: 500; color: #78350f; font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
}
.mymemo-item-actions-inline {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.mymemo-done-btn {
  padding: 2px 9px;
  background: transparent; color: #b45309;
  border: 1.5px solid #b45309; border-radius: 3px;
  font-family: inherit; font-size: 11px; font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.3;
}
.mymemo-done-btn:hover { background: #b45309; color: #fffbeb; }
.mymemo-done-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: #10b981; color: #fff;
  border-radius: 3px;
  font-size: 12px; font-weight: 700;
}
.mymemo-customer-chip {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px;
  background: #fef3c7; color: #92400e;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
}
.mymemo-customer-chip:hover { background: #b45309; color: #fff; }
.mymemo-customer-link {
  font-size: 12px; font-weight: 600;
  color: #2563eb;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.15s;
}
.mymemo-customer-link:hover { color: #1d4ed8; }
.mymemo-due {
  font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 3px;
  white-space: nowrap;
  color: #78350f; background: #fef3c7;
  flex-shrink: 0;
}

.mymemo-menu-wrap { position: relative; }
.mymemo-menu-btn {
  background: transparent; border: none; cursor: pointer;
  font-size: 16px; color: #a16207; line-height: 1;
  padding: 2px 6px; border-radius: 3px;
  font-family: inherit; letter-spacing: 0.05em;
  height: 22px;
}
.mymemo-menu-btn:hover { background: #fef3c7; color: #78350f; }
.mymemo-menu-popover {
  position: fixed;
  background: #fff;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  min-width: 140px;
  z-index: 9100;
  overflow: hidden;
}
.mymemo-menu-item {
  display: block; width: 100%;
  padding: 8px 12px;
  background: transparent; border: none; cursor: pointer;
  font-family: inherit; font-size: 12px; color: #78350f;
  text-align: left;
  white-space: nowrap;
}
.mymemo-menu-item:hover { background: #fef3c7; }
.mymemo-menu-danger { color: #b91c1c; }
.mymemo-menu-danger:hover { background: #fee2e2; }

.mymemo-footer {
  padding: 10px;
  background: #f59e0b;
  flex-shrink: 0;
}
.mymemo-add-btn {
  width: 100%; padding: 9px;
  background: #b45309;
  color: #fffbeb;
  border: none; border-radius: 4px;
  cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 13px;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}
.mymemo-add-btn:hover { background: #92400e; }

.mymemo-form {
  padding: 12px;
  background-image:
    linear-gradient(rgba(146,64,14,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(146,64,14,0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  max-height: 440px; overflow-y: auto;
}
.mymemo-form-row {
  background: rgba(255,255,255,0.9);
  border: 1px solid #fcd34d;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}
.mymemo-form-row label {
  display: block;
  font-size: 11px; font-weight: 700; color: #92400e;
  margin-bottom: 4px;
}
.mymemo-form-row input,
.mymemo-form-row textarea {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #fcd34d;
  border-radius: 3px;
  font-family: inherit; font-size: 13px;
  background: #fff;
  color: #78350f;
}
.mymemo-form-row input:focus,
.mymemo-form-row textarea:focus {
  outline: none; border-color: #b45309;
  box-shadow: 0 0 0 2px rgba(180,83,9,0.15);
}
.mymemo-form-row textarea { resize: vertical; min-height: 60px; }
.mymemo-hint { font-size: 10px; color: #a16207; margin-top: 3px; }
.mymemo-required { color: #dc2626; }
.mymemo-form-row-inline {
  display: flex; gap: 8px;
  margin-bottom: 8px;
}
.mymemo-form-row-inline .mymemo-form-row {
  flex: 1; margin-bottom: 0;
}
.mymemo-half { flex: 1; }

.mymemo-suggest {
  margin-top: 4px;
  max-height: 140px; overflow-y: auto;
}
.mymemo-suggest-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 5px 8px;
  background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 3px; margin-bottom: 3px;
  cursor: pointer; text-align: left;
  font-family: inherit; font-size: 12px; color: #78350f;
}
.mymemo-suggest-item:hover { background: #fef3c7; border-color: #b45309; }
.mymemo-suggest-name { font-weight: 700; }
.mymemo-suggest-num { font-size: 10px; color: #a16207; }
.mymemo-suggest-empty {
  padding: 5px 8px; font-size: 11px; color: #a16207;
}

.mymemo-selected-customer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px;
  background: #fef3c7; border: 1px solid #b45309;
  border-radius: 3px;
  font-size: 13px; font-weight: 700; color: #78350f;
}
.mymemo-customer-clear {
  background: transparent; border: none; cursor: pointer;
  font-size: 14px; color: #a16207; padding: 0 4px;
}
.mymemo-customer-clear:hover { color: #78350f; }

.mymemo-submit-btn {
  width: 100%; padding: 10px;
  background: #b45309; color: #fffbeb;
  border: none; border-radius: 4px;
  cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 14px;
  letter-spacing: 0.05em;
  transition: background 0.15s;
  margin-top: 4px;
}
.mymemo-submit-btn:hover { background: #78350f; }

/* モバイル: 画面幅を控えめに */
@media (max-width: 640px) {
  .mymemo-panel { width: calc(100vw - 40px); max-width: 340px; }
}

/* タイピングインジケーター */
.typing-dots span {
  animation: typingDot 1.4s infinite;
  font-size: 18px;
  line-height: 1;
  font-weight: bold;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* トースト通知スライドイン */
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.animate-slide-in { animation: slideInRight 0.3s ease-out; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* サイドバー左側にカラフルな背景（ガラス越しに透けるように） */
  background:
    radial-gradient(ellipse 400px 500px at 30px 20%, rgba(34, 197, 94, 0.55) 0%, transparent 70%),
    radial-gradient(ellipse 350px 400px at 50px 60%, rgba(163, 230, 53, 0.50) 0%, transparent 70%),
    radial-gradient(ellipse 320px 350px at 20px 95%, rgba(5, 150, 105, 0.45) 0%, transparent 70%),
    #f9fafb;
  background-attachment: fixed;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* 印刷用 */
@media print {
  body * {
    visibility: hidden;
  }
  .print-area, .print-area * {
    visibility: visible;
  }
  .print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 20mm;
    box-shadow: none;
    border: none;
  }
}

/* テーブル行ホバー */
tbody tr {
  transition: background-color 0.15s;
}

/* 入力フォーカス */
input:focus, select:focus, textarea:focus {
  outline: none;
}

/* アニメーション */
.transition-transform {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* サイドバーリサイズハンドル */
.sidebar-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  transition: background 0.2s;
  flex-shrink: 0;
  border-radius: 3px;
  margin: 0 -1px;
  position: relative;
  z-index: 10;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
  background: #6366f1;
}
.sidebar-resize-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 40px;
  background: #d1d5db;
  border-radius: 1px;
  transition: background 0.2s;
}
.sidebar-resize-handle:hover::after,
.sidebar-resize-handle.active::after {
  background: #6366f1;
  height: 60px;
}

/* 会話記録ボーダー色 v2 */
.border-l-green-400 { border-left-color: #4ade80; }
.border-l-red-300 { border-left-color: #fca5a5; }
.border-l-gray-300 { border-left-color: #d1d5db; }

/* 会話カテゴリボタン選択状態 */
.conv-cat-btn.opacity-50 { opacity: 0.4; }
.conv-cat-btn:not(.opacity-50) { opacity: 1; }

/* サイドバー自動非表示（ホバー展開） */
#sidebarHoverZone {
  position: fixed;
  left: 0;
  top: 0;
  width: 18px;
  height: 100%;
  z-index: 49;
  cursor: pointer;
}
#sidebarHoverZone::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 40px;
  border-radius: 2px;
  background: #d1d5db;
  opacity: 0;
  transition: opacity 0.2s;
}
#sidebarHoverZone:hover::after {
  opacity: 1;
}
/* モバイル用サイドバー: 旧スタイル廃止（新しい .glass-sidebar で制御） */
/* ======================= グラスサイドバー ======================= */
.glass-sidebar {
  position: fixed; left: 8px; top: 8px; bottom: 8px;
  width: 220px;
  padding: 12px 0;
  /* 本物のガラス：極薄の白 + ほとんど色なし（背景の色を透かす） */
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  box-shadow:
    /* ドロップシャドウ（浮遊感） */
    0 20px 50px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.06),
    /* 上辺：強い光の反射 */
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    /* 下辺：暗い反射（曲面表現） */
    inset 0 -1px 0 rgba(0, 0, 0, 0.08),
    /* 左辺：光の入射 */
    inset 1px 0 0 rgba(255, 255, 255, 0.6),
    /* 右辺：暗い反射 */
    inset -1px 0 0 rgba(0, 0, 0, 0.05);
  overflow-x: hidden; overflow-y: auto;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: #0f172a;
  z-index: 50;
  display: flex; flex-direction: column;
}
/* 上部ハイライト：ガラスの光沢な反射 */
.glass-sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 45%;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.55) 0%,
    rgba(255,255,255,0.12) 60%,
    transparent 100%);
  pointer-events: none;
  border-radius: 20px 20px 50% 50%;
  z-index: 0;
}
/* 光の帯（ハイライト） */
.glass-sidebar::after {
  content: '';
  position: absolute; top: 8%; bottom: 8%; left: 6px; width: 3px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.6) 30%, rgba(255,255,255,0.6) 70%, transparent);
  pointer-events: none;
  border-radius: 2px;
  filter: blur(1px);
  z-index: 0;
}
.glass-sidebar > * { position: relative; z-index: 1; }
/* .glass-sidebar.collapsed の幅は JS で制御（インラインstyle） */

/* アイコンカラム 固定52px */
.glass-sidebar .col-icon {
  width: 52px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ロゴ */
.glass-sidebar .sb-logo {
  display: flex; align-items: center; height: 58px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(22, 163, 74, 0.15);
  white-space: nowrap;
}
.glass-sidebar .sb-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.7));
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.15), inset 0 1px 0 rgba(255,255,255,0.9);
}
.glass-sidebar .sb-logo-icon img,
.glass-sidebar .sb-logo-icon svg { width: 26px; height: 26px; object-fit: contain; }
.glass-sidebar .sb-logo-text {
  padding-right: 16px;
  display: flex; flex-direction: column; justify-content: center;
  height: 100%; line-height: 1.25;
}
.glass-sidebar .sb-logo-text .name { font-weight: 500; font-size: 11px; white-space: nowrap; opacity: 0.7; color: #14532d; }
.glass-sidebar .sb-logo-text .org { font-size: 11px; white-space: nowrap; font-weight: 700; margin-top: 1px; color: #14532d; }

/* ナビ領域 */
.glass-sidebar .sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; }
.glass-sidebar .sb-footer { border-top: 1px solid rgba(22, 163, 74, 0.15); padding-top: 4px; }

/* アイテム */
.glass-sidebar .sb-item {
  display: flex; align-items: center;
  height: 42px; cursor: pointer; white-space: nowrap;
  color: #1e293b; text-decoration: none;
  transition: background 0.15s; position: relative;
}
.glass-sidebar .sb-item:hover { background: rgba(255,255,255,0.25); backdrop-filter: blur(10px); }
.glass-sidebar .sb-item.active {
  background: linear-gradient(135deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.3) 100%);
  color: #14532d; font-weight: 600;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -1px 0 rgba(22,163,74,0.1),
    0 2px 8px rgba(22,163,74,0.08);
}
.glass-sidebar .sb-item.active::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; background: linear-gradient(180deg, #16a34a, #84cc16); border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(132, 204, 22, 0.6);
}
.glass-sidebar .sb-item-mini { height: 34px; }
.glass-sidebar .sb-item-mini .sb-label { font-size: 11px; opacity: 0.7; }

.glass-sidebar .sb-icon { width: 20px; height: 20px; stroke: currentColor; }

/* カテゴリ別アイコン色分け（視認性重視のカラフル配色） */
/* デフォルト（メイン：ダッシュボード）: インディゴ */
.glass-sidebar .sb-item .sb-icon { color: #4f46e5; }

/* 受付（新規・面談）: ティール */
.glass-sidebar .sb-divider:nth-of-type(1) ~ .sb-item .sb-icon { color: #0d9488; }
/* 案件管理（顧客・債権）: ブルー */
.glass-sidebar .sb-divider:nth-of-type(2) ~ .sb-item .sb-icon { color: #2563eb; }
/* 管理（債権者マスタ・口座管理）: アンバー */
.glass-sidebar .sb-divider:nth-of-type(3) ~ .sb-item .sb-icon { color: #d97706; }
/* 経理・入金: ローズ */
.glass-sidebar .sb-divider:nth-of-type(4) ~ .sb-item .sb-icon { color: #e11d48; }
/* 分析（集計・広告管理）: パープル */
.glass-sidebar .sb-divider:nth-of-type(5) ~ .sb-item .sb-icon { color: #8b5cf6; }

/* アクティブ時は深緑 */
.glass-sidebar .sb-item.active .sb-icon { color: #14532d !important; }
.glass-sidebar .sb-label {
  font-size: 13px; padding-right: 16px;
  transition: opacity 0.2s;
}

/* 区切り線（分類） */
.glass-sidebar .sb-divider {
  display: flex; align-items: center; height: 22px; margin-top: 4px;
  position: relative; white-space: nowrap;
}
.glass-sidebar .sb-divider-label {
  padding-left: 16px; padding-right: 8px;
  color: #166534; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em;
  transition: opacity 0.2s;
  background: inherit; position: relative; z-index: 2;
  opacity: 0.8;
}
.glass-sidebar .sb-divider::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 4px;
  height: 1px; background: linear-gradient(90deg, transparent, rgba(22, 163, 74, 0.25), transparent);
}
.glass-sidebar.collapsed .sb-divider::after { left: 10px; right: 10px; }

/* 折りたたみ時：ラベル系フェードアウト */
.glass-sidebar.collapsed .sb-label,
.glass-sidebar.collapsed .sb-logo-text,
.glass-sidebar.collapsed .sb-divider-label { opacity: 0; pointer-events: none; }

/* ツールチップ（折りたたみ時のみ） */
.glass-sidebar .sb-tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #0f172a; color: #fff; padding: 5px 10px; border-radius: 6px;
  font-size: 11px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
  z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.glass-sidebar.collapsed .sb-item:hover .sb-tip { opacity: 1; }
.glass-sidebar:not(.collapsed) .sb-tip { display: none; }

/* ===== Sandbox サイドバーエントリ ===== */
.sb-item.sb-item-sandbox {
  background: transparent !important;
  border: 1px solid rgba(0,0,0,0.08) !important;
  color: #111827 !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  margin: 4px 0 !important;
}
.sb-item.sb-item-sandbox:hover {
  background: rgba(0,0,0,0.05) !important;
  color: #000000 !important;
}
.sb-item.sb-item-sandbox .sb-icon,
.sb-item.sb-item-sandbox .col-icon,
.sb-item.sb-item-sandbox span {
  color: #111827 !important;
}

/* ===== Sandbox中はサイドバー全体の色を変える（オレンジ枠で警告） ===== */
body.sandbox-active .glass-sidebar {
  background: linear-gradient(180deg, #312e81, #4338ca) !important;
  border: 2px solid #f59e0b !important;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.25), 0 20px 40px rgba(67,56,202,0.4) !important;
}
body.sandbox-active .sb-item.sb-item-sandbox {
  background: rgba(245,158,11,0.95) !important;
  border-color: #b45309 !important;
  color: #1f2937 !important;
}
body.sandbox-active .sb-item.sb-item-sandbox .sb-icon,
body.sandbox-active .sb-item.sb-item-sandbox .col-icon,
body.sandbox-active .sb-item.sb-item-sandbox span {
  color: #1f2937 !important;
}
body.sandbox-active .sb-item.sb-item-sandbox:hover {
  background: rgba(217,119,6,0.95) !important;
}

/* トグルボタン */
.sb-toggle {
  position: fixed; top: 22px; left: 60px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 1px solid rgba(0,0,0,0.1);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; color: #475569;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s;
  z-index: 51;
}
.sb-toggle:hover { color: #4f46e5; }

/* メインエリア（margin-leftはJSで制御） */
.sb-main {
  margin-left: 76px;
  margin-right: 8px;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1024px) {
  .glass-sidebar { display: flex !important; }
}

/* モバイル: サイドバーをオーバーレイ */
@media (max-width: 1023px) {
  .glass-sidebar {
    transform: translateX(-110%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s;
  }
  .glass-sidebar.sidebar-mobile-open { transform: translateX(0); }
  .sb-toggle { display: none; }
  .sb-main { margin-left: 8px; }
}

/* モバイルタッチ改善 */
@media (max-width: 640px) {
  button, a, select {
    min-height: 36px;
  }
  input, select, textarea {
    font-size: 16px !important; /* iOS ズーム防止 */
  }
}

/* モバイルでサイドバーをオーバーレイ */
@media (max-width: 1024px) {
  #conversationSidebar {
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    height: 100vh !important;
    width: 100% !important;
    max-width: 420px !important;
    z-index: 60 !important;
    margin-left: 0 !important;
    border-radius: 0 !important;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15) !important;
  }
  #sidebarResizeHandle {
    display: none !important;
  }
}

/* 顧客向けページ */
.customer-app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #f8fafc;
}
@media (min-width: 768px) {
  .customer-app {
    max-width: 640px;
  }
}

/* カラム設定: ドラッグ&ドロップ */
.col-drag-item {
  cursor: grab;
  user-select: none;
  transition: background 0.15s, box-shadow 0.15s;
}
.col-drag-item:active {
  cursor: grabbing;
}
.col-drag-item.dragging {
  opacity: 0.4;
}
.col-drag-item.drag-over {
  box-shadow: 0 -2px 0 0 #6366f1;
}
.col-drag-preview {
  display: flex;
  gap: 0;
  overflow-x: auto;
  padding: 2px 0;
}
.col-drag-preview .col-header-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #4338ca;
  cursor: grab;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
  transition: transform 0.2s ease, background 0.15s, box-shadow 0.15s;
}
.col-drag-preview .col-header-chip:active {
  cursor: grabbing;
}
.col-drag-preview .col-header-chip.dragging {
  opacity: 0.4;
}
/* 債権者進捗テーブル: 和解成立以降の行を水色でハイライト（cd-prog-settled） */
.cd-prog-settled td {
  background: #ccffff !important; /* Excel水色（ライトターコイズ）に合わせる */
}
.cd-prog-settled:hover td {
  background: #a8f0f0 !important; /* hover は少し濃い水色 */
}
/* インライン編集行 */
.inline-edit-row td {
  background: #fefce8 !important;
}
.inline-edit-row input,
.inline-edit-row select,
.inline-edit-row textarea {
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  width: 100%;
  min-width: 60px;
}

/* ソートヘッダー */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover {
  background: #e5e7eb;
}
th .sort-icon {
  display: inline-block;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  margin-left: 4px;
  opacity: 0.3;
  transition: opacity 0.15s, color 0.15s;
  vertical-align: middle;
}
th .sort-icon.asc,
th .sort-icon.desc {
  opacity: 1;
  font-weight: 700;
  color: #10b981;
}
.table-red th .sort-icon.asc,
.table-red th .sort-icon.desc {
  color: #ef4444;
}

/* 会話記録背景色 */
.bg-green-50\/60 { background-color: rgba(240, 253, 244, 0.6); }
.bg-red-50\/60 { background-color: rgba(254, 242, 242, 0.6); }
.bg-gray-50\/60 { background-color: rgba(249, 250, 251, 0.6); }

/* ミニサイドバー */
#miniSidebar {
  transition: opacity 0.3s;
}
#miniSidebar .mini-nav {
  position: relative;
}
#miniSidebar .mini-nav::after {
  content: attr(title);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  margin-left: 8px;
  z-index: 100;
}
#miniSidebar .mini-nav:hover::after {
  opacity: 1;
}

/* ドラッグ並替アニメーション */
.col-header-chip {
  transition: transform 0.2s ease, opacity 0.2s, box-shadow 0.15s;
}
.col-header-chip.shift-right {
  transform: translateX(14px);
}
.col-header-chip.shift-left {
  transform: translateX(-14px);
}

/* 復元プレビューモーダル */
.restore-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s;
}
.restore-preview-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 高度検索条件行 */
.adv-condition-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.adv-condition-row select, .adv-condition-row input {
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}
.adv-condition-row select:nth-child(2) {
  min-width: 130px;
}

/* 高度な検索: 検索可能フィールド選択 */
.afs-wrap {
  position: relative;
  width: 150px;
  flex-shrink: 0;
}
.afs-input {
  width: 100%;
  font-size: 12px;
  padding: 5px 8px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}
.afs-input:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,.2);
}
.afs-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 60;
  margin-top: 2px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.14);
  max-height: 260px;
  overflow-y: auto;
}
.afs-dropdown.open { display: block; }
.afs-option {
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.afs-option:hover,
.afs-option.afs-hi { background: #eef2ff; }
.afs-option.afs-selected { color: #4f46e5; font-weight: 600; }
.afs-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: #9ca3af;
}

/* Phone popup */
.phone-popup {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 180px;
}
.phone-popup::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 16px;
  width: 12px;
  height: 12px;
  background: white;
  border-left: 1px solid #e5e7eb;
  border-top: 1px solid #e5e7eb;
  transform: rotate(45deg);
}

/* Drag animation for column chips */
.col-chip {
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.col-chip.shift-right {
  transform: translateX(30px);
}
.col-chip.shift-left {
  transform: translateX(-30px);
}
.col-chip.dragging {
  opacity: 0.4;
}
.col-drag-chip.dragging {
  opacity: 0.4;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
  transform: scale(1.05);
}

/* Conversation record improved styles */
.conv-record {
  border-bottom: 1px solid #f3f4f6;
}
.conv-record:last-child {
  border-bottom: none;
}
.conv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1px;
}
.conv-direction-incoming {
  color: #2563eb;
}
.conv-direction-outgoing {
  color: #d97706;
}
.conv-arrow {
  font-size: 12px;
  font-weight: bold;
  margin: 0 3px;
}

/* Column resize handle */
.resizable-th {
  position: relative;
}
.col-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 5;
}
.col-resize-handle:hover,
.col-resize-handle.active {
  background: #6366f1;
}

/* 債権者吹き出しポップアップ */
.creditor-bubble {
  position: fixed;
  z-index: 200;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 240px;
  max-width: 320px;
  animation: bubbleFadeIn 0.15s ease;
}
.creditor-bubble-arrow {
  position: absolute;
  top: -7px;
  left: 24px;
  width: 14px;
  height: 14px;
  background: white;
  border-left: 1px solid #e5e7eb;
  border-top: 1px solid #e5e7eb;
  transform: rotate(45deg);
}
@keyframes bubbleFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* テキストエリア自動伸長 */
textarea.auto-grow {
  overflow-y: hidden;
  resize: none;
  transition: height 0.1s ease;
}

/* ===== 一覧ページ背景グラデーション ===== */
.list-bg-customer {
  background: linear-gradient(135deg, #bae6fd 0%, #a7f3d0 50%, #d1fae5 100%);
  border-radius: 12px;
}
.list-bg-creditor {
  background: linear-gradient(135deg, #fbbf24 0%, #ef4444 50%, #fecaca 100%);
  min-height: calc(100vh - 64px);
}
.list-bg-credmaster {
  background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 50%, #ede9fe 100%);
  min-height: calc(100vh - 64px);
}
.list-bg-case {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 50%, #eff6ff 100%);
  min-height: calc(100vh - 64px);
}

/* ===== サマリーカード「すべて」リセットピル ===== */
/* サマリーカードで絞り込んだ後に「すべて」で解除できるようにする共通タブ（全一覧統一） */
.card-tab-row { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.card-tab {
  font-size: 12px; font-weight: 600; padding: 4px 16px; border-radius: 9999px;
  border: 1px solid #e5e7eb; background: #fff; color: #6b7280; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s; line-height: 1.4;
}
.card-tab:hover { background: #f9fafb; }
.card-tab.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }

/* ===== サマリーカード ===== */
.summary-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.summary-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 768px) {
  .summary-row-3 { grid-template-columns: 1fr; }
  .summary-row-4 { grid-template-columns: repeat(2, 1fr); }
}
.summary-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: 0.2s;
}
.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.summary-card.card-active {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16,185,129,0.2), 0 4px 16px rgba(0,0,0,0.1);
}
.summary-card.card-active-red {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239,68,68,0.2), 0 4px 16px rgba(0,0,0,0.1);
}
.summary-card-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.summary-card-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; }
.summary-card-sub { font-size: 12px; color: #94a3b8; margin-top: 6px; }

/* ===== テーブル内検索バー ===== */
.search-bar-inside {
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-bottom: 1px solid #f1f5f9;
}
.search-wrap-inside {
  position: relative;
  width: 320px;
}
.search-wrap-inside .search-icon-inside {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
  pointer-events: none;
}
.search-input-inside {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  background: #fafafa;
}
.search-input-inside:focus {
  outline: none;
  border-color: #34d399;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
  background: #fff;
}
.search-input-inside.purple-focus:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
}
.search-input-inside.red-focus:focus {
  border-color: #f87171;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.search-input-inside.blue-focus:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.adv-search-link {
  padding: 0;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: #3b82f6;
  cursor: pointer;
  white-space: nowrap;
}
.adv-search-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

/* ===== 一括操作バー（検索バーに重ねる） ===== */
.search-bar-wrapper {
  position: relative;
}
.bulk-action-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: #1e293b;
  color: #fff;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  border-radius: 12px 12px 0 0;
}
.bulk-action-bar.visible {
  opacity: 1;
  pointer-events: auto;
}
.bulk-count { font-size: 14px; font-weight: 700; white-space: nowrap; }
.bulk-count span { color: #60a5fa; }
.bulk-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.2); }
.bulk-btn {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.bulk-btn:hover { background: rgba(255,255,255,0.1); }
.bulk-btn.bulk-danger { border-color: rgba(239,68,68,0.4); color: #fca5a5; }
.bulk-btn.bulk-danger:hover { background: rgba(239,68,68,0.2); }
.bulk-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bulk-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ===== テーブルホバー色（緑/赤） ===== */
.table-green tbody tr:hover td { background: #d1fae5; }
.table-red tbody tr:hover td { background: #fef2f2; }

/* ===== 経過月数ハイライト ===== */
.elapsed-normal { color: #1e293b; }
.elapsed-warn { color: #d97706; font-weight: 700; background: #fffbeb; padding: 2px 8px; border-radius: 4px; }
.elapsed-danger { color: #dc2626; font-weight: 700; background: #fef2f2; padding: 2px 8px; border-radius: 4px; }

/* ===== 空状態 ===== */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: #94a3b8;
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-text { font-size: 15px; font-weight: 600; margin-bottom: 4px; color: #64748b; }
.empty-state-sub { font-size: 13px; }

/* ===== 入金計画テーブル（詳細） ===== */
.pmt-table-detail { width:100%; border-collapse:collapse; font-size:13px; }
.pmt-table-detail thead th.group-header { background:#92400e; color:#fff; padding:4px 10px; text-align:center; font-weight:700; font-size:11px; letter-spacing:.5px; border-right:2px solid rgba(255,255,255,.3); }
.pmt-table-detail thead th.group-header:first-child { border-radius:10px 0 0 0; }
.pmt-table-detail thead th.group-header:last-child { border-right:none; border-radius:0 10px 0 0; }
.pmt-table-detail thead th.group-header.g1 { background:#92400e; }
.pmt-table-detail thead th.group-header.g2 { background:#065f46; }
.pmt-table-detail thead th.group-header.g3 { background:#1e3a5f; }
.pmt-table-detail thead th { background:linear-gradient(135deg,#d97706,#f59e0b); color:#fff; padding:7px 10px; text-align:center; font-weight:600; font-size:12px; white-space:nowrap; position:relative; }
.pmt-table-detail thead th.g2-col { background:linear-gradient(135deg,#059669,#10b981); }
.pmt-table-detail thead th.g3-col { background:linear-gradient(135deg,#2563eb,#3b82f6); }
.pmt-table-detail thead th.g-border-r { border-right:2px solid rgba(255,255,255,.4); }
.pmt-table-detail td { padding:7px 10px; border-bottom:1px solid #f1f5f9; text-align:right; white-space:nowrap; }
.pmt-table-detail td.col-left { text-align:left; }
.pmt-table-detail td.col-center { text-align:center; }
.pmt-table-detail td.g-border-r { border-right:2px solid #e2e8f0; }
.pmt-table-detail tbody tr:hover { background:#fffbeb !important; }
.pmt-table-detail .row-paid { background:#f0fdf4; }
.pmt-table-detail .row-missed { background:#fef2f2; }
.pmt-table-detail .row-short { background:#fff7ed; }
.pmt-table-detail .row-current { background:#fffbeb; border-left:3px solid #d97706; }
.pmt-table-detail .row-future { color:#94a3b8; }
.pmt-table-detail .row-total td { background:#fef3c7; font-weight:700; border-top:2px solid #d97706; }
.pmt-badge { display:inline-block; font-size:11px; font-weight:600; padding:2px 8px; border-radius:9999px; }
.pmt-badge.paid { background:#a7f3d0; color:#1a1a1a; }
.pmt-badge.missed { background:#fef2f2; color:#991b1b; }
.pmt-badge.short { background:#fff7ed; color:#9a3412; }
.pmt-badge.waiting { background:#fffbeb; color:#92400e; }
.pmt-badge.future { background:#f1f5f9; color:#64748b; }
.pmt-badge.changed { background:#fef3c7; color:#92400e; }
.pmt-badge.office-changed { background:#fce7f3; color:#be185d; }
/* 一括編集モーダル セレクト/入力の統一スタイル */
.bulk-sel { padding:5px 8px; border:1px solid #d6d3d1; border-radius:5px; font-size:12px; background:#fff; color:#44403c; cursor:pointer; }
.bulk-sel:focus { outline:none; border-color:#d97706; box-shadow:0 0 0 2px rgba(217,119,6,.15); }
.pmt-edit-btn { background:none; border:1px solid #e2e8f0; border-radius:5px; padding:2px 6px; cursor:pointer; color:#94a3b8; font-size:11px; transition:.15s; }
.pmt-edit-btn:hover { background:#fffbeb; border-color:#d97706; color:#d97706; }
.pmt-table-detail .col-resize-handle { position:absolute; right:0; top:0; bottom:0; width:4px; cursor:col-resize; background:transparent; z-index:11; }
.pmt-table-detail .col-resize-handle:hover,
.pmt-table-detail .col-resize-handle.active { background:rgba(255,255,255,.4); }
/* サマリーカード */
.pmt-summary-grid { display:flex; flex-wrap:wrap; gap:6px; }
.pmt-summary-chip { display:inline-flex; flex-direction:column; padding:0 16px; border-radius:8px; min-width:190px; width:190px; background:#fff; border:1px solid #f3f4f6; box-shadow:0 1px 4px rgba(0,0,0,.05); position:relative; overflow:hidden; }
.pmt-summary-chip .sc-label { font-size:12px; white-space:nowrap; line-height:1; font-weight:600; text-align:left; padding:5px 10px 4px; margin:0 -16px 0; border-radius:7px 7px 0 0; flex-shrink:0; background:linear-gradient(135deg,#fef3c7,#fde68a); color:#92400e; }
.pmt-summary-chip .sc-label .sub { color:#b45309; }
.pmt-summary-chip .sc-value { font-size:15px; font-weight:700; color:#1e293b; padding:5px 0; white-space:nowrap; line-height:1.2; text-align:right; }
.pmt-summary-chip.alert { background:#fef2f2; border-color:#f87171; }
.pmt-summary-chip.alert .sc-label { background:linear-gradient(135deg,#fecaca,#fca5a5); color:#991b1b; }
.pmt-sum-tab { font-size:11px; font-weight:700; padding:3px 12px; border-radius:20px; border:none; cursor:pointer; letter-spacing:.3px; transition:.15s; }
.pmt-sum-tab.active { background:#fef3c7; color:#92400e; }
.pmt-sum-tab:not(.active) { background:#f1f5f9; color:#94a3b8; }
/* サマリーチップ内バー */
.pmt-summary-chip .sc-bar { display:inline-block; width:80px; height:5px; background:#e2e8f0; border-radius:3px; vertical-align:middle; margin:0 5px; }
.pmt-summary-chip .sc-bar-fill { display:block; height:100%; border-radius:3px; background:#10b981; }

/* ============================================================
   依頼者マイページ プレビュー
   ============================================================ */
.mypage-phone-frame {
  width: 390px;
  max-width: 100%;
  background: #f8fafc;
  border-radius: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  overflow: hidden;
  border: 2px solid #e2e8f0;
}
.mypage-phone-notch {
  height: 24px;
  background: #1e1b4b;
  border-radius: 0 0 12px 12px;
  width: 120px;
  margin: 0 auto;
}
.mypage-phone-body {
  max-height: 85vh;
  overflow-y: auto;
}
.mypage-phone-body::-webkit-scrollbar { width: 4px; }
.mypage-phone-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* パルスドット */
.mypage-pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #22c55e;
  animation: mypage-pulse 2s infinite;
}
@keyframes mypage-pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ランナーキャラ */
.mypage-runner-char {
  position: absolute; top: 10px;
  transform: translate(-50%, -100%);
  animation: mypage-runner-bounce 0.6s ease-in-out infinite;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.15));
  z-index: 3;
}
.mypage-runner-char .runner-emoji {
  font-size: 16px; line-height: 1; display: block; transform: scaleX(-1);
}
.mypage-runner-char .runner-img {
  width: 22px; height: 22px; object-fit: contain; display: block;
}
@keyframes mypage-runner-bounce {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-3px); }
}

/* ステップバー */
.mypage-step-bar {
  display: flex; align-items: flex-start; gap: 0; flex-wrap: nowrap;
}
.mypage-step-dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; flex-shrink: 0; z-index: 1;
}
.mypage-step-dot.done { background: #22c55e; color: #fff; }
.mypage-step-dot.current { background: #4f46e5; color: #fff; box-shadow: 0 0 0 3px rgba(79,70,229,.25); }
.mypage-step-dot.future { background: #e2e8f0; color: #94a3b8; }
.mypage-step-dot.resigned { background: #ef4444; color: #fff; }
.mypage-step-line {
  flex: 1; height: 2px; min-width: 8px;
}

/* ============================================================
   レスポンシブ統一ルール（#10 改善）
   ============================================================ */

/* --- タブレット（1023px以下）--- */
@media (max-width: 1023px) {
  /* メインコンテンツの余白を縮小 */
  .sb-main { margin-left: 0 !important; }
  #pageContent { padding: 12px !important; }

  /* ツールバーボタン行: 折り返し対応 */
  .flex.items-center.justify-end.gap-2.mb-2 {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* 検索バー: 幅を自動調整 */
  .search-wrap-inside {
    width: 100% !important;
    min-width: 0;
  }
  .search-bar-inside {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* サマリーカード: 3列→2列 */
  .summary-row-3 { grid-template-columns: repeat(2, 1fr); }
  .summary-row-4 { grid-template-columns: repeat(2, 1fr); }

  /* 2ペインレイアウト（case-detail等）をスタック */
  .flex.w-full.overflow-hidden[style*="calc(100vh"] {
    flex-direction: column;
    height: auto !important;
  }
  .flex.w-full.overflow-hidden[style*="calc(100vh"] > div {
    height: auto !important;
    min-height: 0;
  }

  /* テーブルの最小幅指定で横スクロール確保 */
  table.w-full { min-width: 600px; }
}

/* --- スマホ（640px以下）--- */
@media (max-width: 640px) {
  /* ページタイトル縮小 */
  #pageTitle { font-size: 14px !important; }

  /* サマリーカード: 1列 */
  .summary-row-3,
  .summary-row-4 { grid-template-columns: 1fr; }
  .summary-card-value { font-size: 22px; }

  /* ツールバーボタン: フル幅 */
  .flex.items-center.justify-end.gap-2.mb-2 {
    justify-content: stretch;
  }
  .flex.items-center.justify-end.gap-2.mb-2 > button,
  .flex.items-center.justify-end.gap-2.mb-2 > a {
    flex: 1;
    justify-content: center;
    text-align: center;
  }

  /* モーダルの幅調整 */
  .modal-overlay > div,
  #appConfirmModal > div {
    width: 95vw !important;
    max-width: 95vw !important;
  }

  /* 高度検索条件: 縦積み */
  .adv-condition-row {
    flex-direction: column !important;
    gap: 6px !important;
  }
  .adv-condition-row select,
  .adv-condition-row input {
    width: 100% !important;
  }
  .adv-condition-row .afs-wrap {
    width: 100% !important;
  }

  /* パンくず: テキスト省略 */
  nav[aria-label="パンくず"] a,
  nav[aria-label="パンくず"] span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
  }

  /* カラム設定パネル: チップ縮小 */
  .col-drag-chip {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  /* テーブルセルのパディング縮小 */
  table td, table th {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }
}

/* --- キーボードショートカットヘルプのスマホ対応 --- */
@media (max-width: 640px) {
  #kbHelpClose {
    width: 100%;
  }
}

/* ============================================================
   フェーズ3 項目12: レスポンシブ抜け対応
   - 横スクロールのスムーズ化（iOS慣性）
   - モーダルが小画面ではみ出ないように幅調整
   ============================================================ */
@media (max-width: 640px) {
  .overflow-x-auto { -webkit-overflow-scrolling: touch; }
  /* 既存の confirmModal / 共通モーダルが 90vw を使っているので補完: 幅と余白のフェイルセーフ */
  #appConfirmModal > div,
  .modal-overlay > div,
  .modal-content {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 0 auto;
  }
  /* テーブルの最小幅を抑えて、セルが潰れないよう scroll で見せる */
  .dm-scrollable-table { min-width: 720px; }
}

/* フェーズ2 G4: 保存済バッジのフェードイン */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-fadeIn { animation: fadeIn 0.2s ease-in; }

/* 相談詳細: 顧客管理作成後の編集ロック */
.case-locked input,
.case-locked select,
.case-locked textarea {
  pointer-events: none !important;
  background-color: #f9fafb !important;
  color: #6b7280 !important;
  border-color: #e5e7eb !important;
  cursor: not-allowed !important;
}
/* チェックボックス・ラジオボタンは pointer-events 効くがデフォルト背景が消えるので別指定 */
.case-locked input[type="checkbox"],
.case-locked input[type="radio"] {
  background-color: transparent !important;
  opacity: 0.6 !important;
}
/* ラベルもクリック不可にする（label を経由したラジオ/チェックの操作を防ぐ） */
.case-locked label {
  pointer-events: none !important;
  cursor: not-allowed !important;
  color: #6b7280 !important;
}
.case-locked input[readonly],
.case-locked select[disabled] {
  background-color: #f9fafb !important;
}
.case-locked button:not(.case-locked-allow) {
  pointer-events: none !important;
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}
.case-locked .ss-input,
.case-locked .ss-dropdown {
  pointer-events: none !important;
  background-color: #f9fafb !important;
  color: #6b7280 !important;
}
/* タブ切替ボタンはロック中でも操作可（ヒアリング/面談/帳票・借入情報/個人情報） */
.case-locked [data-tab-btn],
.case-locked [data-main-tab-btn] {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
  color: revert !important;
}
/* 帳票タブの中身はロック中でも全操作可（プレビュー/出力/添付など） */
.case-locked #mainTab_forms input,
.case-locked #mainTab_forms select,
.case-locked #mainTab_forms textarea {
  pointer-events: auto !important;
  background-color: #fff !important;
  color: #111827 !important;
  border-color: #d1d5db !important;
  cursor: auto !important;
}
.case-locked #mainTab_forms input[type="checkbox"],
.case-locked #mainTab_forms input[type="radio"] {
  opacity: 1 !important;
}
.case-locked #mainTab_forms label {
  pointer-events: auto !important;
  cursor: auto !important;
  color: revert !important;
}
.case-locked #mainTab_forms button {
  pointer-events: auto !important;
  opacity: 1 !important;
  cursor: pointer !important;
}
.case-locked #mainTab_forms .ss-input,
.case-locked #mainTab_forms .ss-dropdown {
  pointer-events: auto !important;
  background-color: #fff !important;
  color: #111827 !important;
}

/* ============================================================
   Phase 2 (2026-05-26): Myメモ風アンバートークン / 共通ボタン
   ============================================================ */
:root {
  --color-amber-bg:     #fef3c7;
  --color-amber-border: #f59e0b;
  --color-amber-text:   #78350f;
  --color-amber-50:     #fffbeb;
  --color-amber-100:    #fef3c7;
  --color-amber-200:    #fde68a;
  --color-amber-700:    #b45309;
  --color-amber-900:    #78350f;
}
/* Myメモ風ピル（角丸無し版） */
.btn-mymemo-square {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--color-amber-bg);
  border: 2px solid var(--color-amber-border);
  color: var(--color-amber-text);
  font-size: 12px;
  font-weight: 700;
  font-family: 'Kosugi Maru', sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform .12s;
}
.btn-mymemo-square:hover { transform: translateY(-1px); }
/* メモサイドバー共通背景 */
.memo-sidebar-bg { background: var(--color-amber-50); }
.memo-sidebar-header {
  background: var(--color-amber-50);
  border-bottom: 1px solid var(--color-amber-200);
  padding: 8px 10px;
}
/* 履歴行ハイライト */
.dbt-picker-hi {
  background: #eef2ff !important;
  box-shadow: inset 3px 0 0 #6366f1;
}

/* ============================================================
   Phase 2 (2026-05-26): タブレット最適化（768px〜1024px）
   ============================================================ */
@media (min-width: 768px) and (max-width: 1024px) {
  /* メモサイドバーを折り畳み可能に */
  #csMemoSidebar {
    width: 280px !important;
  }
  /* 借入情報テーブルは横スクロール許可 */
  #debtList,
  #cc_debtList {
    min-width: 720px;
  }
  /* セクション内のグリッドを2列にダウングレード */
  .grid.grid-cols-6 > div:not(.col-span-2):not(.col-span-3):not(.col-span-4) {
    grid-column: span 3 / span 3;
  }
  .grid.grid-cols-8 > div {
    grid-column: span 4 / span 4;
  }
  /* 第N回作成ボタンなどは下に回り込み */
  .flex.items-end.gap-3.flex-wrap > div.flex-shrink-0.self-end {
    width: 100%;
    text-align: right;
    margin-top: 8px;
  }
}

/* ============================================================
   Debt Table (面談 債権者情報一覧): Pattern D - Gradient Indigo→Violet
   ============================================================ */
.debt-table { font-size: 12px; }
.debt-table thead th { padding: 11px 8px; }
.debt-table .debt-row > td { border-bottom: 3px double #cbd5e1; padding: 7px 6px; }
.debt-table tfoot td {
  background: linear-gradient(135deg, #eef2ff, #ede9fe);
  border-top: 3px double #8b5cf6;
  font-weight: 700;
  color: #4c1d95;
  padding: 12px 8px;
}

/* ============================================================
   KPIカード 内訳ツールチップ（2026-07-06）
   アイコンにカーソルを合わせた時だけ表示する。
   ビルド済みtailwind.cssに .invisible / .group-hover:visible が
   無い環境（旧キャッシュ含む）でも確実に隠れるよう専用クラス化。
   ============================================================ */
.kpi-tip-wrap .kpi-tip {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.kpi-tip-wrap:hover .kpi-tip {
  opacity: 1;
  visibility: visible;
}

/* ===== SUGI cloud ログイン画面 (B2 左ブランド帯) ===== */
.sgl {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
  background: #fbfdfb;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  color: #22302a;
}
.sgl-brand {
  position: relative;
  overflow: hidden;
  padding: 48px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(160deg, #eef6ef 0%, #dcecdd 55%, #cfe4d1 100%);
}
.sgl-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
/* ふわっとした雲状のアトモス（ぼかし円） */
.sgl-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  pointer-events: none;
}
.sgl-blob-1 { width: 360px; height: 260px; top: -60px; left: -80px; background: rgba(255,255,255,.55); }
.sgl-blob-2 { width: 420px; height: 300px; bottom: -90px; right: -110px; background: rgba(169,207,200,.4); }
.sgl-center {
  position: relative;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
/* ロゴは白背景PNGなので白カードに載せて馴染ませる */
.sgl-logo-card {
  background: #fff;
  border-radius: 22px;
  padding: 22px 30px;
  margin-bottom: 22px;
  box-shadow: 0 18px 44px -18px rgba(29,74,49,.28), 0 2px 6px rgba(29,74,49,.06);
}
.sgl-logo-img { display: block; width: 240px; max-width: 52vw; height: auto; }
.sgl-title { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: .04em; color: #1d4a31; }
.sgl-title span { font-weight: 300; }
.sgl-sub { font-size: 12px; letter-spacing: .3em; margin-top: 13px; color: #5a8168; }
.sgl-foot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #2f5a41;
}
.sgl-foot-icon { width: 46px; height: auto; display: block; }
.sgl-foot-name { display: inline-flex; align-items: baseline; gap: 8px; color: #1d4a31; line-height: 1; font-family: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; }
.sgl-foot-corp { font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.sgl-foot-office { font-size: 27px; font-weight: 900; letter-spacing: .06em; }
.sgl-form { display: flex; align-items: center; justify-content: center; padding: 48px 44px; }
.sgl-inner { width: 100%; max-width: 340px; }
.sgl-inner h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; color: #1d4a31; }
.sgl-lead { margin: 0 0 26px; color: #66766c; font-size: 13px; }
.sgl-field { margin-bottom: 16px; }
.sgl-field label { display: block; font-size: 12px; font-weight: 700; color: #46554d; margin-bottom: 6px; letter-spacing: .02em; }
.sgl-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #dbe4dc;
  background: #f7faf6;
  font-size: 15px;
  color: #22302a;
  transition: .16s;
}
.sgl-field input::placeholder { color: #a7b1a9; }
.sgl-field input:focus {
  outline: none;
  border-color: #2f7d4f;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(47,125,79,.14);
}
.sgl-err { font-size: 13px; color: #dc2626; min-height: 18px; margin: 2px 0 4px; }
.sgl-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  background: #2f7d4f;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: .04em;
  transition: .18s;
}
.sgl-btn:hover { filter: brightness(1.06); }
.sgl-btn:active { transform: translateY(1px); }
.sgl-test {
  margin-top: 24px;
  padding: 14px;
  background: #f1f5f0;
  border: 1px solid #e2ebe2;
  border-radius: 10px;
}
.sgl-test p { font-size: 11px; color: #66766c; margin: 0 0 8px; }
.sgl-test-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sgl-test-row button {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: filter .15s;
}
.sgl-test-row button:hover { filter: brightness(.95); }
.sgl-drift { animation: sglDrift 34s ease-in-out infinite; }
.sgl-drift.b { animation-duration: 48s; animation-direction: reverse; }
@keyframes sglDrift {
  0% { transform: translateX(-22px); }
  50% { transform: translateX(22px); }
  100% { transform: translateX(-22px); }
}
@media (prefers-reduced-motion: reduce) { .sgl-drift { animation: none; } }
/* サンドボックスバナー分だけブランド面の上部を下げる */
.has-sandbox-banner .sgl-brand { padding-top: 68px; }
@media (max-width: 820px) {
  .sgl { grid-template-columns: 1fr; }
  .sgl-brand { min-height: 260px; padding: 32px; }
  .sgl-logo-img { width: 180px; }
  .sgl-logo-card { padding: 16px 22px; margin-bottom: 16px; }
  .sgl-title { font-size: 32px; }
  .sgl-form { padding: 36px 28px; }
}
