@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.5;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* HEADER */
.header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.header h1 { font-size: 24px; font-weight: 700; }
.header-brand {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  font-weight: 800; font-size: 24px; margin-left: 8px;
}
.header-right { display: flex; gap: 8px; align-items: center; }

/* BUTTONS */
.btn {
  padding: 8px 16px; border-radius: 8px; border: none;
  background: #38bdf8; color: #0f172a; font-weight: 600;
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn:hover { background: #0ea5e9; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { background: transparent; color: #38bdf8; border: 1px solid #38bdf8; }
.btn-outline:hover { background: rgba(56,189,248,0.1); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.badge {
  font-size: 11px; background: rgba(129,140,248,0.2); color: #818cf8;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

/* INPUTS */
input[type="text"], select {
  background: #1e293b; border: 1px solid #334155; color: #e2e8f0;
  padding: 8px 12px; border-radius: 8px; font-size: 13px; font-family: inherit;
}
input[type="text"]:focus, select:focus { border-color: #38bdf8; outline: none; }
.input-wide { flex: 1; min-width: 300px; }
.input-sm { width: 120px; }

/* CARDS */
.card {
  background: #1e293b; border-radius: 16px; padding: 24px;
  border: 1px solid #334155; margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.chart-sub { font-weight: 400; color: #64748b; font-size: 13px; }

/* SCORECARDS */
.scorecards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.scorecard { text-align: center; }
.scorecard-label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.scorecard-value { font-size: 36px; font-weight: 800; color: #38bdf8; margin-top: 4px; }

/* CHARTS ROW */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-card canvas { width: 100% !important; }

/* RESPONSE TABLE */
.prov-col { min-width: 60px; }
.prov-header { font-size: 11px; font-weight: 700; color: #94a3b8; }
.check-no { color: #ef4444; font-size: 15px; font-weight: 600; opacity: 0.6; }
.pos-badge { font-size: 13px; font-weight: 800; padding: 2px 6px; border-radius: 6px; }
.pos-1 { color: #4ade80; background: rgba(74,222,128,0.1); }
.pos-2 { color: #fbbf24; background: rgba(251,191,36,0.1); }
.pos-3 { color: #fb923c; background: rgba(251,146,60,0.1); }
.pos-low { color: #94a3b8; background: rgba(148,163,184,0.08); }

/* TOOLTIPS */
.tooltip-wrap { position: relative; display: inline-block; vertical-align: middle; margin-left: 4px; }
.tip-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%;
  background: #334155; color: #94a3b8; font-size: 9px; font-weight: 700;
  font-style: italic; cursor: help; line-height: 1;
}
.tip-bubble {
  display: none; position: absolute; top: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); width: 260px; padding: 10px 12px;
  background: #334155; color: #e2e8f0; font-size: 12px; font-weight: 400;
  line-height: 1.5; border-radius: 8px; z-index: 50;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4); text-align: left;
  font-style: normal; white-space: normal;
}
.tip-bubble::after {
  content: ''; position: absolute; bottom: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent; border-bottom-color: #334155;
}
.tooltip-wrap:hover .tip-bubble { display: block; }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.resp-table { width: 100%; border-collapse: collapse; }
.resp-table th {
  text-align: left; padding: 10px 12px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px; color: #64748b;
  border-bottom: 2px solid #334155; font-weight: 600;
}
.resp-table td { padding: 10px 12px; border-bottom: 1px solid #1e293b; font-size: 13px; }
.resp-table tr:hover { background: rgba(56,189,248,0.04); }
.resp-table .brand-tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; margin: 1px;
  background: rgba(56,189,248,0.15); color: #38bdf8;
}
.resp-table .brand-tag.positive { background: rgba(74,222,128,0.15); color: #4ade80; }
.resp-table .brand-tag.negative { background: rgba(248,113,113,0.15); color: #f87171; }
.prompt-text { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* PAGINATION */
.pagination { display: flex; gap: 4px; margin-top: 12px; justify-content: center; }
.pagination button {
  background: #334155; border: none; color: #e2e8f0; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; font-size: 12px;
}
.pagination button.active { background: #38bdf8; color: #0f172a; }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7); z-index: 100; justify-content: center; align-items: flex-start;
  padding: 40px 20px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #1e293b; border-radius: 16px; padding: 28px;
  max-width: 900px; width: 100%; border: 1px solid #334155;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; color: #64748b; font-size: 20px; cursor: pointer; }
.modal-meta { font-size: 12px; color: #64748b; margin-bottom: 16px; }
.modal-brands { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.modal-body {
  background: #0f172a; padding: 20px; border-radius: 12px;
  font-size: 14px; line-height: 1.8; white-space: pre-wrap;
  max-height: 500px; overflow-y: auto; margin-bottom: 16px;
}
.modal-body mark {
  background: rgba(56,189,248,0.25); color: #38bdf8;
  padding: 1px 4px; border-radius: 4px;
}
.modal-sources { font-size: 12px; color: #94a3b8; }
.modal-sources a { color: #38bdf8; text-decoration: none; }
.modal-sources a:hover { text-decoration: underline; }

/* PROMPT MANAGEMENT */
.prompt-form { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.prompt-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid #334155; font-size: 13px;
}
.prompt-item .prompt-cat { color: #64748b; font-size: 11px; margin-left: 8px; }
.prompt-item.inactive { opacity: 0.4; }

/* SCORECARD SUB */
.scorecard-sub { font-size: 10px; color: #475569; margin-top: 4px; }

/* HIDDEN */
.hidden { display: none !important; }

/* CENTER */
.center { text-align: center; }

/* SECTION HEADER */
.section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.date-nav { display: flex; gap: 6px; align-items: center; }
.date-input { width: 120px; text-align: center; }
.checkbox-label { font-size: 12px; color: #94a3b8; display: flex; align-items: center; gap: 4px; cursor: pointer; }
.checkbox-label input { accent-color: #38bdf8; }

/* PROMPT TABLE */
.prompt-text-cell { max-width: 350px; font-size: 13px; line-height: 1.4; }
.cat-tag { font-size: 11px; color: #64748b; background: #0f172a; padding: 2px 8px; border-radius: 8px; }
.indicator { font-size: 12px; font-weight: 600; }
.indicator.good { color: #4ade80; }
.indicator.warn { color: #fbbf24; }
.indicator.bad { color: #f87171; }
.indicator.muted { color: #334155; }
.indicator.positive { color: #4ade80; }
.indicator.neutral { color: #94a3b8; }
.indicator.negative { color: #f87171; }
.archived-row { opacity: 0.4; }
.badge-sm { font-size: 9px; padding: 1px 6px; }

/* DETAIL VIEW */
.detail-sticky-header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  position: sticky; top: 0; z-index: 20; background: #0f172a;
  padding: 16px 20px; border-bottom: 1px solid #334155;
  border-radius: 12px 12px 0 0; margin-bottom: 20px;
}
.detail-sticky-header h2 { flex: 1; font-size: 15px; font-weight: 600; }
.detail-header {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px;
  padding: 16px 0; border-bottom: 1px solid #334155;
}
.detail-header h2 { flex: 1; font-size: 15px; }
.detail-date { color: #38bdf8; font-weight: 700; font-size: 14px; }
.avail-dates { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; align-items: center; }
.date-chip {
  background: #334155; border: none; color: #94a3b8; padding: 4px 10px;
  border-radius: 6px; font-size: 11px; cursor: pointer; font-family: inherit;
}
.date-chip.active { background: #38bdf8; color: #0f172a; font-weight: 600; }
.date-chip:hover { background: #475569; }

/* RESPONSE CARDS */
.response-card {
  background: #0f172a; border-radius: 12px; padding: 20px;
  margin-bottom: 16px; border: 1px solid #1e293b;
}
.resp-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.provider-badge {
  background: #334155; color: #e2e8f0; padding: 4px 12px;
  border-radius: 8px; font-weight: 700; font-size: 13px;
}
.resp-meta { font-size: 11px; color: #64748b; }
.resp-brands { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
/* Brand table in detail view */
.brand-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 12px; }
.brand-table th {
  text-align: left; padding: 6px 10px; color: #64748b; font-weight: 600;
  border-bottom: 1px solid #334155; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.brand-table td { padding: 6px 10px; border-bottom: 1px solid #1e293b33; }
.brand-table tr:last-child td { border-bottom: none; }
.brand-table .brand-name { font-weight: 700; }
.sent-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.sent-dot.positive { background: #4ade80; }
.sent-dot.neutral { background: #94a3b8; }
.sent-dot.negative { background: #f87171; }

/* Response body — rendered markdown */
.resp-body {
  font-size: 13px; line-height: 1.7; color: #cbd5e1;
  padding: 16px; background: #1e293b; border-radius: 8px;
  max-height: 500px; overflow-y: auto;
}
.resp-body.rendered-md { white-space: normal; }
.resp-body h1, .resp-body h2, .resp-body h3 { color: #e2e8f0; margin: 16px 0 8px; font-size: 15px; }
.resp-body h1 { font-size: 17px; }
.resp-body p { margin: 8px 0; }
.resp-body ul, .resp-body ol { padding-left: 20px; margin: 8px 0; }
.resp-body li { margin: 4px 0; }
.resp-body a { color: #38bdf8; text-decoration: none; }
.resp-body a:hover { text-decoration: underline; }
.resp-body strong { color: #e2e8f0; }
.resp-body mark { padding: 1px 4px; border-radius: 4px; }

/* Sources list */
.resp-sources { font-size: 12px; color: #94a3b8; margin-top: 12px; }
.resp-sources strong { color: #e2e8f0; }
.source-list { list-style: none; padding: 0; margin: 8px 0 4px; }
.source-list li { padding: 3px 0; border-bottom: 1px solid #1e293b; }
.source-list li:last-child { border-bottom: none; }
.source-list a { color: #38bdf8; text-decoration: none; word-break: break-all; }
.source-list a:hover { text-decoration: underline; }
.source-hidden { display: none; }
.source-redirect { color: #94a3b8; }

/* FOOTER */
footer {
  text-align: center; padding: 20px; color: #475569; font-size: 12px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .scorecards { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .header { flex-direction: column; align-items: flex-start; }
}
