:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-strong: #ecf1f5;
  --ink: #18212b;
  --muted: #647181;
  --line: #d7e0e7;
  --line-strong: #bdcad5;
  --green: #16885f;
  --green-soft: #e3f5ed;
  --blue: #265fbd;
  --blue-soft: #e6eefb;
  --amber: #98690d;
  --amber-soft: #fbf2d9;
  --red: #b42b32;
  --shadow: 0 18px 45px rgba(29, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(38, 95, 189, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(22, 136, 95, 0.09), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Source Han Sans SC", sans-serif;
}

html,
body {
  overflow-x: hidden;
}

a {
  color: inherit;
}

.shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 56px;
}

.portal-shell {
  max-width: 1280px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.portal-topbar {
  min-height: 150px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 680px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  font-weight: 760;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 680;
  text-align: center;
  box-shadow: 0 6px 18px rgba(25, 36, 49, 0.05);
}

.button:hover,
.action-card:hover {
  border-color: var(--blue);
}

.button.primary {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.button.danger {
  background: #fff7f7;
  border-color: var(--red);
  color: var(--red);
}

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

.hero-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(420px, 1.22fr);
  gap: 24px;
  align-items: center;
  margin-top: 26px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel > *,
.split-layout > *,
.section-heading > * {
  min-width: 0;
}

.hero-panel h2,
.section-heading h2,
.split-layout h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.hero-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.75;
  overflow-wrap: anywhere;
}

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

.card,
.action-card,
.resource-card,
.metric,
.command-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card {
  padding: 18px;
  min-height: 150px;
}

.card h2,
.card h3,
.resource-card h3,
.command-panel h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.card p,
.resource-card p,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.section {
  margin-top: 34px;
}

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

.section-note {
  color: var(--muted);
  font-size: 13px;
}

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

.metric {
  min-height: 96px;
  padding: 16px;
  min-width: 0;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.15;
}

.metric.alert strong {
  color: var(--red);
}

.notice {
  display: none;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  line-height: 1.55;
}

.notice strong,
.notice span {
  display: block;
}

.notice span {
  margin-top: 4px;
  color: var(--muted);
}

.notice.info,
.notice.success,
.notice.error {
  display: block;
}

.notice.info {
  background: var(--blue-soft);
  border-color: rgba(38, 95, 189, 0.28);
}

.notice.success {
  background: var(--green-soft);
  border-color: rgba(22, 136, 95, 0.32);
}

.notice.error {
  background: #fff7f7;
  border-color: rgba(180, 43, 50, 0.32);
}

.notice.error strong {
  color: var(--red);
}

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

.action-card {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 172px;
  padding: 18px;
  text-decoration: none;
  box-shadow: 0 12px 30px rgba(29, 45, 61, 0.05);
  min-width: 0;
}

.action-card strong {
  font-size: 17px;
}

.action-card span,
.resource-card p {
  color: var(--muted);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.primary-action {
  background: linear-gradient(180deg, var(--green-soft), #ffffff 72%);
  border-color: rgba(22, 136, 95, 0.35);
}

.resource-card {
  min-height: 150px;
  padding: 18px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 0.78fr);
  gap: 18px;
  align-items: start;
}

.step-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: steps;
}

.step-list li {
  counter-increment: steps;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step-list li::before {
  content: counter(steps);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 760;
}

.step-list strong,
.step-list span {
  grid-column: 2;
}

.step-list span {
  color: var(--muted);
  line-height: 1.55;
}

.command-panel {
  padding: 18px;
  background: #1f2933;
  color: #f6fafc;
  min-width: 0;
}

.command-panel h3 {
  color: #ffffff;
}

input,
textarea,
select {
  width: 100%;
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
}

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

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

.compact-heading {
  align-items: start;
}

.event-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(94px, 0.45fr) auto;
  gap: 10px;
  align-items: end;
  min-width: min(100%, 520px);
}

.key-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(110px, 0.6fr) minmax(110px, 0.6fr);
  gap: 10px;
  align-items: end;
  min-width: min(100%, 560px);
}

.api-keys-card,
.recent-events-card {
  overflow: hidden;
}

.key-summary,
.event-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.key-summary span,
.event-summary span {
  display: grid;
  gap: 3px;
  max-width: 100%;
  min-width: 118px;
  padding: 9px 11px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.key-summary small,
.event-summary small {
  color: var(--muted);
  font-size: 12px;
}

.key-summary strong,
.event-summary strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.key-list,
.event-list {
  display: grid;
  gap: 12px;
}

.key-card,
.event-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(29, 45, 61, 0.04);
}

.key-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.key-card.revoked {
  background: #fbfcfd;
  color: #697786;
}

.key-card-main,
.event-card-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.key-title-row,
.event-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.key-title-row {
  justify-content: space-between;
}

.key-title {
  display: grid;
  gap: 3px;
}

.key-title span,
.key-prefix span {
  color: var(--muted);
  font-size: 12px;
}

.key-title strong,
.event-title strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.key-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 760;
}

.key-status.active {
  background: var(--green-soft);
  border-color: rgba(22, 136, 95, 0.3);
  color: var(--green);
}

.key-status.revoked {
  background: #fff7f7;
  border-color: rgba(180, 43, 50, 0.24);
  color: var(--red);
}

.key-prefix {
  display: grid;
  gap: 5px;
}

.key-prefix code {
  max-width: 100%;
  white-space: normal;
}

.event-meta {
  display: grid;
  grid-template-columns: minmax(180px, 0.78fr) minmax(180px, 0.85fr) minmax(280px, 1.4fr);
  gap: 8px;
}

.event-meta span {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

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

.event-meta time,
.event-meta code {
  color: var(--ink);
  font-size: 13px;
}

.key-tags,
.event-tags {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.key-tags span,
.event-tags span {
  display: grid;
  gap: 4px;
  max-width: 100%;
  padding: 9px 10px;
  background: var(--blue-soft);
  border: 1px solid rgba(38, 95, 189, 0.16);
  border-radius: 8px;
  color: #24435f;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.key-tags span {
  background: var(--surface-strong);
  border-color: var(--line);
}

.key-tags b,
.event-tags b {
  color: var(--muted);
}

.key-tags strong,
.event-tags strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.25;
}

.key-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 84px;
}

.key-actions .button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
  box-shadow: none;
}

.key-details,
.event-details {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.key-details summary,
.event-details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 680;
  font-size: 13px;
}

.key-details pre,
.event-details pre {
  max-height: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.capability-table {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.capability-table > div {
  display: grid;
  grid-template-columns: 0.72fr 1fr 1.5fr;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.capability-table > div:last-child {
  border-bottom: 0;
}

.capability-table .table-head {
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 760;
}

.capability-table span {
  min-width: 0;
  color: var(--muted);
}

.capability-table .table-head span,
.capability-table span:first-child {
  color: var(--ink);
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  vertical-align: top;
}

th {
  color: var(--ink);
  background: var(--surface-strong);
}

code,
pre {
  background: #eef3f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 2px 5px;
  color: #24435f;
  overflow-wrap: anywhere;
}

pre {
  padding: 14px;
  overflow: auto;
}

.command-panel pre,
.command-panel code {
  background: #111922;
  border-color: #344455;
  color: #d6edf7;
}

@media (max-width: 980px) {
  .hero-panel,
  .split-layout,
  .action-grid,
  .resource-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 720px) {
  .shell {
    padding: 22px 14px 42px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .brand,
  .brand span,
  .nav,
  .section,
  .action-grid,
  .resource-grid,
  .capability-table,
  .command-panel,
  .hero-panel {
    max-width: calc(100vw - 28px);
  }

  .topbar,
  .form-grid,
  .key-controls,
  .key-card,
  .event-controls,
  .event-meta,
  .section-heading {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    justify-content: stretch;
    align-items: stretch;
  }

  .portal-topbar {
    min-height: 0;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: 100%;
    max-width: 100%;
  }

  .nav .button {
    width: 100%;
    white-space: normal;
  }

  .brand h1 {
    font-size: 28px;
  }

  .hero-panel {
    width: 100%;
    max-width: 100%;
    padding: 18px;
    overflow: hidden;
  }

  .hero-panel > *,
  .action-card,
  .resource-card,
  .metric {
    max-width: 100%;
  }

  .command-panel pre,
  .command-panel code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .grid,
  .status,
  .capability-table > div {
    grid-template-columns: 1fr;
  }

  .key-tags,
  .event-tags {
    grid-template-columns: 1fr;
  }

  .key-actions {
    justify-content: stretch;
    min-width: 0;
  }

  .key-actions .button {
    width: 100%;
  }
}
