:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #667085;
  --line: #d9e1e5;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --blue: #2563eb;
  --danger: #dc2626;
  --warning: #b45309;
  --ok: #15803d;
  --shadow: 0 16px 42px rgba(18, 38, 63, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel,
.panel,
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(460px, 100%);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.brand-row,
.sidebar-brand,
.topbar,
.panel-head,
.topbar-actions,
.captcha-row,
.modal-actions {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

p {
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.captcha-row {
  gap: 10px;
}

.captcha-row label {
  flex: 1 1 auto;
}

.captcha-button {
  width: 152px;
  height: 48px;
  padding: 0;
  margin-top: 20px;
  border: 1px solid #cbd5da;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.captcha-button img {
  display: block;
  width: 152px;
  height: 48px;
}

.primary,
.ghost,
.danger {
  min-height: 36px;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--primary);
}

.primary:hover {
  background: var(--primary-strong);
}

.ghost {
  color: #1f2937;
  background: #fff;
  border-color: #cbd5da;
}

.ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.danger {
  color: #fff;
  background: var(--danger);
}

.danger.subtle {
  color: var(--danger);
  background: #fff;
  border-color: #fecaca;
}

.full {
  width: 100%;
}

.icon {
  min-width: 36px;
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #18242d;
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-brand {
  gap: 12px;
  padding: 0 8px;
}

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

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  color: #d6dee5;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  background: #263641;
  color: #fff;
}

.main {
  min-width: 0;
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 20px;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  gap: 10px;
}

.user-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: #fff;
  color: #344054;
  font-weight: 700;
}

.workspace-view {
  display: grid;
  gap: 18px;
  align-content: start;
}

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

.summary-tile {
  min-height: 96px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

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

.summary-tile strong {
  font-size: 26px;
  line-height: 1.1;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

th,
td {
  border-bottom: 1px solid #e5ecef;
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: #475467;
  background: #f8fafc;
  font-weight: 800;
}

td {
  color: #1f2937;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.truncate {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid transparent;
}

.badge.ok {
  color: var(--ok);
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.badge.warn {
  color: var(--warning);
  background: #fffbeb;
  border-color: #fde68a;
}

.badge.bad {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 9px;
}

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

.grid-form.compact {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.stack-form {
  display: grid;
  gap: 12px;
}

.key-output {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  border-radius: 6px;
  padding: 12px;
  word-break: break-all;
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.55;
}

.public-key {
  min-height: 140px;
  font-family: Consolas, "Courier New", monospace;
}

.event-list {
  display: grid;
  gap: 10px;
}

.event-item {
  border-left: 3px solid var(--blue);
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px 12px;
}

.event-item strong {
  display: block;
  margin-bottom: 4px;
}

.event-item span,
.definition-list dd {
  color: var(--muted);
}

.definition-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 8px 12px;
  margin: 0 0 18px;
}

.definition-list dt,
.definition-list dd {
  margin: 0;
  font-size: 13px;
}

.definition-list dt {
  font-weight: 800;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  padding: 18px;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.modal-actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

[hidden] {
  display: none !important;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
    min-width: max-content;
  }

  .summary-grid,
  .two-column,
  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .captcha-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .captcha-button {
    margin-top: 0;
  }

  .summary-grid,
  .two-column,
  .grid-form,
  .grid-form.compact {
    grid-template-columns: 1fr;
  }

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