:root {
  color-scheme: dark;
  --bg: #061017;
  --panel: rgba(10, 24, 35, 0.84);
  --line: rgba(96, 239, 255, 0.24);
  --text: #eefbff;
  --muted: #8ba7b4;
  --cyan: #56e6ff;
  --green: #75f5a1;
  --blue: #4a8cff;
  --yellow: #ffd166;
  --red: #ff6b7a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(74, 140, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 85% 18%, rgba(117, 245, 161, 0.12), transparent 24rem),
    linear-gradient(180deg, #07131c 0%, var(--bg) 52%, #03080d 100%);
  color: var(--text);
}

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

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.panel-heading,
.entry-head,
.grid {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 0.96;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.system-state,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 13px;
  color: #cdebf3;
  background: rgba(7, 18, 27, 0.72);
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}

.grid {
  align-items: stretch;
  gap: 18px;
}

.grid > .topology-panel {
  flex: 1 1 72%;
}

.grid > .status-panel {
  flex: 1 1 28%;
}

.lower {
  margin-top: 18px;
}

.lower > .upload-panel {
  flex: 0 0 380px;
}

.lower > .table-panel {
  flex: 1 1 auto;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(86, 230, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 230, 255, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, black, transparent 84%);
}

.panel-heading {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}

.topology {
  position: relative;
  height: 430px;
  margin: 8px 18px 18px;
}

.links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.links path {
  fill: none;
  stroke: rgba(86, 230, 255, 0.36);
  stroke-width: 2;
  stroke-dasharray: 7 8;
}

.packet {
  fill: var(--green);
  filter: drop-shadow(0 0 8px var(--green));
}

.p2,
.p4 {
  fill: var(--cyan);
}

.node {
  position: absolute;
  width: 170px;
  min-height: 112px;
  border: 1px solid rgba(86, 230, 255, 0.28);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(9, 27, 39, 0.95), rgba(7, 17, 26, 0.94));
  box-shadow: 0 0 24px rgba(86, 230, 255, 0.08);
}

.node span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 13px;
  border-radius: 50%;
  background: rgba(86, 230, 255, 0.14);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

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

.node small {
  margin-top: 6px;
  color: var(--muted);
}

.node.active {
  border-color: rgba(117, 245, 161, 0.62);
  box-shadow: 0 0 36px rgba(117, 245, 161, 0.22);
}

.source {
  left: 1%;
  top: 165px;
}

.brain {
  left: 41%;
  top: 88px;
}

.db {
  left: 41%;
  bottom: 68px;
}

.check {
  right: 2%;
  top: 98px;
}

.publish {
  right: 2%;
  bottom: 88px;
}

.status-panel,
.upload-panel,
.table-panel {
  padding-bottom: 20px;
}

.metric-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  padding: 20px 22px 12px;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.metric span,
.hint,
.mapping,
label span,
.empty {
  color: var(--muted);
}

.metric strong {
  font-size: 28px;
}

.hint,
.mapping {
  position: relative;
  z-index: 1;
  padding: 0 22px;
  line-height: 1.7;
}

.dropzone {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  margin: 20px 22px 14px;
  border: 1px dashed rgba(86, 230, 255, 0.44);
  border-radius: 8px;
  padding: 22px;
  cursor: pointer;
  background: rgba(86, 230, 255, 0.05);
}

.dropzone input {
  width: 100%;
}

.dropzone span {
  color: var(--text);
  font-weight: 800;
}

.dropzone small {
  color: var(--muted);
  line-height: 1.6;
}

.primary,
.ghost,
.save {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  color: #001017;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  cursor: pointer;
}

.wide {
  position: relative;
  z-index: 1;
  width: calc(100% - 44px);
  margin: 0 22px 14px;
}

.segmented {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 18px 22px 0;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid rgba(86, 230, 255, 0.2);
  border-radius: 8px;
  color: #d6eef5;
  background: rgba(86, 230, 255, 0.06);
}

.settings-form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  padding: 18px 22px 14px;
}

.settings-form label {
  display: grid;
  gap: 7px;
}

.settings-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.secret-status {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 22px 14px;
}

.secret-status span {
  border: 1px solid rgba(117, 245, 161, 0.18);
  border-radius: 8px;
  padding: 10px;
  color: #c8f5d9;
  background: rgba(117, 245, 161, 0.06);
  font-size: 12px;
  font-weight: 800;
}

.diagnostics-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  padding: 0 22px 14px;
}

.diagnostic {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(86, 230, 255, 0.16);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 12px;
}

.diagnostic strong {
  color: #dff8ff;
}

.diagnostic span {
  color: var(--muted);
  text-align: right;
}

.diagnostic.ok {
  border-color: rgba(117, 245, 161, 0.24);
}

.diagnostic.ok span {
  color: var(--green);
}

.diagnostic.warn {
  border-color: rgba(255, 209, 102, 0.28);
}

.diagnostic.warn span {
  color: var(--yellow);
}

.diagnostic-warnings {
  margin: 0;
  border: 1px solid rgba(255, 209, 102, 0.2);
  border-radius: 8px;
  padding: 10px;
  color: #ffe6a3;
  background: rgba(255, 209, 102, 0.07);
  white-space: pre-wrap;
  line-height: 1.6;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary {
  position: relative;
  z-index: 1;
  margin: 0 22px 14px;
}

.ghost {
  color: var(--cyan);
  background: rgba(86, 230, 255, 0.08);
  border-color: rgba(86, 230, 255, 0.24);
}

.preview {
  position: relative;
  z-index: 1;
  max-height: 260px;
  margin: 0 22px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 12px;
  color: #c9eaf1;
  background: rgba(0, 0, 0, 0.2);
  white-space: pre-wrap;
}

.entry-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  max-height: 720px;
  overflow: auto;
  padding: 20px 22px 2px;
}

.summary-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  padding: 20px 22px 0;
}

.summary-grid .metric {
  display: grid;
  gap: 8px;
}

.summary-grid .metric strong {
  font-size: 22px;
}

.scope-tabs {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 22px 0;
}

.scope-tabs label {
  cursor: pointer;
}

.scope-tabs input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scope-tabs span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid rgba(86, 230, 255, 0.2);
  border-radius: 999px;
  padding: 0 12px;
  color: #cdebf3;
  background: rgba(86, 230, 255, 0.06);
  font-size: 13px;
  font-weight: 800;
}

.scope-tabs b {
  min-width: 24px;
  border-radius: 999px;
  padding: 2px 7px;
  color: #001017;
  background: var(--cyan);
  text-align: center;
}

.scope-tabs input:checked + span {
  border-color: rgba(117, 245, 161, 0.58);
  color: var(--green);
  background: rgba(117, 245, 161, 0.1);
  box-shadow: 0 0 18px rgba(117, 245, 161, 0.12);
}

.task-list {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  max-height: 600px;
  overflow: auto;
  padding: 18px 22px 2px;
}

.entry-card {
  border: 1px solid rgba(86, 230, 255, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: rgba(4, 14, 22, 0.84);
}

.task-card {
  border: 1px solid rgba(117, 245, 161, 0.18);
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(6, 26, 24, 0.9), rgba(4, 14, 22, 0.86));
}

.task-type {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
}

.page-type {
  display: inline-flex;
  margin-left: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.task-priority {
  color: var(--yellow);
}

.task-card h3 {
  margin: 12px 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.55;
}

.task-card p {
  margin-bottom: 10px;
  color: #c6dfe8;
  line-height: 1.7;
}

.task-card p:last-child {
  color: var(--green);
}

.entry-head {
  justify-content: space-between;
  gap: 12px;
}

.category {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.entry-card h3 {
  margin: 12px 0;
  font-size: 16px;
  line-height: 1.6;
}

.entry-card label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

select {
  min-height: 34px;
  padding: 0 10px;
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 10px;
  line-height: 1.6;
}

textarea[readonly] {
  color: #b7cbd3;
}

.save {
  width: 100%;
  margin-top: 12px;
}

.empty {
  margin: 0;
  line-height: 1.8;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.28);
  }
}

@media (max-width: 980px) {
  .topbar,
  .grid {
    display: grid;
  }

  .lower > .upload-panel {
    flex-basis: auto;
  }

  .topology {
    height: 620px;
  }

  .links {
    display: none;
  }

  .node {
    position: relative;
    inset: auto;
    width: auto;
    margin: 12px;
  }

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

  .secret-status {
    grid-template-columns: 1fr;
  }
}
