:root {
  color-scheme: dark;
  --bg: #070a0e;
  --bg-soft: #0b1118;
  --panel: #0f1720;
  --panel-strong: #121d28;
  --panel-line: #1f2f3c;
  --line-soft: rgba(137, 164, 182, 0.18);
  --text: #e6edf2;
  --muted: #8ba0ad;
  --faint: #5d7180;
  --cyan: #4dd9d0;
  --green: #55d17f;
  --amber: #e1b85d;
  --red: #ee6c75;
  --shadow: rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    linear-gradient(90deg, rgba(77, 217, 208, 0.03) 1px, transparent 1px),
    linear-gradient(rgba(77, 217, 208, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(77, 217, 208, 0.12), transparent 32rem),
    radial-gradient(circle at 100% 20%, rgba(85, 209, 127, 0.08), transparent 28rem),
    var(--bg);
  background-size: 36px 36px, 36px 36px, auto, auto, auto;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.login-view,
.app-view {
  min-height: 100vh;
}

.shell[data-auth="logged-out"] .app-view,
.shell[data-auth="logged-in"] .login-view {
  display: none;
}

.login-view {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 460px);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(18, 29, 40, 0.96), rgba(10, 16, 23, 0.98)),
    var(--panel);
  box-shadow: 0 24px 80px var(--shadow);
  padding: 28px;
}

.brand-block {
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 24px;
  padding-bottom: 22px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: clamp(42px, 11vw, 64px);
  letter-spacing: 0;
}

h2,
h3,
h4 {
  margin-bottom: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 22px;
}

h4 {
  font-size: 14px;
}

.brand-block p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.domain-map {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 10px;
  background: rgba(8, 16, 25, 0.62);
}

.domain-map div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.domain-map strong,
.domain-map span {
  font-family: var(--mono);
  font-size: 11px;
}

.domain-map strong {
  overflow-wrap: anywhere;
  color: #c9d9e2;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  color: var(--text);
  background: #081019;
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

input:focus,
textarea:focus {
  border-color: rgba(77, 217, 208, 0.8);
  box-shadow: 0 0 0 3px rgba(77, 217, 208, 0.12);
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(180deg, #1b766f, #13534f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.primary-button:hover:not(:disabled) {
  border-color: rgba(77, 217, 208, 0.55);
}

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

.primary-button.compact {
  min-height: 34px;
}

.button-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px rgba(85, 209, 127, 0.8);
}

.ghost-button {
  background: #0a121a;
  border-color: var(--panel-line);
}

.ghost-button:hover {
  border-color: rgba(139, 160, 173, 0.7);
  background: #0f1a24;
}

.status-note {
  min-height: 18px;
  margin-top: 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.status-note.error {
  color: var(--red);
}

.app-view {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-line);
  background: rgba(7, 10, 14, 0.9);
}

.topbar-actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  color: var(--muted);
  background: #0b1219;
  font-size: 12px;
}

.api-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.api-pill[data-state="ok"] span {
  background: var(--green);
  box-shadow: 0 0 14px rgba(85, 209, 127, 0.75);
}

.api-pill[data-state="error"] span {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--panel-line);
  background: rgba(9, 14, 20, 0.72);
  padding: 14px;
}

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

.nav-item {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--muted);
  text-align: left;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: #0f1720;
  border-color: var(--panel-line);
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--cyan);
}

.sidebar-foot {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
  color: var(--faint);
  font-size: 12px;
}

code {
  color: #b6c8d4;
  font-family: var(--mono);
  word-break: break-all;
}

.content {
  overflow: auto;
  padding: 18px;
}

.route-view {
  display: none;
}

.route-view.active {
  display: grid;
  gap: 16px;
}

.section-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

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

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

.metric-card,
.panel,
.editor-shell,
.empty-shell,
.zone-card {
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: rgba(15, 23, 32, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

.metric-card {
  min-height: 104px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
}

.metric-card small {
  color: var(--faint);
}

.split-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

.panel {
  padding: 14px;
}

.compact-list,
.entity-list,
.detail-body {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compact-row,
.entity-button,
.detail-row,
.zone-card {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(8, 16, 25, 0.7);
}

.compact-row,
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
}

.compact-row strong,
.detail-row strong {
  font-size: 13px;
}

.compact-row span,
.detail-row span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.package-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 1fr);
  gap: 12px;
}

.list-panel,
.detail-panel {
  min-height: 560px;
}

.entity-button {
  width: 100%;
  padding: 11px;
  color: var(--text);
  text-align: left;
}

.entity-button:hover,
.entity-button.active {
  border-color: rgba(77, 217, 208, 0.55);
  background: rgba(19, 83, 79, 0.18);
}

.entity-button strong,
.entity-button span {
  display: block;
}

.entity-button strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.entity-button span {
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.readiness-pill {
  display: inline-flex;
  margin-top: 9px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 10px;
  font-style: normal;
  text-transform: uppercase;
}

.readiness-pill.ok,
.readiness-chip.ok {
  color: var(--green);
  border-color: rgba(85, 209, 127, 0.34);
  background: rgba(85, 209, 127, 0.07);
}

.readiness-pill.warn,
.readiness-chip.warn {
  color: var(--amber);
  border-color: rgba(225, 184, 93, 0.34);
  background: rgba(225, 184, 93, 0.07);
}

.entity-list.tight {
  max-height: 310px;
  overflow: auto;
}

.version-subhead {
  margin-top: 18px;
  border-top: 1px solid var(--line-soft);
  padding-top: 14px;
}

.editor-shell {
  min-height: 620px;
  overflow: hidden;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--panel-line);
  background: #0a1017;
  padding: 10px;
}

.editor-context,
.save-state {
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.editor-tab {
  min-height: 30px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--muted);
  background: #101923;
  font-family: var(--mono);
  font-size: 11px;
}

.editor-tab.active {
  color: var(--text);
  border-color: rgba(77, 217, 208, 0.6);
  background: rgba(77, 217, 208, 0.1);
}

.version-metadata {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--panel-line);
  padding: 10px;
  background: rgba(8, 16, 25, 0.72);
}

.version-readiness {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.readiness-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 0 7px;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metadata-row {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 9px;
  background: rgba(7, 13, 19, 0.74);
}

.metadata-row strong {
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.metadata-row span {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.code-frame {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 560px;
  background: #070d13;
}

#line-gutter {
  overflow: hidden;
  margin: 0;
  border-right: 1px solid var(--panel-line);
  padding: 14px 10px;
  color: #405464;
  background: #080f16;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
  user-select: none;
}

#version-editor {
  min-height: 560px;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 14px;
  color: #dce8ef;
  background:
    linear-gradient(rgba(77, 217, 208, 0.035) 1px, transparent 1px),
    #071019;
  background-size: 100% 24.8px;
  box-shadow: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

#version-editor:disabled {
  color: var(--faint);
}

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

.zone-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.zone-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.zone-card h4 {
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  background: #0a121a;
  font-family: var(--mono);
  font-size: 11px;
}

.badge.ok {
  color: var(--green);
  border-color: rgba(85, 209, 127, 0.34);
}

.badge.warn {
  color: var(--amber);
  border-color: rgba(225, 184, 93, 0.34);
}

.empty-shell {
  display: grid;
  place-items: start;
  gap: 10px;
  min-height: 360px;
  padding: 28px;
}

.empty-shell span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 12px;
}

.empty-shell h4 {
  font-size: 22px;
}

.empty-shell p {
  max-width: 560px;
  color: var(--muted);
  line-height: 1.6;
}

.error-box {
  border: 1px solid rgba(238, 108, 117, 0.45);
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px;
  color: #ffd8dc;
  background: rgba(101, 24, 32, 0.32);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
}

.loading,
.empty {
  border: 1px dashed var(--panel-line);
  border-radius: 6px;
  padding: 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.empty.inline {
  padding: 10px;
}

@media (max-width: 980px) {
  .workspace,
  .package-layout,
  .split-grid {
    grid-template-columns: 1fr;
  }

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

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-foot {
    display: none;
  }

  .metric-grid,
  .zone-grid,
  .metadata-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-head,
  .panel-head,
  .topbar-actions,
  .editor-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .topbar-actions,
  .editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .api-pill {
    grid-column: 1 / -1;
  }

  .workspace {
    min-height: auto;
  }

  .content,
  .sidebar,
  .login-view {
    padding: 12px;
  }

  .nav-list,
  .metric-grid,
  .zone-grid,
  .metadata-grid {
    grid-template-columns: 1fr;
  }

  .domain-map div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .domain-map span {
    text-align: left;
  }

  .metric-card {
    min-height: 86px;
  }

  .editor-toolbar {
    grid-template-columns: 1fr;
  }

  .editor-tabs {
    justify-content: flex-start;
  }

  .code-frame {
    grid-template-columns: 44px minmax(0, 1fr);
  }
}
