:root {
  --background: #ffffff;
  --foreground: #020817;
  --card: #ffffff;
  --card-foreground: #020817;
  --popover: #ffffff;
  --popover-foreground: #020817;
  --primary: #0f172a;
  --primary-foreground: #f8fafc;
  --secondary: #f1f5f9;
  --secondary-foreground: #0f172a;
  --muted: #f8fafc;
  --muted-foreground: #64748b;
  --accent: #f1f5f9;
  --accent-foreground: #0f172a;
  --destructive: #ef4444;
  --destructive-foreground: #f8fafc;
  --border: #e2e8f0;
  --input: #e2e8f0;
  --ring: #020817;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--foreground);
  background: var(--background);
  font-family: "Geist", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

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

button {
  border: 0;
}

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 16px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--primary-foreground);
  background: var(--primary);
  font-weight: 700;
  letter-spacing: 0;
}

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

.brand strong {
  font-size: 15px;
  line-height: 1.25;
}

.brand span {
  margin-top: 2px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.nav a {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--muted-foreground);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.nav a:hover {
  color: var(--foreground);
  background: var(--accent);
}

.nav a.active {
  color: var(--foreground);
  background: var(--background);
  box-shadow: 0 0 0 1px var(--border);
}

.sidebar-note {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  background: var(--background);
  font-size: 12px;
  line-height: 1.5;
}

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

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0;
}

.page-head p {
  margin: 8px 0 0;
  max-width: 680px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background:
    linear-gradient(135deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.96)),
    radial-gradient(circle at 12% 18%, rgba(15, 23, 42, 0.08), transparent 30%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.hero-command {
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.94)),
    radial-gradient(circle at 8% 12%, rgba(15, 23, 42, 0.09), transparent 28%),
    linear-gradient(90deg, transparent 0, transparent 31px, rgba(226, 232, 240, 0.4) 32px),
    linear-gradient(0deg, transparent 0, transparent 31px, rgba(226, 232, 240, 0.34) 32px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

.hero-copy {
  padding: 34px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.hero-console {
  display: grid;
  align-content: space-between;
  gap: 16px;
  padding: 18px;
  border-left: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.72);
}

.console-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  background: var(--background);
  font-size: 12px;
}

.console-head strong {
  color: var(--foreground);
  margin-right: auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warning);
}

.dot.good {
  background: var(--success);
}

.hero-panel h1 {
  margin: 8px 0 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.hero-panel p {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted-foreground);
  font-size: 15px;
  line-height: 1.7;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-foreground);
  background: var(--background);
  font-size: 12px;
  font-weight: 600;
}

.hero-search {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
}

.hero-search label span {
  display: block;
  margin-bottom: 6px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
}

.hero-checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hero-checks span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  background: var(--background);
  font-size: 12px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  color: var(--foreground);
  background: transparent;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px rgba(2, 8, 23, 0.12);
}

.toolbar input {
  width: 320px;
  background: var(--background);
}

.toolbar select {
  width: 180px;
  background: var(--background);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--foreground);
  background: var(--background);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.btn:hover {
  background: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--primary);
  color: var(--primary-foreground);
  background: var(--primary);
}

.btn.primary:hover {
  background: #1e293b;
}

.btn.subtle {
  color: var(--muted-foreground);
}

.btn.danger {
  border-color: #fecaca;
  color: #991b1b;
  background: #fff1f2;
}

.btn.danger:hover {
  background: #ffe4e6;
}

.btn.small {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.btn.full {
  width: 100%;
}

.metric-grid,
.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.metric-grid.no-margin {
  margin-bottom: 0;
}

.metric,
.panel,
.login-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
}

.metric em {
  display: block;
  margin-top: 8px;
  color: var(--muted-foreground);
  font-style: normal;
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(0, 1.28fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

.feature-card {
  display: grid;
  gap: 10px;
  min-height: 168px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  background: var(--card);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.feature-card:hover {
  border-color: var(--foreground);
  box-shadow: 0 0 0 2px rgba(2, 8, 23, 0.08);
}

.feature-card span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
}

.feature-card strong {
  font-size: 18px;
}

.feature-card p {
  margin: 0;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.feature-card-muted {
  background: var(--muted);
}

.lower-grid {
  grid-template-columns: 1.12fr 0.88fr;
}

.admin-grid {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.panel-desc {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.6;
}

.card-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

.card-title p {
  margin: 8px 0 0;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.soft-label {
  color: var(--muted-foreground);
  font-size: 12px;
}

.library-list,
.asset-list,
.rank-list,
.timeline,
.table-list {
  display: grid;
  gap: 8px;
}

.library-list {
  max-height: 632px;
  overflow: auto;
  padding-right: 2px;
}

.library-card,
.asset-row,
.rank-row,
.task-row,
.table-row,
.asset-card,
.status-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
}

.library-card {
  width: 100%;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.library-card:hover,
.library-card.active,
.library-card:focus-visible,
.asset-row.selectable:hover,
.asset-row.selectable.active,
.asset-row.selectable:focus-visible {
  border-color: var(--foreground);
  box-shadow: 0 0 0 2px rgba(2, 8, 23, 0.08);
}

.library-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.library-card p {
  margin: 7px 0 0;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.5;
}

.detail-link {
  margin-top: 10px;
  width: fit-content;
}

.library-card .detail-link {
  cursor: pointer;
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--secondary-foreground);
  background: var(--secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill.good {
  color: #166534;
  background: #dcfce7;
}

.pill.warn {
  color: #92400e;
  background: #fef3c7;
}

.pill.bad {
  color: #991b1b;
  background: #fee2e2;
}

.detail-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  background: var(--muted);
  text-align: center;
}

.detail-empty.compact {
  min-height: 88px;
  padding: 16px;
}

.detail-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.detail-top h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.detail-top p {
  margin: 6px 0 0;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.version-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

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

.detail-controls label span {
  display: block;
  margin-bottom: 6px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 500;
}

.compact-controls {
  grid-template-columns: minmax(0, 260px);
}

.no-margin-head {
  margin: 4px 0 10px;
}

.asset-row,
.rank-row,
.task-row,
.table-row {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.asset-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.asset-row.selectable {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.asset-row code,
.rank-row code,
.asset-card code {
  color: #0f172a;
  overflow-wrap: anywhere;
}

.asset-meta,
.row-meta {
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.danger-text {
  color: var(--destructive);
}

.snippet-box {
  display: grid;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  min-width: 0;
}

.compact-snippet {
  margin-top: 0;
}

.snippet-box > * {
  min-width: 0;
}

.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.snippet-head span {
  color: var(--muted-foreground);
  font-size: 12px;
}

.snippet-box code {
  display: block;
  padding: 12px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border-radius: var(--radius);
  color: #e2e8f0;
  background: #020817;
  white-space: pre;
}

.snippet-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.rank-row {
  grid-template-columns: 34px minmax(0, 1fr) 72px;
  align-items: center;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--secondary);
  font-weight: 600;
}

.task-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.task-row strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

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

.compact-form {
  gap: 10px;
}

.admin-form label span,
.login-card label span {
  display: block;
  margin-bottom: 6px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 500;
}

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

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

.preset-card {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
}

.preset-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.preset-card h3 {
  margin: 10px 0 0;
  font-size: 17px;
  line-height: 1.3;
}

.preset-card p {
  margin: 0;
  color: var(--muted-foreground);
  line-height: 1.6;
}

.preset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted-foreground);
  font-size: 12px;
}

.preset-packages {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.request-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.link-row {
  color: inherit;
  text-decoration: none;
}

.link-row:hover {
  border-color: var(--foreground);
  box-shadow: 0 0 0 2px rgba(2, 8, 23, 0.08);
}

.table-list.dense .table-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.asset-catalog {
  display: grid;
  gap: 10px;
}

.asset-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.asset-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 6px;
}

.asset-card code {
  display: block;
  margin-bottom: 6px;
}

.asset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.status-item {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.status-item span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 500;
}

.status-item strong {
  font-size: 16px;
}

.request-result {
  display: grid;
  margin-top: 16px;
}

.request-result .status-item {
  min-height: 120px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary-foreground);
  background: var(--primary);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.12);
}

.toast.error {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--muted);
}

.login-card {
  width: min(100%, 400px);
  display: grid;
  gap: 16px;
  padding: 24px;
}

.login-brand {
  padding: 0 0 8px;
}

.login-hint {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .metric-grid,
  .mini-metrics,
  .feature-grid,
  .status-strip,
  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

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

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

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-note {
    position: static;
    margin-top: 16px;
  }

  .main {
    padding: 16px;
  }

  .page-head {
    flex-direction: column;
  }

  .toolbar,
  .toolbar input,
  .toolbar select,
  .btn {
    width: 100%;
  }

  .metric-grid,
  .mini-metrics,
  .feature-grid,
  .status-strip,
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .asset-row,
  .asset-card,
  .rank-row,
  .task-row,
  .table-row,
  .table-list.dense .table-row {
    grid-template-columns: 1fr;
  }
}
