:root {
  --ink: #2b2d42;
  --paper: #edf2f4;
  --alert: #ef233c;
  --muted: #8d99ae;
  --line: rgba(43, 45, 66, 0.16);
  --soft: rgba(141, 153, 174, 0.2);
  --ok: #20816d;
  --watch: #b4771d;
  --shadow: 0 22px 70px rgba(43, 45, 66, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(43,45,66,0.055) 1px, transparent 1px),
    linear-gradient(0deg, rgba(43,45,66,0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 34px 34px;
}

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

button {
  cursor: pointer;
}

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

.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  color: rgba(237, 242, 244, 0.68);
  font-size: 12px;
  margin-top: 2px;
}

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

.tab {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(237, 242, 244, 0.13);
  border-radius: 8px;
  color: rgba(237, 242, 244, 0.72);
  background: transparent;
  text-align: left;
  padding: 0 12px;
}

.tab.is-active {
  color: var(--paper);
  border-color: rgba(239, 35, 60, 0.7);
  background: rgba(239, 35, 60, 0.14);
}

.rail-status {
  margin-top: auto;
  border-top: 1px solid rgba(237, 242, 244, 0.16);
  padding-top: 18px;
}

.rail-status strong {
  display: block;
  margin-top: 6px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.mono {
  margin: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.15;
  margin-bottom: 8px;
}

h3 {
  font-size: 16px;
  line-height: 1.2;
  margin-bottom: 8px;
}

p {
  color: rgba(43, 45, 66, 0.72);
  line-height: 1.55;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  width: min(330px, 42vw);
  display: grid;
  gap: 4px;
}

.search input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
}

.search input {
  height: 42px;
  padding: 0 12px;
}

select {
  height: 40px;
  padding: 0 10px;
}

.icon-button,
.primary-button {
  min-height: 42px;
  border-radius: 8px;
  border: 0;
}

.icon-button {
  width: 42px;
  background: var(--ink);
  color: var(--paper);
  font-size: 20px;
}

.primary-button {
  padding: 0 16px;
  background: var(--alert);
  color: white;
  font-weight: 750;
}

.alert-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.52);
  margin-bottom: 18px;
}

.alert-strip article {
  min-height: 84px;
  padding: 14px;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 3px;
}

.alert-strip article:last-child {
  border-right: 0;
}

.alert-strip strong {
  font-size: 26px;
}

.alert-strip small {
  color: rgba(43,45,66,0.62);
}

.alert-strip .is-hot {
  box-shadow: inset 5px 0 0 var(--alert);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.canvas-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.canvas-head p,
.section-head p {
  margin-bottom: 0;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
}

.map-canvas {
  position: relative;
  min-height: 450px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.82), rgba(237,242,244,0.5)),
    radial-gradient(circle at 22% 36%, rgba(239,35,60,0.12), transparent 24%),
    radial-gradient(circle at 72% 62%, rgba(32,129,109,0.13), transparent 23%);
  box-shadow: var(--shadow);
}

.map-canvas::before,
.map-canvas::after {
  position: absolute;
  content: "";
  inset: 34px;
  border: 1px dashed rgba(43,45,66,0.18);
  transform: skewY(-7deg);
}

.map-canvas::after {
  inset: 92px 72px;
  transform: skewY(8deg);
}

.map-lines {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(27deg, transparent 49%, rgba(43,45,66,0.2) 50%, transparent 51%),
    linear-gradient(148deg, transparent 49%, rgba(239,35,60,0.22) 50%, transparent 51%);
  opacity: 0.45;
}

.map-node {
  position: absolute;
  width: 150px;
  min-height: 86px;
  translate: -50% -50%;
  border: 1px solid rgba(43,45,66,0.18);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
  color: var(--ink);
  background: rgba(237,242,244,0.94);
  box-shadow: 0 12px 24px rgba(43,45,66,0.13);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.map-node::before {
  display: block;
  content: "";
  height: 4px;
  width: var(--retention);
  max-width: 100%;
  margin-bottom: 8px;
  background: var(--ok);
}

.map-node.watch::before {
  background: var(--watch);
}

.map-node.alert::before {
  background: var(--alert);
}

.map-node:hover,
.map-node.is-selected {
  transform: translateY(-3px);
  border-color: var(--alert);
  box-shadow: 0 16px 34px rgba(43,45,66,0.22);
}

.map-node span,
.map-node small {
  display: block;
}

.map-node strong {
  display: block;
  font-size: 23px;
  margin: 2px 0;
}

.map-node small {
  color: rgba(43,45,66,0.64);
}

.inspector {
  border-left: 5px solid var(--alert);
  padding: 18px 0 18px 18px;
  background: rgba(255,255,255,0.48);
}

.inspector dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px 12px;
  margin: 20px 0 0;
}

.inspector dt {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.inspector dd {
  margin: 0;
  min-width: 0;
}

.queue-zone,
.analytics-grid,
.timeline,
.import-panel,
.public-board {
  margin-top: 18px;
}

.task-table {
  border-top: 1px solid var(--line);
}

.table-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1.05fr 1.7fr 0.85fr 0.8fr 0.7fr;
  gap: 14px;
  align-items: center;
  min-height: 64px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.table-row:not(.table-head):hover,
.table-row.is-selected {
  background: rgba(255,255,255,0.72);
}

.table-head {
  min-height: 40px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
}

.table-row strong,
.table-row small {
  display: block;
}

.table-row small {
  margin-top: 3px;
  color: rgba(43,45,66,0.58);
  line-height: 1.35;
}

.retention-text {
  font-weight: 800;
}

.retention-text.alert {
  color: var(--alert);
}

.retention-text.watch {
  color: var(--watch);
}

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

.analytics-step {
  border-top: 4px solid var(--ink);
  padding-top: 12px;
}

.analytics-step strong {
  display: block;
  font-size: 32px;
  margin-bottom: 10px;
}

.bar {
  height: 8px;
  background: rgba(43,45,66,0.12);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--alert);
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.timeline-item time {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color: var(--muted);
  font-size: 12px;
}

.timeline-item p {
  margin-bottom: 4px;
}

.import-panel,
.public-board {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.6);
  padding: 24px;
}

.import-panel {
  max-width: 760px;
}

pre {
  overflow: auto;
  margin: 18px 0 0;
  padding: 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
}

.public-board {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

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

.public-item {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  align-content: space-between;
}

.public-item strong {
  font-size: 26px;
}

.public-item.alert {
  border-color: var(--alert);
  box-shadow: inset 5px 0 0 var(--alert);
}

.public-item.watch {
  box-shadow: inset 5px 0 0 var(--watch);
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(520px, calc(100vw - 24px));
  box-shadow: 0 28px 80px rgba(43,45,66,0.34);
}

dialog::backdrop {
  background: rgba(43,45,66,0.46);
}

.dialog-form {
  padding: 22px;
  display: grid;
  gap: 16px;
  background: var(--paper);
}

.dialog-form label {
  display: grid;
  gap: 8px;
}

textarea {
  width: 100%;
  padding: 12px;
  resize: vertical;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-actions button:not(.primary-button) {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: white;
}

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

  .side-rail {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .tab {
    text-align: center;
    padding: 0 8px;
  }

  .ops-grid,
  .public-board {
    grid-template-columns: 1fr;
  }

  .analytics-grid,
  .alert-strip,
  .status-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .table-head {
    display: none;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .canvas-head,
  .section-head {
    display: grid;
  }

  .toolbar,
  .search {
    width: 100%;
    justify-content: stretch;
  }

  .search {
    max-width: none;
  }

  .toolbar .primary-button {
    flex: 1;
  }

  .tabs,
  .analytics-grid,
  .alert-strip,
  .status-list {
    grid-template-columns: 1fr;
  }

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

  .map-node {
    width: 132px;
  }

  .table-row,
  .timeline-item,
  .inspector dl {
    grid-template-columns: 1fr;
  }
}
