:root {
  color-scheme: dark;
  --bg: #070b10;
  --panel: rgba(17, 24, 31, 0.88);
  --panel-strong: rgba(24, 34, 43, 0.94);
  --line: rgba(148, 163, 184, 0.18);
  --line-bright: rgba(94, 234, 212, 0.5);
  --text: #eef6f8;
  --muted: #9fb0bd;
  --cyan: #22d3ee;
  --teal: #2dd4bf;
  --green: #84cc16;
  --amber: #f59e0b;
  --red: #f43f5e;
  --blue: #60a5fa;
  --shadow: 0 18px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(45, 212, 191, 0.04) 1px, transparent 1px),
    linear-gradient(0deg, rgba(45, 212, 191, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 55% 0%, rgba(34, 211, 238, 0.12), transparent 28rem),
    #070b10;
  background-size: 44px 44px, 44px 44px, auto, auto;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(9, 14, 20, 0.92);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-sigil {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(45, 212, 191, 0.48);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.22), rgba(96, 165, 250, 0.12));
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.18);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark strong,
.engine-card strong {
  display: block;
  font-size: 15px;
}

.brand-mark small,
.engine-card small {
  color: var(--muted);
  font-size: 12px;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item,
.primary-button,
.ghost-button,
.task-action {
  border: 1px solid var(--line);
  background: rgba(15, 23, 32, 0.82);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(34, 211, 238, 0.46);
  background: rgba(34, 211, 238, 0.08);
}

.nav-icon,
.button-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  position: relative;
}

.flow-icon::before,
.agent-icon::before,
.qa-icon::before,
.audit-icon::before,
.refresh-icon::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid var(--cyan);
  border-radius: 5px;
}

.agent-icon::after,
.refresh-icon::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  right: 1px;
  top: 1px;
  border-radius: 999px;
  background: var(--green);
}

.qa-icon::before {
  border-color: var(--green);
  transform: rotate(45deg);
}

.audit-icon::before {
  border-color: var(--amber);
  border-radius: 999px;
}

.engine-card {
  margin-top: auto;
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(20, 31, 39, 0.74);
}

.engine-light,
.pulse-dot,
.status-light {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.engine-light,
.pulse-dot {
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.main-grid {
  padding: 24px;
  display: grid;
  gap: 18px;
  grid-template-rows: auto auto auto auto auto;
  min-width: 0;
}

.main-grid > *,
.topbar > *,
.section-heading > *,
.workbench > *,
.audit-strip > * {
  min-width: 0;
}

.topbar,
.section-heading,
.metrics-row,
.workbench,
.audit-strip {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-pill,
.mode-pill {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: rgba(15, 23, 32, 0.82);
}

.primary-button {
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(45, 212, 191, 0.14));
}

.ghost-button {
  min-height: 40px;
  padding: 0 14px;
  color: var(--muted);
}

.ghost-button:hover {
  border-color: rgba(34, 211, 238, 0.46);
  color: var(--text);
}

.metrics-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric,
.savings-console,
.flow-stage,
.task-panel,
.agent-panel,
.audit-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 82px;
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.savings-console {
  padding: 18px;
}

.savings-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.savings-metric {
  min-height: 90px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(8, 13, 19, 0.72);
}

.savings-metric span,
.calculator-controls label,
.calculator-ledger span {
  color: var(--muted);
  font-size: 12px;
}

.savings-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.calculator-body {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.calculator-controls,
.calculator-ledger {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(8, 13, 19, 0.58);
}

.calculator-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.calculator-controls label {
  display: grid;
  gap: 7px;
}

.calculator-controls input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 32, 0.82);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.calculator-controls input:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.62);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

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

.calculator-ledger div {
  min-height: 58px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  padding: 10px;
  background: rgba(15, 23, 32, 0.56);
}

.calculator-ledger strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
}

.flow-stage {
  padding: 18px;
}

.section-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.section-heading.compact {
  padding: 18px 18px 0;
}

.status-legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.status-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.status-light.running {
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
}

.status-light.done {
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.status-light.pending {
  background: var(--blue);
  box-shadow: 0 0 14px var(--blue);
}

.status-light.blocked {
  background: var(--amber);
  box-shadow: 0 0 16px var(--amber);
}

.flow-canvas {
  margin-top: 18px;
  min-height: 180px;
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  position: relative;
}

.flow-node {
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(15, 23, 32, 0.96), rgba(12, 18, 25, 0.82));
  position: relative;
  overflow: hidden;
}

.flow-node::after {
  content: "";
  position: absolute;
  top: 36px;
  right: -18px;
  width: 36px;
  height: 2px;
  background: var(--line-bright);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.5);
}

.flow-node:last-child::after {
  display: none;
}

.node-status {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 16px;
}

.flow-node h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.flow-node p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.node-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: var(--text);
  font-weight: 800;
}

.workbench {
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.75fr);
}

.task-list,
.agent-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.task-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(8, 13, 19, 0.72);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.task-card > div {
  min-width: 0;
}

.task-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  margin-top: 8px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.task-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 7px;
}

.task-action {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
}

.task-action:hover {
  border-color: rgba(34, 211, 238, 0.48);
  color: var(--text);
}

.agent-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  background: rgba(8, 13, 19, 0.72);
}

.human-avatar {
  width: 50px;
  height: 50px;
  border: 1px solid rgba(34, 211, 238, 0.44);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.16), transparent 22px),
    linear-gradient(160deg, rgba(34, 211, 238, 0.24), rgba(45, 212, 191, 0.08));
  box-shadow: inset 0 0 18px rgba(34, 211, 238, 0.12), 0 0 16px rgba(34, 211, 238, 0.16);
}

.human-avatar::before {
  content: "";
  position: absolute;
  inset: auto 7px 3px;
  height: 18px;
  border-radius: 999px 999px 8px 8px;
  background: var(--accent);
  opacity: 0.86;
}

.avatar-head {
  position: absolute;
  left: 50%;
  top: 9px;
  width: 25px;
  height: 29px;
  transform: translateX(-50%);
  border-radius: 44% 44% 48% 48%;
  background: var(--skin);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08), inset 0 -5px 8px rgba(0, 0, 0, 0.08);
  z-index: 2;
}

.avatar-head::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: -3px;
  height: 12px;
  border-radius: 14px 14px 7px 7px;
  background: var(--hair);
}

.avatar-eyes {
  position: absolute;
  left: 7px;
  top: 14px;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(7, 11, 16, 0.78);
  box-shadow: 8px 0 0 rgba(7, 11, 16, 0.78);
}

.avatar-eyes::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  width: 8px;
  height: 3px;
  border-radius: 999px;
  border-bottom: 1px solid rgba(7, 11, 16, 0.46);
}

.avatar-shoulders {
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 38px;
  height: 15px;
  transform: translateX(-50%);
  border-radius: 999px 999px 7px 7px;
  background: linear-gradient(135deg, var(--accent), rgba(34, 211, 238, 0.12));
  z-index: 1;
}

.avatar-sofia {
  --skin: #c98968;
  --hair: #2f1a16;
  --accent: #2dd4bf;
}

.avatar-marcos {
  --skin: #b87958;
  --hair: #1f2933;
  --accent: #60a5fa;
}

.avatar-helena {
  --skin: #d9a37f;
  --hair: #7c3f24;
  --accent: #f59e0b;
}

.avatar-clara {
  --skin: #e0b08d;
  --hair: #322018;
  --accent: #22d3ee;
}

.avatar-livia {
  --skin: #9f674e;
  --hair: #171717;
  --accent: #84cc16;
}

.avatar-teresa {
  --skin: #c58a72;
  --hair: #f1f5f9;
  --accent: #a78bfa;
}

.avatar-rafael {
  --skin: #cf916c;
  --hair: #4b2b20;
  --accent: #38bdf8;
}

.avatar-bruno {
  --skin: #8e5b42;
  --hair: #121212;
  --accent: #fb7185;
}

.avatar-default {
  --skin: #c98968;
  --hair: #2f1a16;
  --accent: #22d3ee;
}

.agent-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-card small {
  color: var(--muted);
}

.agent-focus {
  display: block;
  margin-top: 4px;
  color: rgba(238, 246, 248, 0.72);
  font-size: 11px;
  line-height: 1.35;
}

.audit-strip {
  padding: 16px 18px;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
}

.audit-trail {
  display: flex;
  gap: 10px;
  overflow: hidden;
}

.audit-item {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(8, 13, 19, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid rgba(34, 211, 238, 0.34);
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(8, 13, 19, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.login-body {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
}

.login-card {
  border: 1px solid rgba(45, 212, 191, 0.24);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 16px;
}

.login-card h1 {
  font-size: 28px;
}

.login-card label {
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.login-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 13, 19, 0.82);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

.login-card input:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.62);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.login-button {
  justify-content: center;
}

.login-message {
  min-height: 20px;
  margin: 0;
  color: var(--amber);
  font-size: 13px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .brand-mark div,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
  }

  .engine-card {
    display: none;
  }

  .flow-canvas {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .savings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calculator-body,
  .calculator-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100vw;
  }

  .sidebar {
    display: none;
  }

  .main-grid {
    padding: 14px;
    grid-template-rows: auto;
    max-width: 100vw;
  }

  .topbar,
  .section-heading,
  .metrics-row,
  .audit-strip {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .status-legend {
    flex-wrap: wrap;
  }

  .metrics-row,
  .savings-grid,
  .flow-canvas {
    grid-template-columns: 1fr;
  }

  .calculator-ledger {
    grid-template-columns: 1fr;
  }

  .task-card {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .task-title strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .task-actions {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
  }

  .task-action {
    width: 100%;
  }

  .audit-trail {
    flex-wrap: wrap;
    overflow: visible;
  }

  .audit-item {
    flex: 1 1 150px;
    min-width: 0;
  }
}
