:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --fill: #f5f5f7;
  --fill-2: #e8e8ed;
  --line: #d2d2d7;
  --line-2: #e8e8ed;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --muted: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --green: #1d9e4b;
  --red: #d70015;
  --orange: #b25000;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.021em; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em; background: var(--fill); padding: 1px 6px; border-radius: 5px; color: var(--text-2);
}
.ic-svg { display: block; flex-shrink: 0; }

/* ============================ Top bar ============================ */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px; height: 56px;
  background: rgba(245, 245, 247, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: #1d1d1f; color: #fff;
}
.brand .name { font-size: 16px; font-weight: 600; line-height: 1; }
.brand .tagline { font-size: 12px; color: var(--muted); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.health { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.health .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.health.up .dot { background: var(--green); }
.health.down .dot { background: var(--red); }

/* ============================ Segmented nav ============================ */
.stepper {
  display: flex; gap: 2px; margin: 28px auto 0; padding: 3px;
  background: rgba(0, 0, 0, 0.05); border-radius: 12px; width: fit-content;
}
.step-nav {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; background: transparent; color: var(--text);
  padding: 7px 18px; border-radius: 9px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; font-family: inherit; letter-spacing: -0.01em;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.step-nav .ic-svg { color: var(--muted); }
.step-nav:hover:not(.active) { background: rgba(0, 0, 0, 0.03); }
.step-nav.active { background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 600; }
.step-nav.active .ic-svg { color: var(--accent); }

/* ============================ Layout ============================ */
main { max-width: 940px; margin: 0 auto; padding: 34px 24px 80px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.panel-head .titles h2 { font-size: 28px; font-weight: 600; }
.panel-head .titles p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; max-width: 600px; }

.card {
  background: var(--surface); border-radius: var(--radius); padding: 26px;
  margin-bottom: 18px; box-shadow: var(--shadow-sm); border: 1px solid var(--line-2);
}

/* Guia */
.guide { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 22px 26px; margin-bottom: 22px; box-shadow: var(--shadow-sm); }
.guide-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.guide-head h3 { font-size: 16px; font-weight: 600; }
.guide-body { margin-top: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 22px; }
.guide-item { display: flex; gap: 13px; }
.guide-item .g-num {
  width: 25px; height: 25px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); font-weight: 600; font-size: 12.5px; color: var(--text-2);
}
.guide-item .g-txt strong { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.guide-item .g-txt span { font-size: 13px; color: var(--text-2); }

/* ============================ Forms ============================ */
label { display: block; margin-bottom: 18px; font-size: 14px; font-weight: 500; color: var(--text); }
label .lbl-hint { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin: 3px 0 8px; letter-spacing: 0; }
input, select, textarea {
  width: 100%; margin-top: 8px; padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); font-size: 15px; font-family: inherit; letter-spacing: -0.01em;
  transition: border-color 0.15s, box-shadow 0.15s;
}
label > input:first-child, label > select:first-child, label > textarea:first-child { margin-top: 0; }
textarea { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; resize: vertical; line-height: 1.55; font-size: 13.5px; }
input::placeholder, textarea::placeholder { color: #b0b0b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 200px; }

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  background: var(--fill-2); color: var(--text); border: none;
  padding: 9px 18px; border-radius: 980px; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit; letter-spacing: -0.01em;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: #dcdce1; }
.btn:active { transform: scale(0.98); }
.btn .ic-svg { color: currentColor; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(1.05); }
.btn.danger { background: transparent; color: var(--red); padding-left: 12px; padding-right: 12px; }
.btn.danger:hover { background: rgba(215, 0, 21, 0.08); }
.btn.text { background: transparent; color: var(--accent); padding-left: 10px; padding-right: 10px; }
.btn.text:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.04); }
.btn.small { padding: 6px 13px; font-size: 13px; }
.btn.big { padding: 12px 26px; font-size: 15px; }
.btn.icon-only { padding: 7px; width: 32px; height: 32px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ============================ Lists / items ============================ */
.list { display: flex; flex-direction: column; gap: 12px; }
.item {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 16px 20px; display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}
.item:hover { box-shadow: var(--shadow); }
.item .ic {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; display: grid; place-items: center;
  background: var(--fill); color: var(--text-2);
}
.item .meta { flex: 1; min-width: 0; }
.item .title { font-weight: 600; font-size: 15px; }
.item .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.item .ops { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; padding: 4px 11px; border-radius: 980px; }
.pill.ok { background: rgba(29, 158, 75, 0.1); color: var(--green); }
.pill.off { background: rgba(178, 80, 0, 0.1); color: var(--orange); }

/* Empty state */
.empty {
  text-align: center; padding: 56px 24px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.empty .em-ic { width: 52px; height: 52px; margin: 0 auto 4px; border-radius: 14px; background: var(--fill); display: grid; place-items: center; color: var(--muted); }
.empty h3 { font-size: 19px; margin: 16px 0 6px; }
.empty p { margin: 0 0 20px; font-size: 14.5px; color: var(--text-2); }

/* ============================ Status badges ============================ */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 10px; border-radius: 980px; font-weight: 500; }
.badge.PENDING, .badge.QUEUED { background: var(--fill-2); color: var(--text-2); }
.badge.RUNNING { background: rgba(178, 80, 0, 0.1); color: var(--orange); }
.badge.SUCCESS { background: rgba(29, 158, 75, 0.1); color: var(--green); }
.badge.WARN { background: rgba(178, 80, 0, 0.1); color: var(--orange); }
.badge.FAILED { background: rgba(215, 0, 21, 0.1); color: var(--red); }

/* ============================ Flow / steps builder ============================ */
.steps-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 0 8px; }
.steps-head h4 { font-size: 17px; font-weight: 600; }
.picker-bar { display: flex; align-items: center; gap: 12px; }
.picker-status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.picker-status.active { color: var(--accent); }
.picker-status.done { color: var(--green); }

.steps { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.step { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 16px 18px; }
.step-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.step-top .st-ic { color: var(--accent); }
.step-top .st-name { font-weight: 600; font-size: 14.5px; }
.step-top .st-num { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.step-top .spacer { flex: 1; }
.step .fields { display: flex; flex-direction: column; }
.step .fields label { margin-bottom: 14px; }
.step .fields label:last-child { margin-bottom: 0; }
.field-selector { display: flex; gap: 10px; align-items: flex-end; }
.field-selector label { flex: 1; margin-bottom: 0 !important; }

.var-chips { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin: -6px 0 14px; }
.var-chips .lbl { font-size: 12.5px; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 500; padding: 4px 11px; border-radius: 980px; cursor: pointer;
  background: var(--fill); color: var(--text); border: 1px solid var(--line-2); transition: all 0.13s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .ic-svg { color: var(--muted); }
.chip:hover .ic-svg { color: var(--accent); }

/* Origem do valor */
.vsrc { margin-top: 4px; }
.vs-q { font-size: 13px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 8px; }
.vs-opts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.vs-opt { display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 7px 13px; border: 1px solid var(--line-2); border-radius: 980px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface); transition: all 0.13s; }
.vs-opt:hover { border-color: var(--muted); }
.vs-opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.vs-opt input { width: auto; margin: 0; accent-color: var(--accent); }
.vs-field { margin-bottom: 0 !important; }

/* Add-step palette */
.add-panel { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 20px; margin-top: 10px; background: var(--surface); }
.add-panel > .lbl { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 7px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.type-btn {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  transition: all 0.13s ease; color: var(--text);
}
.type-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.type-btn .ic-svg { color: var(--text-2); }
.type-btn:hover .ic-svg { color: var(--accent); }
.type-btn .tb-name { font-size: 13.5px; font-weight: 500; }

/* Condition branches */
.cond-branch { border-left: 2px solid var(--line); padding-left: 16px; margin: 14px 0 6px; }
.cond-branch.yes { border-color: var(--green); }
.cond-branch.no { border-color: var(--orange); }
.cond-branch h5 { font-size: 13px; font-weight: 600; margin: 10px 0; display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.cond-branch.yes h5 .ic-svg { color: var(--green); }
.cond-branch.no h5 .ic-svg { color: var(--orange); }
.cond-branch .branch-add { display: flex; gap: 8px; margin: 10px 0; }
.cond-branch .branch-add select { max-width: 230px; }

/* Gravador */
.rec-cta { border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--surface), var(--surface-2)); padding: 18px 20px; margin: 12px 0 16px; }
.rec-main { display: flex; align-items: center; gap: 18px; }
.rec-text { flex: 1; }
.rec-title { font-weight: 600; font-size: 15px; }
.rec-desc { font-size: 13px; color: var(--text-2); margin-top: 3px; max-width: 560px; }
.rec-dot-btn { width: 8px; height: 8px; border-radius: 50%; background: #fff; display: inline-block; }
#btn-record { flex-shrink: 0; }
.rec-live { display: flex; align-items: center; gap: 11px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.rec-status-txt { font-size: 13.5px; font-weight: 500; color: var(--red); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: recpulse 1.2s ease-in-out infinite; }
@keyframes recpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.add-details { margin-top: 8px; }
.add-details > summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; padding: 4px 0; }
.add-details > summary::-webkit-details-marker { display: none; }
.add-details[open] > summary { margin-bottom: 8px; }

.callout {
  display: flex; gap: 11px; align-items: flex-start; background: var(--surface-2);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 14px 16px; font-size: 13.5px; color: var(--text-2);
  margin-top: 12px;
}
.callout .ic-svg { color: var(--muted); margin-top: 1px; }

/* ============================ Run tab ============================ */
.run-note { font-size: 14px; color: var(--text-2); margin: 8px 0; }
.flow-data:not(:empty) { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.flow-data h4 { margin: 0 0 4px; }
.flow-data .fd-sub { font-size: 13px; color: var(--text-2); margin: 0 0 12px; }
.col-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.col-chip { font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-family: ui-monospace, "SF Mono", Consolas, monospace; }
#run-table { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* ============================ Toast + modal ============================ */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.92); backdrop-filter: blur(20px); color: #fff;
  padding: 13px 22px; border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 200; font-size: 14px; font-weight: 500; max-width: 90vw;
}
.toast.err { background: rgba(215, 0, 21, 0.94); }
.toast.ok { background: rgba(29, 158, 75, 0.94); }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 150; padding: 24px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius); padding: 30px;
  max-width: 720px; width: 100%; max-height: 86vh; overflow: auto; position: relative; box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute; top: 18px; right: 18px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--fill-2); border: none; color: var(--text-2); cursor: pointer; display: grid; place-items: center;
}
.modal-close:hover { background: #dcdce1; }
.modal-box pre { background: var(--fill); padding: 15px; border-radius: var(--radius-sm); overflow: auto; font-size: 12.5px; }
.modal-box h3 { display: flex; align-items: center; gap: 10px; font-size: 21px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; margin: 18px 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 12px; }
.evidence-grid figure { margin: 0; }
.evidence-grid img { width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-sm); display: block; }
.evidence-grid figcaption { font-size: 11px; color: var(--muted); margin-top: 5px; text-align: center; }

@media (max-width: 720px) {
  .stepper { width: auto; overflow-x: auto; }
  .step-nav { padding: 7px 13px; }
  .panel-head { flex-direction: column; align-items: stretch; }
  .panel-head .titles h2 { font-size: 24px; }
}
