/* IKIGAI × CleverTap: deep green #004830, lime #AFCA32, CleverTap red #E53535. */
:root {
  --brand-green: #004830;
  --brand-green-deep: #00301f;
  --brand-lime: #afca32;
  --ct-red: #e53535;

  --bg: #f3f6f1;
  --surface: #ffffff;
  --surface-2: #f0f4ed;
  --border: #e0e7dc;
  --border-strong: #c8d3c3;
  --text: #13201a;
  --muted: #5a6a61;
  --accent: #004830;
  --accent-hover: #00603f;
  --accent-text: #ffffff;
  --accent-soft: #e5efe8;
  --ring: rgba(175, 202, 50, 0.5);
  --ok: #15784a;
  --ok-soft: #e1f3e8;
  --warn: #935500;
  --warn-soft: #fcf0d9;
  --err: #c0322b;
  --err-soft: #fbe6e4;
  --code-bg: #0f241a;
  --code-text: #d8eadf;
  --code-border: transparent;
  --toast-bg: #0f241a;
  --shadow: 0 1px 2px rgba(0, 48, 31, 0.05), 0 6px 20px -8px rgba(0, 48, 31, 0.12);
  --radius: 14px;
  --page-w: 1360px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

/* Dark palette: follows the OS unless the user picked a theme in Settings (html[data-theme]). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1310;
    --surface: #131c18;
    --surface-2: #1a2520;
    --border: #24322b;
    --border-strong: #34463c;
    --text: #e6eee9;
    --muted: #96a79d;
    --accent: #afca32;
    --accent-hover: #c2dc48;
    --accent-text: #10200f;
    --accent-soft: #222d15;
    --ring: rgba(175, 202, 50, 0.35);
    --ok: #52c58f;
    --ok-soft: #12301f;
    --warn: #e7a93b;
    --warn-soft: #3a2b10;
    --err: #ff7a70;
    --err-soft: #3d1a18;
    --code-bg: #08100c;
    --code-text: #cfe3d6;
    --code-border: var(--border);
    --toast-bg: #1f2c25;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1310;
  --surface: #131c18;
  --surface-2: #1a2520;
  --border: #24322b;
  --border-strong: #34463c;
  --text: #e6eee9;
  --muted: #96a79d;
  --accent: #afca32;
  --accent-hover: #c2dc48;
  --accent-text: #10200f;
  --accent-soft: #222d15;
  --ring: rgba(175, 202, 50, 0.35);
  --ok: #52c58f;
  --ok-soft: #12301f;
  --warn: #e7a93b;
  --warn-soft: #3a2b10;
  --err: #ff7a70;
  --err-soft: #3d1a18;
  --code-bg: #08100c;
  --code-text: #cfe3d6;
  --code-border: var(--border);
  --toast-bg: #1f2c25;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 650; }
p { margin: 0; }
b { font-weight: 650; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Hero: brand lockup, title, tabs ---------- */
.hero {
  position: relative; z-index: 5; color: #fff;
  background:
    radial-gradient(700px 320px at 88% -20%, rgba(175, 202, 50, 0.28), transparent 65%),
    radial-gradient(500px 260px at 0% 120%, rgba(175, 202, 50, 0.12), transparent 70%),
    linear-gradient(135deg, var(--brand-green-deep) 0%, var(--brand-green) 55%, #0a5a3c 100%);
}
.hero-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hero-clover {
  position: absolute; right: -70px; top: -60px; width: 340px; height: 340px;
  opacity: 0.13; transform: rotate(-14deg); pointer-events: none; user-select: none;
}
.hero-inner { position: relative; max-width: var(--page-w); margin: 0 auto; padding: 18px 28px 24px; }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.lockup { display: flex; align-items: center; gap: 16px; min-width: 0; }
.lockup img { display: block; width: auto; }
.lockup-ikigai { height: 34px; }
.lockup-ct { height: 34px; }
.lockup-x { color: rgba(255, 255, 255, 0.55); font-size: 20px; font-weight: 300; line-height: 1; }

.account-pill {
  display: inline-flex; align-items: center; gap: 9px; max-width: 50vw;
  padding: 7px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08); color: #fff; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; backdrop-filter: blur(6px); transition: background 0.15s, border-color 0.15s;
}
#accountLabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.account-pill:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.4); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ff8a80; box-shadow: 0 0 0 3px rgba(255, 138, 128, 0.22); flex: none; }
.dot.ok { background: #c3e23e; box-shadow: 0 0 0 3px rgba(195, 226, 62, 0.25); }

.hero-title { margin-top: 22px; max-width: 760px; }
.hero-title h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.hero-title .sub { margin-top: 4px; color: rgba(255, 255, 255, 0.74); font-size: 14px; }
.hero-title code { background: rgba(175, 202, 50, 0.16); color: #dcef86; border: 1px solid rgba(175, 202, 50, 0.3); white-space: nowrap; }
.hero-title b { color: #fff; }

.tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.tab {
  appearance: none; display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0;
  font: inherit; color: #fff; cursor: pointer; padding: 11px 14px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.13);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.tab:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); }
.tab:focus-visible { outline: 2px solid var(--brand-lime); outline-offset: 2px; }
.tab-icon {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: rgba(175, 202, 50, 0.16); color: var(--brand-lime);
}
.tab-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab-text { display: flex; flex-direction: column; min-width: 0; }
.tab-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-desc { font-size: 12px; color: rgba(255, 255, 255, 0.62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab[aria-selected="true"] {
  background: var(--surface); border-color: var(--brand-lime); color: var(--text);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, 0.45), inset 0 3px 0 var(--brand-lime);
}
.tab[aria-selected="true"] .tab-icon { background: var(--accent); color: var(--accent-text); }
.tab[aria-selected="true"] .tab-desc { color: var(--muted); }

main { padding: 24px 28px 32px; max-width: var(--page-w); margin: 0 auto; }

.site-footer {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; text-align: center;
  padding: 4px 16px 32px; color: var(--muted); font-size: 12.5px;
}
.site-footer img { width: 18px; height: 18px; }
.site-footer b { color: var(--text); font-weight: 600; }

/* ---------- Layout ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.col-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-send { position: sticky; top: 16px; min-width: 0; }
@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .col-send { position: static; }
  .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .hero-inner { padding: 14px 16px 18px; }
  main { padding: 18px 16px 28px; }
  .lockup { gap: 10px; }
  .lockup-ikigai { height: 26px; }
  .lockup-ct { height: 26px; }
  .account-pill { max-width: 100%; }
  .hero-title { margin-top: 16px; }
  .hero-title h1 { font-size: 22px; }
  .hero-clover { width: 220px; height: 220px; right: -60px; top: -40px; }
  .tabs { gap: 8px; margin-top: 16px; }
  .tab { padding: 9px 10px; gap: 9px; }
  .tab-icon { width: 30px; height: 30px; border-radius: 8px; }
  .tab-icon svg { width: 16px; height: 16px; }
  .tab-title { font-size: 13px; }
  .tab-desc { display: none; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
@media (max-width: 600px) { .card { padding: 16px; } }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.card-head .muted { margin-top: 4px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-size: 12.5px; font-weight: 700;
  margin-right: 8px; vertical-align: 1px;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.field > label, .label, .label-row > label { font-weight: 600; font-size: 13px; }
.field > label .muted { font-weight: 400; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 11px; min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8d84' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:focus) { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
textarea { resize: vertical; width: 100%; }
textarea.code, .code { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
textarea.code { background: var(--surface-2); }
textarea.code:focus { background: var(--surface); }
.input-group { display: flex; gap: 6px; min-width: 0; }
.input-group > input { flex: 1; }
.input-group > select { flex: none; }
@media (max-width: 600px) { .input-group { flex-wrap: wrap; } .input-group > input { flex-basis: 100%; } }

.check { display: flex; align-items: center; gap: 9px; font-size: 13px; margin-bottom: 14px; cursor: pointer; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row-between .check { margin-bottom: 0; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled, .btn-primary:disabled:hover {
  background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); opacity: 1;
}
.icon-btn { padding: 6px 9px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; background: none; color: var(--muted);
  padding: 5px 13px; border-radius: 7px; cursor: pointer;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; max-width: 100%;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.target { cursor: default; background: var(--surface-2); border-color: var(--border); font-family: var(--mono); font-size: 12px; font-weight: 400; }
.chip.target:hover { color: var(--text); }
.chip.target span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 0 0 2px; }
.chip .x:hover { color: var(--err); }

.targets { border-top: 1px dashed var(--border-strong); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Property editor ---------- */
.props { display: flex; flex-direction: column; gap: 8px; }
.prop-row { display: grid; gap: 6px; align-items: center; }
.prop-row.with-op { grid-template-columns: minmax(0, 1.2fr) 104px 104px minmax(0, 1.5fr) auto; }
.prop-row.no-op { grid-template-columns: minmax(0, 1.2fr) 108px minmax(0, 1.6fr) auto; }
.prop-row select, .prop-row input { width: 100%; }
.prop-row .remove { color: var(--muted); }
.prop-row .remove:hover { color: var(--err); }
.props-foot { margin-top: 6px; }
.props-foot .btn-ghost { color: var(--accent); }
@media (max-width: 600px) {
  .prop-row.with-op, .prop-row.no-op { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-bottom: 10px; border-bottom: 1px dashed var(--border); }
  .prop-row .remove { grid-column: 1 / -1; justify-self: end; margin-top: -2px; }
}

details.help {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}
details.help summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.help summary:hover { color: var(--text); }
details.help ul { margin: 8px 0 2px; padding-left: 18px; }
details.help li { margin-bottom: 4px; }
details.help li::marker { color: var(--brand-lime); }
details.help .field { margin-top: 12px; }

/* ---------- Reports & messages ---------- */
.report { margin-top: 4px; display: flex; flex-direction: column; gap: 8px; }
.report:empty { display: none; }
.report-line { font-size: 13px; }
.msg {
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
}
.msg ul { margin: 4px 0 0; padding-left: 18px; }
.msg.warn { background: var(--warn-soft); color: var(--warn); }
.msg.err { background: var(--err-soft); color: var(--err); }
.msg.ok { background: var(--ok-soft); color: var(--ok); }
.msg.info { background: var(--accent-soft); color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  background: var(--surface-2); font-weight: 600; white-space: nowrap;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.badge.cancelled { background: var(--surface-2); color: var(--muted); }

/* ---------- Profile lookup ---------- */
.profile-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; }
.profile-card .row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.profile-card summary { cursor: pointer; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }

/* ---------- Send panel ---------- */
.send-card { display: flex; flex-direction: column; gap: 14px; border-top: 3px solid var(--brand-lime); }
.send-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.counter {
  align-self: flex-start; font-size: 13px; color: var(--accent);
  background: var(--accent-soft); padding: 4px 12px; border-radius: 999px;
}
.counter b { color: inherit; font-size: 14px; }
pre.preview {
  margin: 0; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: 10px;
  padding: 14px 16px; max-height: 420px; overflow: auto; font: 12px/1.6 var(--mono); white-space: pre;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.send-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.send-actions .btn { padding: 10px 18px; }
.send-actions .btn-primary { flex: 1; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand-lime), var(--accent)); border-radius: 999px; transition: width 0.3s; }

.result { display: flex; flex-direction: column; gap: 10px; }
.result:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .t { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.success { background: var(--ok-soft); color: var(--ok); }
.badge.partial { background: var(--warn-soft); color: var(--warn); }
.badge.fail { background: var(--err-soft); color: var(--err); }
.badge.dry { background: var(--accent-soft); color: var(--accent); }

/* ---------- Log ---------- */
.log-list { display: flex; flex-direction: column; gap: 6px; }
.log-item { border: 1px solid var(--border); border-radius: 10px; transition: border-color 0.15s; }
.log-item:hover, .log-item[open] { border-color: var(--border-strong); }
.log-item summary { display: flex; gap: 10px; align-items: center; padding: 9px 14px; cursor: pointer; flex-wrap: wrap; font-size: 13px; }
.log-item summary .time { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; }
.log-item summary .what { font-weight: 600; }
.log-item pre { margin: 0 12px 12px; }

/* ---------- Dialog & toasts ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: min(480px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  border-top: 4px solid var(--brand-lime);
}
dialog::backdrop { background: rgba(0, 24, 15, 0.5); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.dialog-head img { width: 28px; height: 28px; }
dialog h2 { font-size: 18px; }
dialog form > .muted { margin-bottom: 16px; }
.note { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 9px 13px; font-size: 13px; margin-bottom: 16px; }
.dialog-status:not(:empty) { margin-bottom: 12px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast {
  background: var(--toast-bg); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px;
  border-left: 4px solid var(--brand-lime); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); max-width: 420px;
  animation: toast-in 0.2s ease-out;
}
.toast.warn { background: #8a5200; border-left-color: #ffc861; }
.toast.err { background: #b02a24; border-left-color: #ffb3ad; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Environment switcher (header) ---------- */
.hero-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.env-switch { position: relative; min-width: 0; }
.account-pill:focus-visible, .hero-icon-btn:focus-visible { outline: 2px solid var(--brand-lime); outline-offset: 2px; }
.account-pill #accountLabel b { font-weight: 650; }
.account-pill .chev { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }
.account-pill.prod { border-color: rgba(255, 128, 118, 0.75); background: rgba(229, 53, 53, 0.2); }
body.env-prod .hero { box-shadow: inset 0 4px 0 var(--ct-red); }
.prod-tag {
  display: inline-block; flex: none; padding: 1px 7px; border-radius: 999px; background: var(--ct-red); color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; line-height: 1.5;
}
.hero-icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.08); color: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.hero-icon-btn:hover { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.4); }
.hero-icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.env-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: min(340px, calc(100vw - 32px)); padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}
.env-menu-head { padding: 8px 10px 6px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.env-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.env-menu-item:hover { background: var(--surface-2); }
.env-menu-item.active { background: var(--accent-soft); }
.env-menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.check-mark { width: 16px; flex: none; color: var(--accent); font-weight: 700; text-align: center; }
.env-menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.env-menu-empty { padding: 4px 10px 8px; }

.env-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.env-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; font-weight: 600; }
.env-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }


/* ---------- Settings dialog ---------- */
dialog.settings-dialog { width: min(860px, calc(100vw - 32px)); height: min(640px, calc(100vh - 48px)); padding: 0; overflow: hidden; }
.settings-dialog[open] { display: flex; flex-direction: column; }
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--border); }
.settings-head .dialog-head { margin: 0; }
.settings-body { display: grid; grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-right: 1px solid var(--border); background: var(--surface-2); }
.settings-nav button {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 9px;
  background: none; color: var(--muted); font: inherit; font-weight: 500; text-align: left; cursor: pointer;
}
.settings-nav button:hover { color: var(--text); }
.settings-nav button.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
.settings-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.settings-nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.settings-content { min-height: 0; overflow-y: auto; padding: 20px 22px 24px; }
.settings-content h3 { font-size: 16px; font-weight: 650; }
.settings-content h3 + .muted { margin: 4px 0 16px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head > div { flex: 1 1 280px; }
.section-head .muted { margin-top: 4px; }
@media (max-width: 680px) {
  dialog.settings-dialog { height: calc(100vh - 32px); }
  .settings-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-nav button { white-space: nowrap; }
  .settings-content { padding: 16px; }
}

.env-form { margin-bottom: 16px; padding: 16px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.env-form h4 { margin: 0 0 12px; font-size: 14px; }
.env-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.env-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.env-item.active { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.env-item.prod { box-shadow: inset 3px 0 0 var(--ct-red); }
.env-item.active.prod { border-color: var(--ct-red); }
.env-item .env-main { flex: 1 1 220px; }
.env-item .actions { margin-left: auto; }
.env-empty { padding: 18px; border: 1px dashed var(--border-strong); border-radius: 12px; text-align: center; }
.btn-ghost.danger:hover { color: var(--err); background: var(--err-soft); }
.check.remember { margin-bottom: 8px; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.choice:hover { border-color: var(--muted); }
.choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.choice-title { font-size: 13.5px; font-weight: 600; }
.swatch { position: relative; width: 100%; height: 72px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; }
.swatch::before { content: ""; position: absolute; inset: 0 0 auto; height: 18px; background: linear-gradient(135deg, #00301f, #004830); }
.swatch i { position: absolute; left: 10px; right: 30%; top: 28px; height: 32px; border-radius: 5px; }
.swatch i::after { content: ""; position: absolute; left: 8px; top: 9px; width: 40%; height: 5px; border-radius: 3px; background: #afca32; }
.swatch-light { background: #f3f6f1; }
.swatch-light i { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.swatch-dark { background: #0c1310; }
.swatch-dark i { background: #1a2520; }
.swatch-system { background: linear-gradient(135deg, #f3f6f1 50%, #0c1310 50%); }
.swatch-system i { background: linear-gradient(135deg, #fff 50%, #1a2520 50%); }
.lang-code {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; letter-spacing: 0.04em;
}
.choice[aria-pressed="true"] .lang-code { background: var(--accent); color: var(--accent-text); }
.settings-content > section > .hint { margin-top: 14px; }

@media (max-width: 600px) {
  .hero-actions { width: 100%; }
  .env-switch { flex: 1; min-width: 0; }
  .account-pill { width: 100%; }
  .env-menu { left: 0; right: auto; width: calc(100vw - 32px); }
}
details.help code { background: var(--surface); }
/* Sending to Production: the real-send buttons turn CleverTap red. */
body.env-prod .send-actions .btn-primary:not(:disabled) { background: var(--ct-red); border-color: var(--ct-red); color: #fff; }
body.env-prod .send-actions .btn-primary:not(:disabled):hover { background: #c92a2a; border-color: #c92a2a; }

/* ---------- First-visit setup ---------- */
.settings-dialog:not(.setup) .title-setup,
.settings-dialog:not(.setup) .setup-intro,
.settings-dialog.setup .title-settings,
.settings-dialog.setup #settingsClose,
.settings-dialog.setup #envCancel { display: none; }
.setup-intro { margin-bottom: 16px; }

/* ---------- Dashboard ---------- */
/* Chart series: validated pair (light & dark) — processed vs rejected/unsent. */
:root { --series-ok: #1d7f5f; --series-bad: #e0703c; }
.dash { display: flex; flex-direction: column; gap: 18px; }
.dash-env { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dash-env .env-main { flex: 1 1 280px; gap: 3px; }
.dash-env .env-name { font-size: 19px; font-weight: 650; }
.dash-env .actions { margin-left: auto; }
.dash-env.prod { border-color: color-mix(in srgb, var(--ct-red) 55%, var(--border)); box-shadow: inset 4px 0 0 var(--ct-red), var(--shadow); }
.dash-eyebrow { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.conn { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.status-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--border-strong); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.fail { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.status-dot.checking { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .status-dot.checking { animation: none; } }

.dash-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-value { color: var(--text); font-size: 28px; font-weight: 650; line-height: 1.15; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }

.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.key-ok { background: var(--series-ok); }
.key-bad { background: var(--series-bad); }

.chart { position: relative; padding-top: 8px; }
.chart-plot { position: relative; height: 220px; margin-left: 44px; border-bottom: 1px solid var(--border-strong); }
.chart-tick { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.chart-tick span {
  position: absolute; right: calc(100% + 8px); top: -8px;
  color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); border-radius: 4px; }
.chart-cols:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart-col { display: flex; align-items: flex-end; justify-content: center; height: 100%; border-radius: 4px 4px 0 0; }
.chart-col.hover { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
.chart-stack { display: flex; flex-direction: column; gap: 2px; width: min(24px, 64%); }
.chart-stack > span { flex-basis: 0; min-height: 2px; }
.chart-stack > :first-child { border-radius: 4px 4px 0 0; }
.chart-col.hover .chart-stack { filter: brightness(1.12); }
.seg-ok { background: var(--series-ok); }
.seg-bad { background: var(--series-bad); }
.chart-x { position: relative; height: 22px; margin-left: 44px; }
.chart-x span { position: absolute; top: 5px; transform: translateX(-50%); color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.chart-tip {
  position: absolute; z-index: 5; padding: 8px 12px; pointer-events: none; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px)); font-size: 12.5px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.tip-date { margin-bottom: 4px; color: var(--muted); }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row b { font-size: 14px; font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--muted); }
.tip-key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; }
.tip-sends { margin-top: 4px; color: var(--muted); font-size: 12px; }
.chart-empty { display: grid; place-items: center; height: 250px; color: var(--muted); font-size: 13px; text-align: center; }

.tool-bars { display: flex; flex-direction: column; gap: 16px; }
.tool-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.tool-head b { font-variant-numeric: tabular-nums; }
.tool-fill { height: 12px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--series-ok); }
.log-more { align-self: flex-start; }
@media (max-width: 600px) {
  .chart-plot, .chart-x { margin-left: 36px; }
  .chart-plot { height: 180px; }
  .kpi-value { font-size: 24px; }
}
