:root {
  --bg: #0c1117;
  --bg-soft: #141b23;
  --surface: #182230;
  --surface-2: #213043;
  --ink: #e5edf6;
  --muted: #8ca1b8;
  --accent: #3ad9a4;
  --accent-2: #40a9ff;
  --warn: #ffca5f;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); }
body { min-height: 100vh; position: relative; }
body.no-scroll { overflow: hidden; }
.bg-shell {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(58, 217, 164, 0.16), transparent 30%),
    radial-gradient(circle at 85% 10%, rgba(64, 169, 255, 0.18), transparent 40%),
    linear-gradient(160deg, #0c1117 0%, #0a1320 55%, #0e1726 100%);
  z-index: -1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
}
.brand { color: var(--ink); text-decoration: none; font-size: 1.2rem; font-weight: 700; letter-spacing: 0.02em; }
.topnav { display: flex; gap: 14px; align-items: center; }
.topnav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topnav a:hover { color: var(--ink); }

.app-shell { width: 100%; }
.app-shell:not(.has-sidebar) .main {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}
.app-shell.has-sidebar {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 16px 24px;
}
.app-shell.has-sidebar .main {
  padding: 20px 8px 0 8px;
  max-width: none;
  margin: 0;
}
.sidebar {
  position: sticky;
  top: 12px;
  align-self: start;
  background: rgba(24, 34, 48, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-top: 18px;
}
.sidebar h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}
.sidebar-nav {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.sidebar-link {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  border-radius: 9px;
  padding: 8px 10px;
}
.sidebar-link:hover { border-color: rgba(64, 169, 255, 0.6); }
.sidebar-link.active {
  border-color: rgba(58, 217, 164, 0.5);
  background: rgba(58, 217, 164, 0.12);
}
.hero { margin-bottom: 18px; }
.hero h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.3rem); }
.hero p { color: var(--muted); max-width: 780px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 14px;
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
}
.card span { color: var(--muted); font-size: 0.9rem; }
.card strong { font-size: 1.8rem; color: var(--accent); }

.panel {
  background: rgba(24, 34, 48, 0.88);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2, .panel h1 { margin-top: 0; }
details summary {
  cursor: pointer;
  user-select: none;
}

.app-shell:not(.has-sidebar) .main:has(.map-shell) {
  max-width: none;
  padding: 0;
}
.map-shell {
  position: relative;
  min-height: calc(100vh - 66px);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(5, 10, 18, 0.38), rgba(3, 8, 14, 0.72)),
    radial-gradient(circle at 50% 48%, rgba(51, 230, 255, 0.10), transparent 48%);
  isolation: isolate;
}
.map-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(51, 230, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 230, 255, 0.045) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at center, black 0, transparent 72%);
  opacity: 0.34;
  z-index: 1;
}
.map-globe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.map-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}
.map-links polyline {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: square;
  stroke-linejoin: miter;
  filter: drop-shadow(0 0 8px currentColor);
  opacity: 0.9;
}
.map-topbar,
.map-status,
.map-detail {
  position: absolute;
  z-index: 8;
}
.map-topbar {
  top: 16px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.map-topbar > * { pointer-events: auto; }
.map-mode-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(51, 230, 255, 0.28);
  background: rgba(3, 12, 20, 0.72);
  backdrop-filter: blur(10px);
}
.map-mode,
.map-reset,
.map-back {
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  color: #ccefff;
  background: rgba(7, 20, 30, 0.82);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  font-size: 0.82rem;
}
.map-mode.active {
  color: #031017;
  border-color: rgba(51, 230, 255, 0.95);
  background: #33e6ff;
}
.map-status {
  top: 72px;
  left: 18px;
  display: grid;
  gap: 3px;
  padding-left: 10px;
  border-left: 2px solid #33e6ff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.map-status strong {
  font-size: 0.78rem;
  color: #dffaff;
}
.map-status span {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: rgba(204, 239, 255, 0.7);
  text-transform: none;
  letter-spacing: 0;
}
.map-reticles,
.map-cards {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.map-reticle {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid var(--map-color);
  background:
    linear-gradient(var(--map-color), var(--map-color)) center/2px 24px no-repeat,
    linear-gradient(90deg, var(--map-color), var(--map-color)) center/24px 2px no-repeat,
    rgba(0, 0, 0, 0.08);
  box-shadow: 0 0 18px color-mix(in srgb, var(--map-color) 70%, transparent);
  pointer-events: auto;
}
.map-reticle::before,
.map-reticle::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid var(--map-color);
  border-radius: 50%;
}
.map-reticle::after {
  inset: 13px;
  background: var(--map-color);
}
.map-reticle.offline {
  animation: map-alert 1s steps(2, end) infinite;
}
@keyframes map-alert {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.42; }
}
.map-node-card {
  position: absolute;
  width: 210px;
  min-height: 92px;
  display: grid;
  gap: 4px;
  text-align: left;
  color: #dffaff;
  border: 1px solid var(--map-color);
  border-radius: 8px;
  padding: 9px 10px;
  background: linear-gradient(135deg, rgba(5, 15, 24, 0.9), rgba(8, 26, 34, 0.74));
  box-shadow: 0 0 18px color-mix(in srgb, var(--map-color) 24%, transparent), inset 0 0 18px rgba(51, 230, 255, 0.06);
  pointer-events: auto;
}
.map-node-card > *,
.map-reticle::before,
.map-reticle::after {
  pointer-events: none;
}
.map-node-card::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 36px;
  height: 14px;
  border-top: 2px solid var(--map-color);
  border-right: 2px solid var(--map-color);
}
.map-node-card.focused {
  width: 280px;
  min-height: 150px;
}
.map-node-card strong {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.map-node-card span,
.map-node-card em {
  font-size: 0.72rem;
  color: rgba(223, 250, 255, 0.72);
}
.map-node-card em {
  color: #ff6472;
  font-family: var(--mono);
  font-style: normal;
  font-size: 1rem;
  letter-spacing: 0.08em;
}
.map-node-region {
  font-family: var(--mono);
  text-transform: uppercase;
  color: var(--map-color) !important;
}
.map-spark-duo {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.map-spark-duo .sparkline {
  width: 58px;
  height: 18px;
}
.map-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 8px;
}
.map-detail {
  left: 16px;
  right: 16px;
  bottom: 14px;
  min-height: 31vh;
  max-height: 42vh;
  border-top: 1px solid rgba(51, 230, 255, 0.35);
  background: linear-gradient(180deg, rgba(3, 11, 18, 0.78), rgba(2, 8, 13, 0.96));
  backdrop-filter: blur(12px);
  padding: 12px;
  overflow: auto;
}
.map-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.map-detail-head div {
  display: grid;
  gap: 2px;
}
.map-detail-head span {
  color: #33e6ff;
  font-family: var(--mono);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.map-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.map-detail-grid article {
  border: 1px solid var(--map-color);
  border-radius: 8px;
  padding: 10px;
  background: rgba(8, 20, 28, 0.72);
}
.map-detail-grid h3 {
  margin: 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}
.map-detail-grid p {
  margin: 3px 0 8px;
  color: rgba(223, 250, 255, 0.66);
  font-size: 0.76rem;
}
.map-detail-grid dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
  margin: 0;
}
.map-detail-grid dl div {
  display: grid;
  gap: 1px;
}
.map-detail-grid dt {
  color: rgba(223, 250, 255, 0.58);
  font-size: 0.68rem;
  text-transform: uppercase;
}
.map-detail-grid dd {
  margin: 0;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}
.map-detail-sparks {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.map-detail-sparks .sparkline {
  width: 86px;
  height: 23px;
}
.offline-text {
  color: #ff6472;
  font-family: var(--mono);
}
details summary::-webkit-details-marker { color: var(--muted); }
details[open] summary { margin-bottom: 10px; }
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.section-grid a {
  color: var(--ink);
  text-decoration: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
}
.section-grid a:hover { border-color: rgba(64, 169, 255, 0.6); }

.split {
  display: grid;
  grid-template-columns: minmax(300px, 420px) 1fr;
  gap: 16px;
}
.grow { overflow: auto; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}
.section-head .actions { margin: 0; }
.status-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 6px 0 10px;
}
.readonly-banner {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 202, 95, 0.45);
  background: rgba(255, 202, 95, 0.12);
  color: var(--warn);
}
.error-banner {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.12);
}
.error-banner .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.error-banner strong { color: var(--ink); }
.error-banner .hint { color: rgba(229, 237, 246, 0.82); }
.section-help {
  margin-top: 0;
  margin-bottom: 10px;
  color: var(--muted);
}

.actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
button, .ghost {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border: none;
  color: #041018;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
}
button.ghost, .ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,0.2);
}

input, textarea, select {
  width: 100%;
  background: rgba(11, 18, 27, 0.9);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 10px;
  font-family: var(--sans);
}
textarea, code, pre { font-family: var(--mono); font-size: 0.84rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.copy-chip {
  width: auto;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 0 0 3px;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid rgba(64,169,255,0.34);
  background: rgba(64,169,255,0.08);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.copy-chip:hover {
  border-color: rgba(64,169,255,0.72);
  background: rgba(64,169,255,0.16);
}
.plain-list {
  list-style: none;
  padding-left: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
}
.plain-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.nowrap { white-space: nowrap; }
.dynamic-form { margin-bottom: 8px; }
.dynamic-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dynamic-form .field span {
  font-size: 0.82rem;
  color: var(--muted);
}
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.table-toolbar h2 { margin: 0; }
.table-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.table-controls input { min-width: 220px; }
.table-controls select {
  min-width: 90px;
  width: auto;
}
.table-wrap {
  overflow: auto;
  max-height: min(68vh, 920px);
  border-radius: 10px;
}
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.column-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.03);
}
.column-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}
.relation-editor {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.relation-editor h3 {
  margin-top: 0;
  margin-bottom: 10px;
}
.service-workspace .service-hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.service-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.service-layout {
  margin-bottom: 16px;
}
.progress-step {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.03);
}
.progress-step .head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}
.progress-step .title {
  font-size: 0.88rem;
  font-weight: 700;
}
.service-timeline-item {
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.03);
}
.service-timeline-item .head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.service-timeline-item .title {
  font-size: 0.85rem;
  font-weight: 700;
}
.service-timeline-item .meta {
  font-size: 0.77rem;
  color: var(--muted);
}
.svc-tab.active {
  border-color: rgba(58, 217, 164, 0.5);
  color: var(--accent);
}
.svc-mini-table-wrap {
  overflow: auto;
}
.svc-mini-table th, .svc-mini-table td {
  font-size: 0.82rem;
}
.svc-mini-actions {
  display: inline-flex;
  gap: 6px;
}
.svc-mini-actions button {
  padding: 5px 8px;
  font-size: 0.75rem;
}
.context-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.context-actions h3 {
  margin: 0 0 8px;
}
.context-actions .actions {
  margin-top: 8px;
}
.operations-feed {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.operations-feed h3 {
  margin: 0 0 8px;
}
.drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(560px, calc(100vw - 32px));
  overflow: auto;
  background: rgba(24, 34, 48, 0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 40;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}
.drawer-head h2 { margin: 0; }
.operation-row {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.operation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.operation-title {
  font-size: 0.88rem;
  font-weight: 700;
}
.operation-body {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.79rem;
  white-space: pre-wrap;
  color: var(--muted);
}
.inline-pre {
  margin: 0;
  max-width: 520px;
  white-space: pre-wrap;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 9px 8px;
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.85rem; }
th.sortable {
  cursor: pointer;
  user-select: none;
}
thead th {
  position: sticky;
  top: 0;
  background: rgba(24, 34, 48, 0.98);
  z-index: 1;
}
tbody tr:hover { background: rgba(64, 169, 255, 0.08); }
tr[data-selected="1"] { background: rgba(58, 217, 164, 0.11); }
tr[data-targeted-record="1"] {
  background: rgba(255, 202, 95, 0.14);
  box-shadow: inset 3px 0 0 rgba(255, 202, 95, 0.9);
}
.row-link {
  color: var(--accent-2);
  text-decoration: none;
}
.row-link:hover { text-decoration: underline; }
.fk-id {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

.wizard .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.wizard .row { margin-bottom: 10px; }
.wizard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.wizard-group {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 12px 12px 6px;
}
.wizard-group legend {
  padding: 0 8px;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0.01em;
}
.wizard-group .hint { margin-top: 2px; margin-bottom: 10px; }
.wizard .form-grid label { display: flex; flex-direction: column; gap: 6px; }
.wizard .form-grid .span-2 { grid-column: span 2; }
.wizard .advanced { margin-top: 12px; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle-ui {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
  position: relative;
  flex: 0 0 auto;
}
.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  transition: transform 140ms ease;
}
.toggle-label { color: var(--muted); font-weight: 700; }
.toggle input:checked + .toggle-ui {
  border-color: rgba(58, 217, 164, 0.5);
  background: rgba(58, 217, 164, 0.14);
}
.toggle input:checked + .toggle-ui::after {
  transform: translateX(20px);
  background: rgba(58, 217, 164, 0.9);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-card {
  position: relative;
  width: min(1100px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  background: rgba(24, 34, 48, 0.96);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-head h2 { margin: 0; }
.hidden { display: none !important; }

.cd-version-card {
  width: 100%;
  min-height: 74px;
  display: grid;
  gap: 4px;
  align-content: start;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 10px;
  cursor: pointer;
}
.cd-version-card:hover { border-color: rgba(92, 200, 255, 0.55); }
.cd-version-card:disabled { cursor: default; opacity: 0.72; }
.cd-version-card strong { font-size: 0.95rem; }
.cd-version-card span,
.cd-version-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.cd-version-card .cd-cell-blocker {
  color: #ffbf57;
  line-height: 1.25;
}
.cd-version-card .cd-cell-attention {
  color: #ffdf9a;
  line-height: 1.25;
}
.cd-version-card.ok { border-color: rgba(58, 217, 164, 0.4); }
.cd-version-card.warn { border-color: rgba(255, 191, 87, 0.45); }
.cd-version-card.danger { border-color: rgba(255, 107, 107, 0.55); }
.cd-version-card.pending {
  border-color: rgba(64, 169, 255, 0.65);
  background: rgba(64, 169, 255, 0.08);
}
.cd-deployment-tile {
  position: relative;
  min-width: 0;
  display: grid;
  gap: 6px;
}
.cd-deployment-tile .cd-version-card {
  padding-right: 38px;
}
.cd-matrix-logs-link {
  width: max-content;
  max-width: 100%;
  min-height: 0;
  padding: 3px 7px;
  font-size: 0.78rem;
  line-height: 1.25;
}
.cd-branch-deploy-button,
.cd-branch-terminate {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  background: rgba(10,18,28,0.84);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
  font-size: 1rem;
}
.cd-deployment-tile > .cd-branch-deploy-button {
  position: absolute;
  top: 8px;
  right: 8px;
}
.cd-branch-deploy-button:hover,
.cd-branch-terminate:hover {
  border-color: rgba(92, 200, 255, 0.65);
  background: rgba(64,169,255,0.14);
}
.cd-branch-row td {
  background: rgba(64,169,255,0.025);
  border-top-color: rgba(64,169,255,0.14);
}
.cd-branch-project-label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: start;
  gap: 8px;
}
.cd-branch-tree {
  color: var(--muted);
  font-size: 1.1rem;
}
.cd-branch-cell {
  min-height: 74px;
  display: grid;
}
.cd-branch-deploy-button.ghost-cell {
  width: 100%;
  height: 74px;
  border-style: dashed;
  background: rgba(255,255,255,0.015);
  color: var(--muted);
  font-size: 1.2rem;
}
.cd-branch-version-card {
  cursor: default;
}
.cd-branch-candidate {
  width: 100%;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.cd-branch-candidate:hover {
  border-color: rgba(92, 200, 255, 0.65);
}
.cd-spin {
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(64, 169, 255, 0.28);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  display: inline-block;
  animation: cd-spin 0.85s linear infinite;
  vertical-align: -0.1rem;
}
.cd-inline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cd-project-findings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.cd-project-findings .badge {
  justify-content: flex-start;
  max-width: 100%;
  white-space: normal;
}
.cd-project-findings .badge small {
  margin-left: 6px;
  font-weight: 600;
  color: inherit;
  opacity: 0.82;
}
@keyframes cd-spin {
  to { transform: rotate(360deg); }
}
.cd-history-list {
  display: grid;
  gap: 10px;
}
.cd-history-card {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.035);
}
.cd-history-card span,
.cd-history-card small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.cd-setting-value code {
  display: inline-block;
  max-width: min(58rem, 100%);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.cd-promotion-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.logs-modal-card {
  width: min(1100px, calc(100vw - 2rem));
}
.logs-output {
  min-height: 420px;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(8, 15, 28, 0.92);
  border: 1px solid rgba(133, 156, 189, 0.25);
  border-radius: 8px;
  padding: 1rem;
  color: #dce8f7;
}
@media (max-width: 800px) {
  .cd-promotion-columns { grid-template-columns: 1fr; }
}

.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.auth-card {
  width: min(440px, calc(100vw - 32px));
  background: rgba(24, 34, 48, 0.95);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 0; }
.sso-buttons {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.sso-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  font-weight: 700;
  color: #041018;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  border-radius: 10px;
  padding: 10px 14px;
}
.auth-divider {
  text-align: center;
  margin: 10px 0;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.metric {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}
.metric strong {
  color: var(--accent);
  font-size: 1.2rem;
}
.metric.loading { color: var(--muted); }
.metric.warn { border-color: rgba(255, 202, 95, 0.45); color: var(--warn); }
.infra-env-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.region-board {
  display: grid;
  gap: 18px;
  margin: 14px 0 18px;
}
.region-board-section {
  display: grid;
  gap: 10px;
}
.region-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.region-board-head h3 {
  margin: 0;
}
.region-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}
.infra-server-card {
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(7, 14, 29, 0.72);
  padding: 12px;
  display: grid;
  gap: 10px;
  min-height: 238px;
}
.infra-server-card.ok { border-color: rgba(58, 217, 164, 0.3); }
.infra-server-card.warn { border-color: rgba(255, 202, 95, 0.32); }
.infra-server-card.danger { border-color: rgba(255, 107, 107, 0.35); }
.infra-card-top,
.infra-card-meta,
.infra-pills,
.spark-row,
.infra-stat-list {
  display: grid;
  gap: 8px;
}
.infra-card-top {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}
.infra-card-top h4 {
  margin: 0;
  display: flex;
  gap: 8px;
  align-items: center;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  background: var(--muted);
}
.status-dot.ok { background: var(--accent); }
.status-dot.warn { background: var(--warn); }
.status-dot.danger { background: var(--danger); }
.infra-card-meta {
  grid-template-columns: minmax(0, 1fr) auto;
  color: var(--muted);
  font-size: 0.82rem;
}
.infra-pills,
.spark-row,
.infra-stat-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.spark-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.infra-pills span {
  border: 1px solid rgba(91, 139, 255, 0.4);
  border-radius: 999px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
}
.infra-pills strong { color: var(--text); }
.spark-row > div {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}
.sparkline {
  width: 100%;
  height: 28px;
}
.sparkline path {
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 1.6;
}
.sparkline.tx path { stroke: var(--warn); }
.infra-stat-list {
  margin: 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 10px;
}
.infra-stat-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.infra-stat-list dt {
  color: var(--muted);
}
.infra-stat-list dd {
  margin: 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}
.badge.ok {
  background: rgba(58, 217, 164, 0.2);
  color: var(--accent);
  border: 1px solid rgba(58, 217, 164, 0.4);
}
.badge.warn {
  background: rgba(255, 202, 95, 0.2);
  color: var(--warn);
  border: 1px solid rgba(255, 202, 95, 0.4);
}
.badge.danger {
  background: rgba(255, 107, 107, 0.22);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.45);
}
.badge.info {
  background: rgba(64, 169, 255, 0.22);
  color: var(--accent-2);
  border: 1px solid rgba(64, 169, 255, 0.45);
}
.badge.idle {
  background: rgba(140, 161, 184, 0.2);
  color: var(--muted);
  border: 1px solid rgba(140, 161, 184, 0.4);
}
.error {
  background: rgba(255,107,107,0.15);
  border: 1px solid rgba(255,107,107,0.35);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 10px 0;
}

@media (max-width: 1280px) {
  .app-shell.has-sidebar {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .sidebar {
    position: static;
    margin: 14px 24px 0;
  }
  .app-shell.has-sidebar .main {
    padding: 14px 24px 24px;
  }
}

@media (max-width: 980px) {
  .split { grid-template-columns: 1fr; }
  .section-shell .panel:first-child { position: static; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-controls input { min-width: 0; }
  .service-workspace .service-hero { flex-direction: column; }
  .sidebar { margin: 12px 16px 0; }
  .app-shell.has-sidebar .main { padding: 12px 16px 20px; }
}
