:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e8e2d6;
  --text: #2a2520;
  --text-muted: #6b6358;
  --primary: #b08f5c;
  --primary-dark: #8e7140;
  --accent: #d4a574;
  --danger: #c0504d;
  --success: #6b8e4e;
  --info: #5b7a99;
  --shadow: 0 1px 3px rgba(42, 37, 32, 0.06), 0 1px 2px rgba(42, 37, 32, 0.04);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); text-decoration: underline; }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.2s;
}

.sidebar-header {
  padding: 20px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}
.sidebar-header .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.nav-section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.nav-section:last-child { border-bottom: none; }

/* マスタ管理セクションの視覚分離（別枠フレーム） */
.nav-divider {
  margin: 8px 12px;
  border-top: 2px dashed var(--border);
  position: relative;
}
.nav-divider::after {
  content: '';
  position: absolute;
  top: -5px; left: 50%;
  width: 8px; height: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 50%;
  transform: translateX(-50%);
}
.nav-section-masters {
  margin: 6px 8px;
  padding: 10px 0 12px;
  background: linear-gradient(135deg, #fff5e6 0%, #fff8ed 100%);
  border: 1px solid #f0d68a;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(168, 90, 62, 0.06);
}
.nav-section-masters .nav-label {
  color: #a85a3e;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.nav-section-masters .nav-item {
  font-size: 13px;
}
.nav-section-masters .nav-item:hover {
  background: rgba(168, 90, 62, 0.08);
}
.nav-section-masters .nav-item.active {
  background: rgba(168, 90, 62, 0.15);
  border-left-color: #a85a3e;
}

/* 役員専用は赤系の枠 */
.nav-section-admin {
  margin: 6px 8px;
  padding: 8px 0;
  background: linear-gradient(135deg, #fdebec 0%, #fff5f5 100%);
  border: 1px solid #f5b7bb;
  border-radius: 10px;
}
.nav-section-admin .nav-label {
  color: #c0504d;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  padding: 4px 18px 8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 14px;
  color: var(--text);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--bg);
  text-decoration: none;
  color: var(--primary-dark);
}
.nav-item.active {
  background: var(--bg);
  border-left-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}
.nav-icon { width: 18px; text-align: center; }

.main {
  flex: 1;
  margin-left: 240px;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
.search-box {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}
.search-box::before {
  content: "🔍";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.5;
}
.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--bg);
  border-radius: 20px;
}
.user-chip strong { color: var(--text); font-weight: 600; }

.content { padding: 32px; max-width: 1100px; }

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.page-header p { color: var(--text-muted); font-size: 14px; }
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--text-muted); }

/* Cards & Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 .badge { font-size: 10px; font-weight: 600; }

/* KPI Card */
.kpi { padding: 18px 20px; }
.kpi .label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.kpi .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.kpi .delta {
  font-size: 12px;
  margin-top: 4px;
}
.kpi .delta.up { color: var(--success); }
.kpi .delta.down { color: var(--danger); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-primary { background: #f4ead8; color: var(--primary-dark); }
.badge-success { background: #e6efdb; color: var(--success); }
.badge-danger { background: #f4dcdb; color: var(--danger); }
.badge-info { background: #dfe7f0; color: var(--info); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: 12px; color: var(--text-muted); letter-spacing: 0.05em; background: var(--bg); }
tr:last-child td { border-bottom: none; }

/* Lists */
.list { list-style: none; }
.list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: none; }

/* Manual cards (link grid) */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: block;
  color: var(--text);
  transition: transform 0.1s, box-shadow 0.1s;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(42, 37, 32, 0.08); text-decoration: none; }
.tile .tile-icon { font-size: 22px; margin-bottom: 10px; }
.tile h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.tile p { font-size: 12px; color: var(--text-muted); }

/* Sections */
.section { margin-bottom: 36px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
}

/* Article (rules, manual content) */
.article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.article h3 { font-size: 17px; font-weight: 700; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article h3:first-child { margin-top: 0; }
.article h4 { font-size: 14px; font-weight: 700; margin: 16px 0 6px; color: var(--primary-dark); }
.article p, .article li { font-size: 14px; line-height: 1.85; }
.article ul, .article ol { margin: 8px 0 12px 24px; }
.article li { margin-bottom: 4px; }
.article .meta { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Alert / Callout */
.callout { padding: 12px 16px; border-radius: 8px; border-left: 4px solid; margin: 12px 0; font-size: 13px; }
.callout-warn { background: #fbf3e3; border-color: #d9a441; color: #6e4f17; }
.callout-info { background: #e8eef5; border-color: var(--info); color: #2f4d6e; }
.callout-danger { background: #f6dfde; border-color: var(--danger); color: #6e2724; }

/* Report list */
.report-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.report-item:last-child { border-bottom: none; }
.report-meta { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.report-summary { font-size: 14px; line-height: 1.6; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: white; }

/* Footer */
.footer {
  padding: 24px 32px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 16px rgba(0,0,0,0.1); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar { padding: 12px 16px; }
  .content { padding: 20px 16px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .user-chip { display: none; }
  .article { padding: 20px; }
  /* スマホで横スクロールするテーブル */
  .card table, .article table, .section-card table { display: block; overflow-x: auto; white-space: nowrap; }
  /* スタッフピッカーは横スクロール */
  .staff-picker { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .staff-picker .staff-pill { flex-shrink: 0; }
  /* KPIカードは小さく */
  .kpi { padding: 14px; }
  .kpi .value { font-size: 22px; }
  /* 評価ページ：モバイルで6列を縦並び＋スコアボタンを大きく */
  .eval-row { padding: 14px 0 !important; }
  .score-pills button { width: 36px !important; height: 36px !important; font-size: 14px !important; }
  /* 検索ボックス縮小 */
  .search-box { max-width: 200px; }
  /* 進捗バーラベル省略表示 */
  .progress-fill { font-size: 10px; padding: 0 6px; }
  /* チャート系の高さを抑える */
  .monthly-chart { height: 100px; }
  .daily-bar { height: 60px; }
}

@media (max-width: 480px) {
  .topbar { gap: 8px; }
  .search-box { max-width: 140px; }
  .search-box input { font-size: 12px; padding: 6px 10px 6px 28px; }
  .page-header h2 { font-size: 18px; }
  .summary-card .total { font-size: 32px !important; }
}

/* ==========================================================
   Phase 1 ポータル共通コンポーネント（顧客・サブスク・回数券）
   ========================================================== */

/* Phaseバナー（モック表示の警告） */
.phase-banner {
  background: linear-gradient(135deg, #fff8e1, #fef0c8);
  border: 1px solid #f0d68a;
  border-left: 4px solid #d9a441;
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #6e4f17;
  display: flex;
  align-items: center;
  gap: 12px;
}
.phase-banner .phase-icon { font-size: 20px; }
.phase-banner strong { color: #8b5a16; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.kpi-card:hover { box-shadow: var(--shadow); }
.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-card .kpi-unit { font-size: 14px; color: var(--text-muted); margin-left: 4px; font-weight: 500; }
.kpi-card .kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-card.warn { border-left: 3px solid #d9a441; }
.kpi-card.warn .kpi-value { color: #d9a441; }
.kpi-card.danger { border-left: 3px solid var(--danger); }
.kpi-card.danger .kpi-value { color: var(--danger); }
.kpi-card.success { border-left: 3px solid var(--success); }
.kpi-card.success .kpi-value { color: var(--success); }
.kpi-card.primary { border-left: 3px solid var(--primary); }
.kpi-card.primary .kpi-value { color: var(--primary-dark); }

/* RFM badges */
.rfm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.rfm-champion { background: linear-gradient(135deg, #f5d76e, #e0a800); color: #5c3d00; }
.rfm-loyal { background: #d4e6f0; color: #1a4d6b; }
.rfm-potential_loyalist { background: #e0eed5; color: #4a6b2c; }
.rfm-new { background: #d4ead8; color: #2e7d4f; }
.rfm-at_risk { background: #fde8c6; color: #8a5a16; }
.rfm-hibernating { background: #e8e8e8; color: #555; }
.rfm-lost { background: #f4dcdb; color: #8a2a26; }
.rfm-uncategorized { background: var(--bg); color: var(--text-muted); }

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { background: #d4ead8; color: #2e7d4f; }
.status-failed { background: #f4dcdb; color: var(--danger); }
.status-paused { background: #fde8c6; color: #8a5a16; }
.status-cancelled { background: #e8e8e8; color: #777; }
.status-completed { background: #d4e6f0; color: #1a4d6b; }
.status-pending { background: #fff5e0; color: #8a6d16; }

/* Tag chips */
.tag-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 11px;
  font-size: 11px;
  background: #fff5e0;
  border: 1px solid #e8d595;
  color: #8b6f1a;
  margin-right: 4px;
  margin-bottom: 2px;
}
.tag-chip.tag-vip { background: linear-gradient(135deg, #fbe8d4, #f5d76e); border-color: #d4af37; color: #6c4a00; font-weight: 700; }
.tag-chip.tag-monitor { background: #e0eed5; border-color: #a8d4a3; color: #4a6b2c; }
.tag-chip.tag-concern { background: #f5e4e3; border-color: #e8b3b3; color: #8a3d3a; }

/* Course pills (顧客一覧の小さな契約表示) */
.course-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 4px;
  margin-bottom: 2px;
  border: 1px solid;
}
.course-pill.subscription { background: #ebf3fe; border-color: #b8d4f0; color: #1a4d6b; }
.course-pill.ticket { background: #fdf3e0; border-color: #f0d590; color: #8a5a16; }
.course-pill.program { background: #fef0c8; border-color: #f5d76e; color: #6c4a00; }
.course-pill.prepaid { background: #e0eed5; border-color: #a8d4a3; color: #4a6b2c; }
.course-pill.failed { background: #f4dcdb; border-color: #d97775; color: var(--danger); font-weight: 700; }
.course-pill .icon { font-size: 12px; }

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.filter-bar select,
.filter-bar input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.filter-bar select:focus,
.filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}
.filter-bar input[type="search"] { min-width: 200px; flex: 1; max-width: 280px; }
.filter-bar .filter-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.data-table thead { background: var(--bg); }
.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { background: #ebe5d6; color: var(--primary-dark); }
.data-table th[data-sort]::after { content: " ⇅"; opacity: 0.3; font-size: 9px; }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: #faf9f5; cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-name strong { font-size: 14px; }
.data-table .col-name .sub { font-size: 11px; color: var(--text-muted); display: block; margin-top: 1px; }
.data-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table code { font-size: 11px; background: var(--bg); padding: 1px 5px; border-radius: 3px; color: var(--text-muted); }

/* Customer detail header */
.detail-header {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 24px;
  padding: 24px;
  background: linear-gradient(135deg, var(--surface), #fbfaf6);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 24px;
  align-items: center;
  box-shadow: var(--shadow);
}
.detail-header .avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 12px rgba(176, 143, 92, 0.25);
}
.detail-header .name-block {
  min-width: 0;
}
.detail-header .name-line {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.detail-header .name-kana {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}
.detail-header .meta-line {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 8px;
}
.detail-header .meta-line span { display: inline-flex; align-items: center; gap: 4px; }
.detail-header .ltv-block {
  text-align: right;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.detail-header .ltv-label { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.detail-header .ltv-value { font-size: 28px; font-weight: 700; color: var(--primary-dark); line-height: 1.1; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.detail-header .ltv-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Course card (詳細ページ用大きいカード) */
.course-card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--surface);
  transition: box-shadow 0.1s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
.course-card:hover { box-shadow: var(--shadow); }
.course-card.subscription { border-left: 4px solid #1a4d6b; }
.course-card.ticket { border-left: 4px solid #d9a441; }
.course-card.program { border-left: 4px solid #d4af37; }
.course-card.prepaid { border-left: 4px solid var(--success); }
.course-card.failed-status { background: #fdf0ef; border-color: #e8b3b3; }
.course-card .course-name { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.course-card .course-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.course-card .course-meta strong { color: var(--text); font-weight: 600; }
.course-card .course-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.course-card .course-stat .big { font-size: 22px; font-weight: 700; color: var(--primary-dark); line-height: 1; }
.course-card .course-stat .small { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Progress bar */
.progress-bar {
  background: var(--bg);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
  margin-top: 8px;
}
.progress-fill { background: var(--primary); height: 100%; transition: width 0.3s; }
.progress-fill.warn { background: #d9a441; }
.progress-fill.danger { background: var(--danger); }
.progress-fill.success { background: var(--success); }

/* Karte entry */
.karte-entry {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.karte-entry .karte-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.karte-entry .karte-date { font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.karte-entry .karte-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.karte-entry .ai-badge { background: linear-gradient(135deg, #6b7eff, #5b6ee0); color: white; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; letter-spacing: 0.02em; }

.soap-grid {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 16px;
  font-size: 13px;
  line-height: 1.7;
}
.soap-grid dt {
  font-weight: 700;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding-top: 2px;
}
.soap-grid dt strong { font-size: 14px; color: var(--primary-dark); }
.soap-grid dd { margin: 0; }

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 10px; opacity: 0.5; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; font-size: 15px; }
.empty-state p { font-size: 13px; }

/* Detail tabs (multiple panels) */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.detail-tabs button {
  padding: 12px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: -2px;
  font-family: inherit;
  white-space: nowrap;
  font-weight: 500;
  transition: color 0.1s, border-color 0.1s;
}
.detail-tabs button.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
  font-weight: 700;
}
.detail-tabs button:hover { color: var(--text); }
.detail-tabs button .count {
  display: inline-block;
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: 6px;
  font-weight: 600;
  color: var(--text-muted);
}
.detail-tabs button.active .count { background: var(--primary); color: white; }

/* Info grid (profile tab) */
.info-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.info-grid dt {
  color: var(--text-muted);
  padding: 12px 16px;
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
.info-grid dd {
  padding: 12px 16px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  word-break: break-word;
}
.info-grid dt:nth-last-of-type(1),
.info-grid dd:nth-last-of-type(1) { border-bottom: none; }

/* Photo grid */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.photo-card {
  aspect-ratio: 1;
  background: linear-gradient(135deg, #d6cfc1, #b3a791);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 12px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.photo-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.3));
}
.photo-card .photo-icon { font-size: 28px; margin-bottom: 6px; opacity: 0.7; z-index: 1; }
.photo-card .photo-label { z-index: 1; line-height: 1.3; }
.photo-card.before-tag { background: linear-gradient(135deg, #c1b1a3, #8e7d6f); }
.photo-card.after-tag { background: linear-gradient(135deg, #d4a574, #b08f5c); }

/* Catalog product groups (subscriptions tab) */
.catalog-group { margin-bottom: 28px; }
.catalog-group h3 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--primary-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.catalog-group h3::before {
  content: "";
  width: 4px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
  display: inline-block;
}
.catalog-group .group-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Concerns list (タグスタイル) */
.concerns-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* LINE chat UI */
.line-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #06c755, #04a544);
  color: white;
  border-radius: 12px;
  margin-bottom: 16px;
}
.line-status.unlinked {
  background: linear-gradient(135deg, #999, #777);
}
.line-status.blocked {
  background: linear-gradient(135deg, #c0504d, #962f2c);
}
.line-status .line-icon { font-size: 24px; }
.line-status .line-info { flex: 1; }
.line-status .line-info-title { font-weight: 700; font-size: 14px; }
.line-status .line-info-sub { font-size: 12px; opacity: 0.9; margin-top: 2px; }

.chat-window {
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  max-height: 500px;
  overflow-y: auto;
  margin-bottom: 14px;
}
.chat-day-divider {
  text-align: center;
  margin: 12px 0;
  font-size: 11px;
  color: #888;
}
.chat-day-divider span { background: white; padding: 2px 10px; border-radius: 10px; border: 1px solid var(--border); }

.chat-message {
  display: flex;
  margin-bottom: 12px;
  max-width: 75%;
  flex-direction: column;
}
.chat-message.outbound { margin-left: auto; align-items: flex-end; }
.chat-message.inbound { margin-right: auto; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-message.outbound .chat-bubble {
  background: #06c755;
  color: white;
  border-bottom-right-radius: 4px;
}
.chat-message.inbound .chat-bubble {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-message.outbound .chat-bubble.template {
  background: #2563eb;
}
.chat-message.outbound .chat-bubble.system {
  background: #6b7280;
  font-style: italic;
}
.chat-message.outbound .chat-bubble.scheduled {
  background: #f59e0b;
  border: 2px dashed white;
}
.chat-message.outbound .chat-bubble.important {
  background: var(--danger);
}

.chat-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}
.chat-meta.outbound-meta { text-align: right; }

.chat-composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.chat-composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  font-size: 14px;
  padding: 4px;
  background: transparent;
}
.chat-composer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.chat-composer-actions .left-tools { display: flex; gap: 4px; }
.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}
.icon-btn:hover { background: var(--border); }
.send-btn {
  margin-left: auto;
  background: #06c755;
  color: white;
  border: none;
  padding: 7px 18px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.send-btn:hover { background: #04a544; }
.send-btn:disabled { background: #ccc; cursor: not-allowed; }

.template-list { display: flex; flex-wrap: wrap; gap: 6px; }
.template-pill {
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
}
.template-pill:hover { background: var(--primary); color: white; border-color: var(--primary); }
.template-pill .cat { color: var(--text-muted); margin-right: 4px; }

/* Integration panel */
.integration-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.integration-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.int-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.int-body { min-width: 0; }
.int-title { font-weight: 700; font-size: 14px; }
.int-status { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.int-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* Event source badge */
.ev-source {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  background: rgba(255,255,255,0.85);
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
  border: 1px solid rgba(0,0,0,0.1);
}

/* CSV upload zone */
.csv-dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
}
.csv-dropzone:hover, .csv-dropzone.drag-over {
  border-color: var(--primary);
  background: #fff8e1;
}
.csv-dropzone .dz-icon { font-size: 42px; margin-bottom: 10px; opacity: 0.7; }
.csv-dropzone .dz-title { font-weight: 700; margin-bottom: 4px; }
.csv-dropzone .dz-sub { font-size: 12px; color: var(--text-muted); }

/* Settings tab in modal */
.tab-pills {
  display: inline-flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 14px;
}
.tab-pills button {
  padding: 6px 14px;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
}
.tab-pills button.active {
  background: white;
  color: var(--primary-dark);
  box-shadow: var(--shadow);
}

/* Calendar (予約管理) */
.cal-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.cal-toolbar .nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.cal-toolbar .nav-btn:hover { background: var(--bg); border-color: var(--primary); }
.cal-toolbar .cal-date {
  font-size: 18px;
  font-weight: 700;
  margin: 0 8px;
  letter-spacing: -0.01em;
}
.cal-toolbar .view-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.cal-toolbar .view-toggle button {
  padding: 7px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-muted);
}
.cal-toolbar .view-toggle button.active {
  background: var(--primary);
  color: white;
}

.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.cal-week-header {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}
.cal-week-header .col-h {
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.cal-week-header .col-h:last-child { border-right: none; }
.cal-week-header .col-h.today { background: #fff8e1; color: var(--primary-dark); font-weight: 700; }
.cal-week-header .col-h .date-num { font-size: 16px; color: var(--text); display: block; margin-top: 2px; }
.cal-week-header .col-h.today .date-num { color: var(--primary-dark); }
.cal-week-header .col-h.weekend { color: var(--danger); }

.cal-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  position: relative;
}
.cal-time-col {
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.cal-time-slot {
  height: 50px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  padding: 2px 8px 0 0;
}
.cal-day-col {
  border-right: 1px solid var(--border);
  position: relative;
  min-height: 700px;
}
.cal-day-col:last-child { border-right: none; }
.cal-day-col .slot {
  height: 50px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.cal-day-col .slot:hover { background: #fff8e1; }
.cal-day-col.today { background: #fffaeb; }

.cal-event {
  position: absolute;
  left: 4px;
  right: 4px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: transform 0.1s;
}
.cal-event:hover { transform: scale(1.02); z-index: 3; }
.cal-event .ev-time { font-weight: 700; font-size: 10px; opacity: 0.85; }
.cal-event .ev-name { font-weight: 700; font-size: 12px; line-height: 1.3; margin-top: 1px; }
.cal-event .ev-menu { font-size: 10px; opacity: 0.85; line-height: 1.2; }
.cal-event .ev-staff { font-size: 9px; opacity: 0.75; margin-top: 1px; }

.cal-event.color-pink { background: #fce7f3; border-color: #ec4899; color: #831843; }
.cal-event.color-blue { background: #dbeafe; border-color: #3b82f6; color: #1e3a8a; }
.cal-event.color-green { background: #d1fae5; border-color: #10b981; color: #064e3b; }
.cal-event.color-yellow { background: #fef3c7; border-color: #f59e0b; color: #78350f; }
.cal-event.color-purple { background: #ede9fe; border-color: #8b5cf6; color: #4c1d95; }
.cal-event.color-orange { background: #ffedd5; border-color: #f97316; color: #7c2d12; }
.cal-event.color-gray { background: #f3f4f6; border-color: #6b7280; color: #1f2937; opacity: 0.85; }
.cal-event.is-block {
  background: repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 6px, #e5e7eb 6px, #e5e7eb 12px);
  border-color: #6b7280;
  color: #4b5563;
}
.cal-event.is-new-visit { font-weight: 700; }
.cal-event.is-new-visit::before { content: "🆕 "; }
.cal-event.is-cancelled { opacity: 0.4; text-decoration: line-through; }

/* Day view (single day with multiple staff/room columns) */
.cal-day-view-header {
  display: grid;
  border-bottom: 2px solid var(--border);
  background: var(--bg);
}
.cal-day-view-header .col-h {
  padding: 10px 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border-right: 1px solid var(--border);
}
.cal-day-view-header .col-h:last-child { border-right: none; }

/* Booking modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 22px; cursor: pointer;
  color: var(--text-muted);
  padding: 0; width: 32px; height: 32px;
  border-radius: 50%;
}
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px 22px; }
.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.modal-body label:first-child { margin-top: 0; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}
.modal-body textarea { resize: vertical; min-height: 70px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--bg);
  border-radius: 0 0 14px 14px;
}

.color-picker { display: flex; gap: 6px; }
.color-swatch {
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
}
.color-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px white inset; }
.color-swatch.color-pink { background: #ec4899; }
.color-swatch.color-blue { background: #3b82f6; }
.color-swatch.color-green { background: #10b981; }
.color-swatch.color-yellow { background: #f59e0b; }
.color-swatch.color-purple { background: #8b5cf6; }
.color-swatch.color-orange { background: #f97316; }
.color-swatch.color-gray { background: #6b7280; }

/* レスポンシブ */
@media (max-width: 900px) {
  .detail-header {
    grid-template-columns: 64px 1fr;
    grid-template-rows: auto auto;
    gap: 16px;
  }
  .detail-header .avatar { width: 64px; height: 64px; font-size: 26px; }
  .detail-header .ltv-block {
    grid-column: 1 / -1;
    border-left: none;
    padding-left: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 14px;
  }
  .detail-header .name-line { font-size: 19px; }
  .info-grid { grid-template-columns: 110px 1fr; font-size: 13px; }
  .info-grid dt, .info-grid dd { padding: 10px 12px; }
  .course-card { grid-template-columns: 1fr; }
  .course-card .course-stat { text-align: left; }
}

@media (max-width: 768px) {
  .data-table { font-size: 12px; display: block; overflow-x: auto; white-space: nowrap; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .filter-bar { padding: 10px; gap: 6px; }
  .filter-bar input[type="search"] { min-width: 140px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-card .kpi-value { font-size: 22px; }
  .soap-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .soap-grid dt { padding-top: 8px; }
}

.print-only { display: none; }
@media print {
  /* 紙出力時の最適化（評価面談・申請書類想定） */
  .sidebar, .topbar, .footer, .menu-toggle, .staff-picker, .view-controls, .period-controls, .store-tabs, .eval-mode-tabs, .tabs, .breadcrumb { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; max-width: 100%; }
  .page-header { margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid #000; }
  .page-header h2 { font-size: 16pt; }
  .article, .card, .section-card { border: 1px solid #ccc !important; box-shadow: none !important; page-break-inside: avoid; }
  .grid-4 { grid-template-columns: repeat(4, 1fr) !important; }
  .grid-3 { grid-template-columns: repeat(3, 1fr) !important; }
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
  body { font-size: 10pt; line-height: 1.5; color: #000; background: white; }
  a { color: #000 !important; text-decoration: none; }
  a[href]:after { content: ""; }  /* URL付き出力を抑制 */
  .btn, button { display: none !important; }
  .note-input, textarea, input { border: 1px solid #999 !important; background: white; }
  .score-pills button.active { background: #000 !important; color: white !important; }
  .progress-fill { background: #888 !important; }
  .summary-card { page-break-after: avoid; }
  table { font-size: 9pt; }
  th, td { padding: 4px 6px; border: 1px solid #999; }
  /* 印刷用に署名欄を表示 */
  .print-only { display: block; margin-top: 30px; padding-top: 20px; border-top: 1px solid #000; }
  .print-only .sig-row { display: flex; gap: 30px; margin-top: 20px; }
  .print-only .sig-row > div { flex: 1; border-bottom: 1px solid #000; padding-bottom: 4px; }
}

/* ==========================================================
   📱 モダンUI / スマホ最適化（2026-05-02 全体UI改善）
   ========================================================== */

/* iOS Safe-area 対応（ホームバー被り防止） */
.main { padding-bottom: env(safe-area-inset-bottom); }
.sidebar { padding-bottom: env(safe-area-inset-bottom); }

/* 横スクロール抑止：bodyのみで行う（html や全体に overflow-x:hidden を入れると
   iOS Safari で position:fixed のサイドバーが「タップで上にスクロールリセット」
   してしまうバグが出るため html には設定しない）。
   さらに sidebar の overflow-y を 'auto' から 'scroll' に変えてiOS Safariのスクロール挙動を安定化。 */
body { overflow-x: clip; }

/* 慣性スクロール（iOS） */
.sidebar, .modal, [data-panel-group], .chat-messages, .qa-list, .photo-grid {
  -webkit-overflow-scrolling: touch;
}

/* サイドバーの内部スクロールを安定化（iOSのfixed内スクロール対策） */
.sidebar {
  overflow-y: scroll;
  overscroll-behavior: contain;  /* スクロールが親に伝播しない */
  -webkit-overflow-scrolling: touch;
}

/* スクロールバー（細く・控えめに） */
@media (hover: hover) {
  *::-webkit-scrollbar { width: 8px; height: 8px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }
  *::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
}

/* ボタンのインタラクション強化（ホバー時の浮き上がり、押下時の沈み込み） */
.btn {
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { box-shadow: 0 2px 6px rgba(42, 37, 32, 0.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(42, 37, 32, 0.1); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { box-shadow: 0 2px 6px rgba(176, 143, 92, 0.25); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(176, 143, 92, 0.35); }

/* カード／タイル の hover 強化 */
.card, .kpi-card, .tile, .qa-row, .task-row, .exp-row, .contract-row, .consume-row, .photo-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.tile:hover, .kpi-card:hover { transform: translateY(-2px); }

/* 入力フィールド：iOS自動ズーム防止 + フォーカス強調 */
input[type="text"], input[type="number"], input[type="date"], input[type="search"],
input[type="email"], input[type="tel"], input[type="password"], select, textarea {
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(176, 143, 92, 0.15);
}

/* バッジ／ピル のシャープな見せ方 */
.badge, .status-badge, .kind-badge, .cat-badge, .ai-badge, .scope-badge, .priority-badge {
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* セクション見出しの視覚階層 */
.section-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ロード中の skeleton（任意で使う） */
.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--surface) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes skeleton-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* モーダルの開閉アニメ */
.modal-backdrop {
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.modal-backdrop.open .modal {
  animation: modal-pop 0.2s ease-out;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ====== サイドバー オーバーレイ（モバイル開閉用） ====== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ====== モバイル特化（768px以下） ====== */
@media (max-width: 768px) {
  /* iOS自動ズーム防止：入力欄を 16px 以上に */
  input[type="text"], input[type="number"], input[type="date"], input[type="search"],
  input[type="email"], input[type="tel"], input[type="password"], select, textarea {
    font-size: 16px !important;
    padding: 10px 12px;
    border-radius: 8px;
  }

  /* タップターゲット 44px 以上を保証 */
  .btn, button.btn, .pay-btn, .filter-tab, .qa-tab, .task-tab, .compare-tab,
  .exp-tab, .annot-tool-btn, .chat-tab, .chm-kind-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
  }
  .btn[style*="font-size:11px"], .btn[style*="font-size: 11px"],
  .btn[style*="font-size:10px"], .btn[style*="font-size: 10px"] {
    /* スマホでは小さい文字ボタンも最低限の高さを確保 */
    min-height: 36px;
  }

  /* トップバーのメニューボタンを大きく */
  .menu-toggle {
    width: 44px; height: 44px;
    font-size: 24px;
    border-radius: 8px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: var(--bg);
  }
  .menu-toggle:active { background: var(--border); }

  /* サイドバー幅を画面の85%に */
  .sidebar { width: 85vw; max-width: 320px; }

  /* ユーザーチップを表示（既存はnone）— 横スクロールせず縮小して残す */
  .user-chip { display: inline-flex; font-size: 11px; padding: 4px 8px; }
  .user-chip strong { font-size: 12px; }

  /* page-header をコンパクトに */
  .page-header h2 { font-size: 18px; line-height: 1.4; }
  .page-header p { font-size: 12px; line-height: 1.5; margin-top: 4px; }

  /* breadcrumb 縮小 */
  .breadcrumb { font-size: 11px; margin-bottom: 8px; }

  /* セクション余白圧縮 */
  .section { margin-bottom: 18px; }
  .section-title { font-size: 13px; margin: 14px 0 8px; }

  /* KPI: フォントサイズと余白 */
  .kpi-card { padding: 12px 14px; }
  .kpi-card .value { font-size: 20px; }
  .kpi-card .kpi-label, .kpi-card .label { font-size: 11px; }

  /* モーダル：画面下部から立ち上げる */
  .modal-backdrop {
    align-items: flex-end !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 92vh !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-backdrop.open .modal {
    animation: modal-slide-up 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }
  @keyframes modal-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-header {
    position: sticky; top: 0;
    background: var(--surface);
    z-index: 1;
    border-bottom: 1px solid var(--border);
  }
  .modal-header::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 6px auto -2px;
  }
  .modal-footer {
    position: sticky; bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }

  /* チャット入力エリア：下端に貼り付け */
  .chat-input-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

  /* 写真グリッド：2列固定 */
  .photo-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }
  .photo-card img { height: 140px; }

  /* チャット 1カラムに */
  .chat-layout { grid-template-columns: 1fr !important; height: calc(100vh - 180px) !important; }
  .chat-sidebar { display: none; }
  .chat-sidebar.mobile-open {
    display: flex; position: fixed; inset: 0; z-index: 50; background: var(--surface);
  }

  /* QAレイアウトを1カラムに */
  .qa-layout { grid-template-columns: 1fr !important; }

  /* タスクとQ&Aの行を見やすく */
  .task-row, .qa-row, .exp-row, .contract-row { padding: 14px 14px; }
  .task-meta, .qa-row .meta { font-size: 11px; gap: 6px; }

  /* テーブルが一定高さで縦スクロール出来るように */
  .data-table-wrap { max-height: 60vh; overflow: auto; }
  table { font-size: 13px; }
  th, td { padding: 8px 10px !important; }

  /* チェックボックス・ラジオの大きさ */
  input[type="checkbox"], input[type="radio"] {
    width: 20px !important; height: 20px !important;
    margin: 4px;
  }

  /* tile-grid: 2列固定 */
  .tile-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* footer 簡潔に */
  .footer { padding: 14px 16px; font-size: 11px; margin-top: 20px; }
}

/* ====== 極小スマホ（375px以下） ====== */
@media (max-width: 375px) {
  .photo-grid { gap: 6px; }
  .kpi-card .value { font-size: 18px; }
  .page-header h2 { font-size: 16px; }
  .modal-body { padding: 14px 16px !important; }
  .modal-header h3 { font-size: 15px; }
}

/* ====== タブレット（768〜1024px） ====== */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main { margin-left: 220px; }
  .content { padding: 24px; }
}

/* ====== Floating Action Button (FAB) ====== */
/* 主要ページで「すぐ手が届く」位置に主操作ボタンを配置するためのクラス */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(176, 143, 92, 0.4);
  font-size: 24px;
  cursor: pointer;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: scale(1.05); box-shadow: 0 6px 20px rgba(176, 143, 92, 0.5); }
.fab:active { transform: scale(0.95); }
@media (max-width: 768px) {
  .fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: 52px; height: 52px; }
}

/* ====== ローディングインジケータ ====== */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(176, 143, 92, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

/* ====== 既存タップターゲット改善（小さいクローズボタン等） ====== */
.modal-close {
  min-width: 36px; min-height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border-radius: 8px;
}
@media (max-width: 768px) {
  .modal-close { min-width: 44px; min-height: 44px; font-size: 22px; }
}

/* ====== バッジ強調（重要通知用） ====== */
.badge-pulse {
  animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

/* ====== 見やすいリンク強調 ====== */
.content a:not(.btn):not(.tile):not(.link-card):not([class*="-link"]) {
  color: var(--primary-dark);
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s;
}
.content a:not(.btn):not(.tile):not(.link-card):not([class*="-link"]):hover {
  border-bottom-color: var(--primary);
  text-decoration: none;
}

/* ====== ステータス色を見やすく ====== */
.status-badge, .kind-badge, .badge {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 10px;
}

/* ====== 入力フォームのラベル可読性 ====== */
.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 14px;
  margin-bottom: 4px;
}
.modal-body label:first-child { margin-top: 0; }
.modal-body input,
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
}

/* ====== ナビゲーションアクティブの強調 ====== */
.nav-section a.active, .nav-section .nav-item.active {
  position: relative;
}
.nav-section a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
