/* ──────────────────────────────────────────────────────
   MAMORU — 品質コンプライアンスAI スタイルシート
   ────────────────────────────────────────────────────── */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-accent: #7c3aed;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

/* ──── ヘッダー ──── */
.header {
  background: linear-gradient(90deg, #1e40af 0%, #2563eb 50%, #7c3aed 100%);
  color: white;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.header h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.header h1 .header-sub {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.75;
  letter-spacing: 0;
  margin-left: 8px;
  vertical-align: middle;
}

.header nav {
  display: flex;
  gap: 8px;
}

.header nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: background 0.2s;
}

.header nav a:hover,
.header nav a.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* ──── コンテナ ──── */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ──── カード ──── */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--gray-700);
}

/* ──── 統計カード ──── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ──── テーブル ──── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--gray-100);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
}

tbody tr:hover {
  background: var(--gray-50);
  cursor: pointer;
}

/* ──── バッジ ──── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-critical { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge-high { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.badge-medium { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.badge-low { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.badge-ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-ng { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge-partial { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.badge-none { background: var(--gray-100); color: var(--gray-500); border: 1px solid var(--gray-200); }

/* ──── ボタン ──── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-primary:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
}

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover { background: var(--gray-50); }

.btn-ok { background: #16a34a; color: white; }
.btn-ok:hover { background: #15803d; }
.btn-ng { background: #dc2626; color: white; }
.btn-ng:hover { background: #b91c1c; }
.btn-partial { background: #f59e0b; color: white; }
.btn-partial:hover { background: #d97706; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ──── フォーム ──── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

textarea {
  width: 100%;
  min-height: 180px;
  padding: 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ──── ファイルアップロード ──── */
.file-drop {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--gray-500);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
}

.file-drop input[type="file"] {
  display: none;
}

.file-drop .file-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.file-drop .file-name {
  font-weight: 500;
  color: var(--gray-900);
  margin-top: 8px;
}

/* ──── プログレス ──── */
.progress-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.progress-overlay.active {
  display: flex;
}

.progress-box {
  background: white;
  border-radius: var(--radius);
  padding: 32px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ──── 指摘カード ──── */
.finding-card {
  border-left: 4px solid var(--gray-300);
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--gray-50);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.finding-card.severity-critical { border-left-color: #dc2626; background: #fef2f2; }
.finding-card.severity-high { border-left-color: #ea580c; background: #fff7ed; }
.finding-card.severity-medium { border-left-color: #eab308; background: #fefce8; }
.finding-card.severity-low { border-left-color: var(--gray-400); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.finding-type {
  font-weight: 600;
  font-size: 13px;
}

.finding-detail {
  font-size: 13px;
  color: var(--gray-700);
  line-height: 1.7;
}

.finding-detail dt {
  font-weight: 600;
  color: var(--gray-500);
  font-size: 12px;
  margin-top: 6px;
}

.finding-detail dd {
  margin-left: 0;
}

/* ──── 指摘単位フィードバックボタン ──── */
.ff-row {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

.ff-btn {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--gray-300);
  background: white;
  cursor: pointer;
  color: var(--gray-500);
  transition: all 0.15s;
}

.ff-btn:hover { border-color: var(--gray-500); color: var(--gray-700); }

.ff-btn.ff-correct.ff-active   { border-color: #16a34a; background: #f0fdf4; color: #16a34a; font-weight: 600; }
.ff-btn.ff-false_positive.ff-active { border-color: #dc2626; background: #fef2f2; color: #dc2626; font-weight: 600; }
.ff-btn.ff-false_negative.ff-active { border-color: #d97706; background: #fffbeb; color: #d97706; font-weight: 600; }

/* ──── フィードバック ──── */
.feedback-section {
  border-top: 1px solid var(--gray-200);
  padding-top: 16px;
  margin-top: 16px;
}

.feedback-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-comment {
  width: 100%;
  min-height: 60px;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 8px;
}

/* ──── ユーティリティ ──── */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--gray-500);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ──── タブ ──── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 14px;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s;
}

.tab:hover { color: var(--gray-700); }

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 500;
}

/* ──── レスポンシブ ──── */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .container {
    padding: 0 12px;
    margin: 12px auto;
  }
}
