* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f5f0eb;
  --dark: #1a2e1a;
  --accent: #2d5a2d;
  --accent-light: #4a7c4a;
  --card-bg: #ffffff;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --red: #dc2626;
  --amber: #d97706;
  --green: #16a34a;
  --blue: #2563eb;
}

body {
  font-family: 'Georgia', serif;
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2.5rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.nav-logo {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dark);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--dark);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-family: inherit;
  transition: background 0.2s;
}

.btn-ghost:hover { background: rgba(0,0,0,0.06); }

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover { background: var(--accent-light); }

/* ── HERO ── */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.8rem 2.5rem 1.4rem;
  gap: 1.5rem;
}

.hero-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-shrink: 0;
}

.hero-logo {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -1px;
}

.hero-tagline {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text-muted);
  margin: 0;
}

.hero-tagline em {
  font-style: italic;
  color: var(--accent);
}

.hero-cta {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.6rem 1.6rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.hero-cta:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* ── SCROLL CARDS ── */
.cards-section {
  padding: 0.5rem 2.5rem 2rem;
}

.cards-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 1.2rem;
}

.cards-track-wrapper {
  width: 100%;
}

.cards-track {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.2rem;
  padding: 0.5rem 0;
}

.cards-track::-webkit-scrollbar { display: none; }

.insight-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  width: 100%;
}

.insight-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.card-thumb { display: none; }
.card-thumb.violation, .card-thumb.warning,
.card-thumb.insight, .card-thumb.summary { display: none; }

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
  font-family: 'Arial', sans-serif;
}

.badge-violation { background: #fee2e2; color: var(--red); }
.badge-warning   { background: #fef3c7; color: var(--amber); }
.badge-insight   { background: #dbeafe; color: var(--blue); }
.badge-summary   { background: #dcfce7; color: var(--green); }
.badge-neutral   { background: #f3f4f6; color: var(--accent); font-weight: 700; }

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark);
  line-height: 1.3;
  font-family: 'Arial', sans-serif;
}

.card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-family: 'Arial', sans-serif;
}

.card-saved-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: #dcfce7;
  color: #16a34a;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-family: 'Arial', sans-serif;
}

/* ── CHAT PAGE ── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.chat-header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark);
}

.chat-domain-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #dcfce7;
  color: var(--green);
  font-family: 'Arial', sans-serif;
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.msg {
  display: flex;
  gap: 0.8rem;
  max-width: 720px;
}

.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.msg.user .msg-avatar { background: var(--accent); color: white; }
.msg.assistant .msg-avatar { background: var(--dark); color: white; }

.msg-bubble {
  padding: 0.9rem 1.2rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.6;
  font-family: 'Arial', sans-serif;
  max-width: 560px;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.assistant .msg-bubble {
  background: white;
  color: var(--dark);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border);
}

.msg-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-family: 'Arial', sans-serif;
}

/* data preview table */
.data-table-wrap {
  overflow-x: auto;
  margin-top: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-family: 'Arial', sans-serif;
}

.data-table th {
  background: #f9fafb;
  padding: 0.5rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.45rem 0.8rem;
  border-bottom: 1px solid #f3f4f6;
  color: var(--dark);
}

.sql-block {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-family: 'Courier New', monospace;
  margin-top: 0.6rem;
  overflow-x: auto;
  white-space: pre;
}

/* chat input */
.chat-input-area {
  padding: 1.2rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-input-row {
  display: flex;
  gap: 0.8rem;
  align-items: flex-end;
  max-width: 720px;
  margin: 0 auto;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 0.6rem 0.6rem 0.6rem 1.2rem;
  transition: border-color 0.2s;
}

.chat-input-row:focus-within { border-color: var(--accent); }

#chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.95rem;
  font-family: 'Arial', sans-serif;
  background: transparent;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  color: var(--dark);
}

.send-btn {
  background: var(--accent);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
  font-size: 1rem;
}

.send-btn:hover { background: var(--accent-light); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* typing indicator */
.typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: flex-start; padding: 1.2rem; gap: 1rem; }
  .hero-logo { font-size: 2rem; }
  .hero-tagline { font-size: 0.9rem; }

  /* Nav — compact on mobile */
  nav { padding: 0.8rem 1rem; }
  #login-stats-badge { display: none !important; }
  .nav-actions { gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
  #nav-user { font-size: 0.75rem !important; }
  #session-timer { font-size: 0.7rem !important; padding: 0.2rem 0.5rem !important; }

  /* Cards section */
  .cards-section { padding: 0.5rem 1rem 1.5rem; }

  /* Brand tabs + search: stack vertically */
  .tabs-search-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.6rem;
  }
  .tabs-search-row #inline-search-box {
    position: static !important;
    width: 100%;
  }
  .tabs-search-row #inline-search-box input {
    width: 100% !important;
  }
  #brand-tabs { justify-content: flex-start !important; }

  /* Side panel — full width */
  .side-panel { width: 100vw !important; right: -100vw !important; }
  .side-panel.open { right: 0 !important; }

  /* Report modal */
  #report-modal > div { padding: 1rem 1rem 3rem !important; }
  #modal-bottom-row { flex-direction: column !important; }
  #modal-answer { padding: 1rem !important; font-size: 0.88rem !important; }

  /* Chat */
  .chat-messages { padding: 0.8rem; }
  .chat-input-area { padding: 0.7rem 0.8rem; }
  .msg-bubble { max-width: 85vw !important; font-size: 0.88rem; }
  .msg { max-width: 100%; }

  /* Register form-row collapse */
  .form-row { grid-template-columns: 1fr !important; }
}

/* ── Status Stepper ── */
.stepper-bubble {
  min-width: 260px;
  padding: 1rem 1.2rem;
}

.stepper-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.7rem;
  font-family: 'Arial', sans-serif;
}

.stepper-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.stepper-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Arial', sans-serif;
  font-size: 0.83rem;
  transition: color 0.2s;
}

.step-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.step-label {
  transition: color 0.3s, font-weight 0.2s;
}

/* ── Brand Summary ── */
.brand-tab {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Arial', sans-serif;
  color: var(--dark);
  transition: all 0.15s;
}
.brand-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.brand-tab:hover:not(.active) { background: #f3f4f6; }

.synopsis-card {
  background: white;
  border-radius: 16px;
  padding: 1.2rem;
  cursor: pointer;
  border: 2px solid var(--border);
  color: var(--dark);
  transition: transform 0.2s, box-shadow 0.2s;
}
.synopsis-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.synopsis-card .card-title { color: var(--dark); }
.synopsis-card .card-meta { color: var(--text-muted); }
.synopsis-card .card-saved-badge { background: #dcfce7; color: #16a34a; }

/* ── Structured Summary Sections ── */
.summary-section-header {
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 1.4rem 0 0.6rem;
  font-family: 'Arial', sans-serif;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--border);
  display: block;
  width: 100%;
}
.summary-section-header.critical { color: var(--red); border-color: #fee2e2; }
.summary-section-header.warning  { color: var(--amber); border-color: #fef3c7; }
.summary-section-header.positive { color: var(--green); border-color: #dcfce7; }

.summary-bullet {
  font-size: 0.92rem;
  font-family: 'Arial', sans-serif;
  padding: 0.5rem 0;
  line-height: 1.7;
  color: var(--dark);
  display: block;
  width: 100%;
  border-bottom: 1px solid #f3f4f6;
}
.summary-bullet:last-child { border-bottom: none; }
.summary-bullet.critical { color: var(--red); }
.summary-bullet.warning  { color: var(--amber); }
.summary-bullet.positive { color: var(--green); }

/* ── Report Modal Content ── */
#modal-answer {
  width: 100%;
  box-sizing: border-box;
}

#modal-answer .summary-section-header,
#modal-answer .summary-bullet {
  width: 100%;
  box-sizing: border-box;
}

#modal-table-wrap .data-table-wrap {
  margin-top: 0;
  border: none;
  border-radius: 0;
}

#modal-table-wrap .data-table {
  width: 100%;
  font-size: 0.88rem;
}

#modal-table-wrap .data-table th,
#modal-table-wrap .data-table td {
  padding: 0.6rem 1rem;
}

/* ── Responsive grid for brand cards ── */
@media (max-width: 1024px) {
  .cards-track { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 700px) {
  .cards-track { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .cards-track { grid-template-columns: repeat(2, 1fr); }
}
