/* VOMS スタイルシート */
:root {
  --primary: #1B4F8A;
  --primary-light: #2E75B6;
  --primary-bg: #EBF3FB;
  --amazon: #FF9900;
  --yahoo: #FF0033;
  --qoo10: #E31C5F;
  --success: #28A745;
  --warning: #FFC107;
  --danger: #DC3545;
  --gray-50: #F8F9FA;
  --gray-100: #F0F2F5;
  --gray-200: #E9ECEF;
  --gray-400: #ADB5BD;
  --gray-600: #6C757D;
  --gray-800: #343A40;
  --sidebar-w: 220px;
}

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

body { font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 14px; }

/* レイアウト */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* サイドバー */
.sidebar { width: var(--sidebar-w); background: var(--primary); display: flex; flex-direction: column; flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.15); }
.logo-icon { font-size: 24px; }
.logo-text { color: white; font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.nav-menu { list-style: none; flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 18px; color: rgba(255,255,255,0.8); cursor: pointer; border-left: 3px solid transparent; transition: all 0.2s; font-size: 13.5px; }
.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; border-left-color: white; font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* サイドバー グループ折りたたみ */
.nav-group { list-style: none; }
.nav-group-header { display: flex; align-items: center; gap: 10px; padding: 11px 18px; color: rgba(255,255,255,0.8); cursor: pointer; border-left: 3px solid transparent; transition: all 0.2s; font-size: 13.5px; user-select: none; }
.nav-group-header:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-arrow { margin-left: auto; font-size: 11px; transition: transform 0.25s ease; }
.nav-group:not(.open) .nav-arrow { transform: rotate(-90deg); }
.nav-group-items { list-style: none; overflow: hidden; max-height: 0; transition: max-height 0.3s ease; }
.nav-group.open .nav-group-items { max-height: 200px; }
.nav-group-items .nav-item { padding: 8px 18px 8px 28px; font-size: 12.5px; }
.nav-group-items .nav-icon { font-size: 12px; width: 16px; color: rgba(255,255,255,0.4); }
.nav-group.has-active .nav-group-header { color: white; border-left-color: rgba(255,255,255,0.5); }

/* Amazon広告 タブ */
.ads-tab-btn { background: none; border: none; padding: 10px 20px; font-size: 13.5px; font-weight: 600; color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.ads-tab-btn:hover { color: #374151; background: #f9fafb; }
.ads-tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }
.ads-tab-panel { display: none; }
.ads-tab-panel.active { display: block; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.15); }
.platform-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 10px; padding: 3px 8px; border-radius: 10px; font-weight: 600; color: white; }
.badge.amazon { background: var(--amazon); }
.badge.yahoo { background: var(--yahoo); }
.badge.qoo10 { background: var(--qoo10); }

/* メインコンテンツ */
.main-content { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: white; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 10; }
.top-bar h1 { font-size: 20px; font-weight: 700; color: var(--primary); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.last-updated { font-size: 12px; color: var(--gray-600); }

.page { display: none; padding: 24px; flex: 1; }
.page.active { display: block; }

/* KPIカード */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: white; border-radius: 10px; padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-left: 4px solid var(--primary-light); }
.kpi-card.alert { border-left-color: var(--warning); }
.kpi-card.danger { border-left-color: var(--danger); }
.kpi-icon { font-size: 28px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* カード */
.card { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 16px; }
.card-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* テーブル */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--gray-50); padding: 10px 12px; text-align: left; font-weight: 600; color: var(--gray-600); border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.data-table tr:hover td { background: var(--primary-bg); }
.loading { text-align: center; color: var(--gray-400); padding: 24px; }

/* ステータスバッジ */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.status-badge.pending { background: #FFF3CD; color: #856404; }
.status-badge.shipping { background: #CCE5FF; color: #004085; }
.status-badge.done { background: #D4EDDA; color: #155724; }
.status-badge.cancel { background: #F8D7DA; color: #721C24; }
.status-badge.in-stock { background: #D4EDDA; color: #155724; }
.status-badge.low { background: #FFF3CD; color: #856404; }
.status-badge.out { background: #F8D7DA; color: #721C24; }

/* プラットフォームバッジ */
.platform-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; color: white; }
.platform-badge.Amazon { background: var(--amazon); }
.platform-badge.Amazon-FBM { background: #FF9900; }
.platform-badge.Amazon-FBA { background: #c25700; }
.platform-badge.Yahoo { background: var(--yahoo); }
.platform-badge.Qoo10 { background: var(--qoo10); }
.platform-badge.BtoB { background: #6366f1; }
.platform-badge.NETSEA { background: #0891b2; }

/* ステータスサマリーカード */
.status-summary-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* フィルターバー */
.filter-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group label { font-size: 13px; color: var(--gray-600); white-space: nowrap; }
.filter-group select, .search-input { border: 1px solid var(--gray-200); border-radius: 6px; padding: 7px 12px; font-size: 13px; outline: none; transition: border 0.2s; }
.filter-group select:focus, .search-input:focus { border-color: var(--primary-light); }
.search-input { width: 240px; }

/* ボタン */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-outline { background: white; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-warning { background: #d97706; color: white; border: none; }
.btn-warning:hover { background: #b45309; }
.btn-warning:disabled { background: var(--gray-300); color: var(--gray-500); cursor: not-allowed; }
.full-width { width: 100%; justify-content: center; }

/* 在庫アラートリスト */
.alert-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 6px; margin-bottom: 8px; background: var(--gray-50); border-left: 3px solid var(--warning); }
.alert-item.out { border-left-color: var(--danger); background: #FFF5F5; }
.alert-name { font-weight: 600; font-size: 13px; }
.alert-qty { font-size: 20px; font-weight: 700; color: var(--danger); }

/* 同期ページ */
.sync-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.sync-card { text-align: center; }
.sync-platform-header { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; border-radius: 8px; margin-bottom: 16px; color: white; }
.sync-platform-header.amazon { background: linear-gradient(135deg, #FF9900, #FF6600); }
.sync-platform-header.yahoo { background: linear-gradient(135deg, #FF0033, #CC0000); }
.sync-platform-header.qoo10 { background: linear-gradient(135deg, #E31C5F, #B5164F); }
.sync-platform-icon { font-size: 24px; }
.sync-platform-header h3 { color: white; font-size: 16px; }
.sync-status { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--primary); }
.sync-info { font-size: 12px; color: var(--gray-600); margin-bottom: 16px; }

/* カウントバッジ */
.count-badge { display: inline-block; background: var(--primary); color: white; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 8px; font-weight: 400; }

/* モーダル */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: white; border-radius: 12px; width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-600); }
.modal-body { padding: 24px; }

/* フォーム */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
  border: 1px solid var(--gray-200); border-radius: 6px; padding: 8px 12px; font-size: 13px; outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--primary-light); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; border-top: 1px solid var(--gray-200); padding-top: 16px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--gray-800); color: white; padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 9999; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ======== トンネルURL表示バナー ======== */
.tunnel-banner {
  background: #0f4c81;
  color: white;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.tunnel-banner .tunnel-label { color: rgba(255,255,255,0.75); white-space: nowrap; }
.tunnel-banner .tunnel-url {
  font-weight: 700; color: #7dd3fc; word-break: break-all;
  cursor: pointer; text-decoration: underline;
}
.tunnel-banner .tunnel-copy {
  background: rgba(255,255,255,0.15); border: none; color: white;
  border-radius: 4px; padding: 3px 10px; font-size: 11px; cursor: pointer;
  white-space: nowrap;
}
.tunnel-banner .tunnel-copy:hover { background: rgba(255,255,255,0.25); }

/* ======== モバイル対応 ======== */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .section-grid { grid-template-columns: 1fr; }
  .sync-grid { grid-template-columns: 1fr; }
}

/* スマホ（768px以下）*/
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .layout { flex-direction: column; height: auto; min-height: 100vh; overflow: auto; }

  /* ハンバーガーメニュー表示 */
  .hamburger-btn {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 38px; height: 38px; border: none; background: transparent;
    font-size: 22px; cursor: pointer; color: var(--primary);
  }

  /* サイドバーをドロワー化 */
  .sidebar {
    position: fixed; top: 0; left: -260px; width: 260px; height: 100vh;
    z-index: 500; transition: left 0.3s ease; overflow-y: auto;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 499;
  }
  .sidebar-overlay.visible { display: block; }

  /* メインコンテンツ */
  .main-content { flex: 1; overflow: visible; }

  /* トップバー */
  .top-bar { padding: 10px 12px; gap: 6px; }
  .top-bar h1 { font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { gap: 6px; flex-shrink: 0; }
  .last-updated { display: none; }
  .top-actions .btn { padding: 6px 10px; font-size: 11px; gap: 3px; }

  /* ページ */
  .page { padding: 10px; }

  /* KPIグリッド */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
  .kpi-card { padding: 10px 12px; gap: 8px; border-left-width: 3px; }
  .kpi-icon { font-size: 20px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }

  /* カード - テーブルの横スクロール対応 */
  .card { padding: 12px; margin-bottom: 10px; overflow-x: auto; }
  .card-title { font-size: 13px; margin-bottom: 10px; }
  .card-header-row { margin-bottom: 10px; }

  /* テーブル横スクロール */
  .data-table { min-width: 500px; font-size: 12px; }
  .data-table th { padding: 8px 8px; font-size: 11px; }
  .data-table td { padding: 8px 8px; font-size: 12px; }

  /* フィルターバー - 縦積みで全幅 */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 12px; }
  .filter-group { width: 100%; display: flex; align-items: center; gap: 8px; }
  .filter-group label { width: 80px; flex-shrink: 0; font-size: 12px; }
  .filter-group select { flex: 1; min-width: 0; }
  .search-input { width: 100%; }
  /* アクションボタン行（margin-left:autoの上書き） */
  .filter-bar > .filter-group:last-child { margin-left: 0 !important; justify-content: flex-start; }
  .filter-bar > div[style*="margin-left"] { margin-left: 0 !important; }

  /* ボタン */
  .btn { padding: 8px 12px; font-size: 12px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }

  /* モーダル */
  .modal-box { width: 96vw; max-height: 92vh; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 14px 16px; }
  .form-grid { grid-template-columns: 1fr; }

  /* セクショングリッド */
  .section-grid { grid-template-columns: 1fr; gap: 10px; }
  .sync-grid { grid-template-columns: 1fr; gap: 10px; }

  /* 同期ページ */
  .sync-card { padding: 14px; }

  /* トースト */
  .toast { bottom: 12px; left: 10px; right: 10px; text-align: center; }

  /* トンネルバナー */
  .tunnel-banner { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }

  /* Amazon広告ページ */
  #page-ads > div:first-child { flex-wrap: wrap; gap: 6px; }
  #ads-last-updated { font-size: 11px; width: 100%; }

  /* 出荷アラートバー */
  #tracking-alert { flex-wrap: wrap; gap: 8px; }
  #tracking-alert button { margin-left: 0 !important; width: 100%; justify-content: center; }

  /* 在庫ページのボタン行 */
  #page-inventory > div[style*="display:flex"] { gap: 8px; }
  #page-inventory > div[style*="display:flex"] .btn { flex: 1; justify-content: center; }
}

/* 超小型スマホ（480px以下）*/
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .kpi-card { padding: 8px 10px; gap: 6px; }
  .kpi-icon { font-size: 18px; }
  .kpi-value { font-size: 17px; }
  .kpi-label { font-size: 10px; }

  .top-bar h1 { font-size: 14px; }
  .top-actions .btn { padding: 5px 8px; font-size: 10px; }

  .page { padding: 8px; }
  .card { padding: 10px; }
  .data-table { font-size: 11px; }
  .data-table th, .data-table td { padding: 6px 6px; }

  /* 広告ページKPIは2列 */
  #page-ads > div[style*="grid-template-columns:repeat(4"] { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  #page-ads > div[style*="grid-template-columns:repeat(4"] > div { padding: 12px !important; }
  #page-ads > div[style*="grid-template-columns:repeat(4"] > div > div[style*="font-size:26px"] { font-size: 20px !important; }
  #page-ads > div[style*="grid-template-columns:repeat(4"] > div > div > div[style*="font-size:20px"] { font-size: 16px !important; }
}

/* ハンバーガーボタン（デスクトップでは非表示）*/
.hamburger-btn { display: none; }

/* ===== BtoB・クレーム固有スタイル ===== */

/* BtoB明細テーブル */
.btob-items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.btob-items-table th { background: var(--gray-50); padding: 8px 6px; text-align: left; font-weight: 600; color: var(--gray-600); border-bottom: 2px solid var(--gray-200); }
.btob-items-table td { padding: 8px 6px; border-bottom: 1px solid var(--gray-200); vertical-align: middle; }
.btob-item-row { background: white; }
.btob-item-row:hover { background: var(--primary-bg); }

/* クレームバッジ */
.claim-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.claim-badge.pending { background: #FFF3CD; color: #856404; }
.claim-badge.processing { background: #CCE5FF; color: #004085; }
.claim-badge.done { background: #D4EDDA; color: #155724; }

/* ===== 新機能ページ共通 ===== */
.page-actions { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-actions .btn { white-space: nowrap; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 13px; box-sizing: border-box; }
.form-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }

/* スマホでの新ページ対応 */
@media (max-width: 768px) {
  .page-actions { gap: 8px; }
  .page-actions .btn { flex: 1; min-width: 0; justify-content: center; font-size: 11px; padding: 8px 6px; }

  /* 仕入フォーム */
  .pur-item-row { grid-template-columns: 1fr 1fr !important; }

  /* レポートKPI */
  #report-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  #page-reports select { width: 100%; }

  /* 見積・請求 */
  #invoice-search { width: 100% !important; }
}
@media (max-width: 480px) {
  .page-actions .btn { font-size: 10px; padding: 6px 4px; }
}

/* ===== ウィザードスタイル ===== */
.wizard-step-bar.active { background: #4f46e5 !important; }
.wizard-channel-card:hover { border-color: #a5b4fc !important; background: #fafafe; }
#setup-wizard-overlay { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== ダッシュボード下段KPI ===== */
.kpi-sub { font-size: 11px; margin-top: 2px; }

/* ===== テナント管理 ===== */
.tenant-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -2px;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.tenant-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tenant-tab:hover { color: var(--primary); }
.tenant-tab-panel { animation: fadeIn 0.2s ease; }

#tenant-create-modal > div,
#user-create-modal > div {
  animation: fadeIn 0.2s ease;
}
