:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f6f6;
  --text: #111111;
  --muted: #4a4a4a;
  --border: #d8d8d8;
  --border-strong: #b4b4b4;
  --accent: #111111;
  --gantt-header-height: 44px;
  --embed-safe: 0px;
  --embed-side-base: 14px;
  --embed-side: var(--embed-side-base);
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header,
main,
.hscroll {
  min-width: 0;
}

/* Embedded (HubSpot iframe / modal) should feel "full page" and not double-card the UI. */
html.embedded,
html.embedded body {
  /* max-width: 90vw; */
}

html.embedded body {
  background: transparent;
  max-width: 90%;
  /* margin: 0 auto; */
  height: 100%;
}

html.framed .title {
  display: none;
}

html.framed .subtitle {
  display: none;
}

html.embedded header {
  padding: 12px var(--embed-side) 10px;
}

html.embedded main {
  padding: 14px var(--embed-side);
  max-width: calc(100vw - calc(2 * var(--embed-side)));
  margin: 0 auto;
  overflow-x: hidden;
}

html.embedded .hscroll {
  padding-left: var(--embed-side);
  padding-right: var(--embed-side);
  background: transparent;
}

html.hubspot {
  --embed-safe: 90px;
  /* --embed-side: calc(var(--embed-side-base) + var(--embed-safe)); */
}

html.hubspot header {
  padding-left: var(--embed-side);
  padding-right: var(--embed-side);
}

html.hubspot main {
  padding-left: var(--embed-side);
  padding-right: var(--embed-side);
  max-width: calc(100vw - calc(2 * var(--embed-side)));
  margin: 0 auto;
}

html.hubspot .hscroll {
  padding-left: var(--embed-side);
  padding-right: var(--embed-side);
}

header {
  background: var(--panel);
  padding: 14px 18px 12px;
  overflow-x: hidden;
}

.title {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.appLogo {
  height: 22px;
  width: auto;
  flex: 0 0 auto;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

.viewTabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.viewTab {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
}

.viewTab:hover {
  background: var(--panel-2);
}

.viewTab.active {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

.viewTab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

html.embedded .controls {
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: 8px;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

.controls > * {
  min-width: 0;
}

.controls input,
.controls select {
  width: 100%;
  min-width: 0;
}

.controls #refresh {
  width: 100%;
  min-width: 0;
}

.controls button {
  width: 100%;
  min-width: 0;
}

input,
select,
textarea,
button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
}

input::placeholder {
  color: #777;
}

textarea::placeholder {
  color: #777;
}

textarea {
  resize: vertical;
}

select option {
  color: var(--text);
  background: var(--panel);
}

select[multiple] {
  height: 40px;
}

button {
  cursor: pointer;
  font-weight: 600;
  padding: 10px 14px;
  background: #111111;
  color: #ffffff;
  border-color: #111111;
}

button:hover {
  background: #000000;
  border-color: #000000;
}

.planPanel {
  margin-top: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.planGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.planStat {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.planLabel {
  font-size: 11px;
  color: var(--muted);
  font-weight: 750;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.planValue {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.planActions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.planActionStatus {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.planInvite {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.planInviteLabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.planInviteActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.planInviteStatus {
  font-size: 12px;
  color: var(--muted);
}

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

.metaSpacer {
  flex: 1 1 auto;
}

.metaAction {
  margin-left: auto;
}

.linkButton {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.linkButton:hover {
  text-decoration-thickness: 2px;
}

.linkButton:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.buttonGhost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}

.buttonGhost:hover {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--border-strong);
}

main {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  padding: 16px 18px;
}

.attribution {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

html.embedded .attribution {
  max-width: 100%;
  margin: 0;
}

.attrIntro {
  margin: 8px 0 14px;
}

.attrIntro h2 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: 0.2px;
}

.attrHint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.method {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 10px 12px;
}

.method summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.method ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.method li {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 4px 0;
}

.method code {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.attrOutput {
  display: grid;
  gap: 12px;
}

.agentsView {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

html.embedded .agentsView {
  max-width: 100%;
  margin: 0;
}

.agentShell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.agentRail {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #faf7f0 0%, #f3efe5 100%);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 10px;
  position: sticky;
  top: 14px;
}

.agentRailButton {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  border-color: transparent;
  padding: 12px 14px;
}

.agentRailButton.active,
.agentRailButton:hover {
  background: #132c22;
  border-color: #132c22;
  color: #f7f5ee;
}

.agentPanel {
  display: grid;
  gap: 14px;
}

.agentNotice {
  border: 1px solid #d2c7a8;
  background: #fff7df;
  color: #5b4311;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

.agentStatGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.agentStatCard,
.agentSection {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 16px;
  padding: 14px;
}

.agentStatLabel {
  font-size: 11px;
  color: var(--muted);
  font-weight: 750;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.agentStatValue {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 700;
}

.agentSection {
  display: grid;
  gap: 12px;
}

.agentSectionHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  flex-wrap: wrap;
}

.agentSectionHeader h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.agentSectionHeader p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  max-width: 700px;
}

.agentFormGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.agentFormWide {
  grid-column: 1 / -1;
}

.agentToggleGrid {
  display: grid;
  gap: 10px;
}

.agentToggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}

.agentToggle input {
  width: auto;
  margin: 0;
}

.agentList,
.agentActivity {
  display: grid;
  gap: 10px;
}

.agentSnapshotGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.agentOnboarding {
  display: grid;
  gap: 10px;
}

.agentStep {
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 10px;
}

.agentStepHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  flex-wrap: wrap;
}

.agentStepEyebrow {
  font-size: 11px;
  color: var(--muted);
  font-weight: 750;
  letter-spacing: 0.24px;
  text-transform: uppercase;
}

.agentStepHeader h4 {
  margin: 2px 0 4px;
  font-size: 15px;
}

.agentStepHeader p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  max-width: 720px;
}

.agentStepBadge {
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  border: 1px solid rgba(17, 24, 39, 0.12);
  background: #f3f4f6;
  color: #374151;
}

.agentStep.is-complete {
  border-color: rgba(19, 44, 34, 0.18);
  background: linear-gradient(180deg, rgba(241, 250, 244, 0.92) 0%, rgba(255, 255, 255, 0.92) 100%);
}

.agentStep.is-complete .agentStepBadge {
  background: #dff3e6;
  color: #184c2f;
  border-color: rgba(24, 76, 47, 0.14);
}

.agentStep.is-active {
  border-color: rgba(176, 123, 33, 0.22);
  background: linear-gradient(180deg, rgba(255, 248, 229, 0.94) 0%, rgba(255, 255, 255, 0.94) 100%);
}

.agentStep.is-active .agentStepBadge {
  background: #fff0c5;
  color: #7c4d00;
  border-color: rgba(124, 77, 0, 0.14);
}

.agentStep.is-locked {
  opacity: 0.72;
}

.agentStepActions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.agentPropertyRow {
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.agentSnapshotCard {
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
}

.agentSnapshotValue {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.pipelinePlanItemRow {
  border: 1px solid rgba(17, 24, 39, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 8px;
}

.agentApprovalRow,
.agentActivityRow {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.agentApprovalRowHeader,
.agentActivityRowHeader {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.agentMeta {
  font-size: 12px;
  color: var(--muted);
}

.agentBadgeRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.agentBadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text);
}

.agentResult {
  border: 1px solid var(--border);
  background: #f8f5ef;
  border-radius: 14px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

.agentEmpty {
  color: var(--muted);
  font-size: 12px;
}

.attrKpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.attrCard {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}

.attrValue {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--text);
}

.attrLabel {
  font-size: 12px;
  color: var(--muted);
}

.attrSubLabel {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  opacity: 0.9;
}

.attrBar {
  height: 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  overflow: hidden;
}

.attrBarFill {
  height: 100%;
  width: calc(var(--pct, 0) * 1%);
  background: #111111;
}

#attrStatus {
  color: var(--muted);
}

.ganttWrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  min-width: 0;
}

html.embedded .ganttWrap {
  padding: 10px;
  max-width: 100%;
}

.ganttSticky {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--gantt-header-height);
  margin-bottom: calc(-1 * var(--gantt-header-height));
  background: var(--panel);
  overflow: hidden;
  pointer-events: none;
}

.ganttStickyScroller {
  height: 100%;
  overflow: hidden;
}

.ganttStickyScroller svg {
  display: block;
}

#gantt {
  padding: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.gantt-container {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#gantt svg,
.gantt-container svg {
  display: block;
}

.errorCard {
  margin: 18px 6px;
  padding: 14px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  display: grid;
  gap: 10px;
  max-width: 720px;
}

.errorTitle {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.errorMessage {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.scopeList {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.scopeList code {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

.scopeDetails {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 8px 10px;
}

.scopeDetails summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}

.scopeDetailsBody {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

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

.errorFieldLabel {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}

.errorInput {
  width: 96px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 650;
}

.errorInput:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.errorActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.errorAction {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #111111;
  background: #111111;
  color: #ffffff;
  font-weight: 650;
  text-decoration: none;
}

.errorAction.secondary {
  background: transparent;
  color: #111111;
}

.errorAction.secondary:hover {
  background: #111111;
  color: #ffffff;
}

.errorAction:hover {
  background: #000000;
  border-color: #000000;
}

.errorLink {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 650;
}

.errorLink:hover {
  text-decoration-thickness: 2px;
}

details.missing {
  margin-top: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 12px;
}

details.missing summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
}

.missingList {
  padding: 10px 6px 4px;
  display: grid;
  gap: 6px;
}

.missingItem {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  min-width: 0;
}

.missingItem a {
  color: var(--accent);
  text-decoration: none;
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.missingItem a:hover {
  text-decoration: underline;
}

.missingItem .status {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

/* Frappe Gantt tweaks */
.gantt-container {
  background: transparent;
  scrollbar-width: none;
}

.gantt-container::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.grid-background {
  fill: transparent;
}

.grid-row {
  fill: rgba(0, 0, 0, 0.02);
}

.today-highlight {
  fill: rgba(0, 0, 0, 0.04);
}

.bar {
  fill: rgba(0, 0, 0, 0.35);
}

.bar-progress {
  fill: rgba(0, 0, 0, 0.7);
}

.bar-label {
  fill: #ffffff;
  font-weight: 650;
}

.bar-wrapper.status-completed .bar {
  fill: rgba(152, 225, 173, 0.5);
}
.bar-wrapper.status-completed .bar-progress {
  fill: rgba(152, 225, 173, 0.85);
}

.bar-wrapper.status-active .bar {
  fill: rgba(0, 0, 0, 0.55);
}

.bar-wrapper.status-in_progress .bar,
.bar-wrapper.status-in-progress .bar {
  fill: rgba(255, 199, 123, 0.52);
}
.bar-wrapper.status-in_progress .bar-progress,
.bar-wrapper.status-in-progress .bar-progress {
  fill: rgba(255, 199, 123, 0.86);
}

.bar-wrapper.status-paused .bar {
  fill: rgba(248, 113, 113, 0.5);
}
.bar-wrapper.status-paused .bar-progress {
  fill: rgba(248, 113, 113, 0.86);
}

.bar-wrapper.no-end .bar {
  stroke: rgba(0, 0, 0, 0.65);
  stroke-dasharray: 4 3;
  stroke-width: 1;
}

/* Read-only UX: no resize/progress handles */
.handle {
  display: none;
}

.bar-wrapper {
  cursor: pointer;
}

.hscroll {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--panel);
}

.hscrollLabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.2px;
  user-select: none;
  flex: 0 0 auto;
}

.hslider {
  flex: 1 1 auto;
  width: 100%;
  margin: 0;
  accent-color: #111111;
  background: transparent;
}

.hslider:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hslider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
}

.hslider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -3px;
  border-radius: 999px;
  background: #111111;
  border: 1px solid #111111;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.hslider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
}

.hslider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #111111;
  border: 1px solid #111111;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

@media (max-width: 900px) {
  .agentShell {
    grid-template-columns: 1fr;
  }

  .agentRail {
    position: static;
  }
}
