:root {
  --blue: #0b3d91; --blue-dark: #072a66; --red: #e63946; --ink: #14213d; --muted: #667085;
  --line: #e3e7ee; --bg: #f4f6fa; --card: #fff; --ok: #12805c; --warn: #b54708;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; }
[hidden] { display: none !important; }
a { color: var(--blue); }
h1 { font-size: 1.6rem; margin: 0 0 18px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 10px; }
h4 { margin: 0 0 6px; font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
code { background: #eef1f6; padding: 1px 6px; border-radius: 4px; font-size: .88em; word-break: break-all; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--red); min-height: 1.2em; }
.msg { color: var(--muted); min-height: 1.2em; margin: 0 0 12px; }
.empty { padding: 28px; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--blue); }
.btn--primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--blue-dark); }
.btn--danger { color: var(--red); border-color: #f3c3c7; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn--file { justify-content: center; margin-bottom: 10px; }
.link { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font: inherit; text-decoration: underline; }
.link.danger, .danger { color: var(--red); }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--blue-dark), var(--blue)); padding: 16px; }
.login__box { background: #fff; padding: 32px; border-radius: 16px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login__box h1 { margin: 6px 0 0; }
.login__box p { margin: 0; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .88rem; margin-bottom: 12px; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid #cfd5df; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

/* shell */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #0a1730; color: #c8d2e6; display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; text-decoration: none; font-size: 1.1rem; padding: 0 8px 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #c8d2e6; text-decoration: none; padding: 9px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side nav a:hover { background: #15264a; color: #fff; }
.side nav a.active { background: var(--blue); color: #fff; }
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 12px; }
.side__foot a, .side__foot .link { color: #c8d2e6; text-align: left; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 700; }
.main { padding: 28px 32px 60px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }
.head__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.head__actions input[type=search] { width: 280px; }
.head__actions select { width: auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 18px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.8rem; }
.stat small { font-size: .9rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.links { columns: 2; }


/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: #fafbfd; }
.table tr:last-child td { border-bottom: 0; }
.table small { color: var(--muted); }
.table select { width: auto; padding: 4px 8px; }
.table .actions { white-space: nowrap; }
.lead-row.is-new td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.lead-detail td { background: #fafbfd; }
.lead-detail__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.lead-detail p { white-space: pre-wrap; margin-top: 0; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef1f6; color: var(--muted); }
.pill--published, .pill--booked { background: #dcfae6; color: var(--ok); }
.pill--draft, .pill--quoted { background: #fef0c7; color: var(--warn); }
.pill--new { background: #fde2e4; color: var(--red); }
.pill--contacted { background: #e0eaff; color: var(--blue); }

/* editor */
.editor__grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.editor__main > label input[name=title] { font-size: 1.3rem; font-weight: 700; }
.rte-head { display: flex; justify-content: space-between; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
#quill { background: #fff; min-height: 460px; font-size: 16px; }
#quill .ql-editor { min-height: 460px; line-height: 1.65; }
.ql-toolbar.ql-snow { background: #fff; border-radius: 8px 8px 0 0; position: sticky; top: 0; z-index: 5; }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; }
.html-source { min-height: 500px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.faqs { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 18px; background: #fff; }
.faqs legend { font-weight: 700; padding: 0 6px; }
.faq-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.faq-row .link { justify-self: start; }
.cover-preview img { width: 100%; border-radius: 8px; margin-bottom: 10px; aspect-ratio: 1200 / 630; object-fit: cover; }
.count { font-weight: 400; color: var(--muted); }
.count.over { color: var(--red); font-weight: 700; }
.serp { border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: Arial, sans-serif; }
.serp__url { color: #202124; font-size: 12px; word-break: break-all; }
.serp__title { color: #1a0dab; font-size: 18px; line-height: 1.3; margin: 2px 0; }
.serp__desc { color: #4d5156; font-size: 13px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: #0a1730; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 100; max-width: 420px; }
.toast--error { background: var(--red); }

@media (max-width: 1100px) {
  .editor__grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side__foot { flex-direction: row; flex-wrap: wrap; margin-top: 12px; }
  .main { padding: 18px 16px 48px; }
  .lead-detail__grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .head__actions input[type=search] { width: 100%; }
}

/* live admin additions */
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }
.small { font-size: .82rem; }
.deploy-pill { display: inline-block; font-size: .8rem; padding: 4px 10px; border-radius: 999px; font-weight: 700; }
.deploy-pill.is-ok { background: #123d2c; color: #8ff0c2; }
.deploy-pill.is-busy { background: #3d3212; color: #ffd66b; }
.deploy-pill.is-bad { background: #4a1418; color: #ffb3b9; }
