*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { background: var(--theme-bg-primary); color: var(--theme-text-primary); }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.45;
  background: var(--theme-bg-primary);
  color: var(--theme-text-primary);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--theme-text-gold); }
img { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; margin: 0; letter-spacing: -0.02em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--theme-accent-gold); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 999px;
  font-size: var(--fs-sm); white-space: nowrap; text-decoration: none;
}
.btn-gold-solid {
  background: linear-gradient(135deg, #D4AF37 0%, #E8C474 50%, #B8860B 100%);
  color: #12121A; border: none; font-weight: 700;
  box-shadow: 0 4px 16px rgba(212,175,55,0.35), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 200ms cubic-bezier(0.16,1,0.3,1), box-shadow 200ms ease-out;
}
.btn-gold-solid:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(212,175,55,0.45), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-gold-ghost {
  background: transparent; color: var(--theme-accent-gold-bright);
  border: 1px solid var(--theme-border-strong); font-weight: 600;
  transition: background 200ms ease-out, border-color 200ms ease-out, transform 200ms ease-out;
}
.btn-gold-ghost:hover:not(:disabled) {
  background: var(--theme-accent-gold-08); border-color: var(--theme-accent-gold);
  transform: translateY(-1px);
}
.btn-gold-subtle {
  background: var(--theme-accent-gold-08); color: var(--theme-text-secondary);
  border: 1px solid var(--theme-border-default); font-weight: 600;
  transition: background 200ms, color 200ms, transform 200ms ease-out;
}
.btn-gold-subtle:hover:not(:disabled) {
  background: var(--theme-accent-gold-15); color: var(--theme-accent-gold-bright);
  transform: translateY(-1px);
}
.btn-danger {
  background: rgb(232 115 115 / 12%); color: var(--theme-accent-red);
  border: 1px solid rgb(232 115 115 / 35%); font-weight: 600; border-radius: 999px;
}
.btn-danger:hover:not(:disabled) { background: rgb(232 115 115 / 22%); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-sm { height: 30px; padding: 0 12px; font-size: var(--fs-xs); }
.btn-block { width: 100%; }

/* ── Switch ── */
.switch {
  --w: 34px; --h: 18px;
  position: relative; width: var(--w); height: var(--h); border: 0; padding: 0;
  background: #3a3a44; border-radius: 999px; flex-shrink: 0;
  transition: background 160ms ease;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  transition: transform 160ms ease;
}
.switch[aria-checked="true"] { background: var(--theme-accent-gold); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch[aria-disabled="true"], .switch:disabled { opacity: 0.45; cursor: not-allowed; background: #2a2a32; }
[data-theme="day"] .switch { background: #D4D4D8; }
[data-theme="day"] .switch[aria-checked="true"] { background: var(--theme-accent-gold); }

/* ── Chips ── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: var(--fs-2xs); font-weight: 600; white-space: nowrap;
}
.chip-ok { background: var(--theme-roas-green-bg); color: var(--theme-roas-green-text); }
.chip-warn { background: var(--theme-roas-yellow-bg); color: var(--theme-roas-yellow-text); }
.chip-err { background: var(--theme-roas-red-bg); color: var(--theme-roas-red-text); }
.chip-muted { background: var(--theme-roas-gray-bg); color: var(--theme-roas-gray-text); }
.chip-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Layout shells ── */
.screen { display: none; min-height: 100vh; background: var(--theme-bg-primary); }
.screen.is-active { display: flex; flex-direction: column; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--theme-bg-dark);
  border-right: 1px solid var(--theme-border-grid);
  display: flex; flex-direction: column; padding: 16px 12px 12px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg);
  color: var(--theme-text-primary); text-decoration: none;
  padding: 4px 8px 18px;
}
.brand-mark {
  width: 22px; height: 18px; display: grid; grid-template-columns: 5px 5px 5px; gap: 2px; align-items: end;
}
.brand-mark i { display: block; background: var(--theme-accent-gold); border-radius: 1px; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 13px; }
.brand-mark i:nth-child(3) { height: 18px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  color: var(--theme-text-secondary); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 500; border: 0; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--theme-surface-hover); color: var(--theme-text-primary); }
.nav-item.is-active {
  background: var(--theme-accent-gold-08);
  color: var(--theme-text-gold);
  box-shadow: inset 0 0 0 1px var(--theme-border-subtle);
  font-weight: 600;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 4px; border-top: 1px solid var(--theme-border-grid); margin-top: 8px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--theme-accent-gold-15); color: var(--theme-text-gold);
  display: grid; place-items: center; font-size: var(--fs-xs); font-weight: 700;
}
.sidebar-user small { display: block; color: var(--theme-text-muted); font-size: var(--fs-2xs); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ── Topbars ── */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px 0 12px;
  border-bottom: 1px solid var(--theme-border-subtle);
  background: var(--theme-bg-primary);
}
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.topbar-title strong {
  font-family: var(--font-display); font-size: var(--fs-base); font-weight: 700;
  display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title span { color: var(--theme-text-muted); font-size: var(--fs-xs); }
.tabs {
  display: flex; background: var(--theme-bg-card);
  border: 1px solid var(--theme-border-default);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.tab {
  height: 28px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--theme-text-secondary);
  font-size: var(--fs-xs); font-weight: 600;
}
.tab.is-active { background: var(--theme-bg-elevated); color: var(--theme-text-primary); box-shadow: 0 0 0 1px var(--theme-border-subtle); }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--theme-border-default);
  font-size: var(--fs-xs); color: var(--theme-text-secondary); background: transparent;
}
.status-live { border-color: rgb(232 196 116 / 35%); color: var(--theme-accent-yellow); }
.status-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--theme-accent-yellow); box-shadow: 0 0 8px var(--theme-accent-yellow); }
.badge-studio {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  padding: 2px 6px; border-radius: 4px;
  background: var(--theme-accent-gold-15); color: var(--theme-text-gold);
  vertical-align: middle;
}

/* ── Page body ── */
.page { flex: 1; padding: 20px 24px 32px; overflow: auto; }
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: var(--fs-2xl); }
.page-head p { color: var(--theme-text-secondary); font-size: var(--fs-sm); margin-top: 4px; }
.page-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--theme-border-subtle); margin: 16px 0 20px; }
.page-tab {
  background: none; border: 0; padding: 8px 0 10px; color: var(--theme-text-secondary);
  font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: inset 0 -2px 0 transparent;
}
.page-tab.is-active { color: var(--theme-text-gold); box-shadow: inset 0 -2px 0 var(--theme-accent-gold); }

/* ── Cards ── */
.card {
  background: var(--theme-bg-card);
  border: 1px solid var(--theme-border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--theme-shadow-card);
}
.card-premium { border-color: var(--theme-border-strong); box-shadow: var(--theme-shadow-premium); }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(180px, 220px)) 1fr; gap: 12px; align-items: start; margin-bottom: 22px; }
.kpi { padding: 14px 16px; }
.kpi-label { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em; color: var(--theme-text-muted); }
.kpi-value { font-family: var(--font-mono); font-size: var(--fs-xl); font-weight: 600; margin-top: 4px; }
.kpi-value.up { color: var(--theme-accent-green); }
.kpi-value.gold { color: var(--theme-text-gold); }
.hub-tools { display: flex; justify-content: flex-end; gap: 8px; align-items: center; height: 100%; }
.search {
  height: 36px; min-width: 240px; padding: 0 12px 0 34px;
  border-radius: 999px; border: 1px solid var(--theme-border-default);
  background: var(--theme-bg-card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%238E8E99' stroke-width='1.6'><circle cx='6' cy='6' r='4.5'/><path d='M9.5 9.5 L12 12'/></svg>") 12px 50% no-repeat;
  color: var(--theme-text-primary);
}
.search::placeholder { color: var(--theme-text-muted); }
.filter-btn { height: 36px; padding: 0 12px; border-radius: 999px; }

.section-label {
  font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em;
  color: var(--theme-text-gold); margin: 0 0 10px;
}

/* ── Workflow list ── */
.wf-list { display: flex; flex-direction: column; overflow: hidden; margin-bottom: 28px; }
.wf-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) 110px minmax(180px, 1fr) 150px 44px 110px;
  gap: 12px; align-items: center;
  padding: 14px 16px;
  border: 0; background: transparent; color: inherit; text-align: left; width: 100%;
  border-bottom: 1px solid var(--theme-border-divider);
}
.wf-row:last-child { border-bottom: 0; }
.wf-row:hover { background: var(--theme-surface-hover); }
.wf-row.is-error { background: rgb(232 115 115 / 6%); }
.wf-name { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-base); }
.wf-meta { color: var(--theme-text-muted); font-size: var(--fs-xs); margin-top: 2px; }
.wf-when { font-size: var(--fs-xs); color: var(--theme-text-secondary); }
.wf-money { font-size: var(--fs-xs); font-family: var(--font-mono); }
.wf-money .up { color: var(--theme-accent-green); }
.wf-money .down { color: var(--theme-accent-red); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }

.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.template {
  padding: 16px; text-align: left; cursor: pointer; width: 100%;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.template:hover { transform: translateY(-2px); box-shadow: var(--theme-shadow-premium); }
.template-kicker { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em; color: var(--theme-text-gold); margin-bottom: 6px; }
.template h3 { font-size: var(--fs-md); margin-bottom: 6px; }
.template p { font-size: var(--fs-xs); color: var(--theme-text-secondary); }

/* ── Empty / skeleton ── */
.empty {
  border: 1px dashed var(--theme-border-strong);
  border-radius: var(--radius-2xl);
  background: var(--theme-bg-dark);
  text-align: center; padding: 56px 24px;
}
.empty-icon { width: 36px; height: 36px; margin: 0 auto 14px; color: var(--theme-text-muted); }
.empty h2 { font-size: var(--fs-xl); margin-bottom: 8px; }
.empty p { color: var(--theme-text-secondary); font-size: var(--fs-sm); max-width: 460px; margin: 0 auto 18px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.skeleton-list { margin-top: 28px; overflow: hidden; }
.skel {
  height: 10px; border-radius: 6px;
  background: linear-gradient(90deg, var(--theme-bg-elevated) 0%, var(--theme-accent-gold-08) 50%, var(--theme-bg-elevated) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-row { display: grid; grid-template-columns: 1.6fr 80px 1fr 80px; gap: 24px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--theme-border-divider); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── Editor workspace ── */
.editor { height: 100vh; overflow: hidden; }
.workspace { flex: 1; display: flex; min-height: 0; }
.canvas {
  flex: 1; position: relative; overflow: hidden;
  background-color: var(--theme-bg-primary);
  background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1px);
  background-size: 22px 22px;
}
.flow {
  position: absolute; left: 50%; top: 46%;
  width: min(1000px, 96%);
  aspect-ratio: 1000 / 600;
  transform: translate(-50%, -50%);
}
.flow svg.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.node {
  position: absolute; width: 156px; display: flex; flex-direction: column; align-items: center;
  background: none; border: 0; color: inherit; padding: 0;
  transform: translate(-50%, -50%);
}
.node-orb {
  width: 84px; height: 84px; border-radius: var(--radius-2xl);
  background: var(--theme-bg-card);
  border: 1px solid var(--theme-border-default);
  display: grid; place-items: center;
  color: var(--theme-text-secondary);
  box-shadow: var(--theme-shadow-card);
  position: relative;
}
.node-orb svg { width: 28px; height: 28px; }
.node.is-selected .node-orb {
  border-color: var(--theme-accent-gold);
  color: var(--theme-accent-gold);
  box-shadow: 0 0 0 1px var(--theme-accent-gold), var(--theme-shadow-glow), var(--theme-shadow-premium);
}
.node.is-success .node-orb { border-color: var(--theme-accent-green); color: var(--theme-accent-green); }
.node.is-error .node-orb { border-color: var(--theme-accent-red); color: var(--theme-accent-red); box-shadow: 0 0 24px rgb(232 115 115 / 25%); }
.node.is-run .node-orb { border-color: var(--theme-accent-gold); color: var(--theme-accent-gold); box-shadow: var(--theme-shadow-glow); }
.node.is-add .node-orb {
  border: 1.5px dashed var(--theme-accent-gold); background: transparent;
  color: var(--theme-accent-gold); box-shadow: none;
}
.node-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  background: var(--theme-accent-green); color: #0D0F14;
}
.node.is-error .node-badge { background: var(--theme-accent-red); color: #fff; }
.node-fila {
  position: absolute; top: -8px; right: -10px;
  font-size: 8px; font-weight: 800; letter-spacing: 0.06em;
  background: var(--theme-accent-gold); color: #0D0F14;
  padding: 2px 5px; border-radius: 4px;
}
.node-pct {
  position: absolute; bottom: 6px; right: 6px;
  font-size: 9px; font-weight: 800; color: var(--theme-accent-green);
}
.node-label { margin-top: 8px; text-align: center; }
.node-label strong { display: block; font-size: var(--fs-sm); font-weight: 650; font-family: var(--font-display); }
.node-label span { display: block; font-size: var(--fs-2xs); color: var(--theme-text-muted); margin-top: 2px; }
.edge-badge {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-default);
  color: var(--theme-text-secondary); white-space: nowrap; z-index: 2;
}
.edge-badge.ok { color: var(--theme-accent-green); border-color: rgb(159 212 163 / 35%); background: #14181A; }
.edge-badge.no { color: var(--theme-accent-red); border-color: rgb(232 115 115 / 35%); background: #1A1416; }
[data-theme="day"] .edge-badge.ok { background: #fff; }
[data-theme="day"] .edge-badge.no { background: #fff; }
.add-step {
  position: absolute; transform: translate(-50%, -50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-strong);
  color: var(--theme-text-gold); font-size: 14px; line-height: 1; z-index: 2; padding: 0;
}
.zoom-bar {
  position: absolute; left: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 6px;
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-default);
  border-radius: 999px; padding: 4px 6px; z-index: 3;
}
.zoom-bar button {
  width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: transparent; color: var(--theme-text-secondary);
}
.zoom-bar span { font-size: var(--fs-xs); font-family: var(--font-mono); min-width: 40px; text-align: center; }
.zoom-bar .sep { width: 1px; height: 16px; background: var(--theme-border-grid); margin: 0 2px; }

/* Inspector */
.inspector {
  width: var(--inspector-w); flex-shrink: 0;
  background: var(--theme-bg-dark);
  border-left: 1px solid var(--theme-border-subtle);
  display: flex; flex-direction: column;
}
.inspector-body { flex: 1; padding: 20px 18px; overflow: auto; }
.kicker { font-size: var(--fs-2xs); font-weight: 700; letter-spacing: 0.08em; color: var(--theme-text-gold); margin-bottom: 6px; }
.inspector h2 { font-size: var(--fs-xl); margin-bottom: 6px; }
.lede { font-size: var(--fs-sm); color: var(--theme-text-secondary); margin-bottom: 18px; }
.field { margin-bottom: 16px; }
.field > label, .field-label { display: block; font-size: var(--fs-sm); color: var(--theme-text-secondary); margin-bottom: 6px; }
.field-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-default);
  border-radius: var(--radius-md); padding: 8px 10px; font-size: var(--fs-sm);
}
.field-box .tag { color: var(--theme-accent-green); font-size: var(--fs-xs); font-weight: 600; }
.hint {
  margin-top: 8px; font-size: var(--fs-xs); color: var(--theme-text-gold);
  background: var(--theme-accent-gold-08); border: 1px solid var(--theme-border-default);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.cond-row { display: grid; grid-template-columns: 1fr 40px 90px; gap: 8px; margin-bottom: 8px; }
.cond-row .box {
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-default);
  border-radius: var(--radius-md); padding: 8px 10px; font-size: var(--fs-sm);
  font-family: var(--font-mono);
}
.cond-row .op { text-align: center; color: var(--theme-text-muted); display: grid; place-items: center; }
.outs { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.out { display: flex; justify-content: space-between; font-size: var(--fs-sm); }
.out .ok { color: var(--theme-accent-green); }
.out .no { color: var(--theme-accent-red); }
.inspector-foot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 16px 18px; border-top: 1px solid var(--theme-border-grid);
}
.error-panel .kicker { color: var(--theme-accent-red); }
.error-card {
  background: rgb(232 115 115 / 10%);
  border: 1px solid rgb(232 115 115 / 30%);
  border-radius: var(--radius-lg); padding: 12px; margin-bottom: 16px;
  font-size: var(--fs-xs); color: var(--theme-text-secondary);
}
.error-card strong { display: block; color: var(--theme-text-primary); font-size: var(--fs-sm); margin-bottom: 4px; }
.ok-list { list-style: none; padding: 0; margin: 0 0 16px; font-size: var(--fs-xs); color: var(--theme-text-secondary); }
.ok-list li { padding: 4px 0; }
.ok-list li::before { content: "✓ "; color: var(--theme-accent-green); }

/* Financial bar */
.preview {
  height: var(--preview-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px 0 170px;
  border-top: 1px solid var(--theme-border-subtle);
  background: var(--theme-bg-dark);
}
.preview-copy { min-width: 240px; }
.preview-copy .kicker { margin-bottom: 2px; }
.preview-copy p { font-size: var(--fs-xs); color: var(--theme-text-muted); }
.preview-stat { min-width: 160px; }
.preview-stat strong { display: block; font-size: var(--fs-sm); font-weight: 700; }
.preview-stat span { font-size: var(--fs-2xs); color: var(--theme-text-muted); }
.preview-stat.up strong { color: var(--theme-accent-green); }
.preview-stat.down strong { color: var(--theme-accent-red); }
.preview-stat.hold strong { color: var(--theme-text-primary); }
.preview .btn { margin-left: auto; }

/* ── Banners ── */
.banners { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 0; }
.banner {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--radius-lg); padding: 10px 12px 10px 16px;
  font-size: var(--fs-sm);
}
.banner p { flex: 1; }
.banner-err { background: rgb(232 115 115 / 12%); border: 1px solid rgb(232 115 115 / 35%); color: var(--theme-text-primary); }
.banner-warn { background: var(--theme-accent-gold-08); border: 1px solid var(--theme-border-strong); }
.banner-info { background: var(--theme-bg-card); border: 1px solid var(--theme-border-default); color: var(--theme-text-secondary); }

/* ── Modal / toast ── */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 40;
  background: rgb(0 0 0 / 55%);
  align-items: center; justify-content: center; padding: 24px;
}
.overlay.is-open { display: flex; }
.modal {
  width: min(520px, 100%);
  background: var(--theme-bg-card);
  border: 1px solid var(--theme-border-strong);
  border-radius: var(--radius-2xl);
  box-shadow: var(--theme-shadow-premium);
  padding: 22px 22px 18px;
}
.modal h2 { font-size: var(--fs-xl); margin: 4px 0 8px; }
.modal .lede { margin-bottom: 16px; }
.facts { display: grid; gap: 8px; margin: 12px 0 20px; font-size: var(--fs-sm); }
.facts div { display: flex; justify-content: space-between; gap: 16px; color: var(--theme-text-secondary); }
.facts strong { color: var(--theme-text-gold); font-family: var(--font-mono); font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-close {
  float: right; width: 28px; height: 28px; border: 0; background: transparent;
  color: var(--theme-text-muted); font-size: 18px;
}
.form-field { margin: 0 0 14px; }
.form-field label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: 6px; }
.form-field input {
  width: 100%; height: 40px; padding: 0 12px;
  border-radius: var(--radius-md); border: 1px solid var(--theme-border-default);
  background: var(--theme-bg-elevated);
}
.form-field .help { font-size: var(--fs-xs); color: var(--theme-text-muted); margin-top: 6px; }
.note {
  display: flex; gap: 8px; align-items: flex-start;
  border: 1px solid var(--theme-border-default); border-radius: var(--radius-md);
  padding: 10px 12px; font-size: var(--fs-xs); color: var(--theme-text-secondary); margin: 8px 0 18px;
}
.toast {
  position: fixed; right: 20px; bottom: 24px; z-index: 50;
  display: none; align-items: center; gap: 12px;
  background: var(--theme-bg-elevated); border: 1px solid var(--theme-border-strong);
  border-radius: var(--radius-lg); padding: 12px 14px;
  box-shadow: var(--theme-shadow-premium); font-size: var(--fs-sm);
}
.toast.is-open { display: flex; }

/* ── Execuções table ── */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.chip-btn {
  height: 28px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--theme-border-default); background: var(--theme-bg-card);
  color: var(--theme-text-secondary); font-size: var(--fs-xs); font-weight: 600;
}
.chip-btn.is-active { background: var(--theme-accent-gold-15); border-color: var(--theme-border-strong); color: var(--theme-text-gold); }
.chip-btn.is-err { color: var(--theme-accent-red); border-color: rgb(232 115 115 / 35%); }
.chip-btn.is-err.is-active { background: var(--theme-roas-red-bg); }
.filters .search { margin-left: auto; }
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th {
  text-align: left; font-size: var(--fs-2xs); letter-spacing: 0.06em; font-weight: 700;
  color: var(--theme-text-gold); padding: 10px 12px;
  border-bottom: 1px solid var(--theme-border-default);
}
table.data td { padding: 12px; border-bottom: 1px solid var(--theme-border-divider); vertical-align: middle; }
table.data tr:hover td { background: var(--theme-surface-hover); }
table.data tr.is-error td { background: rgb(232 115 115 / 8%); }
.mono { font-family: var(--font-mono); font-size: var(--fs-xs); }
.sub { display: block; font-size: var(--fs-2xs); color: var(--theme-text-muted); margin-top: 2px; }

/* ── Rastreamento ── */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: flex; background: var(--theme-bg-card); border: 1px solid var(--theme-border-default); border-radius: 999px; padding: 3px; margin-left: auto; }
.seg button { height: 26px; padding: 0 10px; border: 0; background: transparent; color: var(--theme-text-secondary); border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.seg button.is-active { background: var(--theme-bg-elevated); color: var(--theme-text-primary); }
.select {
  height: 36px; padding: 0 12px; border-radius: var(--radius-md);
  border: 1px solid var(--theme-border-default); background: var(--theme-bg-card);
}
.states-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.state-card { padding: 16px 18px; }
.state-card h3 { font-size: var(--fs-md); display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.state-card p { font-size: var(--fs-sm); color: var(--theme-text-secondary); margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); margin: 12px 0; }
.check input { margin-top: 3px; accent-color: var(--theme-accent-gold); }
.config-card { padding: 22px; margin-bottom: 14px; max-width: 760px; }
.pixel-row { display: flex; align-items: center; gap: 12px; padding: 16px 18px; max-width: 760px; }
.pixel-row .grow { flex: 1; }
.icon-btn {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  border: 1px solid var(--theme-border-default); background: transparent; color: var(--theme-text-secondary);
  display: inline-grid; place-items: center;
}

/* ── Mobile product screens ── */
.phone-frame { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 24px; background: #0a0a10; }
.phone {
  width: 390px; min-height: 844px; background: var(--theme-bg-primary);
  border-radius: 32px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid #2a2a32;
}
.mobile-screen { background: var(--theme-bg-primary); min-height: 844px; display: flex; flex-direction: column; }
.status-bar {
  height: 48px; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px 0; font-weight: 700; font-size: 15px;
}
.status-bar .sigs { display: flex; gap: 6px; font-size: 12px; opacity: 0.9; }
.mobile-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 8px 20px 16px; }
.mobile-head h1 { font-size: 28px; }
.mobile-head p { font-size: var(--fs-sm); color: var(--theme-text-muted); }
.mobile-head p.warn { color: var(--theme-accent-red); }
.mob-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 20px 16px; }
.mob-card { margin: 0 20px 12px; padding: 14px 14px 12px; }
.mob-card h3 { font-size: var(--fs-md); margin-bottom: 4px; }
.mob-foot {
  margin-top: auto; padding: 16px 20px 28px;
}
.mob-foot p {
  border: 1px solid var(--theme-border-default); border-radius: var(--radius-lg);
  padding: 12px; text-align: center; font-size: var(--fs-xs); color: var(--theme-text-muted);
}

/* ── State sheet ── */
.sheet { padding: 32px 40px 60px; max-width: 1100px; }
.sheet h1 { font-size: var(--fs-3xl); margin: 4px 0 8px; }
.sheet .intro { color: var(--theme-text-secondary); margin-bottom: 24px; }
.sheet-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; margin-top: 16px; }

/* ── Proto switcher ── */
.proto-switcher {
  position: fixed; left: 12px; bottom: 16px; z-index: 60;
  font-size: var(--fs-xs);
}
.proto-toggle {
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--theme-bg-elevated); color: var(--theme-text-gold);
  border: 1px solid var(--theme-border-strong); font-weight: 700;
  box-shadow: var(--theme-shadow-card);
}
.proto-panel {
  display: none; position: absolute; left: 0; bottom: 40px;
  width: 280px; max-height: min(70vh, 520px); overflow: auto;
  background: var(--theme-bg-card); border: 1px solid var(--theme-border-strong);
  border-radius: var(--radius-xl); padding: 10px; box-shadow: var(--theme-shadow-premium);
}
.proto-switcher.is-open .proto-panel { display: block; }
.proto-panel strong {
  display: block; font-size: 10px; letter-spacing: 0.08em; color: var(--theme-text-gold);
  margin: 8px 6px 4px; font-family: var(--font-sans);
}
.proto-panel a {
  display: block; padding: 6px 8px; border-radius: 8px;
  color: var(--theme-text-secondary); text-decoration: none;
}
.proto-panel a:hover, .proto-panel a.is-current { background: var(--theme-surface-hover); color: var(--theme-text-primary); }

/* ── MGDash home ── */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; max-width: 800px; }
.home-card { padding: 20px; text-align: left; width: 100%; }
.home-card h2 { font-size: var(--fs-lg); margin: 8px 0 6px; }
.home-card p { color: var(--theme-text-secondary); font-size: var(--fs-sm); }

/* ── Switch row in lists ── */
.switch-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 10px; font-size: var(--fs-xs); color: var(--theme-text-muted); }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .hub-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .wf-row { grid-template-columns: 1fr 100px 1fr auto; }
  .templates { grid-template-columns: 1fr; }
  .inspector { width: 300px; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .workspace { flex-direction: column; }
  .inspector { width: 100%; border-left: 0; border-top: 1px solid var(--theme-border-subtle); max-height: 40vh; }
  .kpis { grid-template-columns: 1fr; }
  .wf-row { grid-template-columns: 1fr; gap: 6px; }
  .states-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .preview { flex-wrap: wrap; height: auto; padding: 12px; }
  .sheet-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .page { padding: 16px 14px 80px; }
  .desktop-only-editor-msg { display: block; }
  .hub-desktop { display: none !important; }
  .screen[data-screen="hub"] > .topbar { display: none !important; }
  .hub-mobile { display: flex !important; }
  .proto-switcher { bottom: 16px; left: auto; right: 12px; }
  .phone-frame { padding: 0; background: var(--theme-bg-primary); }
  .phone { width: 100%; border: 0; border-radius: 0; min-height: 100vh; box-shadow: none; }
  .proto-switcher { right: 12px; left: auto; }
  .proto-panel { left: auto; right: 0; }
}
@media (min-width: 481px) {
  .hub-mobile { display: none !important; }
}
.hub-mobile { display: none; flex-direction: column; min-height: 100vh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.switch-row { flex-wrap: wrap; }
