/* =============================================
   AI事務局 販売代理店支援ポータル - 共通スタイル v2.0
   Design: Clean・Light・Future-forward / Sony-inspired
   ============================================= */

/* ─────────────────────────────────────────────
   ■ Google Fonts Inter (数字・英字は Inter を優先)
   ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ─────────────────────────────────────────────
   ■ デザイントークン（CSS Custom Properties）
   ───────────────────────────────────────────── */
:root {
  /* ─ Brand / Accent ─ */
  --primary:        #0066FF;
  --primary-dark:   #0052CC;
  --primary-light:  #EBF2FF;
  --primary-subtle: #F0F6FF;

  --accent-cyan:    #00C9E4;
  --accent-violet:  #7C5CFC;
  --accent-green:   #00C48C;
  --accent-orange:  #FF7842;

  /* ─ Gamification ─ */
  --gm-bronze:   #CD8B50;
  --gm-silver:   #8EA5C0;
  --gm-gold:     #F5C842;
  --gm-platinum: #A78BFA;
  --gm-xp:       #F5C842;
  --gm-success:  #00C48C;

  /* ─ Neutral / Surface ─ */
  --bg:           #F4F7FB;
  --bg-white:     #FFFFFF;
  --surface:      #FFFFFF;
  --surface-alt:  #F8FAFD;
  --surface-hover:#EEF3FF;

  /* ─ Text ─ */
  --text-heading: #0A0F1E;
  --text-main:    #1A2035;
  --text-sub:     #6B7A99;
  --text-muted:   #9AA5BB;
  --text-on-dark: #FFFFFF;

  /* ─ Border ─ */
  --border:       #E2E8F5;
  --border-focus: #0066FF;

  /* ─ State ─ */
  --success: #00A878;
  --warning: #F59E0B;
  --danger:  #EF4444;
  --info:    #0EA5E9;

  /* ─ Shadow ─ */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-sm: 0 2px 8px rgba(15,23,42,0.06), 0 0 1px rgba(15,23,42,0.04);
  --shadow:    0 4px 16px rgba(15,23,42,0.08), 0 1px 3px rgba(15,23,42,0.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.05);
  --shadow-lg: 0 20px 48px rgba(15,23,42,0.12), 0 4px 12px rgba(15,23,42,0.06);

  /* ─ Shape ─ */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;
  --radius-full:9999px;

  /* ─ Spacing ─ */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;

  /* ─ Layout ─ */
  --sidebar-width: 244px;
  --header-height: 60px;

  /* ─ Typography ─ */
  --font-base: 'Noto Sans JP', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-num:  'Inter', 'Noto Sans JP', Arial, sans-serif;

  /* ─ Transitions ─ */
  --ease-out:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring:cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:  0.12s;
  --t-base:  0.2s;
  --t-slow:  0.35s;
}

/* ─────────────────────────────────────────────
   ■ Reset
   ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* ─────────────────────────────────────────────
   ■ アバターアイコン（共通）
   ───────────────────────────────────────────── */
.ai-girl-icon {
  width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover;
  display: inline-block; vertical-align: middle;
}
.ai-girl-icon-lg {
  width: 72px; height: 72px;
  border-radius: 50%; object-fit: cover;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
img[src="images/girl.png"] {
  background: linear-gradient(135deg, #0066FF, #7C5CFC);
  color: transparent;
}

/* ─────────────────────────────────────────────
   ■ レイアウト
   ───────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─────────────────────────────────────────────
   ■ サイドバー（明るいクリーン版）
   ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  box-shadow: 2px 0 16px rgba(15,23,42,0.04);
}

.sidebar-logo {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent-violet));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white;
  box-shadow: 0 4px 12px rgba(0,102,255,0.3);
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: 12px; font-weight: 800;
  color: var(--text-heading); line-height: 1.3; white-space: nowrap;
}
.sidebar-logo .logo-sub { font-size: 10px; color: var(--text-sub); }

/* 権限バッジ */
.logo-role-badge {
  display: inline-block;
  margin-top: 3px;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.logo-role-agency-user   { background: #EBF2FF; color: #0052CC; border: 1px solid #BFDBFE; }
.logo-role-agency-admin  { background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.logo-role-support-agent { background: #F3EEFF; color: #6D28D9; border: 1px solid #C4B5FD; }
.logo-role-portal-admin  { background: #FFFBEB; color: #92400E; border: 1px solid #FCD34D; }
.logo-role-auditor       { background: #F1F5F9; color: #475569; border: 1px solid #CBD5E1; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section {
  padding: 10px 10px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all var(--t-fast);
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  position: relative;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px; text-align: center;
}

/* サイドバー下部ユーザー情報 */
.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent-violet));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: white; font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; overflow: hidden; }
.sidebar-user .user-name {
  font-size: 12px; font-weight: 700;
  color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role { font-size: 10px; color: var(--text-sub); }
.sidebar-user .logout-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px;
  border-radius: 6px; transition: all var(--t-fast);
}
.sidebar-user .logout-btn:hover {
  color: var(--danger);
  background: #FEE2E2;
}

/* ─────────────────────────────────────────────
   ■ メインコンテンツ
   ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

.top-header {
  height: var(--header-height);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.top-header h1 { font-size: 17px; font-weight: 800; flex: 1; color: var(--text-heading); letter-spacing: -0.01em; }
.top-header .header-actions { display: flex; align-items: center; gap: 10px; }

.search-global {
  display: flex; align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 14px; gap: 8px;
  width: 260px;
  transition: all var(--t-base);
}
.search-global:focus-within {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(0,102,255,0.10);
}
.search-global input {
  border: none; background: none; outline: none;
  font-size: 13px; width: 100%;
  font-family: var(--font-base);
  color: var(--text-main);
}
.search-global input::placeholder { color: var(--text-muted); }
.search-global .search-icon { color: var(--text-muted); font-size: 14px; }

.icon-btn {
  width: 36px; height: 36px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sub);
  position: relative;
  transition: all var(--t-fast);
}
.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.icon-btn .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px; border-radius: var(--radius-full);
  min-width: 16px; text-align: center;
}

.page-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ─────────────────────────────────────────────
   ■ カード
   ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 800; color: var(--text-heading); }
.card-header h3 { font-size: 13px; font-weight: 700; color: var(--text-heading); }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* ─────────────────────────────────────────────
   ■ ボタン
   ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 700;
  cursor: pointer; border: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
  font-family: var(--font-base);
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0);
  transition: background var(--t-fast);
}
.btn:active { transform: scale(0.97); }
.btn:active::after { background: rgba(255,255,255,0.12); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #0052D4);
  color: white;
  box-shadow: 0 2px 8px rgba(0,102,255,0.30);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,102,255,0.40);
}

.btn-secondary {
  background: white;
  color: var(--text-main);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary-light);
}
.btn-ghost:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-success { background: linear-gradient(135deg, #00C48C, #00A878); color: white; box-shadow: 0 2px 8px rgba(0,168,120,0.3); }
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,168,120,0.4); }
.btn-danger { background: linear-gradient(135deg, #EF4444, #DC2626); color: white; box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(239,68,68,0.4); }
.btn-warning { background: linear-gradient(135deg, #F59E0B, #D97706); color: white; box-shadow: 0 2px 8px rgba(245,158,11,0.3); }
.btn-warning:hover { transform: translateY(-1px); }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--radius-md); }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ─────────────────────────────────────────────
   ■ バッジ
   ───────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-primary  { background: var(--primary-light);  color: var(--primary-dark); }
.badge-success  { background: #DCFCE7; color: #166534; }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-info     { background: #E0F2FE; color: #075985; }
.badge-gray     { background: #F1F5F9; color: #475569; }
.badge-purple   { background: #F3EEFF; color: #6D28D9; }
.badge-cyan     { background: #ECFEFF; color: #0E7490; }

/* ─────────────────────────────────────────────
   ■ テーブル
   ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--surface-alt);
  padding: 10px 16px;
  text-align: left; font-size: 11px; font-weight: 800;
  color: var(--text-sub); text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td {
  background: var(--primary-subtle);
  transition: background var(--t-fast);
}

/* ─────────────────────────────────────────────
   ■ フォーム
   ───────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 12px; font-weight: 700;
  margin-bottom: 6px; color: var(--text-sub);
  letter-spacing: 0.02em;
}
.form-control {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
  outline: none;
  transition: border var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  background: white;
  color: var(--text-main);
  font-family: var(--font-base);
}
.form-control:hover { border-color: #C2CEDE; }
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.10);
  background: white;
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }

/* ─────────────────────────────────────────────
   ■ 統計カード（KPI）
   ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: all var(--t-base);
  cursor: default;
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: #C8D8F0;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.blue     { background: linear-gradient(135deg, #EBF2FF, #DBEAFE); }
.stat-icon.green    { background: linear-gradient(135deg, #ECFDF5, #D1FAE5); }
.stat-icon.orange   { background: linear-gradient(135deg, #FFF7ED, #FED7AA); }
.stat-icon.red      { background: linear-gradient(135deg, #FFF1F2, #FEE2E2); }
.stat-icon.purple   { background: linear-gradient(135deg, #F5F3FF, #EDE9FE); }
.stat-icon.cyan     { background: linear-gradient(135deg, #ECFEFF, #CFFAFE); }
.stat-value {
  font-size: 28px; font-weight: 900; line-height: 1;
  font-family: var(--font-num);
  color: var(--text-heading);
  letter-spacing: -0.02em;
}
.stat-label { font-size: 12px; color: var(--text-sub); margin-top: 4px; font-weight: 500; }
.stat-trend { font-size: 11px; margin-top: 4px; font-weight: 600; }
.stat-trend.up   { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ─────────────────────────────────────────────
   ■ グリッドレイアウト
   ───────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.gap-y  { margin-bottom: 20px; }

/* ─────────────────────────────────────────────
   ■ フィルターバー
   ───────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar input, .filter-bar select {
  height: 38px; padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 13px;
  outline: none; background: white;
  transition: border var(--t-fast), box-shadow var(--t-fast);
  color: var(--text-main);
  font-family: var(--font-base);
}
.filter-bar input:focus, .filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.10);
}
.filter-bar input { width: 240px; }

/* ─────────────────────────────────────────────
   ■ タブ
   ───────────────────────────────────────────── */
.tab-nav {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; gap: 0;
}
.tab-btn {
  padding: 10px 20px; border: none; background: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--t-fast);
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-base);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text-main); background: var(--surface-hover); }

/* ─────────────────────────────────────────────
   ■ モーダル
   ───────────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(10,15,30,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: white; border-radius: var(--radius-lg);
  width: 90%; max-width: 640px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--t-slow) var(--ease-spring);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: white; z-index: 1;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--text-heading); }
.modal-close {
  background: var(--surface-alt); border: none; font-size: 18px; cursor: pointer;
  color: var(--text-sub); width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
}
.modal-close:hover { background: #FEE2E2; color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-lg { max-width: 880px; }

/* ─────────────────────────────────────────────
   ■ アラート
   ───────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13px;
  display: flex; align-items: flex-start; gap: 10px;
  font-weight: 500;
}
.alert-info    { background: #E0F2FE; color: #0C4A6E; border: 1px solid #BAE6FD; }
.alert-success { background: #DCFCE7; color: #14532D; border: 1px solid #86EFAC; }
.alert-warning { background: #FEF3C7; color: #78350F; border: 1px solid #FCD34D; }
.alert-danger  { background: #FEE2E2; color: #7F1D1D; border: 1px solid #FCA5A5; }

/* ─────────────────────────────────────────────
   ■ 空状態
   ───────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 64px 20px;
  color: var(--text-sub);
}
.empty-state .empty-icon { font-size: 52px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--text-main); }
.empty-state p  { font-size: 13px; color: var(--text-sub); }

/* ─────────────────────────────────────────────
   ■ ページヘッダー
   ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 900; color: var(--text-heading); letter-spacing: -0.02em; }
.page-header p  { font-size: 13px; color: var(--text-sub); margin-top: 4px; }

/* ─────────────────────────────────────────────
   ■ ステータスドット
   ───────────────────────────────────────────── */
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
}
.status-dot::before {
  content: ''; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.status-dot.green::before  { background: var(--success); box-shadow: 0 0 0 2px rgba(0,168,120,0.2); }
.status-dot.red::before    { background: var(--danger);  box-shadow: 0 0 0 2px rgba(239,68,68,0.2); }
.status-dot.yellow::before { background: var(--warning); box-shadow: 0 0 0 2px rgba(245,158,11,0.2); }
.status-dot.blue::before   { background: var(--primary); box-shadow: 0 0 0 2px rgba(0,102,255,0.2); }
.status-dot.gray::before   { background: #94A3B8; }

/* ─────────────────────────────────────────────
   ■ ログイン画面
   ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #EBF4FF 0%, #F0EEFF 50%, #E8F8F4 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 20% 30%, rgba(0,102,255,0.08) 0%, transparent 70%),
              radial-gradient(ellipse 60% 50% at 80% 70%, rgba(124,92,252,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.login-card {
  background: white; border-radius: 24px;
  padding: 44px 40px; width: 100%; max-width: 460px;
  box-shadow: 0 24px 64px rgba(15,23,42,0.12), 0 4px 16px rgba(15,23,42,0.06);
  border: 1px solid rgba(255,255,255,0.8);
  position: relative; z-index: 1;
}

/* ─────────────────────────────────────────────
   ■ チャット（AI事務局）
   ───────────────────────────────────────────── */
.chat-layout {
  display: flex; height: calc(100vh - var(--header-height)); overflow: hidden;
}
.chat-sidebar {
  width: 280px; background: white;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
  background: var(--bg);
}
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 16px 20px; background: white;
}
.chat-input-wrap {
  display: flex; gap: 10px; align-items: flex-end;
}
.chat-input-wrap textarea {
  flex: 1; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font-base);
  resize: none; outline: none; line-height: 1.5;
  max-height: 120px;
  transition: border var(--t-fast), box-shadow var(--t-fast);
}
.chat-input-wrap textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.10);
}
.chat-send-btn {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none; border-radius: var(--radius); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast); flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,102,255,0.35);
}
.chat-send-btn:hover {
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 16px rgba(0,102,255,0.45);
}

.msg { display: flex; gap: 12px; max-width: 85%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.msg-avatar.ai   { background: linear-gradient(135deg, var(--primary), var(--accent-violet)); color: white; }
.msg-avatar.user { background: linear-gradient(135deg, #0EA5E9, #0284C7); color: white; }
.msg-bubble {
  padding: 12px 16px; border-radius: 14px;
  font-size: 13px; line-height: 1.65;
}
.msg.ai .msg-bubble {
  background: white; border: 1px solid var(--border);
  border-radius: 3px 14px 14px 14px;
  box-shadow: var(--shadow-sm);
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 14px 3px 14px 14px;
  box-shadow: 0 2px 8px rgba(0,102,255,0.25);
}
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; display: block; }
.msg.user .msg-time { text-align: right; }

.msg-actions { display: flex; gap: 6px; margin-top: 8px; }
.msg-action-btn {
  padding: 4px 10px; border-radius: var(--radius-full);
  border: 1.5px solid var(--border); background: white;
  font-size: 11px; cursor: pointer; color: var(--text-sub);
  transition: all var(--t-fast); font-family: var(--font-base);
  font-weight: 500;
}
.msg-action-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.msg-action-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 8px 0; }
.typing-dot {
  width: 8px; height: 8px;
  background: var(--primary); border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ─────────────────────────────────────────────
   ■ ナレッジ参照タグ
   ───────────────────────────────────────────── */
.knowledge-ref {
  background: var(--primary-subtle);
  border: 1px solid #C2D9FF;
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 12px; color: #1E40AF;
  margin-top: 8px;
}
.knowledge-ref-label { font-weight: 700; margin-bottom: 4px; }

/* ─────────────────────────────────────────────
   ■ エスカレーションカード
   ───────────────────────────────────────────── */
.escalation-card {
  background: #FFFBEB; border: 1px solid #FCD34D;
  border-radius: var(--radius); padding: 14px 16px;
  margin-top: 8px;
}
.escalation-card h4 { font-size: 13px; font-weight: 700; color: #78350F; margin-bottom: 6px; }
.escalation-card p  { font-size: 12px; color: #92400E; margin-bottom: 10px; }

/* ─────────────────────────────────────────────
   ■ ナレッジセンター
   ───────────────────────────────────────────── */
.knowledge-center-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
}
.knowledge-categories { position: sticky; top: 0; }
.category-list { list-style: none; }
.category-item {
  padding: 10px 14px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--text-sub);
  display: flex; align-items: center; justify-content: space-between;
  transition: all var(--t-fast); margin-bottom: 2px;
}
.category-item:hover { background: var(--primary-light); color: var(--primary); }
.category-item.active { background: var(--primary); color: white; }
.category-item .category-count {
  background: rgba(255,255,255,0.3); padding: 2px 6px;
  border-radius: var(--radius-full); font-size: 11px;
}
.category-item:not(.active) .category-count {
  background: var(--bg); color: var(--text-sub);
}

.content-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  cursor: pointer;
  transition: all var(--t-base);
  margin-bottom: 10px;
}
.content-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  transform: translateY(-1px);
}
.content-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.content-icon.faq      { background: linear-gradient(135deg, #FFFBEB, #FEF3C7); }
.content-icon.doc      { background: linear-gradient(135deg, #EBF2FF, #DBEAFE); }
.content-icon.download { background: linear-gradient(135deg, #ECFDF5, #D1FAE5); }
.content-icon.spec     { background: linear-gradient(135deg, #F5F3FF, #EDE9FE); }
.content-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; color: var(--text-heading); }
.content-meta  { font-size: 11px; color: var(--text-sub); display: flex; gap: 10px; flex-wrap: wrap; }
.content-tags  { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.content-tag {
  padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--surface-alt); color: var(--text-sub);
  font-size: 11px; font-weight: 500;
}

/* ─────────────────────────────────────────────
   ■ FAQ アコーディオン
   ───────────────────────────────────────────── */
.faq-item { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 8px; overflow: hidden; }
.faq-question {
  padding: 14px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  background: white; transition: background var(--t-fast);
}
.faq-question:hover { background: var(--surface-alt); }
.faq-answer {
  padding: 14px 18px; font-size: 13px; line-height: 1.75;
  background: var(--surface-alt);
  border-top: 1px solid var(--border); display: none;
}
.faq-item.open .faq-answer { display: block; }
.faq-arrow { transition: transform var(--t-base); color: var(--text-sub); }
.faq-item.open .faq-arrow { transform: rotate(180deg); }

/* ─────────────────────────────────────────────
   ■ タイムライン
   ───────────────────────────────────────────── */
.timeline { padding: 0; list-style: none; }
.timeline-item { display: flex; gap: 12px; padding-bottom: 18px; position: relative; }
.timeline-item::before {
  content: ''; position: absolute;
  left: 14px; top: 30px; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--border), transparent);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-light); border: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; z-index: 1;
}
.timeline-content { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 700; color: var(--text-heading); }
.timeline-time  { font-size: 11px; color: var(--text-sub); }
.timeline-desc  { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

/* ─────────────────────────────────────────────
   ■ ローディング
   ───────────────────────────────────────────── */
.loading-spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────
   ■ ユーティリティ
   ───────────────────────────────────────────── */
.text-center     { text-align: center; }
.text-right      { text-align: right; }
.text-sub        { color: var(--text-sub); }
.text-sm         { font-size: 12px; }
.text-xs         { font-size: 11px; }
.font-bold       { font-weight: 700; }
.font-black      { font-weight: 900; }
.flex            { display: flex; }
.flex-center     { display: flex; align-items: center; justify-content: center; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-1   { margin-top: 4px; }
.mt-2   { margin-top: 8px; }
.mt-3   { margin-top: 12px; }
.mt-4   { margin-top: 16px; }
.mb-2   { margin-bottom: 8px; }
.mb-3   { margin-bottom: 12px; }
.mb-4   { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ─────────────────────────────────────────────
   ■ スクロールバー
   ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

/* ─────────────────────────────────────────────
   ■ トーストUI（ゲーミフィケーション）
   ───────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 99990;
  display: flex; flex-direction: column-reverse; gap: 10px;
  pointer-events: none;
}
.toast-msg {
  background: var(--text-heading);
  color: white; border-radius: 12px;
  padding: 12px 18px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-spring) forwards;
  pointer-events: auto;
  max-width: 340px;
  border-left: 3px solid var(--primary);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}

/* ─────────────────────────────────────────────
   ■ ゲーミフィケーション - スコア/ランクUI
   ───────────────────────────────────────────── */
.rank-bar-wrap {
  display: flex; flex-direction: column; gap: 4px;
}
.rank-bar-track {
  height: 6px; border-radius: var(--radius-full);
  background: #E9EEF7; overflow: hidden;
}
.rank-bar-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 1.2s var(--ease-out);
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
}
.rank-bar-fill.gold     { background: linear-gradient(90deg, #F5C842, #FFAA00); }
.rank-bar-fill.platinum { background: linear-gradient(90deg, #A78BFA, #7C5CFC); }
.rank-bar-fill.silver   { background: linear-gradient(90deg, #8EA5C0, #94A3B8); }

/* ─────────────────────────────────────────────
   ■ ゲーミフィケーション - ポイント加算エフェクト
   ───────────────────────────────────────────── */
@keyframes xpFloat {
  0%   { opacity: 1; transform: translateY(0)   scale(1);    }
  60%  { opacity: 1; transform: translateY(-40px) scale(1.1);  }
  100% { opacity: 0; transform: translateY(-70px) scale(0.9);  }
}
@keyframes xpCountUp {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes particleBurst {
  0%   { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--tx,0),var(--ty,-60px)) scale(0); }
}
@keyframes glowPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,102,255,0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(0,102,255,0); }
}
@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* ─────────────────────────────────────────────
   ■ ゲーミフィケーション - マイクロインタラクション
   ───────────────────────────────────────────── */
.hover-lift {
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base);
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.pulse-on-change { animation: glowPulse 0.6s ease-out; }

/* ─────────────────────────────────────────────
   ■ プログレスバー（アニメーション付き）
   ───────────────────────────────────────────── */
.progress-bar {
  height: 8px; background: #E9EEF7;
  border-radius: var(--radius-full); overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
  transition: width 1s var(--ease-out);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.4) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* ─────────────────────────────────────────────
   ■ reduced-motion 対応
   ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─────────────────────────────────────────────
   ■ レスポンシブ
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-100%); transition: transform var(--t-base); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .knowledge-center-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .filter-bar input { width: 100%; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px; }
}
