:root {
  color-scheme: light;
  --bg: #f5f9fb;
  --sidebar-bg: linear-gradient(158deg, #fff4ef 0%, #f3f2fb 45%, #dff0fb 100%);
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --surface-strong: #edf4fa;
  --line: #d5dde3;
  --line-strong: #b7c4cf;
  --text: #1d2a32;
  --muted: #65727b;
  --muted-strong: #34444e;
  --accent: #0b75bb;
  --accent-strong: #263d4a;
  --accent-soft: #e7f3ff;
  --blue: #0b75bb;
  --blue-soft: #e7f3ff;
  --danger: #b42318;
  --danger-soft: #fff1ef;
  --warning: #8f5c00;
  --warning-soft: #fff6df;
  --shadow: 0 14px 40px rgb(29 41 57 / 8%);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.login-page {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbfd 0%, var(--bg) 100%);
}

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

.login-card {
  width: min(100%, 380px);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  align-items: center;
}

.login-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  margin: 0;
  border: 1px solid #f1b4ad;
  border-radius: 6px;
  padding: 9px 11px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 720;
}

.login-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface-soft);
  color: var(--text);
}

.login-form input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.login-form button {
  min-height: 40px;
  border: 1px solid var(--accent-strong);
  border-radius: 6px;
  background: var(--accent-strong);
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
}

.login-form button:hover,
.login-form button:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  outline: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

.settings-sidebar {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 24px 26px;
  background: var(--sidebar-bg);
  border-right: 1px solid rgb(180 193 204 / 55%);
}

.main-area {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #f8fbfd 0%, var(--bg) 100%);
}

.topbar {
  min-height: 88px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 22px 32px 14px;
  background: transparent;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid #ffffff;
  border-radius: 7px;
  background: #d8a7e8;
  color: #73419a;
  box-shadow: 0 1px 4px rgb(29 41 57 / 18%);
  font-size: 22px;
  font-weight: 850;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.1;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 760;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 780;
  line-height: 1.1;
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab {
  width: 100%;
  min-height: 37px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-weight: 650;
}

.tab:hover,
.tab:focus-visible {
  color: var(--text);
  outline: 0;
}

.tab.is-active {
  background: var(--accent-strong);
  color: #ffffff;
  box-shadow: 0 1px 2px rgb(15 23 42 / 14%);
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-heading {
  margin: 0 0 4px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 780;
}

.nav-item {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--text);
}

.nav-item.is-muted {
  color: var(--muted-strong);
}

.private-badge {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.private-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  min-height: 0;
  margin: 0 32px 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(31 45 61 / 8%);
  overflow: hidden;
}

.pane {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.is-hidden {
  display: none;
}

.map-header,
.list-tools,
.personal-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 78px;
  margin-bottom: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.pane-personal:not(.is-hidden) {
  display: grid;
  min-height: 100%;
  place-items: start stretch;
}

.personal-empty {
  min-height: 100%;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.personal-empty h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 760;
}

.personal-empty p {
  margin: 0;
  color: var(--muted);
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.map-canvas {
  width: 100%;
  height: calc(100vh - 230px);
  min-height: 420px;
  border: 0;
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.node {
  cursor: pointer;
}

.node circle {
  fill: var(--accent);
  stroke: #ffffff;
  stroke-width: 2px;
}

.node text {
  fill: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.node:focus-visible circle,
.node:hover circle {
  stroke: var(--text);
  outline: 0;
}

.node[data-status="ambiguous"] circle,
.node[data-status="pending"] circle {
  fill: var(--warning);
}

.node[data-status$="failed"] circle {
  fill: var(--danger);
}

.node[data-status="sent"] circle,
.node[data-status="simulated"] circle {
  fill: var(--blue);
}

.list-tools {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

.list-tools input,
.list-tools select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
}

.list-tools input {
  flex: 1;
  min-width: 150px;
  padding: 0 12px;
}

.list-tools input::placeholder {
  color: #98a3a8;
}

.list-tools select {
  width: 184px;
  padding: 0 10px;
}

.list-tools input:focus,
.list-tools select:focus,
.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}

.pepita-list,
.pipeline-list {
  display: grid;
  gap: 0;
}

.pipeline-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 20px 18px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}

.pepita-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.pepita-row-main {
  min-width: 0;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  padding: 20px 54px 20px 18px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  box-shadow: none;
}

.pepita-row:hover,
.pepita-row:focus-within,
.pepita-row.is-active,
.pipeline-row:hover,
.pipeline-row:focus-visible,
.pipeline-row.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: 0;
}

.pepita-row.is-active,
.pipeline-row.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.pepita-row-main:focus-visible,
.row-menu-button:focus-visible,
.row-menu-item:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.row-menu {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
}

.row-menu-button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  font-weight: 760;
  line-height: 1;
  opacity: 0;
  transition: opacity 120ms ease, border-color 120ms ease, background 120ms ease;
}

.pepita-row:hover .row-menu-button,
.pepita-row:focus-within .row-menu-button {
  opacity: 1;
}

.row-menu-button:hover,
.row-menu-button[aria-expanded="true"] {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.row-menu-popover {
  position: absolute;
  top: 34px;
  right: 0;
  min-width: 118px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(28, 45, 56, 0.12);
}

.row-menu-item {
  width: 100%;
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}

.row-menu-item.danger-action {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
  box-shadow: none;
}

.row-menu-item.danger-action:hover,
.row-menu-item.danger-action:focus-visible {
  border-color: transparent;
  background: var(--danger-soft);
  box-shadow: none;
}

.row-title,
.detail-title {
  font-weight: 730;
  overflow-wrap: anywhere;
}

.row-title {
  font-size: 14px;
}

.row-meta,
.detail-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.row-extra {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.pepita-heading {
  font-size: 22px;
  line-height: 1.18;
}

.tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.muted-chip {
  color: var(--muted);
}

.operator-phase {
  display: inline-flex;
  width: fit-content;
  margin-top: 9px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 730;
}

.operator-ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.operator-waiting {
  background: var(--blue-soft);
  color: var(--blue);
}

.operator-stop {
  background: var(--danger-soft);
  color: var(--danger);
}

.detail-panel {
  min-width: 0;
  padding: 30px 28px;
  background: var(--surface);
  overflow: auto;
}

.empty-detail {
  min-height: calc(100vh - 124px);
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
}

.detail-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.compact-section {
  margin-top: 14px;
}

.detail-section .secondary-action + .secondary-action {
  margin-left: 8px;
}

.detail-section h2 {
  margin: 0 0 9px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.warning {
  margin-top: 14px;
  border: 1px solid #efcf86;
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--warning);
  background: var(--warning-soft);
}

.thread-box {
  display: grid;
  gap: 12px;
}

.thread-subsection {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-soft);
}

.thread-subsection h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 730;
}

.meta-grid {
  display: grid;
  grid-template-columns: minmax(112px, max-content) minmax(0, 1fr);
  gap: 7px 14px;
  margin: 0;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 730;
}

.meta-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.secondary-action,
.primary-action {
  min-height: 36px;
  border-radius: 7px;
  padding: 0 13px;
  cursor: pointer;
  font-weight: 650;
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.danger-action {
  border-color: #f4b8b1;
  background: var(--danger-soft);
  color: var(--danger);
}

.primary-action {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-action:hover,
.secondary-action:focus-visible,
.primary-action:hover,
.primary-action:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: 0;
}

.danger-action:hover,
.danger-action:focus-visible {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.primary-action:disabled {
  cursor: progress;
  opacity: 0.72;
}

.edit-shell {
  display: grid;
  gap: 18px;
}

.editable-card,
.read-only-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
}

.editable-card {
  border-color: #a9cbc6;
  box-shadow: 0 8px 22px rgb(15 111 100 / 8%);
}

.read-only-card {
  background: var(--surface-soft);
}

.edit-helper {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.edit-form {
  display: grid;
  gap: 12px;
}

.edit-field {
  display: grid;
  gap: 6px;
}

.edit-label {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 730;
}

.edit-field input,
.edit-field select,
.edit-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
}

.edit-field textarea {
  min-height: 220px;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: -24px;
  padding: 10px 0 0;
  background: var(--surface);
}

.edit-message {
  min-height: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.inline-action {
  min-height: 30px;
}

.text-block {
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.command-section {
  display: grid;
  gap: 10px;
}

.command-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.command-row {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr) max-content;
  gap: 8px;
  align-items: center;
}

.command-label {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 730;
}

.command-code {
  display: block;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  background: var(--surface-soft);
  color: var(--text);
  overflow-wrap: anywhere;
}

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

  .settings-sidebar {
    min-height: auto;
    gap: 16px;
    padding: 18px 16px;
  }

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

  .tabs {
    width: 100%;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab {
    min-width: 0;
  }

  .private-badge {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .workspace {
    grid-template-columns: 1fr;
    margin: 0 16px 16px;
  }

  .pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .detail-panel {
    min-height: 320px;
  }

  .empty-detail {
    min-height: 220px;
  }
}

@media (max-width: 680px) {
  .detail-panel {
    padding: 16px;
  }

  .list-tools {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 0;
    background: transparent;
  }

  .list-tools input,
  .list-tools select {
    width: 100%;
  }

  .map-canvas {
    min-height: 320px;
  }

  .command-row {
    grid-template-columns: 1fr;
  }
}
