/* SEO Dashboard — light, clean, professional. System fonts, no webfonts. */

:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9aa3b2;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 1.4rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 0 0 0.6rem; }
h4 { font-size: 1rem; margin: 1.2rem 0 0.4rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--red); }
.hidden { display: none !important; }
.break { word-break: break-all; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.login-card h1 { margin-bottom: 0.25rem; }
.login-card label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; }
.login-card input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: #f1f4f8; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-dark); }
.btn-small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-block { width: 100%; margin-top: 1rem; }

.linkbtn {
  background: none;
  border: none;
  padding: 0;
  color: #92400e;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ------------------------------------------------------------ top bar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--muted); gap: 0.15rem; }
.ctl select {
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 9rem;
}

.flash {
  margin: 0;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  text-align: center;
}
.flash.ok { background: #ecfdf5; color: #065f46; border-top: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #991b1b; border-top: 1px solid #fecaca; }

/* ------------------------------------------------------------ alert banner */
.banner {
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  padding: 0.7rem 1rem;
  text-align: center;
  font-size: 0.95rem;
}

/* ------------------------------------------------------------ tabs */
.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.25rem;
  padding: 0 1rem;
  max-width: 1120px;
  margin: 0 auto;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.badge {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.05em 0.4em;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  vertical-align: 1px;
}

/* ------------------------------------------------------------ layout */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.notice {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
}
.notice .btn { margin-top: 0.5rem; }

/* ------------------------------------------------------------ KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.kpi { margin-bottom: 0; }
.kpi-value { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-label { font-weight: 600; margin-top: 0.15rem; }
.kpi-hint { font-size: 0.8rem; color: var(--muted); }

/* ------------------------------------------------------------ chart */
.chart-card { position: relative; padding: 1rem; }
#trendChart { width: 100%; display: block; }
.chart-tip {
  position: absolute;
  z-index: 5;
  background: #111827;
  color: #f9fafb;
  font-size: 0.8rem;
  line-height: 1.6;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  pointer-events: none;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ------------------------------------------------------------ tables */
.table-wrap { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
thead th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f9fafb;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid #f1f3f6;
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: #fcfdff; }
tbody tr:hover { background: #f3f6fb; }
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--accent); }
th.sorted-asc::after { content: " ▲"; }
th.sorted-desc::after { content: " ▼"; }
tr.clickable { cursor: pointer; }
table.compact td, table.compact th { padding: 0.45rem 0.6rem; }

/* social-media rows in the traffic sources table */
tr.social { background: #f0fdf4 !important; }
tr.social td:first-child { border-left: 3px solid var(--green); }
.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #166534;
  background: #dcfce7;
  border-radius: 999px;
  padding: 0.05em 0.55em;
  margin-left: 0.4em;
  vertical-align: 1px;
}

/* ------------------------------------------------------------ three-column grid */
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .grid3 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ audits */
#auditStatus { margin-left: 0.6rem; }
.issues { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.issues li {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  background: #fff;
}
.issue-head { font-weight: 600; }
.issue-url { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.issue-meta {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 4px;
  padding: 0.1em 0.5em;
  margin: 0.25rem 0.25rem 0 0;
}

/* ------------------------------------------------------------ alerts */
.alert-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}
.alert-main { flex: 1; min-width: 0; }
.alert-type {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #92400e;
  background: #fef3c7;
  border-radius: 999px;
  padding: 0.1em 0.7em;
  margin-right: 0.5em;
}
.alert-site { font-size: 0.85rem; color: var(--muted); }
.alert-msg { margin-top: 0.35rem; }
.alert-time { margin-top: 0.25rem; }

/* ------------------------------------------------------------ lead finder */
.lf-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.lf-input {
  font-size: 0.95rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
input.lf-input { flex: 1 1 12rem; }
select.lf-input { flex: 0 1 auto; }
.lf-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}
.lf-filters { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; margin-bottom: 0.4rem; }
.lf-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.92rem; cursor: pointer; }
.lf-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.lf-viewbar {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin: 1rem 0;
}
.lf-view.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.lf-lead { margin-bottom: 1rem; }
.lf-lead.is-contacted { opacity: 0.72; }
.lf-lead-top { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; justify-content: space-between; }
.lf-lead-top h3 { margin: 0; }
.lf-flags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.flag {
  display: inline-block; font-size: 0.78rem; font-weight: 700;
  border-radius: 999px; padding: 0.12em 0.7em; white-space: nowrap;
}
.flag-bad  { color: #991b1b; background: #fee2e2; }
.flag-web  { color: #92400e; background: #fef3c7; }
.flag-few  { color: #1e40af; background: #dbeafe; }
.flag-thin { color: #5b21b6; background: #ede9fe; }
.flag-done { color: #065f46; background: #d1fae5; }
.lf-meta { margin: 0.3rem 0; }
.stars { color: #f59e0b; letter-spacing: 0.05em; }
.lf-links a { color: var(--accent); }
.warn-text { color: #b45309; }
.ok-text { color: var(--green); }
.lf-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.7rem; }

.lf-reviews { margin-top: 0.8rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.lf-reviews h4 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.lf-review { background: #f9fafb; border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.75rem; margin-bottom: 0.5rem; }
.lf-review-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.lf-review-head .btn { margin-left: auto; }
.lf-review-text { margin: 0.4rem 0 0; font-size: 0.92rem; }

.lf-scanrow { cursor: pointer; }
.lf-scanrow:hover td { background: #f3f4f6; }

/* draft-email modal */
.modal {
  display: none !important; position: fixed !important; inset: 0 !important; z-index: 60 !important;
  background: rgba(17, 24, 39, 0.55) !important;
  padding: 1rem !important; overflow-y: auto !important;
  width: 100% !important; height: 100% !important;
  margin: 0 !important; box-sizing: border-box !important;
}
.modal.open { display: block !important; }
.modal-card {
  background: #fff; border-radius: var(--radius); max-width: 620px;
  margin: 4vh auto; padding: 1.2rem 1.3rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-head h3 { margin: 0; }
.lf-draft-preview { margin-top: 0.8rem; }
.lf-draft-preview pre {
  white-space: pre-wrap; word-wrap: break-word;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 6px;
  padding: 0.8rem; font-size: 0.9rem; font-family: inherit;
  max-height: 46vh; overflow-y: auto; margin: 0.4rem 0 0;
}
.modal-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }
.modal-actions .btn { text-decoration: none; }

@media (max-width: 640px) {
  .lf-form { grid-template-columns: 1fr 1fr; }
  .modal-card { margin: 2vh auto; padding: 1rem; }
  .lf-review-head .btn { margin-left: 0; }
}
