/* ==========================================================================
   ExpLog (SinqConsent) 共通スタイル
   ブランド方針 02_共通ブランド方針.md 準拠
   Primary: #1c3464 (ネイビー)
   Accent:  #5C7EA8 (中立ブルーグレー・仮置き・--accent 変数で後差替可)
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }

:root {
  --primary:       #1c3464;
  --primary-dark:  #14254a;
  --primary-light: #e3eaf5;

  /* ExpLog Accent: 中立ブルーグレー（仮置き・オーナー後確定で差替可） */
  --accent:        #5C7EA8;
  --accent-light:  #e8eff7;
  --accent-hover:  #4a6a91;

  color-scheme: light;
  --text-primary:   #111827;
  --text-secondary: #374151;
  --text-tertiary:  #6b7280;
  --text-muted:     #9ca3af;
  --text-inverse:   #ffffff;

  --bg-app:    #f4f5f7;
  --bg-card:   #ffffff;
  --bg-sidebar:#ffffff;
  --bg-hover:  #f3f4f6;
  --bg-subtle: #fafbfc;

  --border:        #e2e5ea;
  --border-strong: #c9ced6;

  --success: #047857;
  --warning: #b45309;
  --danger:  #b91c1c;
  --info:    #1e40af;

  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 6px 16px rgba(0,0,0,.08);

  --sidebar-width: 232px;
}

body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN","Hiragino Sans","Yu Gothic UI",
    "Yu Gothic Medium","Yu Gothic","Meiryo",sans-serif;
  color: var(--text-primary);
  background: var(--bg-app);
  line-height: 1.85;
  font-size: 15px;
  letter-spacing: 0.04em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* レイアウト */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main { padding: 24px 32px 40px; min-width: 0; }

/* ブランド */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
  font-family: Georgia, 'Times New Roman', serif;
}
.brand-name  { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.brand-tag   { font-size: 10.5px; color: var(--text-tertiary); margin-top: 1px; }

/* ナビ */
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; min-height: 44px;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; user-select: none; line-height: 1.4;
}
.nav-item:hover { background: var(--bg-hover); text-decoration: none; color: var(--text-primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; color: var(--text-tertiary); }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-section {
  font-size: 10.5px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 18px 12px 6px; font-weight: 600;
}

/* ページヘッダー */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 16px;
}
.page-title { font-size: 21px; font-weight: 600; color: var(--text-primary); margin: 0; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }

/* ボタン */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 4px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  transition: background .12s, border-color .12s;
  text-decoration: none; letter-spacing: .02em;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); text-decoration: none; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #9b1616; text-decoration: none; color: #fff; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 10px 20px; font-size: 14px; }
.btn-xl  { padding: 14px 28px; font-size: 16px; font-weight: 700; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* カード */
.card {
  background: var(--bg-card);
  border-radius: 6px; border: 1px solid var(--border);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.card-title { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; color: var(--text-primary); }

/* バッジ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 3px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  border: 1px solid transparent;
}
.badge-primary  { background: var(--primary-light); color: var(--primary); border-color: #cdd8e8; }
.badge-accent   { background: var(--accent-light);  color: var(--accent);  border-color: #c5d6e8; }
.badge-success  { background: #d1fae5; color: var(--success); border-color: #a7f0c5; }
.badge-warning  { background: #fef3c7; color: var(--warning); border-color: #fde68a; }
.badge-info     { background: #dbeafe; color: var(--info);    border-color: #bfdbfe; }
.badge-neutral  { background: var(--bg-hover); color: var(--text-secondary); border-color: var(--border); }
.badge-danger   { background: #fee2e2; color: var(--danger); border-color: #fecaca; }

/* 入力 */
.input, .textarea, .select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-family: inherit; font-size: 13.5px;
  color: var(--text-primary); background: var(--bg-card); line-height: 1.5;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.textarea { resize: vertical; min-height: 80px; }
.label { display: block; font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.field { margin-bottom: 16px; }
.field-hint { font-size: 14px; color: var(--text-tertiary); margin-top: 4px; }

/* グリッド */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
  .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; }
}

/* 統計カード */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 6px; padding: 14px 16px;
}
.stat-label { font-size: 14px; color: var(--text-secondary); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.stat-sub   { font-size: 14px; color: var(--text-tertiary); margin-top: 3px; }

/* セクション見出し */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.section-header h2, .section-header h3 {
  margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-primary);
}

/* テーブル */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { background: var(--bg-subtle); padding: 9px 12px; text-align: left; font-size: 12px; color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-hover); }

/* 確認ダイアログ共通 */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.confirm-box {
  background: #fff; border-radius: 12px; padding: 32px;
  max-width: 460px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.confirm-title { font-size: 17px; font-weight: 700; margin: 0 0 12px; }
.confirm-msg   { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* クォータ警告 */
.quota-warn-80  { background: #fef3c7; border: 1px solid #fde68a; border-radius: 6px; padding: 10px 14px; font-size: 13px; color: #92400e; }
.quota-warn-95  { background: #fee2e2; border: 1px solid #fecaca; border-radius: 6px; padding: 10px 14px; font-size: 13px; color: #7f1d1d; }
.quota-warn-100 { background: #fef2f2; border: 2px solid var(--danger); border-radius: 6px; padding: 14px 16px; font-size: 14px; font-weight: 600; color: var(--danger); }

/* 状態バッジ（送信一覧） */
.status-badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 3px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status-draft     { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.status-sent      { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.status-viewed    { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.status-agreed    { background: #d1fae5; color: #065f46; border: 1px solid #a7f0c5; }
.status-revoked   { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; }
.status-expired   { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }

/* ウィザードステップ */
.wizard-steps {
  display: flex; align-items: center; gap: 0;
  margin-bottom: 24px;
}
.wizard-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-tertiary); font-weight: 500;
}
.wizard-step.active  { color: var(--primary); font-weight: 600; }
.wizard-step.done    { color: var(--success); }
.wizard-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg-hover); border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.wizard-step.active  .wizard-step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.wizard-step.done    .wizard-step-num { background: var(--success); border-color: var(--success); color: #fff; }
.wizard-sep { flex: 1; height: 1px; background: var(--border); margin: 0 8px; max-width: 40px; }

/* プランカード（O-5） */
.plan-card {
  border: 2px solid var(--border);
  border-radius: 10px; padding: 20px 22px;
  background: #fff;
  transition: border-color .15s;
}
.plan-card.recommended {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.plan-name  { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.plan-price { font-size: 22px; font-weight: 700; color: var(--primary); margin: 8px 0; }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--text-tertiary); }
.plan-desc  { font-size: 14px; color: var(--text-secondary); margin-bottom: 14px; line-height: 1.6; }
.plan-features { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.plan-features li { padding: 4px 0; color: var(--text-secondary); display: flex; align-items: flex-start; gap: 6px; }
.plan-features li::before { content: "✓"; color: var(--success); font-weight: 700; flex-shrink: 0; }
.plan-features li.disabled { color: var(--text-muted); }
.plan-features li.disabled::before { content: "—"; color: var(--text-muted); }

/* モバイル */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 12px; left: 12px; z-index: 1000;
  width: 44px; height: 44px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  font-size: 22px; cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.mobile-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 998;
}
.mobile-overlay.active { display: block; }

@media (max-width: 768px) {
  .app { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: 80%; max-width: 320px;
    transform: translateX(-100%); transition: transform .3s ease;
    z-index: 999; box-shadow: 4px 0 16px rgba(0,0,0,.1);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: inline-flex; }
  .main { padding: 56px 16px 32px; }
  button, .nav-item { min-height: 44px; }
  a.btn, a.btn-primary, a.btn-secondary, a.btn-ghost, a.btn-accent {
    min-height: 44px; padding: 12px 18px; font-size: 15px;
  }
  a.btn-accent { min-height: 48px; }
  input[type="text"],input[type="email"],input[type="password"],textarea,select {
    font-size: 16px !important; min-height: 44px;
  }
  .page-title { font-size: 19px; }
  /* 高-2: dashboardテーブルをカード型にフォールバック */
  .delivery-table { display: block; }
  .delivery-table thead { display: none; }
  .delivery-table tbody, .delivery-table tr, .delivery-table td { display: block; }
  .delivery-table tr {
    background: #fff; border: 1px solid var(--border);
    border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
  }
  .delivery-table tr:hover td { background: transparent; }
  .delivery-table td {
    padding: 4px 0; border-bottom: none;
    display: flex; align-items: flex-start; gap: 8px; font-size: 13.5px;
  }
  .delivery-table td::before {
    content: attr(data-label);
    font-size: 11px; font-weight: 600; color: var(--text-tertiary);
    min-width: 64px; flex-shrink: 0; padding-top: 2px;
  }
  .delivery-table td:first-child {
    font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border);
    padding-bottom: 8px; margin-bottom: 4px;
  }
  .delivery-table td:first-child::before { display: none; }
  .delivery-table td:last-child a.btn {
    display: block; width: 100%; text-align: center;
    min-height: 44px; padding: 12px 18px; font-size: 14px; margin-top: 4px;
  }
  .main table:not(.delivery-table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ユーティリティ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-sm  { font-size: 12.5px; }
.text-xs  { font-size: 11px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary  { color: var(--text-tertiary); }
.fw-600  { font-weight: 600; }
.fw-700  { font-weight: 700; }
.text-center { text-align: center; }
.text-right  { text-align: right; }

/* アクセシビリティ */
button:focus-visible, a:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
