:root {
  --bg: #07131d;
  --bg-soft: #0c1c28;
  --panel: #102432;
  --panel-2: #132c3c;
  --line: rgba(255,255,255,.09);
  --text: #eef8fb;
  --muted: #8faab6;
  --teal: #3ed4cf;
  --teal-soft: rgba(62,212,207,.12);
  --danger: #ff7b7b;
  --warning: #ffd479;
  --radius: 18px;
  --shadow: 0 22px 70px rgba(0,0,0,.25);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 80% 0%, rgba(62,212,207,.08), transparent 32%),
    var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

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

.auth-card {
  width: min(100%, 480px);
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), transparent),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 38px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 190px;
  max-height: 92px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 18px;
}

.auth-card h1,
.topbar h2,
.panel h3,
.hero-card h3 {
  margin: 0;
}

.auth-card h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -.04em;
}

.auth-foot {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.eyebrow {
  color: var(--teal);
  letter-spacing: .16em;
  font-weight: 800;
  font-size: .68rem;
  margin: 0 0 10px;
}

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

.tiny {
  font-size: .8rem;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .83rem;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(0,0,0,.2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(62,212,207,.7);
  box-shadow: 0 0 0 3px rgba(62,212,207,.08);
}

textarea {
  resize: vertical;
}

.primary,
.secondary,
.danger-button {
  border-radius: 11px;
  padding: 11px 16px;
  border: 1px solid transparent;
  font-weight: 750;
}

.primary {
  background: var(--teal);
  color: #042126;
}

.secondary {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255,255,255,.04);
}

.danger-button {
  color: #ffdede;
  border-color: rgba(255,123,123,.25);
  background: rgba(255,123,123,.08);
}

.small {
  padding: 8px 12px;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(5,17,25,.95);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.brand img {
  width: 165px;
  height: 68px;
  object-fit: contain;
  object-position: left center;
}

#nav {
  display: grid;
  gap: 7px;
  margin-top: 30px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 11px;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--teal-soft);
}

.sidebar-foot {
  margin-top: auto;
  color: var(--muted);
  font-size: .76rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--teal);
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  margin-bottom: 26px;
}

.topbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.context-select {
  min-width: 155px;
}

.identity {
  display: grid;
  gap: 2px;
  padding: 0 10px;
}

.identity span {
  color: var(--muted);
  font-size: .75rem;
}

.view {
  display: grid;
  gap: 18px;
}

.hero-card,
.panel,
.metric {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,.025), transparent),
    var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 34px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
}

.hero-card h3 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  letter-spacing: -.045em;
  max-width: 700px;
}

.hero-card p:not(.eyebrow) {
  color: var(--muted);
  max-width: 700px;
  line-height: 1.65;
}

.sovereign-badge {
  width: 170px;
  min-width: 170px;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  border: 1px solid rgba(62,212,207,.3);
  background:
    radial-gradient(circle, rgba(62,212,207,.16), rgba(62,212,207,.03));
}

.sovereign-badge span,
.sovereign-badge small {
  color: var(--muted);
  font-size: .66rem;
}

.sovereign-badge strong {
  font-size: 1.35rem;
  margin: 4px 0;
}

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

.metric {
  padding: 20px;
  display: grid;
  gap: 10px;
}

.metric span {
  color: var(--muted);
  font-size: .77rem;
}

.metric strong {
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.panel {
  padding: 24px;
}

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

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

.kv {
  background: rgba(0,0,0,.16);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  min-width: 0;
}

.kv span {
  color: var(--muted);
  display: block;
  font-size: .72rem;
  margin-bottom: 5px;
}

.kv strong {
  overflow-wrap: anywhere;
}

.pill {
  color: var(--teal);
  background: var(--teal-soft);
  border: 1px solid rgba(62,212,207,.24);
  padding: 7px 10px;
  border-radius: 99px;
  font-size: .75rem;
}

.chat-log {
  min-height: 390px;
  max-height: 60vh;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 13px;
  padding: 6px 2px 20px;
}

.message {
  max-width: min(80%, 760px);
  border-radius: 14px;
  padding: 14px 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.assistant {
  background: rgba(62,212,207,.07);
  border: 1px solid rgba(62,212,207,.12);
}

.message.user {
  margin-left: auto;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}

.message.error {
  background: rgba(255,123,123,.07);
  border: 1px solid rgba(255,123,123,.17);
}

.composer {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.composer-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.composer-row label {
  width: 150px;
}

.inline-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 20px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.warning,
.notice {
  border-radius: 12px;
  padding: 12px 14px;
}

.warning {
  color: #ffe8b4;
  background: rgba(255,212,121,.08);
  border: 1px solid rgba(255,212,121,.18);
}

.notice {
  color: #c9fffc;
  background: var(--teal-soft);
  border: 1px solid rgba(62,212,207,.18);
}

.danger-outline {
  border-color: rgba(255,123,123,.25);
}

.secret-view,
.json-view {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 44px));
  background: #102b38;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 86px minmax(0,1fr);
  }

  .sidebar {
    padding-inline: 12px;
  }

  .brand img {
    width: 62px;
  }

  .nav-item {
    font-size: 0;
    min-height: 42px;
  }

  .nav-item::first-letter {
    font-size: .9rem;
  }

  .sidebar-foot {
    display: none;
  }

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

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

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

  .brand {
    display: none;
  }

  #nav {
    margin: 0;
    grid-template-columns: repeat(3,1fr);
  }

  .nav-item {
    font-size: .75rem;
    text-align: center;
  }

  .main-panel {
    padding: 18px;
  }

  .topbar,
  .hero-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .context-select {
    width: 100%;
  }

  .metrics-grid,
  .key-value,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .sovereign-badge {
    display: none;
  }

  .message {
    max-width: 94%;
  }
}
