:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-muted: #eef3ed;
  --line: #d9e1d8;
  --text: #17211b;
  --muted: #617067;
  --brand: #0f8f61;
  --brand-dark: #0a5f45;
  --warn: #9a6400;
  --warn-bg: #fff3d4;
  --danger: #b42318;
  --danger-bg: #fee4df;
  --good-bg: #daf7e8;
  --shadow: 0 18px 42px rgba(29, 45, 36, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.admin-shell > * {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand-lockup strong {
  display: block;
  font-size: 17px;
}

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

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.sidebar-nav button {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 9px 11px;
}

.sidebar-nav button:hover,
.sidebar-nav button:focus-visible,
.sidebar-nav button.is-active {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--text);
  outline: none;
}

.sidebar-note {
  margin-top: 28px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.admin-login {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-login label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-login input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  color: var(--text);
}

.admin-login button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #ffffff;
  font-weight: 800;
}

.admin-login small {
  color: var(--muted);
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  max-width: 780px;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 21px;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.lead {
  max-width: 880px;
  color: var(--muted);
}

.environment-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 7px 13px;
  color: var(--brand-dark);
  font-weight: 700;
}

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

.summary-tile,
.section-block,
.module-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-tile {
  padding: 16px;
}

.summary-tile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  line-height: 1.1;
}

.section-block {
  margin-bottom: 24px;
  padding: 20px;
}

.page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.page-layout > *,
.detail-grid > *,
.module-hero > *,
.operation-panel > * {
  min-width: 0;
}

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

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

.module-link-card {
  display: grid;
  gap: 12px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 160ms ease, background 160ms ease;
}

.module-link-card:hover,
.module-link-card:focus-visible {
  border-color: var(--brand);
  background: #f7fbf8;
  outline: none;
}

.module-link-card span,
.module-link-card small {
  color: var(--muted);
  font-size: 12px;
}

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

.module-hero {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr 1.2fr;
  gap: 14px;
  margin-bottom: 24px;
}

.module-hero div {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.module-hero span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.module-hero strong {
  display: block;
  font-size: 22px;
  line-height: 1.25;
  text-wrap: pretty;
}

.operation-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.operation-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.operation-form--compact {
  grid-template-columns: minmax(160px, 240px) auto;
}

.operation-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.operation-form input,
.operation-form select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 10px;
  color: var(--text);
}

.operation-form button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #ffffff;
  padding: 8px 13px;
  font-weight: 800;
  white-space: nowrap;
}

.operation-status {
  grid-column: 1 / -1;
  min-height: 20px;
  color: var(--muted);
}

.operation-status[data-tone="good"] {
  color: var(--brand-dark);
}

.operation-status[data-tone="danger"] {
  color: var(--danger);
}

.event-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.event-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.event-toolbar label {
  display: grid;
  gap: 5px;
  min-width: 260px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.event-filters {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(110px, 0.7fr) minmax(220px, 1.4fr);
  gap: 10px;
  align-items: end;
}

.event-toolbar input,
.event-toolbar select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 8px 10px;
  color: var(--text);
}

.event-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.event-pagination {
  display: inline-flex;
  gap: 6px;
}

.event-pagination button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--brand-dark);
  padding: 5px 10px;
  font-weight: 800;
}

.event-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.copy-button {
  min-height: 28px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--brand-dark);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.copy-button:hover,
.copy-button:focus-visible {
  border-color: var(--brand);
  background: #ffffff;
  outline: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.status-pill--good {
  background: var(--good-bg);
  color: var(--brand-dark);
}

.status-pill--warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-pill--neutral {
  background: var(--surface-muted);
  color: var(--muted);
}

.metric-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 18px 0;
}

.metric-row strong {
  font-size: 28px;
  line-height: 1;
}

.metric-row span {
  color: var(--muted);
}

.module-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.module-meta div {
  display: grid;
  gap: 3px;
}

.module-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.module-meta dd {
  margin: 0;
}

.guard-list {
  display: grid;
  gap: 7px;
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  background: var(--surface);
}

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

thead th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

td span {
  display: block;
  margin-bottom: 5px;
}

code {
  border-radius: 6px;
  background: var(--surface-muted);
  padding: 2px 6px;
  color: var(--brand-dark);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.queue-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.queue-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--surface);
}

.queue-item span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.queue-item small {
  color: var(--muted);
}

.queue-item--warn span {
  color: var(--warn);
}

.queue-item--danger span {
  color: var(--danger);
}

.queue-item--info span {
  color: var(--brand-dark);
}

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

@media (max-width: 1100px) {
  .summary-grid,
  .page-layout,
  .detail-grid,
  .module-hero,
  .operation-panel,
  .operation-form,
  .operation-form--compact {
    grid-template-columns: 1fr;
  }

  .event-toolbar {
    display: grid;
  }

  .event-toolbar label,
  .event-filters {
    min-width: 0;
  }

  .event-filters {
    grid-template-columns: 1fr;
  }

  .event-summary {
    align-items: stretch;
    display: grid;
  }

  .module-directory {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 18px;
  }

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

  .main {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }
}

@media (max-width: 540px) {
  .sidebar-nav {
    grid-template-columns: 1fr;
  }
}
