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

body {
  font-family: -apple-system, 'Segoe UI', sans-serif;
  background: #f7f8fa;
  color: #0f172a;
  font-size: 14px;
}

/* Nav */
.nav {
  background: #0f172a;
  color: #fff;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  row-gap: 8px;
}
.nav-brand { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.nav-breadcrumb { color: #94a3b8; font-size: 12px; min-width: 0; flex: 1; }
.nav-user { color: #475569; font-size: 11px; flex-wrap: wrap; }
.nav-user a { color: #64748b; text-decoration: none; }
.nav-user a:hover { color: #94a3b8; }
.nav-user button:hover { filter: brightness(0.95); }
.nav-user button:focus-visible,
.nav-user a:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

/* KPI bar */
.kpi-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}
.kpi-card {
  flex: 1 1 160px;
  min-width: 0;
  background: #fff;
  padding: 14px 20px;
}
.kpi-label {
  font-size: 9px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}
.kpi-sub {
  font-size: 9px;
  color: #94a3b8;
  margin-top: 2px;
}
.kpi-sub.active { color: #22c55e; }

/* Page content */
.page { padding: 20px 24px; }

/* Cards */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  color: #0f172a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* Grid */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

/* Wrap any wide table for horizontal scrolling on small screens */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Client table (overview) */
.client-table { width: 100%; border-collapse: collapse; }
.client-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
}
.client-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f8fafc;
  font-size: 13px;
}
.client-table tr:hover td { background: #f8fafc; cursor: pointer; }

/* Prompt results table */
.prompt-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.prompt-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  padding: 4px 8px;
  border-bottom: 1px solid #e2e8f0;
}
.prompt-table td { padding: 5px 8px; border-bottom: 1px solid #f8fafc; color: #334155; }
.prompt-table .yes { color: #22c55e; text-align: center; }
.prompt-table .no { color: #ef4444; text-align: center; }

/* Bar chart */
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bar-label { width: 52px; font-size: 10px; color: #475569; }
.bar-track { flex: 1; background: #f1f5f9; height: 8px; border-radius: 4px; }
.bar-fill { background: #3b82f6; height: 100%; border-radius: 4px; }
.bar-count { font-size: 10px; font-weight: 600; color: #0f172a; width: 16px; text-align: right; }

/* Platform table */
.platform-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.platform-table td { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.platform-table td.dim { color: #cbd5e1; }

/* Trend chart */
.trend-canvas { width: 100%; height: 80px; display: block; }

/* Badge */
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: #94a3b8; }

/* Rankings table */
.rankings-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rankings-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  padding: 4px 8px;
  border-bottom: 1px solid #e2e8f0;
}
.rankings-table td { padding: 7px 8px; border-bottom: 1px solid #f8fafc; color: #334155; }
.rank-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.rank-top10 { background: #dcfce7; color: #166534; }
.rank-mid   { background: #fef9c3; color: #854d0e; }
.rank-low   { background: #fee2e2; color: #991b1b; }
.rank-none  { background: #f1f5f9; color: #94a3b8; }

/* Mentioned prompts (LLM responses) */
.mp-filter {
  font-family: inherit;
  font-size: 11px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.mp-filter:hover { background: #e2e8f0; }
.mp-filter.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.mp-filter .mp-count {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: #94a3b8;
}
.mp-filter.active .mp-count { color: #cbd5e1; }

.mp-item {
  border: 1px solid #e2e8f0;
  border-left: 3px solid #22c55e;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fafbfc;
}
.mp-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.mp-platform {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
  flex-shrink: 0;
}
.mp-platform-claude     { background: #fef3c7; color: #92400e; }
.mp-platform-openai     { background: #dcfce7; color: #166534; }
.mp-platform-gemini     { background: #dbeafe; color: #1e40af; }
.mp-platform-perplexity { background: #ede9fe; color: #5b21b6; }
.mp-prompt {
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
  min-width: 200px;
  word-break: break-word;
}
.mp-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.mp-tag {
  display: inline-block;
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
}
.mp-tag-cited    { background: #dbeafe; color: #1e40af; }
.mp-tag-positive { background: #dcfce7; color: #166534; }
.mp-tag-negative { background: #fee2e2; color: #991b1b; }
.mp-tag-neutral  { background: #f1f5f9; color: #475569; }
.mp-date { font-size: 10px; color: #94a3b8; }
.mp-competitors {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.mp-response {
  font-size: 12px;
  line-height: 1.55;
  color: #334155;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 8px 10px;
  white-space: pre-wrap;
  word-break: break-word;
}
.mp-toggle {
  margin-top: 6px;
  font-family: inherit;
  font-size: 11px;
  color: #3b82f6;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.mp-toggle:hover { text-decoration: underline; }

/* Integrations panel */
.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.integration-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fafbfc;
}
.integration-icon {
  font-size: 14px;
  line-height: 1;
  margin-top: 1px;
}
.integration-ok    { border-color: #bbf7d0; background: #f0fdf4; }
.integration-ok .integration-icon { color: #16a34a; }
.integration-missing { border-color: #fee2e2; background: #fef2f2; }
.integration-missing .integration-icon { color: #ef4444; }
.integration-text { flex: 1; min-width: 0; }
.integration-name { font-size: 12px; font-weight: 600; color: #0f172a; }
.integration-hint { font-size: 10px; color: #64748b; margin-top: 2px; word-break: break-word; }
.integration-hint code { background: #f1f5f9; padding: 0 4px; border-radius: 3px; font-size: 10px; }

/* Run status bar */
.run-status-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.run-pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.run-pill-running { background: #fef3c7; color: #92400e; }
.run-pill-done    { background: #dcfce7; color: #166534; }
.run-pill-error   { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: #0f172a; }

/* Form */
#add-client-form { padding: 16px 18px; }
.form-row { margin-bottom: 12px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 4px;
}
.form-hint { color: #94a3b8; font-weight: 400; margin-left: 4px; }
.form-hint code { background: #f1f5f9; padding: 0 4px; border-radius: 3px; }
.form-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
}
.form-input:focus { border-color: #3b82f6; }
textarea.form-input { resize: vertical; }
.form-error {
  color: #ef4444;
  font-size: 12px;
  min-height: 16px;
  margin-bottom: 6px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.btn {
  font-family: inherit;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary { background: #3b82f6; color: #fff; border: 1px solid #3b82f6; }
.btn-primary:hover { background: #2563eb; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #fff; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #f1f5f9; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f8fa;
}
.login-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 32px 40px;
  width: 340px;
}
.login-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-sub { font-size: 12px; color: #94a3b8; margin-bottom: 24px; }
.login-label { display: block; font-size: 11px; color: #475569; margin-bottom: 4px; }
.login-input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  outline: none;
}
.login-input:focus { border-color: #3b82f6; }
.login-btn {
  width: 100%;
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.login-btn:hover { background: #1e293b; }
.login-error { color: #ef4444; font-size: 12px; margin-top: 12px; }

/* Wide modal + tabs + row editor */
.modal-wide { max-width: 760px; }
.tab-bar {
  display: flex;
  gap: 0;
  padding: 0 18px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}
.tab {
  background: transparent;
  border: none;
  padding: 10px 14px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: #0f172a; }
.tab-active { color: #0f172a; border-bottom-color: #3b82f6; font-weight: 600; }
.tab-count {
  display: inline-block;
  font-size: 10px;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 6px;
  border-radius: 10px;
}
.tab-active .tab-count { background: #dbeafe; color: #1e40af; }
.tab-panel { padding: 14px 18px; }

.add-row-form {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.add-row-form .form-input { flex: 1; min-width: 160px; }
.form-input-sm { font-size: 12px; }
.form-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #475569;
}

.row-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid #f1f5f9;
  border-radius: 6px;
}
.row-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-prompt { font-size: 12px; color: #0f172a; word-break: break-word; }
.row-meta { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.row-tag {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
}
.row-tag-high   { background: #fee2e2; color: #991b1b; }
.row-tag-medium { background: #fef3c7; color: #92400e; }
.row-tag-low    { background: #e0f2fe; color: #075985; }
.row-tag-muted { font-size: 10px; color: #94a3b8; text-decoration: none; }
.row-delete {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.row-delete:hover { color: #ef4444; }

/* Suggest from website */
.suggest-bar {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  background: #fafbfc;
  flex-wrap: wrap;
}
.suggest-bar .form-input { flex: 1; min-width: 200px; }
.suggest-error { color: #ef4444; font-size: 12px; padding: 0 18px; }
.suggest-results {
  padding: 12px 18px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  max-height: 360px;
  overflow-y: auto;
}
.suggest-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.suggest-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .suggest-cols { grid-template-columns: 1fr; } }
.suggest-col-title {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.suggest-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #f8fafc;
}
.suggest-row:last-child { border-bottom: none; }
.suggest-text { font-size: 12px; color: #334155; word-break: break-word; }
.suggest-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* Global focus & interaction polish */
button { font-family: inherit; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
button:not(:disabled) { transition: background-color 120ms, opacity 120ms, filter 120ms; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: #64748b;
}
.empty-state-title { font-size: 14px; font-weight: 600; color: #0f172a; margin-bottom: 4px; }
.empty-state-text { font-size: 12px; color: #94a3b8; margin-bottom: 14px; }

/* Responsive — tablet */
@media (max-width: 900px) {
  .page { padding: 16px; }
  .nav { padding: 10px 16px; }
  .run-status-bar { padding: 8px 16px; }
  .kpi-value { font-size: 22px; }
  .kpi-card { padding: 12px 16px; }
}

/* Responsive — phone */
@media (max-width: 600px) {
  body { font-size: 13px; }
  .nav { padding: 10px 12px; gap: 6px; }
  .nav-breadcrumb { width: 100%; flex: none; }
  .nav-user { width: 100%; justify-content: flex-start; gap: 8px; }
  .nav-user button { flex: 1 1 auto; min-width: 0; }
  .kpi-value { font-size: 20px; }
  .kpi-card { flex: 1 1 50%; padding: 10px 12px; }
  .page { padding: 12px; }
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 12px; }
  .card-title { margin-bottom: 8px; }
  .modal-backdrop { padding: 20px 12px; align-items: center; }
  .modal { max-width: 100%; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .mp-head { gap: 6px; }
  .mp-prompt { min-width: 100%; }
  .mp-meta { width: 100%; }
}
