:root{
  --bg:#f4f6f4;--card:#fff;--ink:#16211a;--muted:#647268;--line:#e1e7e2;
  --brand:#7dc242;--brand-dark:#6fb136;--navy:#0b1d33;--danger:#c0392b;--radius:12px;
}
*{box-sizing:border-box}
body{margin:0;font-family:Barlow,system-ui,sans-serif;background:var(--bg);color:var(--ink);font-size:15px;line-height:1.5}
a{color:#3f7d16}
h1{font-size:1.6rem;margin:.2rem 0}
h3{margin:0 0 .2rem}
code{background:#eef2ee;padding:.1rem .35rem;border-radius:5px;font-size:.85em}
.muted{color:var(--muted)}
.small{font-size:.85rem}

.topnav{display:flex;justify-content:space-between;align-items:center;padding:0 24px;height:58px;background:var(--navy);position:sticky;top:0;z-index:20}
.topnav .link{color:rgba(255,255,255,.8)}
.topnav .link:hover{color:#fff}
.logo{display:flex;align-items:center;gap:.6rem;color:#fff;text-decoration:none;font-family:'Barlow Condensed',sans-serif;font-weight:700;font-size:1.05rem;letter-spacing:.05em;text-transform:uppercase}
.logo img{height:34px;width:auto}
.login-logo{height:64px;width:auto;margin:0 auto .6rem}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:.4rem;padding:.6rem 1rem;border-radius:9px;border:1px solid var(--line);background:#fff;color:var(--ink);font:inherit;font-weight:600;cursor:pointer;text-decoration:none;white-space:nowrap}
.btn:hover{border-color:#c6d1c8;background:#fafcfa}
.btn.primary{background:var(--brand);border-color:var(--brand);color:var(--navy)}
.btn.primary:hover{background:var(--brand-dark);border-color:var(--brand-dark)}
.btn.danger{color:var(--danger)}
.btn.danger:hover{background:#fdf1ef;border-color:#f0c4be}
.btn.danger-solid{background:var(--danger);border-color:var(--danger);color:#fff}
.btn.danger-solid:hover{background:#a93226;border-color:#a93226}
.btn.block{width:100%}

/* Modal */
.modal{border:0;padding:28px 26px 22px;border-radius:16px;width:min(420px,calc(100% - 32px));background:#fff;color:var(--ink);box-shadow:0 24px 60px rgba(11,29,51,.28);text-align:center;animation:modal-in .18s ease-out}
.modal::backdrop{background:rgba(11,29,51,.55);backdrop-filter:blur(3px);animation:fade-in .18s ease-out}
.modal.closing{animation:modal-out .14s ease-in forwards}
.modal.closing::backdrop{animation:fade-out .14s ease-in forwards}
.modal-icon{width:52px;height:52px;margin:0 auto 14px;border-radius:50%;display:grid;place-items:center;background:#eaf6df;color:#3f7d16}
.modal-icon svg{width:26px;height:26px}
.modal[data-tone=danger] .modal-icon{background:#fdecea;color:var(--danger)}
.modal[data-tone=warn] .modal-icon{background:#fff4dc;color:#b7791f}
.modal-title{font-family:'Barlow Condensed',sans-serif;font-size:1.45rem;margin:0 0 .35rem;line-height:1.2}
.modal-text{color:var(--muted);margin:0 0 1.4rem}
.modal-actions{display:flex;gap:.6rem}
.modal-actions .btn{flex:1;padding:.7rem 1rem}
.modal-actions .btn[hidden]{display:none}
@keyframes modal-in{from{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}
@keyframes modal-out{to{opacity:0;transform:translateY(6px) scale(.98)}}
@keyframes fade-in{from{opacity:0}}
@keyframes fade-out{to{opacity:0}}

/* Saved toast */
.alert.ok.toast{position:fixed;left:50%;top:72px;translate:-50% 0;z-index:50;margin:0;display:flex;align-items:center;gap:.5rem;padding:.8rem 1.1rem;background:var(--navy);color:#fff;border:0;border-left:0;box-shadow:0 12px 30px rgba(11,29,51,.25);cursor:pointer;animation:toast-in .25s ease-out;transition:opacity .3s,transform .3s}
.alert.toast svg{width:18px;height:18px;color:var(--brand);flex:none}
.alert.toast.hide{opacity:0;transform:translateY(-8px);pointer-events:none}
@keyframes toast-in{from{opacity:0;transform:translateY(-12px)}}
@media (prefers-reduced-motion:reduce){.modal,.modal::backdrop,.alert.toast{animation:none;transition:none}}
.btn.small{padding:.45rem .8rem;font-size:.85rem}
.link{background:none;border:0;color:var(--muted);font:inherit;cursor:pointer;text-decoration:none;padding:0}
.link:hover{color:var(--ink)}
.icon-btn{width:30px;height:30px;border-radius:8px;border:1px solid var(--line);background:#fff;cursor:pointer;font-size:.9rem;color:var(--muted)}
.icon-btn:hover{color:var(--ink);border-color:#c6d1c8}
.icon-btn.danger:hover{color:var(--danger);border-color:#f0c4be}
.count{background:#e6f0e6;color:var(--brand-dark);border-radius:999px;padding:0 .45rem;font-size:.8rem}
.pill{display:inline-block;font-size:.72rem;font-weight:700;padding:.05rem .5rem;border-radius:999px;background:#eceff0;color:var(--muted);margin-left:.3rem}
.pill.ok{background:#e3f4e4;color:#1f7a2a}

.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:20px}
.alert{padding:.7rem .9rem;border-radius:9px;margin:.75rem 0;font-weight:600}
.alert.ok{background:#e6f5e7;color:#1f6b28;border:1px solid #c5e6c8}
.alert.error{background:#fdf1ef;color:var(--danger);border:1px solid #f0c4be}
.empty{text-align:center;color:var(--muted);padding:48px 16px;border:2px dashed var(--line);border-radius:var(--radius)}

/* form fields */
.f{display:grid;gap:.3rem;margin-bottom:.9rem}
.f > span{font-weight:600;font-size:.82rem;color:#3b4a40}
.f small{color:var(--muted);font-size:.78rem}
input[type=text],input[type=tel],input[type=email],input[type=url],input[type=password],input:not([type]),select,textarea{width:100%;padding:.6rem .75rem;border:1px solid var(--line);border-radius:8px;font:inherit;background:#fff;color:var(--ink)}
input:focus,select:focus,textarea:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(125,194,66,.25)}
textarea{resize:vertical}
.check{display:flex;align-items:center;gap:.5rem;font-weight:500;cursor:pointer;margin:.3rem 0}
.check input{width:16px;height:16px;accent-color:var(--brand)}
.checks{display:flex;flex-wrap:wrap;gap:.3rem 1.4rem}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 .9rem}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:0 .9rem}

/* login */
.login{min-height:100vh;display:grid;place-items:center;padding:16px}
.login-card{width:min(380px,100%);text-align:center}
.login-card .f{text-align:left;margin-top:1rem}

/* dashboard */
.wrap{width:min(1000px,100% - 32px);margin:28px auto 60px}
.page-head{display:flex;justify-content:space-between;align-items:end;margin:.5rem 0 1.2rem}
.new-site{display:flex;gap:.8rem;align-items:end;margin-bottom:1.5rem}
.new-site .f{margin:0;flex:1}
.site-list{display:grid;gap:.8rem}
.site-card{display:flex;align-items:center;gap:1rem;background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:14px}
.site-thumb{width:72px;height:72px;border-radius:12px;flex:none;display:grid;place-items:center;font-size:1.8rem;background:linear-gradient(135deg,var(--p),color-mix(in srgb,var(--p) 60%,#000));border-bottom:6px solid var(--a);overflow:hidden}
.site-thumb img{max-width:80%;max-height:80%;object-fit:contain;background:#fff;border-radius:6px;padding:3px}
.site-meta{flex:1;min-width:0}
.site-meta p{margin:.1rem 0}
.site-actions{display:flex;gap:.5rem;flex-wrap:wrap;justify-content:flex-end}
.site-actions form{margin:0}

/* builder */
.builder{display:grid;grid-template-columns:minmax(380px,520px) 1fr;height:calc(100vh - 58px)}
.editor{overflow-y:auto;padding:20px 22px 0;border-right:1px solid var(--line);background:var(--bg)}
.editor-head{margin-bottom:1rem}
.sec{background:#fff;border:1px solid var(--line);border-radius:var(--radius);margin-bottom:.8rem}
.sec summary{cursor:pointer;padding:14px 16px;font-weight:700;list-style:none;display:flex;justify-content:space-between}
.sec summary::-webkit-details-marker{display:none}
.sec summary::after{content:"▾";color:var(--muted);transition:transform .2s}
.sec:not([open]) summary::after{transform:rotate(-90deg)}
.sec > :not(summary){margin-left:16px;margin-right:16px}
.sec > :last-child{margin-bottom:16px}
.savebar{position:sticky;bottom:0;display:flex;gap:.6rem;padding:14px 0 18px;background:linear-gradient(transparent,var(--bg) 30%)}
.savebar .primary{flex:1}

.presets{display:flex;flex-wrap:wrap;gap:.45rem}
.preset{display:flex;align-items:center;gap:3px;padding:.3rem .55rem .3rem .35rem;border:1px solid var(--line);border-radius:999px;background:#fff;cursor:pointer;font:inherit;font-size:.78rem}
.preset:hover{border-color:#b9c6bc}
.preset i{width:16px;height:16px;border-radius:50%;display:inline-block;border:1px solid rgba(0,0,0,.08)}
.preset span{margin-left:4px}
.color{display:flex;align-items:center;gap:.5rem;border:1px solid var(--line);border-radius:8px;padding:.3rem .4rem;background:#fff}
.color input{width:34px;height:28px;border:0;padding:0;background:none;cursor:pointer}
.color code{background:none;padding:0}

.gal-thumbs{display:grid;grid-template-columns:repeat(auto-fill,minmax(96px,1fr));gap:.6rem;margin-bottom:.4rem}
.gal-thumb img{width:100%;height:68px;object-fit:cover;border-radius:8px}
.gal-thumb .check{font-size:.78rem;margin:.2rem 0 0}
.img-row{display:flex;gap:.8rem;align-items:flex-start}
.img-row input[type=file]{font-size:.82rem;max-width:100%}
.img-row small{display:block;margin-top:.3rem}
.img-preview{width:92px;height:72px;flex:none;border-radius:9px;border:1px solid var(--line);background:#f7f9f7 repeating-conic-gradient(#eef1ee 0 25%,#fff 0 50%) 0 0/14px 14px;display:grid;place-items:center;overflow:hidden;font-size:.72rem;color:var(--muted)}
.img-preview img{max-width:100%;max-height:100%;object-fit:contain}

.repeater .rep-list{display:grid;gap:.6rem;margin-bottom:.7rem}
.rep-row{position:relative;border:1px solid var(--line);border-radius:10px;padding:12px 12px 2px;background:#fbfcfb}
.rep-row .f{margin-bottom:.6rem}
.rep-tools{position:absolute;top:8px;right:8px;display:flex;gap:4px}
.rep-tools .icon-btn{width:24px;height:24px;font-size:.75rem}
.rep-row .f:first-child{padding-right:84px}

.preview{display:flex;flex-direction:column;background:#dfe5e0;min-width:0}
.preview-bar{display:flex;align-items:center;gap:.8rem;padding:10px 14px;background:#fff;border-bottom:1px solid var(--line)}
.dots{display:flex;gap:5px}
.dots i{width:10px;height:10px;border-radius:50%;background:#e2e6e3}
.url{flex:1;background:var(--bg);border-radius:7px;padding:.3rem .7rem;color:var(--muted);font-size:.82rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.devices{display:flex;gap:4px}
.devices button{border:1px solid var(--line);background:#fff;border-radius:7px;padding:.2rem .5rem;cursor:pointer;opacity:.55}
.devices button.on{opacity:1;border-color:var(--brand)}
.frame-wrap{flex:1;display:flex;justify-content:center;padding:14px;overflow:hidden}
.frame-wrap iframe{width:100%;height:100%;border:0;border-radius:10px;background:#fff;box-shadow:0 10px 30px rgba(0,0,0,.12);transition:width .25s}
.frame-wrap.mobile iframe{width:390px}

/* leads */
.table-card{padding:0;overflow-x:auto}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:12px 14px;border-bottom:1px solid var(--line);vertical-align:top}
th{font-size:.78rem;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);background:#fafcfa}
td.msg{max-width:340px;white-space:pre-wrap}
tr:last-child td{border-bottom:0}

@media (max-width:960px){
  .builder{grid-template-columns:1fr;height:auto}
  .editor{overflow:visible;border-right:0}
  .preview{height:80vh}
  .site-card{flex-wrap:wrap}
  .site-actions{width:100%;justify-content:flex-start}
}
@media (max-width:560px){
  .grid2,.grid3{grid-template-columns:1fr}
  .new-site{flex-direction:column;align-items:stretch}
  .topnav{padding:0 16px}
}
