:root {
  color-scheme: light dark;
  --accent: #0040ff;
  --accent-ink: #ffffff;
  --ink: #0d1017;
  --red: #d64545;
  --yellow: #b8860b;
  --green: #2f9e44;
  --manual: #7048e8;
  --none: color-mix(in srgb, CanvasText 35%, transparent);
  --card-bg: color-mix(in srgb, CanvasText 4%, Canvas);
  --card-border: color-mix(in srgb, CanvasText 10%, transparent);
  --card-tint: color-mix(in srgb, #a1a7b3 12%, transparent);
  --radius: 12px;
  --shadow: 0 1px 2px color-mix(in srgb, CanvasText 6%, transparent), 0 8px 24px color-mix(in srgb, CanvasText 5%, transparent);
}

* { box-sizing: border-box; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: Canvas;
  color: CanvasText;
}

a { color: var(--accent); }

/* ---- App shell: sidebar + content ---- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: none;
  background: var(--ink);
  color: #e7e9ee;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 24px;
}
.sidebar .wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}
.sidebar .wordmark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: color-mix(in srgb, #e7e9ee 75%, transparent);
  text-decoration: none;
  font-size: 0.92rem;
}
.sidebar nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar nav a:hover:not(.active) { background: color-mix(in srgb, #fff 8%, transparent); }
.sidebar .sidebar-footer { margin-top: auto; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--card-border);
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 700; }

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { text-decoration: underline; }

.container { max-width: 1040px; margin: 0 auto; padding: 24px 32px 64px; width: 100%; }

/* ---- Login ---- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--ink); }
.login-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 340px;
  padding: 32px;
  background: Canvas;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; font-size: 1.3rem; }
.error { color: var(--red); font-size: 0.9rem; margin: 0; }

/* ---- Form controls ---- */

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; }
input, textarea, button, select {
  font: inherit;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: Canvas;
  color: CanvasText;
}
button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border: none;
}
button:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
button:disabled { opacity: 0.5; cursor: default; }
button.link-button, button.secondary {
  background: none;
  color: var(--accent);
  border: 1px solid var(--card-border);
}
button.secondary:hover { background: var(--card-tint); }

.audit-form { display: grid; gap: 12px; margin-bottom: 24px; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }

.status { padding: 16px; border-radius: var(--radius); background: var(--card-tint); }

/* ---- Stat strip ---- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: Canvas;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-card .value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-card .label { font-size: 0.82rem; opacity: 0.65; margin-top: 4px; }

/* ---- Add-site ---- */

.add-site {
  margin-bottom: 20px;
  background: Canvas;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
}
.add-site summary { cursor: pointer; font-weight: 600; }
.add-site .audit-form { margin: 16px 0 4px; }

/* ---- Sites table ---- */

.sites-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 32px;
  background: Canvas;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sites-table th, .sites-table td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.9rem;
}
.sites-table th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.6;
  background: var(--card-tint);
}
.sites-table tbody tr:hover { background: var(--card-tint); }
.sites-table tbody tr:last-child td { border-bottom: none; }

.priority-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--none);
}
.priority-dot.p-red { background: var(--red); }
.priority-dot.p-yellow { background: var(--yellow); }
.priority-dot.p-green { background: var(--green); }
.priority-dot.p-manual { background: var(--manual); }

/* ---- Detail panel ---- */

.detail {
  background: Canvas;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 28px;
}
.detail-meta { opacity: 0.65; font-size: 0.9rem; }

.audit-history { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 0.9rem; }

/* ---- Issues (LLM report) ---- */

.issues { display: grid; gap: 12px; }
.issue {
  border-left: 4px solid var(--green);
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--card-tint);
}
.issue h3 { margin: 4px 0; font-size: 1rem; }
.issue p { margin: 4px 0; font-size: 0.9rem; }
.issue-priority {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.issue-red { border-color: var(--red); }
.issue-red .issue-priority { color: var(--red); }
.issue-yellow { border-color: var(--yellow); }
.issue-yellow .issue-priority { color: var(--yellow); }
.issue-green { border-color: var(--green); }
.issue-green .issue-priority { color: var(--green); }
.issue-manual { border-color: var(--manual); }
.issue-manual .issue-priority { color: var(--manual); }

#draftMessage { width: 100%; margin-bottom: 8px; }

/* ---- Raw checks, grouped by category ---- */

.check-blocks { display: grid; gap: 10px; margin-top: 8px; }
.check-block {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}
.check-block summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.92rem;
  background: var(--card-tint);
}
.check-block .check-list { padding: 4px 14px 12px; display: grid; gap: 8px; }
.check-row { display: flex; gap: 10px; align-items: baseline; font-size: 0.87rem; padding: 4px 0; border-bottom: 1px solid var(--card-border); }
.check-row:last-child { border-bottom: none; }
.check-row .priority-dot { flex: none; margin-top: 3px; }
.check-row .check-name { font-weight: 600; }
.check-row .check-summary { opacity: 0.8; }

/* ---- Checklist ("что будет проверено") ---- */

.checklist-toggle { margin-bottom: 16px; }
.checklist-hint { font-size: 0.85rem; opacity: 0.75; margin: 10px 0; }
.checklist-hint .link-button { font-size: inherit; }
.checklist-row { padding: 8px 0; border-bottom: 1px solid var(--card-border); font-size: 0.87rem; }
.checklist-row:last-child { border-bottom: none; }
.checklist-row-head { display: flex; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.checklist-row-head .priority-dot { flex: none; }
.checklist-checkbox { width: auto; margin: 0; flex: none; }
.checklist-desc { margin: 4px 0 2px; opacity: 0.85; }
.checklist-source { margin: 0; font-size: 0.8rem; opacity: 0.6; }
.checklist-note { opacity: 0.7; font-style: italic; }

.paid-badge {
  display: inline-block;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.paid-badge.paid-free { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.paid-badge.paid-optional { background: color-mix(in srgb, var(--yellow) 15%, transparent); color: var(--yellow); }
.paid-badge.paid-paid { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.paid-badge.paid-manual { background: color-mix(in srgb, var(--manual) 15%, transparent); color: var(--manual); }
