:root {
  color-scheme: light;
  --ink: #15202b;
  --muted: #607083;
  --line: #d7dee7;
  --surface: #ffffff;
  --page: #eef3f7;
  --green: #0f766e;
  --green-dark: #115e59;
  --red: #b42318;
  --amber: #c77800;
  --blue: #1d4ed8;
  --violet: #6d28d9;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 16px;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.portal-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  margin-bottom: 24px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.portal-tab {
  padding: 8px 13px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.portal-tab:hover {
  color: var(--green-dark);
  background: #edf7f5;
}

.portal-tab.is-active {
  color: #fff;
  background: var(--green);
}

.portal-tab:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.endpoint-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 8px;
  width: min(620px, 100%);
}

.endpoint-panel div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.endpoint-panel span,
.facts dt,
.token-box span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.endpoint-panel strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1px solid;
  background: var(--surface);
  font-weight: 700;
}

.notice.success {
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--green-dark);
}

.notice.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--red);
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.user-card {
  display: flex;
  min-width: 0;
  min-height: 360px;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(21, 32, 43, 0.06);
}

.card-top {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.avatar {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
}

.theme-a {
  background: var(--green);
}

.theme-b {
  background: var(--blue);
}

.theme-c {
  background: var(--amber);
}

.theme-d {
  background: #9f1239;
}

.theme-e {
  background: #334155;
}

.theme-f {
  background: var(--violet);
}

.identity {
  min-width: 0;
}

.profile-number {
  display: block;
  margin-bottom: 3px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.identity h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.15;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tier {
  min-width: 38px;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e7f7f4;
  color: var(--green-dark);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0;
}

.facts div {
  min-width: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf1f5;
}

.facts dd {
  margin: 3px 0 0;
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-fact {
  overflow: visible !important;
}

.balance-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin: 0;
}

.balance-editor input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 4px 7px;
  border: 1px solid #bfd0df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.balance-editor input:focus-visible {
  border-color: var(--green);
  outline: 3px solid rgba(15, 118, 110, 0.2);
  outline-offset: 1px;
}

.balance-editor input:invalid {
  border-color: var(--red);
}

.balance-unit {
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 900;
}

.save-balance-button {
  grid-column: 1 / -1;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: var(--amber);
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
}

.save-balance-button:hover {
  filter: brightness(0.92);
}

.save-balance-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.save-balance-button:focus-visible {
  outline: 3px solid rgba(199, 120, 0, 0.28);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-row span {
  padding: 5px 8px;
  border: 1px solid #dbe5ee;
  border-radius: 999px;
  color: #344256;
  font-size: 0.78rem;
  font-weight: 700;
}

.token-box {
  min-width: 0;
  margin-top: auto;
  padding: 10px;
  border-radius: 8px;
  background: #f6f8fb;
}

.token-box code {
  display: block;
  min-width: 0;
  margin-top: 4px;
  overflow: hidden;
  color: #223047;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.launch-target-section {
  display: grid;
  gap: 9px;
}

.launch-target-section form {
  margin: 0;
}

.launch-target-section.azure-launch-target {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.launch-target-heading {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.azure-launch-target .launch-target-heading {
  color: var(--blue);
}

.copy-token-button,
.launch-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
}

.copy-token-button {
  border: 1px solid #bfd0df;
  background: #fff;
  color: #233349;
}

.copy-token-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.copy-token-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.copy-token-button.is-copied {
  border-color: rgba(15, 118, 110, 0.35);
  background: #e7f7f4;
  color: var(--green-dark);
}

.copy-token-button.is-error {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff4f2;
  color: var(--red);
}

.launch-button {
  background: var(--green);
  color: #fff;
}

.launch-button:hover {
  background: var(--green-dark);
}

.live-log-viewer {
  min-width: 0;
}

.live-log-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.live-log-description {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 126px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(199, 120, 0, 0.12);
}

.live-status.is-connected {
  border-color: rgba(15, 118, 110, 0.3);
  color: var(--green-dark);
}

.live-status.is-connected .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.live-status.is-disconnected {
  border-color: rgba(180, 35, 24, 0.28);
  color: var(--red);
}

.live-status.is-disconnected .status-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.1);
}

.live-log-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.82rem;
}

.live-log-toolbar strong {
  color: var(--ink);
}

.live-only-label {
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7f7f4;
  color: var(--green-dark);
  font-weight: 800;
}

.clear-log-button {
  margin-left: auto;
  padding: 7px 11px;
  border: 1px solid #bfd0df;
  border-radius: 7px;
  background: #fff;
  color: #233349;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.clear-log-button:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.clear-log-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

.live-log-feed {
  display: grid;
  gap: 10px;
}

.live-log-empty {
  display: grid;
  min-height: 280px;
  place-content: center;
  gap: 7px;
  padding: 28px;
  border: 1px dashed #bdcad7;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  text-align: center;
}

.live-log-empty strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.live-log-entry {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 7px 18px rgba(21, 32, 43, 0.045);
}

.live-log-entry.kafka-log-entry {
  border-left-color: var(--blue);
}

.live-log-entry header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.live-log-entry h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.3;
}

.live-log-entry time {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.log-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.log-badge {
  max-width: 320px;
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid #dbe5ee;
  border-radius: 999px;
  color: #344256;
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-badge.is-mega {
  border-color: rgba(15, 118, 110, 0.24);
  background: #e7f7f4;
  color: var(--green-dark);
}

.log-badge.is-kafka {
  border-color: rgba(29, 78, 216, 0.22);
  background: #edf3ff;
  color: var(--blue);
}

.log-badge.is-token {
  max-width: 190px;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.live-log-entry pre {
  max-height: 420px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: 7px;
  background: #111827;
  color: #dbeafe;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.copy-token-button:focus-visible,
.launch-button:focus-visible,
.save-balance-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.28);
  outline-offset: 2px;
}

@media (max-width: 1180px) {
  .user-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 560px);
    padding-top: 16px;
  }

  .workspace-head,
  .endpoint-panel,
  .live-log-head {
    display: block;
  }

  .endpoint-panel {
    margin-top: 14px;
  }

  .endpoint-panel div + div {
    margin-top: 8px;
  }

  .user-grid {
    grid-template-columns: 1fr;
  }

  .live-status {
    margin-top: 14px;
  }

  .live-log-toolbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .clear-log-button {
    margin-left: 0;
  }

  .live-log-entry header {
    display: block;
  }

  .log-badges {
    justify-content: flex-start;
    margin-top: 10px;
  }
}
