/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1B3A6B;
  --navy-dark: #122850;
  --navy-light: #2a4f8a;
  --accent: #4A9EFF;
  --accent-light: #7bbdff;
  --white: #ffffff;
  --bg: #f4f7fb;
  --text: #1a1a2a;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --sidebar-width: 220px;
}

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo h1 {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.4;
}
.sidebar-logo .logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 16px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.sidebar-nav a.active {
  background: rgba(74,158,255,0.15);
  color: var(--white);
  border-left-color: var(--accent);
}
.sidebar-nav a .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}
.sidebar-footer .user-name {
  color: var(--white);
  font-weight: 600;
}
.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 11px;
}
.sidebar-footer a:hover { color: var(--white); }

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}
.page-header .header-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-body {
  padding: 24px 28px;
  flex: 1;
}

/* ===== Cards ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Stat Cards ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  margin-top: 4px;
}
.stat-card .stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
  line-height: 1;
}
.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: var(--navy-light); color: var(--white); }
.btn-accent {
  background: var(--accent);
  color: var(--white);
}
.btn-accent:hover { background: var(--accent-light); color: var(--white); }
.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--navy);
}
.btn-outline:hover { background: var(--navy); color: var(--white); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 11px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ===== Badge / Status ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-todo { background: #f1f5f9; color: var(--text-muted); }
.badge-active { background: #dbeafe; color: #1d4ed8; }
.badge-done { background: #d1fae5; color: #065f46; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,158,255,0.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}
.login-box {
  background: var(--white);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.login-logo p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 8px;
}
.login-btn:hover { background: var(--navy-light); }

/* ===== Dashboard ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Ranking */
.ranking-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ranking-item:last-child { border-bottom: none; }
.ranking-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ranking-rank.rank-1 { background: #fef3c7; color: #b45309; }
.ranking-rank.rank-2 { background: #f1f5f9; color: #64748b; }
.ranking-rank.rank-3 { background: #fef3c7; color: #92400e; }
.ranking-name { flex: 1; font-weight: 600; font-size: 13px; }
.ranking-count { font-size: 20px; font-weight: 700; color: var(--navy); }
.ranking-unit { font-size: 11px; color: var(--text-muted); }

/* ===== Propose Page ===== */
.propose-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1000px) {
  .propose-layout { grid-template-columns: 1fr; }
}

.phase-output {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.phase-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.phase-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.phase-tab.active {
  color: var(--navy);
  border-bottom-color: var(--accent);
  background: var(--white);
}
.phase-tab:hover { color: var(--navy); }

.phase-content {
  padding: 20px;
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
}
.phase-content.hidden { display: none; }

.output-text {
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}
.output-text h2, .output-text h3 {
  color: var(--navy);
  font-weight: 700;
  margin: 12px 0 6px;
}

.status-bar {
  background: #f0f9ff;
  border-bottom: 1px solid #bae6fd;
  padding: 8px 14px;
  font-size: 12px;
  color: #0369a1;
  display: none;
}
.status-bar.show { display: block; }

.download-bar {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Manus progress */
.manus-progress {
  display: none;
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin-top: 12px;
}
.manus-progress.show { display: block; }
.progress-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

/* ===== Lead Detail ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.activity-item {
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 8px;
}
.activity-item .activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.activity-type {
  font-size: 11px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.activity-memo { font-size: 13px; color: var(--text); }

/* ===== Alert ===== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #065f46; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ===== Spinner ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Misc ===== */
.text-muted { color: var(--text-muted); }
.text-navy { color: var(--navy); }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ===== Search Bar ===== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input { flex: 1; min-width: 200px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== Info rows ===== */
.info-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  width: 120px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.info-value { flex: 1; }
