/* Publiflect app. Mobile first. */
:root {
  --ink: #111827; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb; --soft: #f5f6f8;
  --bg: #f3f4f6; --card: #fff; --accent: #4f46e5; --accent-ink: #3730a3;
  --up: #047857; --down: #b91c1c; --warn: #92400e; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #f9fafb; --text: #e5e7eb; --muted: #9ca3af; --line: #2d3340; --soft: #1b2030; --bg: #0f131c; --card: #161b26; --accent: #818cf8; --accent-ink: #c7d2fe; --up: #34d399; --down: #f87171; --warn: #fbbf24; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); }
h1, h2, h3 { color: var(--ink); line-height: 1.25; }
h2 { font-size: 17px; margin: 0 0 10px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: var(--soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
code.block { display: block; padding: 10px 12px; margin: 6px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.up { color: var(--up); }
.down { color: var(--down); }
.warn { color: var(--warn); font-weight: 600; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; flex: none; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #4f46e5, #06b6d4); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.logo.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 24px; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-weight: 500; }
.nav a.active { background: var(--soft); color: var(--ink); }

.main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.main.narrow { max-width: 460px; padding-top: 40px; }
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-brand h1 { margin: 10px 0 2px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 4px 0 14px; }
.page-title { font-size: 24px; margin: 0; }
.intro { color: var(--muted); max-width: 760px; margin: 0 0 14px; }
.section-title { font-size: 16px; margin: 24px 0 10px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-2 > .card { margin: 0; }
.site-grid { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 14px; }
.site-grid .card { margin: 0; }
.site-card { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
.site-card:hover { border-color: var(--accent); }
.site-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.site-card h2 { margin: 0; }
.setup ol { margin: 0; padding-left: 20px; }
.setup li { margin: 6px 0; }
.setup li.done { color: var(--muted); text-decoration: line-through; }

/* KPIs and stats */
.kpis { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.kpis .card { margin: 0; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--ink); }
.kpi-value.down { color: var(--down); }
.kpi-value.up { color: var(--up); }
.kpi-note { font-size: 12px; color: var(--muted); }
.kpi-note.up { color: var(--up); }
.kpi-note.down { color: var(--down); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.stats div { background: var(--soft); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.stats dd.small { font-weight: 500; font-size: 12px; }
.stats.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats .muted { color: var(--muted); }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; }

/* Tabs and chips */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 0 0 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 10px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; font-weight: 500; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.count, .chip span { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--soft); font-size: 12px; text-align: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.chip { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-size: 14px; }
.chip.active { border-color: var(--accent); color: var(--accent-ink); }

/* Pills */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--text); margin: 2px 0; }
.pill-bad, .pill-rankings, .pill-low_rpm { background: #fee2e2; color: #991b1b; }
.pill-good { background: #d1fae5; color: #065f46; }
.pill-ctr, .pill-low_ctr { background: #cffafe; color: #155e75; }
.pill-demand, .pill-no_ads { background: #fef3c7; color: #92400e; }
.pill-dropped { background: #1f2937; color: #fff; }
.pill-seasonal { background: #e0e7ff; color: #3730a3; }
.pill-striking { background: #ede9fe; color: #5b21b6; }
.pill-no_affiliate { background: #dcfce7; color: #166534; }
.pill-stale { background: #f3e8ff; color: #6b21a8; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 4px; }
.list .title { display: block; font-weight: 600; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.list-side { display: flex; gap: 12px; font-weight: 600; white-space: nowrap; }
.list-side > span + span { margin-left: 12px; }
.next { margin: 6px 0 0; font-size: 14px; }
.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: 10px 0; border-top: 1px solid var(--line); }
.log li:first-child { border-top: 0; }

/* Findings */
.finding { scroll-margin-top: 70px; }
.finding:target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.finding-head { display: flex; gap: 10px; align-items: flex-start; }
.finding-title { min-width: 0; }
.finding-title a { display: block; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.finding-title .muted { display: block; overflow-wrap: anywhere; }
.rank { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.diagnosis { margin: 4px 0; }
.steps-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.steps { margin: 0; padding-left: 22px; }
.steps li { margin: 6px 0; }

/* Chart */
.chart-wrap { margin: 4px 0 8px; }
.chart { width: 100%; height: 160px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line-now { fill: none; stroke: var(--accent); stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.chart .line-ly { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; opacity: .7; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.key { display: inline-block; width: 16px; height: 0; border-top: 3px solid var(--accent); vertical-align: middle; margin-right: 2px; }
.key-ly { border-top: 2px dashed var(--muted); }
.chart-range { margin-left: auto; }

/* Forms */
.form label { display: block; font-weight: 600; margin: 0 0 14px; }
.form label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.form input[type=text], .form input[type=email], .form input[type=url], .form input[type=password], .form input[type=number], .form select, textarea.code {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form .w-sm, .form .w-sm input { max-width: 160px; }
.form .row { display: flex; gap: 12px; }
.form .row > label { flex: 1; }
.form h2 { margin-top: 6px; }
.hint { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 4px; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.help { background: var(--soft); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.help summary { font-weight: 600; cursor: pointer; }
.help ol { padding-left: 20px; margin: 10px 0 0; }
.help li { margin: 8px 0; }
.inline { display: inline; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.danger h2 { color: var(--down); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--down); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: progress; }
.copy-btn { margin-left: 6px; }

/* Flash */
.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; border: 1px solid; }
.flash-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* Tables: cards on phones, table on larger screens */
.table { width: 100%; border-collapse: collapse; }
.table.stack thead { display: none; }
.table.stack tr { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.table.stack td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.table.stack td:first-child { display: block; border-top: 0; font-weight: 600; overflow-wrap: anywhere; }
.table.stack td:first-child a { color: var(--ink); text-decoration: none; }
.table.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 500; }
.table.stack td:first-child::before { content: none; }

@media (min-width: 720px) {
  .main { padding: 24px; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .site-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .list li { flex-direction: row; justify-content: space-between; }
  .list-side { flex-direction: column; align-items: flex-end; gap: 2px; }
  .list-side > span + span { margin-left: 0; }
  .table.stack { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .table.stack thead { display: table-header-group; }
  .table.stack tr { display: table-row; border: 0; border-radius: 0; padding: 0; margin: 0; }
  .table.stack th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--soft); }
  .table.stack td, .table.stack td:first-child { display: table-cell; padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
  .table.stack td::before { content: none; }
  .table.stack tr:first-child td { border-top: 0; }
}
@media (prefers-color-scheme: dark) {
  .pill-bad, .pill-rankings, .pill-low_rpm { background: #450a0a; color: #fecaca; }
  .pill-good { background: #064e3b; color: #a7f3d0; }
  .pill-ctr, .pill-low_ctr { background: #083344; color: #a5f3fc; }
  .pill-demand, .pill-no_ads { background: #451a03; color: #fde68a; }
  .pill-seasonal { background: #1e1b4b; color: #c7d2fe; }
  .pill-striking { background: #2e1065; color: #ddd6fe; }
  .pill-no_affiliate { background: #052e16; color: #bbf7d0; }
  .pill-stale { background: #3b0764; color: #e9d5ff; }
  .pill-dropped { background: #e5e7eb; color: #111827; }
  .flash-success { background: #052e16; border-color: #065f46; color: #a7f3d0; }
  .flash-error { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
  .flash-warn { background: #451a03; border-color: #78350f; color: #fde68a; }
}
