:root {
  color-scheme: dark;
  --bg-app: #0e1117;
  --bg-panel: #161b22;
  --bg-panel-2: #1c2128;
  --bg-node: #111923;
  --border: #30363d;
  --border-soft: #242b33;
  --text-main: #e6edf3;
  --text-muted: #8b949e;
  --green: #2ea043;
  --green-2: #38d996;
  --purple: #8957e5;
  --blue: #58a6ff;
  --amber: #d29922;
  --red: #da3633;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-main);
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.console {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(520px, 1fr) 330px;
  grid-template-rows: minmax(0, 1fr) 242px;
  grid-template-areas:
    "left center right"
    "left bottom right";
  background:
    radial-gradient(circle at 50% 20%, rgba(46, 160, 67, 0.09), transparent 32%),
    var(--bg-app);
}

.panel-surface {
  background: rgba(22, 27, 34, 0.94);
  border: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
}

.left-panel {
  grid-area: left;
  border-width: 0 1px 0 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.graph-stage {
  grid-area: center;
  margin: 14px;
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.right-panel {
  grid-area: right;
  border-width: 0 0 0 1px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.content-rail {
  grid-area: bottom;
  margin: 0 14px 14px;
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  min-height: 44px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  display: grid;
  place-items: center;
  color: #061018;
  font-weight: 950;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small, small, .eyebrow { color: var(--text-muted); }

.profile-card, .money-card, .provider-box, .caption-box, .spark-panel, .accounts {
  background: #0f141b;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #263342;
  border: 1px solid #3b4655;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.live-dot {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
}

.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}

.live-dot.online::before { background: var(--green-2); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-grid article {
  min-height: 78px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #10161f;
  padding: 12px;
}

.metric-grid span { color: var(--text-muted); }
.metric-grid strong { display: block; margin-top: 8px; font-size: 26px; line-height: 1; }

.section-head, .stage-top, .rail-head, .stage-actions, .rail-actions, .form-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head, .stage-top, .rail-head { justify-content: space-between; }
.section-head { margin-bottom: 10px; color: var(--text-muted); font-weight: 800; }

.account-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  border-top: 1px solid var(--border-soft);
}

.account-row:first-of-type { border-top: 0; }
.account-row strong, .account-row small { display: block; }
.account-row b { color: var(--green-2); font-size: 12px; }

.platform {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
}

.platform.ig { background: #2d1d37; color: #f5a6ff; }
.platform.tt { background: #102b2d; color: #62e6e9; }
.platform.yt { background: #351616; color: #ff8b8b; }

.spark-panel svg { width: 100%; height: 66px; }
.spark-panel path { fill: none; stroke: var(--green-2); stroke-width: 4; stroke-linecap: round; }

.stage-top {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.76);
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

h1, h2 { margin: 0; line-height: 1.08; }
h1 { font-size: clamp(25px, 3vw, 40px); }
h2 { font-size: 16px; }

.button, .icon {
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 36px;
  color: var(--text-main);
  background: #10161e;
  font-weight: 850;
}

.button { padding: 0 13px; }
.button.primary { background: linear-gradient(135deg, #238636, #2ea043); color: #f4fff8; border-color: #359a49; }
.button.secondary { background: #161b22; }
.icon { width: 36px; display: grid; place-items: center; }
.button:hover, .icon:hover { border-color: var(--green-2); }

.graph-canvas {
  position: relative;
  overflow: hidden;
  min-height: 0;
  background:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px),
    #0d1117;
  background-size: 30px 30px;
}

.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.wire {
  fill: none;
  stroke: #3f4b58;
  stroke-width: 3;
  stroke-linecap: round;
}

.wire.active {
  stroke: var(--green-2);
  stroke-dasharray: 10 16;
  animation: wireFlow 1.55s linear infinite;
  filter: drop-shadow(0 0 6px rgba(56, 217, 150, .38));
}

.wire.delay-a { animation-delay: -.35s; }
.wire.delay-b { animation-delay: -.7s; }
.wire.delay-c { animation-delay: -1.05s; }

@keyframes wireFlow { to { stroke-dashoffset: -52; } }

.node {
  position: absolute;
  width: 126px;
  min-height: 54px;
  border: 1px solid #364250;
  border-top: 3px solid var(--border);
  border-radius: 7px;
  background: var(--bg-node);
  color: var(--text-main);
  text-align: left;
  padding: 8px 10px;
  box-shadow: 0 12px 26px rgba(0,0,0,.22);
}

.node small, .node strong { display: block; }
.node small { color: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.node strong { margin-top: 4px; font-size: 13px; }
.node.ready { border-top-color: var(--green-2); }
.node.active { border-top-color: var(--purple); box-shadow: 0 0 0 1px rgba(137,87,229,.28), 0 12px 26px rgba(0,0,0,.22); }
.node.muted { opacity: .58; }
.node:hover { border-color: var(--green-2); }

.node.source { left: 34px; top: calc(50% - 27px); }
.node.lane.one { left: 29%; top: 18%; }
.node.lane.two { left: 29%; top: calc(50% - 27px); }
.node.lane.three { left: 29%; bottom: 18%; }
.node.step.one { left: 52%; top: 18%; }
.node.step.two { left: 52%; top: calc(50% - 27px); }
.node.step.three { left: 52%; bottom: 18%; }
.node.out.one { right: 34px; top: 18%; }
.node.out.two { right: 34px; top: calc(50% - 27px); }
.node.out.three { right: 34px; bottom: 18%; }

.money-card {
  background: linear-gradient(180deg, rgba(46,160,67,.18), #0f141b 42%);
}

.money-card span { color: var(--text-muted); text-transform: uppercase; font-size: 11px; font-weight: 900; }
.money-card strong { display: block; margin: 9px 0; font-size: 28px; }
.money-card p, .note { color: var(--text-muted); line-height: 1.45; }

.provider-list, .caption-list { display: grid; gap: 8px; }
.provider, .caption, .queue-card, .clip-card {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #10161f;
}

.provider {
  padding: 9px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
}

.provider strong, .provider small { display: block; }
.provider small { grid-column: 1 / -1; color: var(--text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 0 8px;
  background: #222b36;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}
.chip.approved, .chip.connected, .chip.configured { background: rgba(46,160,67,.18); color: var(--green-2); }
.chip.approval_required, .chip.pending { background: rgba(210,153,34,.16); color: #f0c36a; }

.form-row { align-items: stretch; }
.form-row label { flex: 1; color: var(--text-muted); display: grid; gap: 6px; font-size: 12px; font-weight: 850; }
select, textarea, input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1117;
  color: var(--text-main);
}
select, input { min-height: 36px; padding: 0 10px; }
textarea { margin: 10px 0; padding: 10px; line-height: 1.45; resize: vertical; }

.caption { padding: 9px; }
.caption p { margin: 0; line-height: 1.36; color: #c9d1d9; }
.caption small { display: block; margin: 6px 0; color: var(--text-muted); }
.caption .button { width: 100%; }

.rail-head { min-height: 42px; }
.cards {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.clip-card {
  flex: 0 0 282px;
  padding: 0;
  overflow: hidden;
  color: inherit;
  text-align: left;
}

.clip-card:hover { background: var(--bg-panel-2); border-color: #465565; }
.clip-thumb {
  height: 96px;
  background: linear-gradient(135deg, #18324d 0 31%, #d6a449 32% 56%, #2e8b67 57% 72%, #111923 73%);
}
.clip-card:nth-child(2n) .clip-thumb { background: linear-gradient(135deg, #271e38 0 32%, #7a5aa3 33% 54%, #d7e3ef 55% 68%, #1e6e81 69%); }
.clip-card:nth-child(3n) .clip-thumb { background: linear-gradient(135deg, #342023 0 28%, #c75d50 29% 50%, #e5c37b 51% 65%, #17344d 66%); }
.clip-body { padding: 10px; }
.clip-body strong, .clip-body small { display: block; }
.clip-body small { margin-top: 5px; color: var(--text-muted); }

.queue-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-height: 37px;
}
.queue-card {
  flex: 0 0 auto;
  min-width: 220px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
}
.queue-card small { grid-column: 1; color: var(--text-muted); }
.queue-card .button { grid-row: 1 / span 2; grid-column: 2; min-height: 30px; }

dialog {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  color: var(--text-main);
  width: min(560px, calc(100vw - 32px));
  padding: 18px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.62); }
menu { padding: 0; margin: 16px 0 0; display: flex; justify-content: flex-end; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #e6edf3;
  color: #0d1117;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  font-weight: 850;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  body { overflow: auto; }
  .console {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "left" "center" "right" "bottom";
  }
  .left-panel, .right-panel { border-width: 0 0 1px; }
  .graph-stage, .content-rail { margin: 12px; }
  .graph-canvas { min-height: 520px; }
}

@media (max-width: 720px) {
  .left-panel, .right-panel, .content-rail { padding: 12px; }
  .stage-top, .rail-head { align-items: flex-start; flex-direction: column; }
  .stage-actions, .rail-actions { width: 100%; flex-wrap: wrap; }
  .stage-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-row { flex-direction: column; }
  .node { width: 118px; }
  .node.source { left: 18px; }
  .node.lane.one, .node.lane.two, .node.lane.three { left: 24%; }
  .node.step.one, .node.step.two, .node.step.three { left: 49%; }
  .node.out.one, .node.out.two, .node.out.three { right: 18px; }
}
