:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0c4a8c;
  --brand-2: #0ea5e9;
  --brand-soft: #e0f2fe;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --sim: #7c3aed;
  --sim-soft: #ede9fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .05);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 6px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.env-banner { background: #0f172a; color: #fde68a; text-align: center; font-size: 12px; padding: 6px 12px; letter-spacing: .02em; }
.env-banner strong { color: #facc15; }
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 30px); }
.sidebar { background: linear-gradient(180deg, #0c4a8c, #083766); color: #e0f2fe; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #38bdf8, #e0f2fe); display: grid; place-items: center; color: #0c4a8c; font-weight: 800; }
.brand-name { font-weight: 700; color: #fff; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; color: #bae6fd; font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #e0f2fe; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.nav a.active { background: #fff; color: var(--brand); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.sidebar-foot { margin-top: 20px; padding: 12px; background: rgba(255, 255, 255, .08); border-radius: 10px; font-size: 12px; }
.sidebar-foot .row { display: flex; justify-content: space-between; margin: 3px 0; }

.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--brand-2); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; cursor: pointer; transition: background .15s, border-color .15s; font-family: inherit; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0a3d74; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.warn { color: var(--warn); border-color: #fde68a; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.btn.loading::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge.ok, .badge.published, .badge.passed, .badge.approved, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.retry_wait, .badge.blocked, .badge.expired, .badge.draft, .badge.paused, .badge.planned { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.failed, .badge.flagged, .badge.uncertain { background: var(--bad-soft); color: var(--bad); }
.badge.info, .badge.scheduled, .badge.running { background: var(--brand-soft); color: var(--brand); }
.badge.sim { background: var(--sim-soft); color: var(--sim); }
.badge.canceled, .badge.archived, .badge.completed { background: #f1f5f9; color: #64748b; }
.badge.platform { background: #0f172a; color: #fff; text-transform: capitalize; }

form .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
label { font-weight: 600; font-size: 12px; color: #334155; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=file], select, textarea {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
input:invalid:not(:placeholder-shown) { border-color: #fca5a5; }
.row-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .icon { font-size: 30px; margin-bottom: 6px; }
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; font-size: 13px; }
.alert.warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.alert.bad { background: var(--bad-soft); border-color: #fecaca; color: #7f1d1d; }
.alert.info { background: var(--brand-soft); border-color: #bae6fd; color: #0c4a6e; }
.alert.sim { background: var(--sim-soft); border-color: #ddd6fe; color: #4c1d95; }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); box-shadow: 0 24px 60px rgba(15, 23, 42, .3); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 14px 14px; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 16px; border-radius: 10px; color: #fff; box-shadow: var(--shadow); font-weight: 500; animation: slide .2s ease-out; }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }
.toast.info { background: #0c4a8c; }
.toast.warn { background: #92400e; }
@keyframes slide { from { transform: translateY(12px); opacity: 0; } }
#progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--brand-2); z-index: 2000; transition: width .3s; }
#progress.on { width: 70%; }

/* Content cards */
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.post { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.post.highlight { border-color: var(--brand-2); box-shadow: 0 0 0 3px #bae6fd; }
.post-head { display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 14px 0; align-items: center; }
.post-body { padding: 10px 14px; flex: 1; }
.post-body .hook { font-weight: 700; margin-bottom: 6px; }
.post-body .caption { white-space: pre-wrap; color: #1e293b; font-size: 13px; max-height: 190px; overflow: auto; }
.post-body .tags { color: var(--brand); font-size: 12px; margin-top: 8px; word-break: break-word; }
.post-body .concept { margin-top: 8px; font-size: 12px; color: var(--muted); background: #f8fafc; border-radius: 8px; padding: 8px; }
.post-media img { width: 100%; max-height: 220px; object-fit: cover; display: block; border-top: 1px solid var(--line); }
.post-foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; background: #fbfdff; }
.issues { margin: 8px 0 0; padding: 8px 10px 8px 26px; background: var(--bad-soft); color: #7f1d1d; border-radius: 8px; font-size: 12px; }
.claims-ok { margin-top: 8px; font-size: 12px; color: var(--ok); }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.media-item img { width: 100%; height: 160px; object-fit: cover; background: #e2e8f0; display: block; }
.media-item .meta { padding: 8px 10px; font-size: 12px; flex: 1; }
.media-item .foot { padding: 8px 10px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.picker button { border: 2px solid transparent; padding: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; }
.picker button:hover { border-color: var(--brand-2); }
.picker img { width: 100%; height: 100px; object-fit: cover; display: block; }
.dropzone { border: 2px dashed #94a3b8; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); background: #f8fafc; }
.dropzone.over { border-color: var(--brand-2); background: var(--brand-soft); }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal .dow { background: #f8fafc; padding: 8px; font-weight: 600; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day.other { background: #fafbfc; color: #94a3b8; }
.cal .day.today { background: #f0f9ff; }
.cal .num { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.cal .ev { display: block; width: 100%; text-align: left; font-size: 11px; padding: 4px 6px; border-radius: 6px; margin-bottom: 4px; border: 0; cursor: pointer; background: var(--brand-soft); color: var(--brand); font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev.published { background: var(--ok-soft); color: var(--ok); cursor: default; }
.cal .ev.failed, .cal .ev.uncertain, .cal .ev.blocked, .cal .ev.expired { background: var(--bad-soft); color: var(--bad); }
.cal .ev.retry_wait { background: var(--warn-soft); color: var(--warn); }

/* Charts */
.chart { width: 100%; height: 240px; }
.chart text { font-size: 11px; fill: #64748b; font-family: inherit; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; background: var(--c); vertical-align: -1px; }

.feed { max-width: 620px; }
.feed-post { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.feed-post .head { display: flex; justify-content: space-between; padding: 12px 14px; align-items: center; }
.feed-post .text { padding: 0 14px 12px; white-space: pre-wrap; }
.feed-post img { width: 100%; display: block; }
.events li { padding: 7px 0; border-bottom: 1px solid var(--line); list-style: none; display: flex; gap: 10px; }
.events { margin: 0; padding: 0; }
.events li:last-child { border-bottom: 0; }
.events .t { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 120px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); gap: 16px; }
.switch-row:last-child { border-bottom: 0; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-foot { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .cal .day { min-height: 80px; }
}

/* layout fixes */
.layout { background: linear-gradient(90deg, #083766 0, #083766 240px, transparent 240px); }
.grid > .card + .card { margin-top: 0; }
.filters select { width: auto; min-width: 150px; }
td.actions { display: table-cell; white-space: normal; }
td.actions > * { margin: 0 4px 4px 0; }
@media (max-width: 960px) { .layout { background: none; } }

/* ---- v2: environments, sub-navigation, leads, public pages ---- */
.env-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; margin-right: 8px; font-weight: 700; color: #0f172a; background: #e2e8f0; }
.env-badge.env-test { background: #f97316; color: #fff; }
.env-badge.env-prod { background: #22c55e; color: #052e16; }
.env-badge.env-dev { background: #a78bfa; color: #fff; }
body.env-test .sidebar { background: linear-gradient(180deg, #7c2d12, #431407); }
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: -4px 0 16px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.subnav a.active { color: var(--brand); border-bottom-color: var(--brand); }
.subnav a:hover { text-decoration: none; color: var(--ink); }
form.inline { display: inline; margin: 0; }
.linkish { background: none; border: 0; padding: 0; color: #bae6fd; cursor: pointer; font: inherit; text-decoration: underline; }
.badge.new, .badge.contacted { background: var(--brand-soft); color: var(--brand); }
.badge.qualified, .badge.appointment_scheduled { background: var(--warn-soft); color: var(--warn); }
.badge.converted { background: var(--ok-soft); color: var(--ok); }
.badge.closed, .badge.retired, .badge.rejected { background: #f1f5f9; color: #64748b; }
.badge.needs_verification { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.note-body { white-space: pre-wrap; }
.cap-table td, .cap-table th { vertical-align: top; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }

/* public pages (lead form, login): no dashboard chrome */
body.public { background: linear-gradient(180deg, #e0f2fe, var(--bg) 320px); }
.public-wrap { max-width: 720px; margin: 0 auto; padding: 32px 16px 64px; }
.public-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 18px; color: var(--brand); }
.public-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.public-card h1 { margin-bottom: 8px; }
.public-card fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 18px 0; }
.public-card legend { font-weight: 700; padding: 0 6px; }
.public-card .help { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.field-error { color: var(--bad); font-size: 12px; margin-top: 4px; }
.privacy { font-size: 12px; color: var(--muted); background: #f8fafc; border-radius: 8px; padding: 10px 12px; }
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }
.avail-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.public-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }

/* Content: more generation options, selling points, campaign ideas */
details.more-options { margin: 4px 0 12px; }
details.more-options > summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.check-list { display: flex; flex-direction: column; gap: 4px; max-height: 180px; overflow: auto; }
.ideas { display: grid; gap: 12px; margin-top: 12px; }
.post.idea .post-body ul { margin: 4px 0 6px 18px; padding: 0; }
.env-banner.test { background: #fef3c7; color: #78350f; }
