:root {
  --bg: #071019;
  --bg-soft: #0b1724;
  --panel: #0f1d2b;
  --panel-2: #132436;
  --line: #23384d;
  --line-strong: #31506c;
  --text: #edf4fa;
  --muted: #91a7ba;
  --muted-2: #6f879a;
  --accent: #5fd1c5;
  --accent-strong: #81e2d9;
  --danger: #ff8f8f;
  --danger-bg: #2b161b;
  --warning: #efc873;
  --radius: 18px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% 10%, rgba(31, 92, 106, 0.18), transparent 32rem),
    linear-gradient(160deg, #06101a 0%, #091521 55%, #071019 100%);
  color: var(--text);
}

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

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px 22px;
  border-right: 1px solid rgba(66, 94, 119, 0.35);
  background: rgba(7, 16, 25, 0.88);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(95, 209, 197, 0.42);
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: var(--accent-strong);
  background: rgba(95, 209, 197, 0.08);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  font-weight: 750;
}

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

.brand strong {
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 0.68rem;
}

.nav-list {
  margin-top: 42px;
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 13px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.nav-item:hover:not(:disabled),
.nav-item.active {
  background: rgba(95, 209, 197, 0.09);
  color: var(--text);
}

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

.nav-item:disabled {
  cursor: default;
  opacity: 0.62;
}

.nav-icon {
  width: 18px;
  color: var(--accent);
  text-align: center;
}

.pill {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.62rem;
  color: var(--muted-2);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 14px;
}

.status-dot-row {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted-2);
  font-size: 0.72rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(95, 209, 197, 0.55);
}

.main {
  width: min(1440px, 100%);
  padding: 34px 42px 70px;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 750;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 3vw, 2.55rem);
  letter-spacing: -0.035em;
}

h2 {
  font-size: 1.12rem;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 0.9rem;
  color: #d9e6f0;
}

.identity-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 29, 43, 0.78);
  padding: 8px 9px 8px 14px;
  border-radius: 14px;
}

.identity-copy {
  text-align: right;
}

.identity-copy strong,
.identity-copy span {
  display: block;
}

.identity-copy strong {
  font-size: 0.82rem;
}

.identity-copy span {
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 0.68rem;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(95, 209, 197, 0.12);
  color: var(--accent-strong);
  border: 1px solid rgba(95, 209, 197, 0.25);
  font-weight: 750;
}

.panel,
.response-card,
.state-card {
  border: 1px solid rgba(49, 80, 108, 0.55);
  background: linear-gradient(180deg, rgba(16, 31, 46, 0.96), rgba(11, 24, 37, 0.96));
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.7fr);
  gap: 20px;
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 1.28rem;
}

.secure-badge,
.audit-badge {
  white-space: nowrap;
  border: 1px solid rgba(95, 209, 197, 0.3);
  background: rgba(95, 209, 197, 0.07);
  color: var(--accent-strong);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.68rem;
}

.field {
  display: grid;
  gap: 8px;
  color: #c8d8e5;
  font-size: 0.78rem;
  font-weight: 650;
}

.field em {
  color: var(--muted-2);
  font-style: normal;
  font-weight: 500;
}

.field small {
  color: var(--muted-2);
  font-size: 0.69rem;
  line-height: 1.45;
  font-weight: 450;
}

.field-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

textarea,
input,
select {
  width: 100%;
  color: var(--text);
  background: #091522;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 138px;
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(95, 209, 197, 0.65);
  box-shadow: 0 0 0 3px rgba(95, 209, 197, 0.08);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.query-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.hint {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.7rem;
}

.primary-button,
.ghost-button {
  border-radius: 11px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, border-color 120ms ease;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #06201e;
  font-weight: 800;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.ghost-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.context-panel h2 {
  margin-bottom: 22px;
}

.context-list,
.scope-list {
  margin: 0;
  display: grid;
}

.context-list > div,
.scope-list > div {
  border-top: 1px solid rgba(49, 80, 108, 0.45);
  padding: 12px 0;
}

.context-list dt,
.scope-list dt {
  color: var(--muted-2);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.context-list dd,
.scope-list dd {
  margin: 5px 0 0;
  color: #dce9f2;
  font-size: 0.79rem;
}

.result-section {
  margin-top: 26px;
}

.result-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.result-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

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

.response-card {
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 14px;
}

.answer-card {
  border-color: rgba(95, 209, 197, 0.28);
  background: linear-gradient(180deg, rgba(17, 42, 50, 0.95), rgba(11, 26, 37, 0.96));
}

.answer-card p,
.response-card li {
  color: #d6e3ec;
  line-height: 1.65;
  font-size: 0.84rem;
}

.response-card.danger,
.state-card.danger {
  border-color: rgba(255, 143, 143, 0.35);
  background: linear-gradient(180deg, rgba(43, 22, 27, 0.96), rgba(24, 18, 25, 0.96));
}

.response-card.danger p {
  color: #ffc2c2;
}

.evidence-list {
  margin: 0;
  padding-left: 18px;
}

.evidence-list li + li {
  margin-top: 9px;
}

.raw-details {
  margin-top: 8px;
  border: 1px solid rgba(49, 80, 108, 0.45);
  border-radius: 13px;
  background: rgba(5, 14, 22, 0.55);
  overflow: hidden;
}

.raw-details summary {
  padding: 13px 15px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.74rem;
}

.raw-details pre {
  margin: 0;
  border-top: 1px solid rgba(49, 80, 108, 0.35);
  padding: 16px;
  max-height: 360px;
  overflow: auto;
  color: #b9c9d5;
  background: #07111b;
  font-size: 0.7rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.state-card {
  width: min(620px, 100%);
  margin: 70px auto;
  padding: 42px;
  border-radius: 20px;
  text-align: center;
}

.state-card p {
  margin: 0 auto;
  max-width: 470px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.86rem;
}

.state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(95, 209, 197, 0.08);
  border: 1px solid rgba(95, 209, 197, 0.28);
  color: var(--accent-strong);
  font-weight: 800;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid rgba(145, 167, 186, 0.2);
  border-top-color: var(--accent);
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(66, 94, 119, 0.35);
    padding: 18px 22px;
  }

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

  .sidebar-footer {
    margin-top: 16px;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .main {
    padding: 28px 24px 60px;
  }
}

@media (max-width: 760px) {
  .topbar,
  .panel-heading,
  .query-actions,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .identity-card {
    align-self: flex-start;
  }

  .identity-copy {
    text-align: left;
  }

  .workspace-grid,
  .response-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .sidebar-footer {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 24px 16px 50px;
  }

  .panel,
  .response-card,
  .state-card {
    border-radius: 14px;
  }
}


.section-copy {
  max-width: 760px;
  margin: -4px 0 22px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.inline-notice {
  margin: 0 0 14px;
  padding: 11px 13px;
  border: 1px solid rgba(95, 209, 197, 0.28);
  border-radius: 11px;
  background: rgba(95, 209, 197, 0.07);
  color: #cce9e5;
  font-size: 0.74rem;
  line-height: 1.5;
}

.inline-notice.danger {
  border-color: rgba(255, 143, 143, 0.35);
  background: rgba(255, 143, 143, 0.07);
  color: #ffc2c2;
}

.compact-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 18px;
  border: 1px solid rgba(49, 80, 108, 0.52);
  border-radius: 14px;
  background: rgba(8, 22, 34, 0.68);
}

.history-copy {
  min-width: 0;
}

.history-copy h3 {
  margin-bottom: 7px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.history-meta {
  margin: 0;
  color: var(--muted-2);
  font-size: 0.69rem;
}

.history-status {
  display: inline-block;
  margin-top: 9px;
  padding: 3px 7px;
  border: 1px solid rgba(95, 209, 197, 0.24);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 0.61rem;
  letter-spacing: 0.04em;
}

.compact-button {
  flex: 0 0 auto;
  padding: 8px 12px;
  font-size: 0.72rem;
}

.danger-button {
  border-color: rgba(255, 143, 143, 0.28);
}

.danger-button:hover {
  border-color: rgba(255, 143, 143, 0.5);
  color: #ffc2c2;
}

.preferences-panel {
  max-width: 980px;
}

.toggle-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(49, 80, 108, 0.45);
  border-radius: 13px;
  background: rgba(8, 22, 34, 0.5);
  cursor: pointer;
}

.toggle-row input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
}

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

.toggle-row strong {
  color: #dce9f2;
  font-size: 0.78rem;
}

.toggle-row small {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 0.68rem;
  line-height: 1.5;
}

@media (max-width: 760px) {
  .history-item {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-button {
    align-self: flex-start;
  }
}


.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.7fr);
  gap: 20px;
}

.admin-invite-panel {
  align-self: start;
}

.admin-field-gap {
  margin-top: 14px;
}

.admin-create-button {
  width: 100%;
  margin-top: 18px;
}

.admin-users-list {
  display: grid;
  gap: 12px;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, auto);
  gap: 18px;
  align-items: center;
  padding: 17px 18px;
  border: 1px solid rgba(49, 80, 108, 0.52);
  border-radius: 14px;
  background: rgba(8, 22, 34, 0.68);
}

.admin-user-identity {
  min-width: 0;
}

.admin-user-identity h3 {
  margin-bottom: 5px;
  font-size: 0.88rem;
}

.admin-user-identity p {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  overflow-wrap: anywhere;
}

.admin-user-controls {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) minmax(125px, 1fr) auto;
  gap: 9px;
  align-items: center;
}

.admin-user-controls select {
  min-width: 0;
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 0.72rem;
}

.admin-user-controls button:last-child:nth-child(4) {
  grid-column: 1 / -1;
  justify-self: end;
}

.invite-result {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(239, 200, 115, 0.3);
  border-radius: 13px;
  background: rgba(239, 200, 115, 0.06);
}

.invite-result strong {
  display: block;
  color: var(--warning);
  font-size: 0.78rem;
}

.invite-result p {
  margin: 7px 0 12px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.5;
}

.invite-result input {
  font-size: 0.68rem;
}

.invite-result button {
  margin-top: 10px;
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

@media (max-width: 1050px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-invite-panel {
    max-width: none;
  }
}

@media (max-width: 760px) {
  .admin-user-card {
    grid-template-columns: 1fr;
  }

  .admin-user-controls {
    grid-template-columns: 1fr;
  }

  .admin-user-controls button:last-child:nth-child(4) {
    grid-column: auto;
    justify-self: stretch;
  }
}
