/* Hillyard Sites dashboard + editor */
:root {
  --bg: #f5f7f9; --surface: #fff; --text: #141c27; --muted: #5a6677; --line: #dde2e9;
  --accent: #0f7a6c; --accent-ink: #fff; --accent-soft: #dcf1ed; --danger: #c43c3c; --warn: #b7791f;
  --dark: #0d1420; --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 18px rgba(16,24,40,.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hidden, [hidden] { display: none !important; }

/* Top bar */
.top { background: var(--dark); color: #e9eef4; height: 58px; display: flex; align-items: center; gap: 18px; padding: 0 20px; position: sticky; top: 0; z-index: 30; }
.top .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; }
.top .brand img { width: 26px; height: 26px; }
.top .spacer { flex: 1; }
.top a, .top button.link { color: #b9c6d4; text-decoration: none; font-weight: 600; background: none; border: 0; font: inherit; cursor: pointer; }
.top a:hover, .top button.link:hover { color: #fff; }

.page { max-width: 1100px; margin: 0 auto; padding: 32px 20px 80px; }
.page-narrow { max-width: 460px; margin: 60px auto; padding: 0 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* Forms */
label.f { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
input, textarea, select { font: inherit; font-weight: 400; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: .92rem; margin-bottom: 12px; cursor: pointer; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: 9px 0 0 9px; }
.input-suffix span { background: #eef1f4; border: 1px solid var(--line); border-left: 0; border-radius: 0 9px 9px 0; padding: 9px 11px; color: var(--muted); white-space: nowrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  border-radius: 9px; padding: 9px 16px; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: #fff; color: var(--danger); border-color: #efc4c4; }
.btn.sm { padding: 5px 10px; font-size: .86rem; border-radius: 7px; }
.btn.lg { padding: 12px 22px; font-size: 1.02rem; }
.icon-btn { background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--muted); font: inherit; }
.icon-btn:hover { background: #eef1f4; color: var(--text); }

.msg { padding: 10px 14px; border-radius: 9px; background: var(--accent-soft); color: #0b4f46; font-weight: 600; }
.msg.error { background: #fbe7e7; color: #8a2424; }
.msg.warn { background: #fdf2dc; color: #7a4f0d; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eef1f4; color: var(--muted); }
.pill.ok { background: var(--accent-soft); color: #0b4f46; }
.pill.warn { background: #fdf2dc; color: #7a4f0d; }
.pill.bad { background: #fbe7e7; color: #8a2424; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }
.copybox { display: flex; gap: 8px; align-items: center; background: #f1f4f7; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.copybox span { flex: 1; overflow-wrap: anywhere; }

/* Sites list / templates */
.site-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.site-card:hover { border-color: var(--accent); }
.tpl { cursor: pointer; padding: 0; overflow: hidden; text-align: left; font: inherit; color: inherit; }
.tpl img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.tpl div { padding: 12px 14px; }
.tpl[aria-pressed="true"] { outline: 3px solid var(--accent); }

/* Site tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.bar { height: 120px; display: flex; align-items: flex-end; gap: 3px; }
.bar div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bar div:hover { background: #0b5a50; }
.price-card h3 { margin: 0; }
.price-card .amt { font-size: 1.8rem; font-weight: 800; }
.price-card.current { outline: 2px solid var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 110px; border: 2px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; background: #fff; font: inherit; font-size: .85rem; font-weight: 600; text-align: left; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch .dots { display: flex; gap: 4px; margin-bottom: 6px; }
.swatch .dots i { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); display: block; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-grid button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: #eef1f4; aspect-ratio: 1; position: relative; }
.media-grid button:hover { border-color: var(--accent); }
.media-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(8,14,22,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 14px; width: min(760px, 100%); max-height: 88vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; z-index: 200; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }

/* ---------- Editor ---------- */
body.editor { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.ed-top { gap: 12px; }
.ed-top select { width: auto; min-width: 160px; background: #1b2635; color: #fff; border-color: #2a3747; padding: 6px 10px; }
.ed-top .save-state { color: #8fa1b5; font-size: .85rem; min-width: 80px; }
.ed-top .btn.ghost { background: transparent; color: #dfe7ef; border-color: #33445a; }
.ed-top .seg { display: flex; border: 1px solid #33445a; border-radius: 8px; overflow: hidden; }
.ed-top .seg button { background: transparent; color: #b9c6d4; border: 0; padding: 6px 10px; cursor: pointer; font: inherit; font-weight: 600; }
.ed-top .seg button[aria-pressed="true"] { background: #2a3747; color: #fff; }
.ed-body { flex: 1; display: flex; min-height: 0; }
.ed-side { width: 330px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ed-side-scroll { flex: 1; overflow: auto; padding: 16px; }
.ed-side h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 6px 0 10px; }
.blk { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 12px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; cursor: pointer; background: #fff; }
.blk:hover { border-color: #b9c4d0; }
.blk.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.blk .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk .sub { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; }
.blk.dragging { opacity: .4; }
.add-list button { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; font: inherit; }
.add-list button:hover { border-color: var(--accent); }
.add-list button strong { display: block; }
.add-list button span { color: var(--muted); font-size: .85rem; }
.add-list button:disabled { opacity: .5; cursor: not-allowed; }
.ed-stage { flex: 1; background: #e3e8ee; display: flex; justify-content: center; overflow: hidden; padding: 16px; }
.ed-stage iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; box-shadow: var(--shadow); transition: width .2s; }
.ed-stage.mobile iframe { width: 400px; }
.tip { background: #f3f6f9; border-radius: 9px; padding: 10px 12px; font-size: .85rem; color: var(--muted); }
.list-items .li { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 8px; }
.list-items .li-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: .85rem; margin-bottom: 6px; color: var(--muted); }
.img-field { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.img-field img, .img-field .ph { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #eef1f4; flex: none; }
@media (max-width: 800px) { .ed-side { width: 100%; position: absolute; z-index: 20; height: calc(100vh - 58px); } .ed-side.closed { display: none; } }
