:root {
  --bg: #0f1115;
  --panel: #161a21;
  --panel-2: #1c212a;
  --line: #262c37;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #5b8cff;
  --accent-2: #e5484d;
  --ok: #3dd68c;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* dark UA widgets (number spinners, scrollbars, the colour picker dialog) */
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; transition: 120ms;
}
.btn:hover { border-color: #3a4352; background: #232936; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0b1020; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--accent-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input {
  width: 100%; background: #0b0e13; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; outline: none;
}
.input:focus { border-color: var(--accent); }
/* a colour input keeps its swatch in a shadow element: the 10px input padding
   squeezed it to a hairline, so the theme colours looked empty */
input[type="color"].input { padding: 4px; height: 38px; cursor: pointer; }
input[type="color"].input::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].input::-webkit-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
input[type="color"].input::-moz-color-swatch { border: 1px solid var(--line); border-radius: 6px; }
/* a 2-row textarea plus 20px padding is shorter than two lines of text, which
   clipped the first line in the consent banner field */
textarea.input { min-height: 72px; line-height: 1.45; resize: vertical; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }

/* auth */
.auth-wrap { display: grid; place-items: center; height: 100%; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-card h1 { font-size: 20px; margin: 0 0 6px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.error { color: var(--accent-2); font-size: 13px; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* shell */
.shell { display: grid; grid-template-rows: 52px 1fr; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.spacer { flex: 1; }
.user { color: var(--muted); font-size: 13px; }

/* flows */
.page { padding: 28px; max-width: 900px; margin: 0 auto; }
.page h1 { font-size: 22px; margin: 0 0 18px; }
.new-flow { display: flex; gap: 10px; margin-bottom: 22px; }
.flow-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.flow-row:hover { border-color: #3a4352; }
.flow-row .title { font-weight: 600; }
.flow-row .meta { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* editor */
.editor { display: grid; grid-template-columns: 260px 1fr 300px; height: 100%; overflow: hidden; }
.rail { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; overflow: hidden; }
.rail-head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.rail-list { overflow-y: auto; padding: 8px; flex: 1; }
.screen-item {
  padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; margin-bottom: 4px;
  cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text);
}
.screen-item:hover { background: var(--panel-2); }
.screen-item.active { background: var(--panel-2); border-color: var(--accent); }
.screen-item .idx { color: var(--muted); font-size: 12px; width: 18px; }
.rail-actions { padding: 10px; border-top: 1px solid var(--line); }

.canvas { background:
  radial-gradient(circle at 1px 1px, #1c212a 1px, transparent 0) 0 0/22px 22px, var(--bg);
  display: grid; place-items: center; overflow: auto; }
.screen-frame { width: min(520px, 86%); background: #f7f8fa; color: #12161f; border-radius: 12px; min-height: 320px; padding: 28px; box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.screen-frame h2 { margin: 0 0 6px; font-size: 18px; }
.screen-frame .muted { color: #667; font-size: 13px; }
.placeholder { border: 1px dashed #c9cede; border-radius: 8px; padding: 18px; color: #778; font-size: 13px; margin-top: 16px; }

.inspector { border-left: 1px solid var(--line); background: var(--panel); padding: 16px; overflow-y: auto; }
.inspector h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv { margin-bottom: 12px; }
.kv .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.saving { color: #d8a13a; }
.save-state.saved { color: var(--ok); }

/* admin pages: integrations + analytics */
.page.wide { max-width: 1080px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; }
.page-head .meta { color: var(--muted); font-size: 12px; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.grid-form .kv.full { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.notice {
  border: 1px solid #3a4352; background: var(--panel-2); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
}
.pill { font-size: 11px; border-radius: 99px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: rgba(46, 160, 67, .5); }
.pill.bad { color: var(--accent-2); border-color: rgba(220, 80, 80, .5); }
.pill.warn { color: #d8a13a; border-color: rgba(216, 161, 58, .5); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.err { color: var(--accent-2); font-size: 12px; max-width: 260px; word-break: break-word; }
.hint-sm { color: var(--muted); font-size: 11px; }

/* content translations */
.tr-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; background: var(--panel-2); }
.tr-block-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 10px; }
.tr-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; margin-bottom: 10px; }
.tr-field .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.tr-text { font-size: 13px; opacity: .85; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice.error { border-color: rgba(220, 80, 80, .5); color: var(--accent-2); }
@media (max-width: 760px) { .tr-field { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }

.bar { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.alt span { background: var(--ok); }
.tag {
  display: inline-block; font-size: 11px; border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; margin: 2px 4px 2px 0; color: var(--text); background: var(--panel-2);
}
.tag b { color: var(--muted); margin-left: 4px; }
.ref-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ref-list li { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.ref-list li b { font-variant-numeric: tabular-nums; }

/* language switch */
.lang-switch { display: flex; gap: 2px; align-items: center; }
.lang-switch .btn[aria-current] { color: var(--accent); border-color: var(--accent); }

/* media library */
.media-upload { padding: 16px; margin-bottom: 18px; }
.media-upload h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-card {
  margin: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.media-thumb {
  height: 116px; display: grid; place-items: center; background: var(--panel-2);
  color: var(--muted); font-size: 12px; letter-spacing: .08em; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card figcaption { padding: 10px; display: grid; gap: 6px; }
.media-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-meta { color: var(--muted); font-size: 11px; }
.media-url { padding: 6px 8px; font-size: 11px; }
.media-card .row-actions { margin-top: 0; gap: 4px; align-items: center; }

/* template gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tpl-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.tpl-preview {
  height: 210px; overflow: hidden; background: var(--s-bg, #fff); color: var(--s-text, #111);
  padding: 18px 16px; border-bottom: 1px solid var(--line); pointer-events: none;
}
.tpl-preview .screen-body { gap: 8px; }
.tpl-preview .blk-title { font-size: 20px !important; }
.tpl-preview .blk-text { font-size: 12px; line-height: 1.4; }
.tpl-preview .blk-image.placeholder, .tpl-preview .blk-tic-ph, .tpl-preview .blk-logo-ph { display: none; }
.tpl-body { padding: 14px; display: grid; gap: 8px; }
.tpl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tpl-head h2 { margin: 0; font-size: 15px; }
.tpl-desc { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.tpl-meta { margin: 0; color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------- media search */
.media-search { display: flex; gap: 8px; margin: 0 0 12px; align-items: center; flex-wrap: wrap; }
.media-search .input { flex: 1; min-width: 220px; }
.media-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line, #e2e5ee); color: inherit; text-decoration: none; font-size: 13px; }
.chip:hover { border-color: var(--accent, #4f46e5); }
.chip.active { background: var(--accent, #4f46e5); border-color: var(--accent, #4f46e5); color: #fff; }
.chip-count { opacity: .7; font-variant-numeric: tabular-nums; }
.media-pager { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; }

/* ------------------------------------------------------------ import box */
.import-box { border: 1px solid var(--line, #e2e5ee); border-radius: 12px; padding: 12px 16px; margin: 0 0 22px; }
.import-box summary { cursor: pointer; font-weight: 600; }
.import-box .new-flow { margin-top: 12px; }
.import-paste { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.import-paste textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; resize: vertical; }

/* -------------------------------------------------------------- diff view */
.diff-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; }
.diff-picker .input { max-width: 260px; }
.diff-summary { display: flex; gap: 8px; margin: 0 0 12px; }
.diff-section { border-top: 1px solid var(--line, #e2e5ee); padding: 12px 0; }
.diff-section h2 { font-size: 16px; margin: 0 0 8px; }
.diff-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.diff-list li { display: flex; gap: 8px; align-items: baseline; }
.diff-mark { display: inline-block; width: 14px; text-align: center; font-weight: 700; }
.diff-add .diff-mark { color: #0f766e; }
.diff-remove .diff-mark { color: #b91c1c; }
.diff-change .diff-mark { color: #b45309; }
.section-title { margin: 26px 0 10px; font-size: 18px; }
.tpl-save { margin-top: 26px; }

/* ------------------------------------------------------------- tracking */
.blk-hidden-preview { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 8px 10px; font-size: 13px; color: #475569; }
.hf-consent { position: fixed; left: 16px; bottom: 16px; max-width: 360px; background: #fff; color: #111827; border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, .18); z-index: 9999; }
.hf-consent p { margin: 0 0 10px; font-size: 14px; line-height: 1.4; }
.hf-consent-actions { display: flex; gap: 8px; }
.hf-consent-settings { position: fixed; left: 16px; bottom: 16px; z-index: 9998; background: #fff; color: #374151; border: 1px solid #e5e7eb; border-radius: 999px; padding: 6px 12px; font-size: 12px; cursor: pointer; box-shadow: 0 4px 12px rgba(15, 23, 42, .12); }

/* ------------------------------------------------------------- insights */
.grid-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.heat-stage { position: relative; width: 420px; max-width: 100%; margin: 0 auto; }
.heat-render { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; color: #111; }
.heat-render .screen { display: block; }
.heat-render .screen-body { padding: 18px 14px; display: grid; gap: 10px; }
.heat-dots { position: absolute; inset: 0; pointer-events: none; }
.heat-dot {
  position: absolute; transform: translate(-50%, -50%); border-radius: 999px;
  background: rgba(239, 68, 68, .45); box-shadow: 0 0 0 2px rgba(239, 68, 68, .25);
}
