/* =============================================
   Bカートレビューアプリ 管理画面 CSS
   Design System v2 — Noto Sans JP / Sidebar Dark
   ============================================= */

/* --- CSS変数 --- */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-hover: #15803d;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fee2e2;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e6e8ee;
  --border-strong: #d4d7df;

  --sidebar-bg: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-text-muted: #64748b;
  --sidebar-hover: rgba(255,255,255,0.05);
  --sidebar-active-bg: rgba(96,165,250,0.12);
  --sidebar-active-text: #ffffff;
  --sidebar-width: 244px;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 16px rgba(15,23,42,0.06);

  --font: 'Noto Sans JP', sans-serif;
  --transition: 150ms ease;
}

/* --- リセット・ベース --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'palt' 1;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

ul { list-style: none; }

/* =============================================
   ログイン画面
   ============================================= */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-logo-icon {
  font-size: 28px;
  color: var(--primary);
}

.login-logo h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.auth-tab.active {
  background: var(--primary);
  color: #fff;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* =============================================
   アプリレイアウト
   ============================================= */
#app-layout {
  display: flex;
  min-height: 100vh;
}

/* =============================================
   サイドバー
   ============================================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sidebar-logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.sidebar-subtitle {
  font-size: 0.6875rem;
  color: var(--sidebar-text-muted);
  display: block;
  margin-top: 3px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav li {
  padding: 0 10px;
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--warning);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

/* サイドバーCTA — サブトル */
.sidebar-cta {
  margin: 12px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 14px;
}

.cta-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 4px;
}

.cta-text {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  background: transparent;
  color: #93c5fd;
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition);
}

.cta-button::after {
  content: '\2192';
  transition: transform var(--transition);
}

.cta-button:hover {
  color: #fff;
  text-decoration: none;
}

.cta-button:hover::after {
  transform: translateX(2px);
}

/* サイドバーフッター */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-email {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
  word-break: break-all;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--sidebar-text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: center;
}

.btn-logout:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* =============================================
   メインコンテンツ
   ============================================= */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* トップバー（モバイル用） */
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.topbar-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.user-email-mobile {
  font-size: 0.75rem;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* モバイルオーバーレイ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

/* グローバルアラート */
.global-alert {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

/* =============================================
   ページ共通
   ============================================= */
.page {
  padding: 32px 32px 60px;
  max-width: 1180px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.page-header-title-group {
  flex: 1;
  min-width: 0;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 6px;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* =============================================
   カード
   ============================================= */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.card-body {
  padding: 20px 22px;
}

/* テキストリンク（「すべて見る」など） */
.card-action-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  transition: color var(--transition), gap var(--transition);
}

.card-action-link::after {
  content: '\2192';
  transition: transform var(--transition);
}

.card-action-link:hover {
  color: var(--primary-hover);
  text-decoration: none;
}

.card-action-link:hover::after {
  transform: translateX(2px);
}

/* =============================================
   ボタン
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  text-decoration: none;
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  text-decoration: none;
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  text-decoration: none;
  color: #fff;
}

.btn-danger.btn-outline {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger.btn-outline:hover:not(:disabled) {
  background: var(--danger-light);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8125rem;
}

.btn-full {
  width: 100%;
}

/* =============================================
   フォーム
   ============================================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* カラーピッカー */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-picker {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
}

.color-value {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-family: monospace;
}

/* トグルスイッチ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* =============================================
   アラート / バッジ
   ============================================= */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(220,38,38,0.2);
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(22,163,74,0.2);
}

.alert-warning {
  background: var(--warning-light);
  color: #92400e;
  border: 1px solid rgba(245,158,11,0.2);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: var(--warning-light);
  color: #92400e;
}

.badge-approved {
  background: var(--success-light);
  color: var(--success);
}

.badge-rejected {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-trialing {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-active {
  background: var(--success-light);
  color: var(--success);
}

.badge-past-due {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-canceled {
  background: #f1f5f9;
  color: var(--text-secondary);
}

/* 設置済みバッジ */
.badge-installed {
  background: var(--success-light);
  color: var(--success);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-not-installed {
  background: var(--warning-light);
  color: #92400e;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 600;
}

/* =============================================
   ダッシュボード — 統計カード
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--border-strong);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.stat-icon-warning { background: var(--warning-light); color: #b45309; }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-danger  { background: var(--danger-light);  color: var(--danger); }
.stat-icon-primary { background: var(--primary-light); color: var(--primary); }

.stat-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 2.625rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-feature-settings: 'tnum' 1;
}

.stat-trend {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* 使用状況バナー（無料プラン上限） */
.usage-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px 14px;
  margin-bottom: 20px;
  transition: border-color var(--transition), background var(--transition);
}

.usage-banner-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.usage-banner-text {
  flex: 1;
  min-width: 0;
}

.usage-banner-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.usage-banner-sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.usage-banner-progress {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.usage-banner-progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--success);
  transition: width 400ms ease, background var(--transition);
}

.usage-banner-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-feature-settings: 'tnum' 1;
}

/* 状態別: 安全（緑） */
.usage-banner.usage-ok {
  border-color: var(--border);
}
.usage-banner.usage-ok .usage-banner-progress-fill {
  background: var(--success);
}

/* 状態別: 注意（黄） */
.usage-banner.usage-warning {
  background: #fffbeb;
  border-color: #fde68a;
}
.usage-banner.usage-warning .usage-banner-title {
  color: #92400e;
}
.usage-banner.usage-warning .usage-banner-progress-fill {
  background: var(--warning);
}

/* 状態別: 上限到達（赤） */
.usage-banner.usage-limit {
  background: #fef2f2;
  border-color: #fecaca;
}
.usage-banner.usage-limit .usage-banner-title {
  color: #991b1b;
}
.usage-banner.usage-limit .usage-banner-sub {
  color: #b91c1c;
}
.usage-banner.usage-limit .usage-banner-progress-fill {
  background: var(--danger);
}

/* アクションバナー（承認待ち通知など） */
.action-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.action-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}

.action-banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fef3c7;
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.action-banner-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.action-banner-title {
  font-size: 1rem;
  font-weight: 700;
  color: #92400e;
  line-height: 1.4;
}

.action-banner-text {
  font-size: 0.8125rem;
  color: #b45309;
  margin-top: 3px;
}

/* マイルストーンバナー — トーンダウン */
.milestone-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--success-light);
  color: #14532d;
  border: 1px solid rgba(22,163,74,0.18);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.milestone-banner p {
  font-size: 0.9375rem;
  font-weight: 600;
}

.milestone-banner .btn {
  background: var(--success);
  color: #fff;
  flex-shrink: 0;
}

.milestone-banner .btn:hover:not(:disabled) {
  background: var(--success-hover);
  color: #fff;
}

/* ダッシュボード 2カラム（最新レビュー＋サマリー） */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
  align-items: start;
}

.dashboard-grid .card {
  margin-bottom: 0;
}

/* 評価分布バー */
.rating-distribution {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rating-row {
  display: grid;
  grid-template-columns: 44px 1fr 36px;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.rating-row-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text);
  font-weight: 600;
  font-feature-settings: 'tnum' 1;
}

.rating-row-label svg,
.rating-row-label span {
  color: var(--warning);
}

.rating-row-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.rating-row-bar-fill {
  height: 100%;
  background: var(--warning);
  border-radius: 4px;
  transition: width 400ms ease;
}

.rating-row-count {
  text-align: right;
  color: var(--text);
  font-weight: 600;
  font-feature-settings: 'tnum' 1;
}

/* ダッシュボード — 最近のレビュー */
.recent-review-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.recent-review-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.recent-review-item:first-child {
  padding-top: 0;
}

.review-stars {
  display: flex;
  gap: 1px;
  color: var(--warning);
  font-size: 15px;
  flex-shrink: 0;
  line-height: 1;
}

.review-star-empty {
  color: #e2e8f0;
}

.review-meta {
  flex: 1;
  min-width: 0;
}

.review-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.review-author {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.review-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.review-body {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.65;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.review-product {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* クイックリンク */
.quick-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: -6px -8px;
}

.quick-links li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition);
}

.quick-links li a:hover {
  background: var(--bg);
  text-decoration: none;
}

.quick-link-arrow {
  color: var(--text-muted);
  font-size: 0.9375rem;
  transition: transform var(--transition), color var(--transition);
}

.quick-links li a:hover .quick-link-arrow {
  color: var(--primary);
  transform: translateX(2px);
}

/* 空状態CTA */
.empty-cta-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-strong);
  text-align: center;
  padding: 40px 32px;
  margin-bottom: 20px;
}

.empty-cta-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-cta-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 20px;
}

/* =============================================
   レビュー管理
   ============================================= */
.reviews-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.filter-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.search-box {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-box .form-input {
  width: 220px;
}

/* レビューアイテム */
.review-item {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.review-item:hover {
  box-shadow: var(--shadow-md);
}

.review-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.review-item-info {
  flex: 1;
  min-width: 0;
}

.review-item-rating {
  display: flex;
  gap: 2px;
  color: var(--warning);
  font-size: 15px;
  margin-bottom: 6px;
}

.review-item-author-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.review-item-author {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.review-item-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.review-item-product {
  font-size: 0.8125rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-item-product-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-family: 'Courier New', Courier, monospace;
}

.review-item-body {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.7;
}

.review-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* 返信エリア */
.review-reply-area {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
}

.review-reply-existing {
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
}

.review-reply-existing strong {
  color: var(--primary);
  display: block;
  margin-bottom: 4px;
  font-size: 0.8125rem;
}

.review-reply-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-reply-form .form-textarea {
  min-height: 70px;
}

.review-reply-submit {
  align-self: flex-end;
}

/* ページネーション */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
  padding: 8px 0 20px;
}

.page-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
  min-width: 100px;
  text-align: center;
}

/* 空状態 */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

/* ローディング */
.loading-state {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* =============================================
   設定
   ============================================= */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.settings-card {
  margin-bottom: 0;
}

.settings-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ウィジェットプレビュー */
.widget-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
}

.preview-stars {
  display: flex;
  gap: 2px;
  margin-bottom: 8px;
}

.star {
  font-size: 18px;
  color: var(--border);
}

.star.filled {
  color: var(--warning);
}

.preview-text {
  font-size: 0.9375rem;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.65;
}

.preview-author {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.preview-form-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.preview-form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.preview-input-mock {
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 8px;
}

.preview-btn-mock {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
}

/* OAuth状態 */
.oauth-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.oauth-connected {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--success);
  font-weight: 500;
}

.oauth-disconnected {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 許可ドメイン管理（widget用） */
.origin-add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.origin-add-form .form-input {
  flex: 1;
}

.origin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.origin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--transition);
}

.origin-row.disabled {
  background: var(--bg);
  opacity: 0.6;
}

.origin-row-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.origin-row-text {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  color: var(--text);
  word-break: break-all;
  font-weight: 500;
}

.origin-row-badge {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.origin-row-badge.badge-auto {
  background: var(--primary-light);
  color: var(--primary);
}

.origin-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.origin-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* 設定保存ボタン */
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}

/* 設定画面フッターCTA */
.settings-cta-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  flex-wrap: wrap;
}

.settings-cta-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.settings-cta-text {
  font-size: 0.875rem;
  color: rgba(255,255,255,0.7);
}

/* =============================================
   プラン・お支払い
   ============================================= */
/* ビリングステータス */
.billing-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.billing-plan-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.billing-trial-info {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.billing-trial-days {
  font-weight: 700;
  color: var(--primary);
}

/* プランセクション */
.plan-toggle-section {
  margin-bottom: 20px;
}

.plan-toggle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.billing-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.billing-toggle-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.billing-toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.badge-save {
  background: var(--success);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.billing-toggle-btn.active .badge-save {
  background: rgba(255,255,255,0.25);
}

/* プランカード */
.plan-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.plan-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  padding: 28px 24px;
  position: relative;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.plan-card-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.08);
}

.plan-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.plan-badge-popular {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
}

.plan-price {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 6px;
}

.plan-amount {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.plan-unit {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.plan-price-note {
  font-size: 0.8125rem;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 6px;
}

.plan-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.plan-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.plan-trial-note {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
}

.plan-trial-note strong {
  color: var(--primary);
  font-weight: 700;
}

.plan-features li {
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* お支払い管理 */
.billing-manage-card {}

.billing-manage-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.billing-manage-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  max-width: 480px;
}

.billing-manage-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* =============================================
   埋め込みコード
   ============================================= */
.code-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.7;
}

.code-block {
  background: #1e293b;
  color: #e2e8f0;
  padding: 20px;
  border-radius: var(--radius);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
}

/* 設置手順 */
.install-steps {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.install-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.install-step:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.install-step:first-child {
  padding-top: 0;
}

.step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* 設置状態 */
.install-status-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.install-status-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* =============================================
   トラブルシュート枠（設定ページ末尾）
   ============================================= */
.troubleshoot-card {
  margin-top: 16px;
}

.troubleshoot-card[open] .troubleshoot-arrow {
  transform: rotate(90deg);
}

.troubleshoot-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.troubleshoot-summary::-webkit-details-marker {
  display: none;
}

.troubleshoot-summary:hover {
  color: var(--text-primary);
}

.troubleshoot-title {
  font-weight: 500;
}

.troubleshoot-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 0.8rem;
  color: var(--text-tertiary, #94a3b8);
}

/* =============================================
   トースト通知
   ============================================= */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  animation: toastIn 200ms ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   チェックボックス（一括選択）
   ============================================= */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* =============================================
   レスポンシブ（768px以下）
   ============================================= */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .topbar {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page {
    padding: 20px 16px 40px;
  }

  .page-title {
    font-size: 1.375rem;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .action-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .billing-manage-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-box .form-input {
    width: 160px;
  }

  .reviews-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .plan-toggle-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .settings-cta-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px 14px;
    gap: 10px;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .filter-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .filter-tab {
    flex: 1;
    text-align: center;
    padding: 6px 6px;
    font-size: 0.75rem;
  }

  .login-card {
    padding: 28px 20px;
  }
}
