:root {
  color-scheme: dark;
  --black: #010402;
  --surface: rgba(3, 12, 6, 0.94);
  --surface-solid: #061009;
  --green: #68ff8d;
  --green-strong: #24df5d;
  --green-dim: #16853a;
  --text: #dbffe3;
  --muted: #75a982;
  --line: #174c27;
  --danger: #ff6060;
}

* {
  box-sizing: border-box;
  scrollbar-width: auto;
  scrollbar-color: var(--green-strong) #031008;
}

*::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

*::-webkit-scrollbar-track {
  background: #031008;
  border-left: 1px solid var(--line);
}

*::-webkit-scrollbar-thumb {
  border: 3px solid #031008;
  border-radius: 3px;
  background: var(--green-strong);
  box-shadow: inset 0 0 0 1px var(--green);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--green-strong);
}

*::-webkit-scrollbar-corner {
  background: #020704;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--black);
  color: var(--text);
  font-family: "Cascadia Code", "Courier New", monospace;
}

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

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

button,
select,
input,
textarea {
  border-radius: 3px;
}

#matrix-rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.42;
  pointer-events: none;
}

body::after {
  position: fixed;
  z-index: 0;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(rgba(68, 255, 117, 0.025) 1px, transparent 1px);
  background-size: 100% 4px;
}

.console-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 330px;
  background: rgba(1, 5, 2, 0.76);
}

.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--line);
  background: rgba(3, 10, 5, 0.96);
}

.brand-mark {
  width: 100%;
  height: 74px;
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 800;
  text-shadow: 0 0 14px var(--green-strong);
}

.nav-rail nav {
  width: 100%;
  display: grid;
}

.nav-button {
  width: 100%;
  height: 66px;
  border: 0;
  border-bottom: 1px solid rgba(23, 76, 39, 0.62);
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(36, 223, 93, 0.1);
  color: var(--green);
  box-shadow: inset 3px 0 var(--green-strong);
}

.rail-state {
  margin-top: auto;
  padding: 20px 0;
  display: grid;
  justify-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.65rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.status-dot.offline {
  background: var(--danger);
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(46, 184, 92, 0.035) 1px, transparent 1px),
    rgba(1, 6, 3, 0.9);
  background-size: 100% 4px;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 12, 6, 0.9);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.68rem;
}

h1 {
  margin: 0;
  color: var(--green);
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(105, 255, 143, 0.42);
}

.workspace-tagline {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.67rem;
}

.runtime-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.account-strip,
.account-button,
.profile-avatar-row,
.admin-actions,
.inline-control {
  display: flex;
  align-items: center;
}

.account-strip {
  gap: 18px;
}

.credit-chip {
  display: grid;
  gap: 3px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
  text-align: right;
}

.credit-chip span,
.account-button small {
  color: var(--muted);
  font-size: 0.62rem;
}

.credit-chip strong {
  color: var(--green);
  font-size: 1rem;
}

.account-button {
  gap: 10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.account-button > span:last-child {
  display: grid;
  gap: 3px;
}

.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--green-dim);
  border-radius: 50%;
  background: #07160b;
  color: var(--green);
  font-weight: 800;
}

.avatar.large {
  width: 72px;
  height: 72px;
  font-size: 1.5rem;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slash {
  color: var(--line);
}

select,
input,
textarea {
  border: 1px solid var(--line);
  outline: none;
  background: #020704;
  color: var(--text);
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--green-dim);
  box-shadow: 0 0 0 2px rgba(104, 255, 141, 0.08);
}

.runtime-strip select {
  max-width: 230px;
  padding: 8px 10px;
}

.messages {
  min-height: 0;
  height: 100%;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 34px clamp(22px, 4vw, 58px);
}

.message {
  width: min(100%, 1040px);
  margin-bottom: 34px;
}

.message-meta {
  margin-bottom: 7px;
  color: var(--green-dim);
  font-size: 0.66rem;
  font-weight: 700;
}

.message.user .message-meta {
  color: #78a9ff;
}

.message-body {
  padding: 2px 0 2px 18px;
  border-left: 2px solid var(--line);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .message-body {
  color: #fff;
  border-left-color: #315f9e;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  background: var(--surface-solid);
}

.prompt {
  color: var(--green);
  font-weight: 800;
}

.composer textarea {
  min-height: 46px;
  max-height: 160px;
  resize: vertical;
  padding: 12px;
}

button {
  border: 1px solid var(--green-dim);
  padding: 11px 15px;
  background: var(--green-strong);
  color: #001b07;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.14);
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

.inspector {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  color: var(--green);
  font-size: 0.72rem;
}

.mobile-close {
  display: none;
  padding: 5px 8px;
  background: transparent;
  color: var(--green);
}

.view-panel {
  display: none;
  min-height: 0;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 20px;
}

.view-panel.active {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 16px;
}

h2 {
  margin: 0;
  color: var(--green);
  font-size: 1rem;
}

.metric {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.metric span,
.field label,
.signal span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.64rem;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: grid;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px;
}

.field.grow {
  flex: 1;
}

.field.grow textarea {
  min-height: 170px;
  resize: vertical;
}

.secondary-action {
  background: transparent;
  color: var(--green);
}

.button-link,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--green-dim);
  border-radius: 3px;
  padding: 11px 15px;
  background: transparent;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.upload-button input {
  display: none;
}

.profile-avatar-row {
  gap: 16px;
  padding: 4px 0 10px;
}

.danger-action {
  border-color: #702c2c;
  background: transparent;
  color: var(--danger);
}

.password-panel {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.password-panel summary {
  color: var(--green);
  font-size: 0.7rem;
  cursor: pointer;
}

.password-panel[open] {
  display: grid;
  gap: 12px;
}

.text-action {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--green);
  font-size: 0.65rem;
}

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

.signal code {
  color: var(--green);
  font-size: 0.75rem;
}

.service-note {
  margin-top: auto;
  padding: 18px 0 4px;
  border-top: 1px solid var(--line);
}

.service-note strong {
  color: var(--green);
  font-size: 0.68rem;
}

.service-note p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.6;
}

.operation-result {
  min-height: 18px;
  margin: 0;
  color: var(--green);
  font-size: 0.68rem;
}

.panel-copy,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.6;
}

.plan-list,
.payment-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.plan-row,
.payment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.plan-row div {
  display: grid;
  gap: 4px;
}

.plan-row span,
.payment-row span,
.invoice-panel > span {
  color: var(--muted);
  font-size: 0.64rem;
}

.plan-row button {
  padding: 8px 10px;
  font-size: 0.65rem;
}

.invoice-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--green-dim);
  background: rgba(36, 223, 93, 0.05);
}

.invoice-panel strong {
  color: var(--green);
  font-size: 1.25rem;
}

.invoice-panel code {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.68rem;
}

.hidden {
  display: none;
}

.status-confirmed {
  color: var(--green);
}

.status-pending,
.status-submitted {
  color: #ffd866;
}

.auth-body {
  min-height: 100vh;
  height: auto;
  overflow-y: auto;
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 520px);
  align-items: stretch;
  background: rgba(1, 5, 2, 0.76);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 8vw, 120px);
  border-right: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(2, 10, 5, 0.72), rgba(2, 10, 5, 0.28));
}

.official-lockup {
  display: flex;
  align-items: center;
  gap: 22px;
}

.official-mark {
  width: 72px;
  height: 72px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--green);
  background: rgba(36, 223, 93, 0.08);
  color: var(--green);
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(36, 223, 93, 0.18), inset 0 0 20px rgba(36, 223, 93, 0.08);
}

.auth-brand h1 {
  font-size: clamp(3rem, 6vw, 6.2rem);
}

.auth-lead {
  max-width: 560px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
}

.product-points {
  width: min(680px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 34px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.product-points div {
  min-height: 105px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(2, 10, 5, 0.54);
}

.product-points strong {
  color: var(--green);
  font-size: 0.7rem;
}

.product-points span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.auth-signal {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  color: var(--green);
  font-size: 0.7rem;
}

.auth-terminal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 70px);
  background: rgba(3, 12, 6, 0.96);
  overflow-y: auto;
}

.terminal-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 28px;
}

.terminal-heading span {
  color: var(--green-dim);
  font-size: 0.64rem;
}

.terminal-heading strong {
  color: var(--text);
  font-size: 0.9rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--line);
}

.auth-body[data-admin="true"] .auth-tabs {
  grid-template-columns: 1fr;
}

.auth-tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
}

.auth-tab.active {
  border-bottom-color: var(--green);
  color: var(--green);
}

.auth-form {
  display: none;
  gap: 18px;
}

.auth-form.active {
  display: grid;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.66rem;
}

.auth-form input {
  min-height: 48px;
  padding: 12px;
}

.auth-footer {
  margin: 30px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.6;
}

.mobile-scroll-cue {
  display: none;
}

.admin-body {
  height: auto;
  min-height: 100vh;
  overflow-y: auto;
  background: #020603;
}

.admin-topbar {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(3, 12, 6, 0.98);
}

.admin-topbar h1 {
  font-size: 1.8rem;
}

.admin-actions {
  gap: 16px;
  color: var(--muted);
  font-size: 0.72rem;
}

.admin-main {
  width: min(1400px, calc(100% - 40px));
  margin: 32px auto 80px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
}

.stat-block {
  display: grid;
  gap: 12px;
  padding: 24px;
  border-right: 1px solid var(--line);
}

.stat-block:last-child {
  border-right: 0;
}

.stat-block span {
  color: var(--muted);
  font-size: 0.65rem;
}

.stat-block strong {
  color: var(--green);
  font-size: 2rem;
}

.admin-band {
  padding: 38px 0;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-heading span {
  color: var(--green-dim);
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.inline-control {
  max-width: 600px;
  gap: 10px;
}

.inline-control select {
  flex: 1;
  padding: 11px;
}

.knowledge-admin {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
}

.knowledge-admin textarea {
  grid-column: 1 / -1;
  padding: 12px;
}

.knowledge-admin input {
  padding: 11px;
}

.table-wrap {
  overflow-x: auto;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
}

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

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

th {
  color: var(--muted);
  font-size: 0.62rem;
}

td small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.credit-adjust {
  display: flex;
  gap: 6px;
}

.credit-adjust input {
  width: 75px;
  padding: 8px;
}

.credit-adjust button,
td button {
  padding: 8px;
  font-size: 0.62rem;
}

.file-list,
.model-list,
.history-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.file-row,
.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.7rem;
}

.file-row span,
.model-row strong {
  overflow-wrap: anywhere;
}

.file-row code,
.model-row span {
  color: var(--muted);
}

.history-row {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.history-row span {
  color: var(--green-dim);
  font-size: 0.62rem;
}

.history-row strong {
  font-size: 0.72rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (max-width: 980px) {
  .console-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    z-index: 4;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, calc(100vw - 64px));
    transform: translateX(100%);
    transition: transform 160ms ease;
  }

  .inspector.open {
    transform: translateX(0);
  }

  .mobile-close {
    display: block;
  }
}

@media (max-width: 640px) {
  .console-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 58px;
  }

  .nav-rail {
    grid-row: 2;
    flex-direction: row;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand-mark,
  .rail-state {
    display: none;
  }

  .nav-rail nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-button {
    height: 58px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .nav-button:hover,
  .nav-button.active {
    box-shadow: inset 0 3px var(--green-strong);
  }

  .workspace {
    grid-row: 1;
  }

  .topbar {
    min-height: 82px;
    padding: 14px 16px;
  }

  .brand-copy .eyebrow,
  .credit-chip {
    display: none;
  }

  .account-button > span:last-child {
    display: none;
  }

  h1 {
    font-size: 1.65rem;
  }

  .runtime-strip {
    align-items: flex-end;
    flex-direction: column;
    gap: 5px;
  }

  .runtime-strip .slash {
    display: none;
  }

  .runtime-strip select {
    max-width: 150px;
  }

  .messages {
    padding: 24px 16px 34px;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 16px 14px;
  }

  .composer .prompt {
    grid-column: 1 / -1;
    font-size: 0.72rem;
  }

  .composer textarea {
    min-height: 54px;
  }

  .inspector {
    width: 100%;
    bottom: 58px;
    height: auto;
    overflow: hidden;
    background: #030c06;
  }

  .view-panel {
    padding-bottom: 40px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 220px;
    padding: 32px 24px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .auth-brand h1 {
    font-size: 2.5rem;
  }

  .official-mark {
    width: 54px;
    height: 54px;
  }

  .auth-lead {
    margin-top: 20px;
    font-size: 0.86rem;
  }

  .product-points {
    grid-template-columns: 1fr;
    margin-top: 22px;
  }

  .product-points div {
    min-height: 84px;
  }

  .auth-terminal {
    padding: 32px 24px;
  }

  .mobile-scroll-cue {
    position: fixed;
    z-index: 6;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 10px;
    border: 1px solid var(--green-dim);
    background: rgba(3, 16, 8, 0.94);
    color: var(--green);
    font-size: 0.58rem;
    pointer-events: none;
  }

  .mobile-scroll-cue span {
    font-size: 0.9rem;
  }

  .admin-topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .stat-block:nth-child(2) {
    border-right: 0;
  }

  .stat-block:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

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

  .knowledge-admin textarea {
    grid-column: auto;
  }
}
