/* ======================== CSS Variables ======================== */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-radius: 12px;
}

/* ======================== Reset ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  min-height: 100vh;
  overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font: inherit; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }

/* ======================== Login Screen (Immersive) ======================== */
.login-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 78% 4%, rgba(103, 232, 249, .26), transparent 34%),
    radial-gradient(circle at 18% 82%, rgba(183, 121, 31, .18), transparent 32%),
    linear-gradient(135deg, #0a101d 0%, #101826 30%, #0f2733 60%, #0f172a 100%);
  overflow: hidden;
}
.login-screen.hidden { display: none; }
.login-ambient {
  position: absolute; pointer-events: none;
  filter: blur(60px); opacity: 0.4;
}
.login-ambient-a {
  width: 400px; height: 400px; right: 5vw; top: 5vh;
  background: radial-gradient(circle, rgba(8,145,178,.45), transparent 68%);
  animation: ambientFloat 8s ease-in-out infinite;
}
.login-ambient-b {
  width: 440px; height: 440px; left: 10vw; bottom: -5vh;
  background: radial-gradient(circle, rgba(15,118,110,.28), transparent 70%);
  animation: ambientFloat 10s ease-in-out infinite reverse;
}
@keyframes ambientFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -20px) scale(1.08); }
}
.login-grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.2fr 400px;
  gap: 60px; max-width: 1100px; width: 95%; align-items: center;
}

/* Left: Visual */
.login-visual {
  display: flex; flex-direction: column; gap: 32px;
}
.login-brand {
  display: flex; align-items: center; gap: 16px;
  color: #fff;
}
.login-brand .brand-mark {
  display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 20px; flex-shrink: 0;
  background: linear-gradient(135deg, #67e8f9, #f7d070);
  color: #07111f; font-size: 24px; font-weight: 950;
}
.login-brand h2 { font-size: 28px; margin: 0; letter-spacing: 0.5px; }
.login-brand p { margin: 4px 0 0; color: #7ea3ba; font-size: 14px; }

/* Score Orb */
.login-core {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 360px;
}
.geo-orb {
  position: relative; z-index: 2;
  display: grid; place-items: center;
  width: 200px; height: 200px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff, #67e8f9 20%, #0f766e 64%, #0f172a);
  box-shadow: 0 0 80px rgba(103,232,249,.35), 0 0 160px rgba(103,232,249,.12);
  animation: orbPulse 3s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { box-shadow: 0 0 80px rgba(103,232,249,.35), 0 0 160px rgba(103,232,249,.12); }
  50% { box-shadow: 0 0 110px rgba(103,232,249,.55), 0 0 200px rgba(103,232,249,.2); }
}
.geo-orb-value {
  font-size: 64px; font-weight: 950; color: #07111f; line-height: 1;
}
.geo-orb small { margin-top: -28px; color: #0f172a; font-weight: 900; font-size: 13px; }

.geo-orbit {
  position: absolute; border: 1px solid rgba(103,232,249,.22); border-radius: 50%;
}
.geo-o1 { width: 300px; height: 300px; animation: geoSpin 18s linear infinite; }
.geo-o2 { width: 380px; height: 210px; transform: rotate(-26deg); animation: geoSpin 24s linear infinite reverse; }
@keyframes geoSpin { to { transform: rotate(360deg); } }

.geo-signal {
  position: absolute; z-index: 3;
  padding: 7px 12px; border-radius: 999px;
  color: #dffaff; background: rgba(15,23,42,.75); border: 1px solid rgba(103,232,249,.22);
  font-size: 12px; white-space: nowrap;
  animation: signalFloat 4s ease-in-out infinite;
}
.geo-s1 { top: 40px; right: 80px; animation-delay: 0s; }
.geo-s2 { left: 80px; top: 220px; animation-delay: 1.3s; }
.geo-s3 { right: 90px; bottom: 70px; animation-delay: 2.6s; }
@keyframes signalFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Flow steps */
.login-flow {
  display: flex; align-items: center; gap: 0;
}
.flow-step {
  flex: 1; padding: 14px 10px; border-radius: 16px; text-align: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
  color: #cbd5e1;
}
.flow-step strong { display: block; color: #67e8f9; font-size: 15px; margin-bottom: 4px; }
.flow-step span { font-size: 12px; line-height: 1.5; }
.flow-arrow { color: #3b82f6; font-size: 18px; padding: 0 4px; flex-shrink: 0; }

/* Right: Login Form */
.login-form-side {
  display: flex; flex-direction: column; align-items: center;
}
.login-form-card {
  width: 100%; padding: 42px 36px; border-radius: 20px;
  background: rgba(255,255,255,.05); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 28px 80px rgba(0,0,0,.4);
}
.login-form-card h3 { font-size: 22px; color: #fff; margin-bottom: 6px; }
.login-form-card > p { color: #7ea3ba; font-size: 13px; margin-bottom: 28px; line-height: 1.6; }
.login-form-card .form-group { margin-bottom: 18px; }
.login-form-card .form-group label { color: #94a3b8; font-size: 12px; font-weight: 600; }
.login-form-card .form-group input {
  width: 100%; padding: 13px 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07);
  color: #fff; font-size: 14px; outline: none;
}
.login-form-card .form-group input:focus {
  border-color: #67e8f9; box-shadow: 0 0 0 3px rgba(103,232,249,.15);
}
.login-form-card .btn-primary {
  background: linear-gradient(135deg, #67e8f9, #0891b2);
  padding: 14px; font-size: 15px; margin-top: 4px;
}
.login-form-card .btn-primary:hover {
  transform: translateY(-2px); box-shadow: 0 8px 24px rgba(102,217,239,.3);
}
.login-form-card .error-text { color: #ef4444; margin-top: 14px; }

/* ======================== Login Modal (Old - hidden by default now) ======================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  width: 100%; max-width: 400px; padding: 40px; border-radius: 16px;
  background: #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-head { text-align: center; margin-bottom: 28px; }
.modal-head h2 { font-size: 22px; color: var(--gray-900); }
.modal-head p { margin-top: 6px; color: var(--gray-500); font-size: 13px; }
.form-group { margin-bottom: 18px; min-width: 0; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--gray-700); }
.form-group input,
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--gray-300);
  outline: none;
  font-size: 14px;
  line-height: 1.55;
  color: var(--gray-900);
  background: #fff;
}
.form-group select { min-height: 46px; }
.form-group textarea {
  min-height: 108px;
  resize: vertical;
  overflow: auto;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.company-info-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}
.company-info-grid .form-group { margin-bottom: 12px; }
.company-info-grid textarea { min-height: 120px; }
.company-info-grid .wide-field { grid-column: 1 / -1; }
.research-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.research-source-card {
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  min-width: 0;
}
.research-source-card strong { display: block; margin-bottom: 6px; color: var(--gray-900); }
.research-source-card p { color: var(--gray-600); font-size: 12px; line-height: 1.7; word-break: break-word; }
.error-text { margin-top: 14px; color: var(--danger); font-size: 13px; text-align: center; min-height: 20px; }

/* ======================== App Shell ======================== */
#app { height: 100vh; overflow: hidden; }
#mainLayout { display: flex; height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: 260px; min-width: 260px; height: 100vh;
  background: var(--sidebar-bg); color: #cbd5e1;
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  color: #fff; font-weight: 900; font-size: 18px; flex-shrink: 0;
}
.sidebar-brand strong { display: block; font-size: 15px; color: #f1f5f9; }
.sidebar-brand small { display: block; margin-top: 3px; font-size: 11px; color: #64748b; }

.sidebar-nav { flex: 1; padding: 12px 12px 0; overflow-y: auto; }
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
  font-size: 13px; font-weight: 500; color: #94a3b8;
}
.nav-group-title:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-group-title svg { flex-shrink: 0; opacity: 0.6; }
.nav-group.active .nav-group-title { color: #e2e8f0; }
.nav-group.active .nav-group-title svg { opacity: 1; }
.nav-group-title .arrow { margin-left: auto; transition: transform 0.2s; }
.nav-group.active .arrow { transform: rotate(90deg); }

.nav-group-items {
  overflow: hidden; max-height: 0; transition: max-height 0.25s ease;
  padding-left: 38px;
}
.nav-group.active .nav-group-items { max-height: 760px; }
.nav-group-items a {
  display: block; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; color: #94a3b8; transition: all 0.15s;
}
.nav-group-items a:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-group-items a.active { background: rgba(37,99,235,0.2); color: #60a5fa; font-weight: 600; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(59,130,246,0.3); color: #60a5fa;
  font-weight: 700; font-size: 14px;
}
.user-info strong { font-size: 13px; color: #e2e8f0; display: block; }
.user-info small { font-size: 11px; color: #64748b; display: block; margin-top: 2px; }
.sidebar-footer select {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08);
  color: #cbd5e1; font-size: 12px; outline: none; margin-bottom: 10px;
}
.sidebar-footer select option { background: var(--sidebar-bg); color: #cbd5e1; }
.sidebar-footer .btn-outline { border-color: rgba(255,255,255,0.2); color: #94a3b8; width: 100%; }
.sidebar-footer .btn-outline:hover { background: rgba(255,255,255,0.1); color: #e2e8f0; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 200px; min-width: 200px; }
  .main-content { padding: 20px; }
}
@media (max-width: 640px) {
  #mainLayout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; height: auto; max-height: 200px; }
  .main-content { height: calc(100vh - 200px); }
}

/* ---- Main Content ---- */
.main-content {
  flex: 1; overflow-y: auto; padding: 28px 32px; min-width: 0;
}

/* ======================== Overview Hero ======================== */
.overview-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 360px;
  gap: 28px; padding: 42px 48px; margin-bottom: 20px;
  overflow: hidden; border-radius: 24px; color: #fff;
  background:
    radial-gradient(circle at 80% 24%, rgba(103, 232, 249, .22), transparent 34%),
    linear-gradient(135deg, #101826 0%, #12313c 54%, #0f172a 100%);
  box-shadow: 0 28px 80px rgba(16, 24, 38, .24);
}
.overview-hero:after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(120deg, rgba(0,0,0,.85), transparent 70%);
}
.overview-hero-copy, .overview-hero-visual { position: relative; z-index: 1; }
.eyebrow-badge {
  display: inline-block; margin: 0 0 18px;
  padding: 8px 16px; border-radius: 999px;
  color: #67e8f9; background: rgba(103,232,249,.1);
  border: 1px solid rgba(103,232,249,.26);
  font-weight: 900; font-size: 13px;
}
.overview-hero h1 {
  margin: 0 0 14px; font-size: clamp(28px, 3.2vw, 44px);
  line-height: 1.15; letter-spacing: 0;
}
.overview-hero .overview-hero-copy > p {
  color: #cfdae7; font-size: 14px; line-height: 1.8; max-width: 580px;
}
.hero-mini-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px;
}
.hero-mini-steps > div {
  padding: 12px; border-radius: 14px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
}
.hero-mini-steps strong { display: block; color: #fff; font-size: 13px; margin-bottom: 4px; }
.hero-mini-steps small { color: #94a3b8; font-size: 12px; line-height: 1.5; }

/* Hero Orb */
.overview-hero-visual {
  display: flex; align-items: center; justify-content: center; min-height: 280px;
}
.hero-orb-wrap { position: relative; width: 240px; height: 240px; }
.hero-orb {
  position: relative; z-index: 2;
  display: grid; place-items: center;
  width: 180px; height: 180px; margin: 30px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #fff, #67e8f9 20%, #0f766e 64%, #0f172a);
  box-shadow: 0 0 70px rgba(103,232,249,.35);
  animation: orbPulse 3s ease-in-out infinite;
}
.hero-orb span { font-size: 52px; font-weight: 950; color: #07111f; }
.hero-orb small { margin-top: -22px; color: #0f172a; font-weight: 900; font-size: 12px; }
.hero-orb-ring {
  position: absolute; border: 1px solid rgba(103,232,249,.24); border-radius: 50%;
}
.hero-ring-1 { width: 240px; height: 240px; top: 0; left: 0; animation: geoSpin 18s linear infinite; }
.hero-ring-2 { width: 300px; height: 160px; top: 40px; left: -30px; transform: rotate(-22deg); animation: geoSpin 24s linear infinite reverse; }
.hero-orb-tag {
  position: absolute; z-index: 3;
  padding: 6px 10px; border-radius: 999px;
  color: #dffaff; background: rgba(15,23,42,.75); border: 1px solid rgba(103,232,249,.22);
  font-size: 11px; white-space: nowrap;
}
.tag-top { top: -5px; right: 20px; }
.tag-mid { left: -10px; top: 140px; }
.tag-bot { right: 10px; bottom: 10px; }

/* Flow Visual */
.overview-flow-panel .flow-visual {
  display: grid;
  grid-template-columns: 1fr 36px 1fr 36px 1fr 36px 1fr;
  align-items: stretch; margin-top: 12px;
}
.flow-node {
  padding: 14px 12px; border-radius: 14px;
  background: var(--gray-100); border: 1px solid var(--gray-200); text-align: center;
}
.flow-node.active {
  color: #fff;
  background: linear-gradient(135deg, #0f766e, #0891b2);
}
.flow-node b { color: var(--warning); font-size: 13px; }
.flow-node.active b { color: #f7d070; }
.flow-node strong { display: block; margin: 6px 0 4px; font-size: 13px; }
.flow-node span { color: inherit; opacity: .65; font-size: 11px; display: block; }
.flow-line {
  height: 2px; align-self: center;
  background: linear-gradient(90deg, rgba(15,118,110,.1), rgba(15,118,110,.72), rgba(15,118,110,.1));
}
@media (max-width: 900px) {
  .overview-hero { grid-template-columns: 1fr; padding: 28px; }
  .overview-hero-visual { min-height: 200px; }
  .overview-flow-panel .flow-visual { grid-template-columns: 1fr; gap: 8px; }
  .flow-line { height: 20px; width: 2px; justify-self: center; }
}

/* Page Header */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header p { margin-top: 4px; color: var(--gray-500); font-size: 13px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* Card Grid */
.card-grid { display: grid; gap: 16px; }
.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }
.card-grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1200px) { .card-grid-3, .card-grid-4, .card-grid-5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .card-grid-2, .card-grid-3, .card-grid-4, .card-grid-5 { grid-template-columns: 1fr; } }

/* Stat Card */
.stat-card {
  background: #fff; border-radius: var(--card-radius); padding: 20px;
  box-shadow: var(--card-shadow);
}
.stat-card .stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-card .stat-desc { margin-top: 6px; font-size: 12px; color: var(--gray-400); }

/* Panel */
.panel {
  background: #fff; border-radius: var(--card-radius); padding: 24px;
  box-shadow: var(--card-shadow);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.panel-header h2 { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.panel-header h3 { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.helper, .muted { color: var(--gray-500); font-size: 12px; line-height: 1.6; }
.muted { margin-top: 4px; }

.report-preview-frame {
  display: block;
  width: 100%;
  height: min(760px, calc(100vh - 260px));
  min-height: 520px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 768px) {
  .report-preview-frame {
    height: 620px;
    min-height: 420px;
  }
}

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
table td {
  padding: 12px 14px; border-bottom: 1px solid var(--gray-100);
  font-size: 13px; color: var(--gray-700); vertical-align: middle;
}
table tr:hover td { background: var(--gray-50); }
.path-cell {
  max-width: 420px; color: var(--gray-500); font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px; word-break: break-all;
}

.image-card-preview-grid {
  display: grid; grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 14px;
  margin: 0 0 18px;
}
.image-card-preview {
  display: block; text-decoration: none; color: var(--gray-800);
  border: 1px solid var(--gray-200); border-radius: 10px; overflow: hidden;
  background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.image-card-preview img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; background: var(--gray-50);
}
.image-card-preview div { padding: 10px 12px; display: grid; gap: 4px; }
.image-card-preview strong { font-size: 13px; line-height: 1.35; color: var(--gray-900); }
.image-card-preview span { font-size: 12px; color: var(--gray-500); }
@media (max-width: 1200px) { .image-card-preview-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .image-card-preview-grid { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 0;
  font-size: 13px; font-weight: 600; transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--gray-800); color: #fff; }
.btn-secondary:hover { background: var(--gray-700); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Badges / Tags */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue { background: var(--primary-bg); color: var(--primary); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-amber { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Empty State */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--gray-400);
}
.empty-state h2 {
  font-size: 22px; color: var(--gray-800); margin-bottom: 10px;
}
.empty-state svg { display: block; margin: 0 auto 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* Progress Bar */
.progress-bar {
  height: 8px; border-radius: 4px; background: var(--gray-200); overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: 4px; transition: width 0.4s ease;
}
.progress-bar-fill.blue { background: var(--primary); }
.progress-bar-fill.green { background: var(--success); }
.progress-bar-fill.red { background: var(--danger); }

/* GEO Score Ring */
.score-ring-wrap {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  padding: 24px;
}
.score-ring {
  position: relative; width: 160px; height: 160px;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring .ring-bg { stroke: var(--gray-200); fill: none; stroke-width: 10; }
.score-ring .ring-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.score-ring .score-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-ring .score-text strong { font-size: 42px; font-weight: 800; color: var(--gray-900); line-height: 1; }
.score-ring .score-text small { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--gray-200); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px; border: 0; background: none; font-size: 13px; font-weight: 500;
  color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Article Card */
.article-card {
  background: #fff; border-radius: var(--card-radius); padding: 20px;
  box-shadow: var(--card-shadow); display: grid;
  grid-template-columns: 1fr auto; gap: 16px; align-items: start;
}
.article-card + .article-card { margin-top: 12px; }
.article-card-left h3 { font-size: 16px; font-weight: 600; color: var(--gray-900); }
.article-card-left .meta {
  margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}
.article-card-left .meta span { font-size: 12px; color: var(--gray-500); }
.article-card-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.article-card-full { display: none; }

/* Platform Tab Icons */
.platform-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0; }
.platform-tab {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--gray-300);
  background: #fff; color: var(--gray-600); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.platform-tab:hover { border-color: var(--primary); color: var(--primary); }
.platform-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Countdown Timer */
.countdown {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; background: var(--primary-bg);
  color: var(--primary); font-weight: 700; font-size: 16px;
}
.countdown.running { animation: pulse 1.5s infinite; }

/* Article HTML Preview */
.article-preview {
  max-height: 600px; overflow-y: auto; border: 1px solid var(--gray-200);
  border-radius: 8px; padding: 24px; background: #fff; font-size: 14px; line-height: 1.8;
}
.article-preview h2 { font-size: 20px; margin: 20px 0 12px; }
.article-preview h3 { font-size: 16px; margin: 16px 0 8px; }
.article-preview p { margin: 10px 0; }
.article-preview img { max-width: 100%; border-radius: 8px; }

/* Input Groups */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.chip input { width: auto; cursor: pointer; }
.input-row { display: flex; gap: 10px; align-items: center; }
.input-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; outline: none; }
.input-row input:focus { border-color: var(--primary); }
.wide-field { grid-column: 1 / -1; }
.intake-chat-log {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  max-height: 260px;
  overflow-y: auto;
}
.intake-message {
  margin-bottom: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  background: #fff;
  color: var(--gray-800);
}
.intake-message.assistant { border-left: 3px solid var(--primary); }
.intake-message.user { background: #eef2ff; }

/* Toast */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  padding: 12px 20px; border-radius: 8px; font-size: 13px; font-weight: 500;
  animation: slideIn 0.3s ease;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Score Row */
.score-row { display: flex; gap: 20px; align-items: center; margin: 16px 0; }
.score-category { flex: 1; }
.score-category-label { font-size: 12px; color: var(--gray-500); margin-bottom: 4px; }
.score-category-value { font-size: 24px; font-weight: 700; }
.score-category .progress-bar { margin-top: 4px; }

/* Chart Container */
.chart-container { position: relative; }
.chart-container canvas { width: 100% !important; border-radius: 8px; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 9998;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
}
.modal-mask.hidden { display: none; }
.modal-panel {
  background: #fff; border-radius: 16px; padding: 32px; max-width: 800px; width: 90%;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-panel .close-btn {
  float: right; background: none; border: 0; font-size: 24px;
  color: var(--gray-400); cursor: pointer; line-height: 1;
}
.register-panel {
  width: min(440px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 12px;
}
.register-panel .modal-head {
  text-align: left;
  margin-bottom: 22px;
}
.register-panel .modal-head h2 {
  color: var(--gray-900);
  font-size: 22px;
}
.register-panel .form-group {
  margin-bottom: 16px;
}
.register-panel .form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
}
.register-panel .form-group input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  outline: none;
}
.register-panel .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.register-panel .error-text {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}
