/* ChatFlow Local — folha de estilo unica */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e4e7ee;
  --border-strong: #d3d8e3;
  --text: #1a1d29;
  --muted: #6b7186;
  --faint: #9aa0b4;

  --brand: #6152e8;
  --brand-soft: #ede9ff;
  --brand-ink: #4b3fd0;

  --green: #12a45c;
  --green-soft: #e3f7ec;
  --amber: #c2810b;
  --amber-soft: #fdf2dc;
  --red: #d64545;
  --red-soft: #fdeaea;
  --blue: #2b71d8;
  --blue-soft: #e7f0fd;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06), 0 1px 3px rgba(20, 24, 40, .04);
  --shadow: 0 4px 12px rgba(20, 24, 40, .08), 0 1px 3px rgba(20, 24, 40, .04);
  --shadow-lg: 0 16px 48px rgba(20, 24, 40, .16);
  --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161f;
    --surface: #1c1f2b;
    --surface-2: #222634;
    --border: #2c3142;
    --border-strong: #3a4058;
    --text: #e8eaf2;
    --muted: #9aa1b9;
    --faint: #6f7794;
    --brand-soft: #2a2450;
    --green-soft: #16301f;
    --amber-soft: #322612;
    --red-soft: #351a1c;
    --blue-soft: #16233b;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }

/* O atributo hidden precisa vencer qualquer display definido aqui. Sem isto,
   uma regra como `.sim { display: flex }` tem a mesma especificidade que o
   `[hidden] { display: none }` do navegador e ganha por vir depois — o
   elemento continua na tela e intercepta os cliques do que está embaixo. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

#app { display: flex; height: 100%; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #171a26;
  color: #c9cee0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6152e8, #8b6ef0);
  border-radius: 9px; font-size: 17px;
}
.brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand small { color: #7d85a3; font-size: 11px; text-transform: uppercase; letter-spacing: .09em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #a8afc7; font-weight: 500; font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: #21253550; color: #e6e9f5; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { font-size: 15px; width: 18px; text-align: center; }

.badge {
  margin-left: auto; background: var(--red); color: #fff;
  border-radius: 99px; padding: 1px 6px; font-size: 11px; font-weight: 700;
}
.nav a.active .badge { background: #fff; color: var(--brand); }

.sim-toggle {
  display: flex; align-items: center; gap: 9px;
  background: #21253a; border: 1px solid #2e3450; color: #c9cee0;
  padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 500; font-size: 13.5px; margin-bottom: 10px;
}
.sim-toggle:hover { background: #272c45; color: #fff; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #6b7290; padding: 0 8px; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.conn.ok i { background: #38d17a; }
.conn.off i { background: var(--red); }

/* quem está logado e em qual conta */
.userbox { margin-top: 12px; padding-top: 12px; border-top: 1px solid #262b40; }
.userbox-who { display: flex; align-items: center; gap: 9px; padding: 0 4px 10px; }
.userbox-avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: #2e3450; color: #c9cee0; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.userbox-id { min-width: 0; }
.userbox-id strong {
  display: block; color: #e6e9f5; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.userbox-id small {
  display: block; color: #6b7290; font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.userbox-actions { display: flex; gap: 6px; }
.userbox-actions .btn { flex: 1; justify-content: center; color: #a8afc7; }
.userbox-actions .btn:hover { background: #21253a; border-color: #2e3450; color: #fff; }
.userbox-actions select {
  width: 100%; margin-bottom: 6px; background: #21253a; color: #c9cee0;
  border: 1px solid #2e3450; border-radius: var(--radius-sm);
  padding: 6px 8px; font-size: 12px; font-family: inherit;
}
.userbox-actions:has(select:not([hidden])) { flex-wrap: wrap; }

/* ------------------------------------------------------------------- main */
.main { flex: 1; overflow: auto; display: flex; flex-direction: column; min-width: 0; }

.page { padding: 26px 30px 60px; max-width: 1180px; width: 100%; }
.page.wide { max-width: none; }
.page.flush { padding: 0; height: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 3px; font-size: 22px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 62ch; }
.page-head .spacer { flex: 1; }

section.block { margin-top: 30px; }
section.block > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); margin: 0 0 12px; font-weight: 700;
}

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin-top: 3px; }
.stat .hint { font-size: 12px; color: var(--faint); margin-top: 2px; }
.stat.accent .value { color: var(--brand); }
.stat.warn .value { color: var(--amber); }
.stat.danger .value { color: var(--red); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--surface); border: 1px solid var(--border-strong);
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 550; font-size: 13.5px; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.danger { color: var(--red); border-color: #f0c9c9; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.btn-icon {
  background: transparent; border: 1px solid transparent; cursor: pointer;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-size: 14px; color: var(--muted);
}
.btn-icon:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font-weight: 550; }
.link:hover { text-decoration: underline; }

.row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px;
}
.field .help { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.45; }

input[type=text], input[type=url], input[type=number], input[type=password],
input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 11px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}
textarea { resize: vertical; min-height: 76px; line-height: 1.55; font-family: inherit; }
select { cursor: pointer; }

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.switch { position: relative; width: 38px; height: 21px; flex: 0 0 38px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span {
  position: absolute; inset: 0; background: var(--border-strong);
  border-radius: 99px; cursor: pointer; transition: background .16s;
}
.switch span::after {
  content: ''; position: absolute; top: 2.5px; left: 2.5px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform .16s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(17px); }

/* ----------------------------------------------------------------- tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 700; padding: 0 12px 9px;
}
table.list td { padding: 11px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
table.list tr:hover td { background: var(--surface-2); }
table.list td.right, table.list th.right { text-align: right; }

/* ------------------------------------------------------------------ chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }
.chip.green { background: var(--green-soft); border-color: transparent; color: var(--green); }
.chip.amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.chip.red { background: var(--red-soft); border-color: transparent; color: var(--red); }
.chip.blue { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.chip button { background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.chip button:hover { opacity: 1; }

.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.empty p { margin: 0 auto 16px; max-width: 44ch; font-size: 13.5px; }

/* ------------------------------------------------------------ flow builder */
.builder { display: flex; flex-direction: column; height: 100%; }

.builder-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.builder-bar input.flow-name {
  border: 1px solid transparent; background: transparent;
  font-size: 15px; font-weight: 650; width: 260px; padding: 5px 8px;
}
.builder-bar input.flow-name:hover { border-color: var(--border); }
.save-state { font-size: 12px; color: var(--faint); min-width: 96px; }

.builder-body { flex: 1; display: flex; min-height: 0; }

.palette {
  width: 178px; flex: 0 0 178px; background: var(--surface);
  border-right: 1px solid var(--border); padding: 14px 12px; overflow: auto;
}
.palette h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); margin: 0 0 9px;
}
.palette-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; margin-bottom: 5px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 550; text-align: left;
}
.palette-item:hover { border-color: var(--brand); background: var(--brand-soft); }
.palette-item .dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 9px; }

.canvas-wrap {
  flex: 1; position: relative; overflow: hidden; min-width: 0;
  background:
    radial-gradient(circle, var(--border-strong) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--bg);
  cursor: grab;
}
.canvas-wrap.panning { cursor: grabbing; }
.world { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.world svg.wires { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.world svg.wires path { fill: none; stroke: var(--border-strong); stroke-width: 2.5; }
.world svg.wires path.hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.world svg.wires g:hover path.line { stroke: var(--red); }
.world svg.wires path.ghost { stroke: var(--brand); stroke-dasharray: 6 4; }

.node {
  position: absolute; width: 246px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); cursor: grab; user-select: none;
}
.node:hover { box-shadow: var(--shadow); }
.node.selected { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow); }
.node.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 20; }

.node-head {
  position: relative;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 11px; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  border-radius: 10px 10px 0 0;
}
.node-body { padding: 10px 11px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.node-body .preview {
  white-space: pre-wrap; word-break: break-word;
  max-height: 88px; overflow: hidden; color: var(--text);
}
.node-body .meta { font-size: 11.5px; color: var(--faint); margin-top: 6px; }
.node-body .empty-hint { font-style: italic; color: var(--faint); }

.node[data-type=start]     .node-head { background: var(--green-soft); color: var(--green); }
.node[data-type=message]   .node-head { background: var(--blue-soft); color: var(--blue); }
.node[data-type=question]  .node-head { background: var(--brand-soft); color: var(--brand-ink); }
.node[data-type=condition] .node-head { background: var(--amber-soft); color: var(--amber); }
.node[data-type=action]    .node-head { background: #e9f6f3; color: #0d8f7d; }
.node[data-type=delay]     .node-head { background: #f0eefb; color: #6a5acd; }
.node[data-type=jump]      .node-head { background: #fdeef7; color: #b8437f; }
.node[data-type=end]       .node-head { background: var(--red-soft); color: var(--red); }

@media (prefers-color-scheme: dark) {
  .node[data-type=action] .node-head { background: #12302c; color: #4fd6c0; }
  .node[data-type=delay]  .node-head { background: #221f3d; color: #a89bf5; }
  .node[data-type=jump]   .node-head { background: #331c2a; color: #f07db5; }
}

.node-ports { padding: 0 11px 10px; }
.port-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 5px 0; font-size: 12px; position: relative;
}
.port-row .port-label {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--muted); font-weight: 550;
}
.port-row.btn-port .port-label {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 10px; color: var(--text); font-size: 11.5px;
}
.port-row.yes .port-label { color: var(--green); }
.port-row.no .port-label { color: var(--red); }

.port {
  width: 13px; height: 13px; border-radius: 50%; flex: 0 0 13px;
  background: var(--surface); border: 2.5px solid var(--border-strong);
  cursor: crosshair; transition: transform .1s, border-color .1s;
}
.port:hover { border-color: var(--brand); transform: scale(1.25); }
.port.connected { background: var(--brand); border-color: var(--brand); }
.port-in {
  position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--border-strong);
}
.node.link-target .port-in { border-color: var(--brand); background: var(--brand-soft); }

.canvas-tools {
  position: absolute; right: 14px; bottom: 14px; display: flex; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px; box-shadow: var(--shadow);
}

.canvas-hint {
  position: absolute; left: 14px; bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 11px;
  font-size: 11.5px; color: var(--muted); box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------- inspector */
.inspector {
  width: 316px; flex: 0 0 316px; background: var(--surface);
  border-left: 1px solid var(--border); overflow: auto; padding: 16px;
}
.inspector h3 { margin: 0 0 3px; font-size: 15px; }
.inspector .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.inspector .none { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 10px; }

.btn-list { display: flex; flex-direction: column; gap: 7px; }
.btn-list-item { display: flex; gap: 6px; align-items: center; }
.btn-list-item input { flex: 1; }

.rule-item, .op-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px; margin-bottom: 8px; background: var(--surface-2);
}
.rule-item .row, .op-item .row { margin-bottom: 6px; }
.rule-item .row:last-child, .op-item .row:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ inbox */
.inbox { display: flex; height: 100%; }
.threads {
  width: 296px; flex: 0 0 296px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column;
}
.threads-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.threads-list { overflow: auto; flex: 1; }

.thread {
  display: flex; gap: 10px; padding: 11px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--brand-soft); }
.avatar {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
  background: linear-gradient(135deg, #6152e8, #9b7ef2); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.thread-main { min-width: 0; flex: 1; }
.thread-name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.thread-last {
  color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-time { font-size: 11px; color: var(--faint); flex: 0 0 auto; }

.conversation { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.conv-head {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface); display: flex; align-items: center; gap: 12px;
}
.conv-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 9px; }
.conv-foot { border-top: 1px solid var(--border); background: var(--surface); padding: 12px 16px; }
.conv-form { display: flex; gap: 8px; }

.bubble {
  max-width: 62%; padding: 9px 13px; border-radius: 15px;
  font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.bubble.in { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.bubble.out.human { background: var(--green); }
.bubble.out.error { background: var(--red-soft); color: var(--red); border: 1px solid var(--red); }
.bubble .stamp { font-size: 10.5px; opacity: .65; margin-top: 4px; }
.bubble .btns { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.bubble .btns span {
  border: 1px solid currentColor; opacity: .8; border-radius: 99px;
  padding: 2px 9px; font-size: 11.5px;
}
.bubble img { max-width: 100%; border-radius: 9px; margin-bottom: 6px; display: block; }

.day-sep { align-self: center; font-size: 11.5px; color: var(--faint); padding: 4px 0; }

/* -------------------------------------------------------------- simulador */
.sim {
  position: fixed; right: 20px; bottom: 20px; width: 344px; height: min(620px, 84vh);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; z-index: 60;
}
.sim-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.sim-head strong { display: block; font-size: 13.5px; }
.sim-head small { color: var(--muted); font-size: 11.5px; }
.sim-head .sim-actions { margin-left: auto; display: flex; gap: 2px; }
.sim-body { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.sim-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.sim-quick button {
  background: var(--surface); border: 1px solid var(--brand); color: var(--brand);
  border-radius: 99px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; font-weight: 550;
}
.sim-quick button:hover { background: var(--brand-soft); }
.sim-form { display: flex; gap: 8px; padding: 12px; }
.sim-form input { flex: 1; }
.sim-form button {
  width: 38px; border: 0; background: var(--brand); color: #fff;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 15px;
}
.sim-foot { padding: 0 12px 12px; font-size: 12px; }

/* --------------------------------------------------------- toasts / modal */
#toasts { position: fixed; right: 20px; top: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 15px; font-size: 13.5px; max-width: 360px;
  animation: slide-in .18s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

.modal-back {
  position: fixed; inset: 0; background: rgba(16, 19, 30, .5);
  display: grid; place-items: center; z-index: 150; padding: 20px;
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 15px; box-shadow: var(--shadow-lg);
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 18px 20px 0; }
.modal-head h2 { margin: 0 0 3px; font-size: 17px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end;
  position: sticky; bottom: 0; background: var(--surface);
}

/* ------------------------------------------------------------------ misc */
.callout {
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px;
  line-height: 1.55; border: 1px solid;
}
.callout.info { background: var(--blue-soft); border-color: transparent; color: var(--blue); }
.callout.warn { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.callout.ok { background: var(--green-soft); border-color: transparent; color: var(--green); }
.callout strong { display: block; margin-bottom: 3px; }

code, .mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px; background: var(--surface-2);
  padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border);
  word-break: break-all;
}

.bar-chart { display: flex; align-items: flex-end; gap: 7px; height: 116px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bar-stack { flex: 1; width: 100%; display: flex; align-items: flex-end; gap: 2px; }
.bar { flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.in { background: var(--blue); }
.bar.out { background: var(--brand); }
.bar-label { font-size: 10.5px; color: var(--faint); white-space: nowrap; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

@media (max-width: 980px) {
  .sidebar { width: 62px; flex: 0 0 62px; padding: 14px 8px; }
  .brand div, .nav a span.txt, .sim-toggle { display: none; }
  .nav a { justify-content: center; }
  .palette { width: 62px; flex: 0 0 62px; }
  .palette h4, .palette-item span.txt { display: none; }
  .inspector { position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; box-shadow: var(--shadow-lg); }
}
