:root {
  --bg-950: #0a0a0a;
  --bg-900: #171717;
  --bg-850: #1f1f1f;
  --bg-800: #262626;
  --border-800: #303030;
  --border-700: #454545;
  --text-100: #ffffff;
  --text-300: #d4d4d4;
  --text-400: #a3a3a3;
  --text-500: #737373;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-300);
  background: var(--bg-950);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  animation: pageIn 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.brand-label {
  margin: 0;
  color: var(--text-500);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand-title {
  margin: 6px 0 0;
  color: var(--text-100);
  font-weight: 300;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.menu-left,
.menu-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-link {
  border: 1px solid var(--border-800);
  background: var(--bg-900);
  color: var(--text-400);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: 0.2s ease;
}

.menu-link:hover {
  border-color: var(--border-700);
  color: var(--text-300);
}

.menu-link.is-active {
  background: var(--bg-850);
  color: var(--text-100);
}

.content {
  display: grid;
  gap: 14px;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--border-800);
  border-radius: var(--radius);
  background: rgba(23, 23, 23, 0.9);
  padding: 18px;
}

.kicker {
  margin: 0;
  color: var(--text-500);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.section-title {
  margin: 8px 0 0;
  color: var(--text-100);
  font-weight: 300;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.controls {
  margin-top: 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

label {
  color: var(--text-400);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.check-label {
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.explorer-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  align-items: end;
}

.filter-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.filter-field select {
  min-width: 0;
  width: 100%;
}

.explorer-actions > * {
  min-width: 0;
}

select,
input,
textarea,
button {
  border: 1px solid var(--border-800);
  background: var(--bg-850);
  color: var(--text-100);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

select,
input {
  min-width: 260px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 180px;
  font-family: inherit;
  line-height: 1.4;
}

button {
  min-width: 100px;
  cursor: pointer;
  transition: 0.2s ease;
}

button:hover {
  border-color: var(--border-700);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status {
  margin: 14px 0 0;
  min-height: 18px;
  color: var(--text-400);
  font-size: 13px;
}

.results {
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--border-800);
  border-radius: 12px;
  background: rgba(23, 23, 23, 0.75);
  padding: 12px;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  opacity: 0;
  transform: translateY(8px);
  animation: cardIn 0.35s ease forwards;
}

.card img {
  width: 100%;
  height: 112px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-800);
}

.meta {
  display: grid;
  gap: 6px;
}

.title {
  color: var(--text-100);
  font-size: 19px;
  font-weight: 300;
  letter-spacing: -0.01em;
}

.description {
  color: var(--text-400);
  line-height: 1.4;
  font-size: 14px;
}

.source {
  color: var(--text-500);
  font-size: 12px;
  line-height: 1.45;
}

.settings-grid {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.preprocessor-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: end;
}

.settings-subtitle {
  grid-column: 1 / -1;
  margin-top: 8px;
  color: var(--text-300);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preprocessor-grid input {
  min-width: 0;
  width: 100%;
}

.seed-settings {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-800);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint {
  margin: 4px 0 0;
  color: var(--text-500);
  font-size: 12px;
}

.status-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--border-700);
}

.badge-running {
  background: rgba(90, 90, 90, 0.35);
  color: #f0f0f0;
}

.badge-success {
  background: rgba(70, 110, 70, 0.28);
  color: #d7f6d7;
}

.badge-partial {
  background: rgba(120, 110, 60, 0.3);
  color: #f4ecc7;
}

.badge-failed {
  background: rgba(120, 60, 60, 0.34);
  color: #ffd7d7;
}

.badge-neutral {
  background: rgba(80, 80, 80, 0.24);
  color: #d0d0d0;
}

.seed-error {
  margin-top: 6px;
  font-size: 11px;
  color: #f1a9a9;
  max-width: 560px;
  white-space: normal;
}

.asset-cards {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.asset-card {
  border: 1px solid var(--border-800);
  border-radius: 12px;
  padding: 12px;
  background: rgba(22, 22, 22, 0.9);
  display: grid;
  gap: 8px;
}

.asset-card-top {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

.asset-card-top > div {
  min-width: 0;
}

.asset-thumb {
  width: 120px;
  height: 78px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-800);
}

.asset-title {
  color: var(--text-100);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.asset-id {
  color: var(--text-500);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.asset-desc {
  font-size: 13px;
  color: var(--text-400);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.asset-meta {
  font-size: 12px;
  color: var(--text-500);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.asset-id a {
  color: inherit;
  text-decoration: underline;
  overflow-wrap: anywhere;
}

.asset-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-badge {
  border: 1px solid var(--border-700);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-300);
}

.mini-warning {
  border-color: #7a5757;
  color: #f2c8c8;
}

.mini-good {
  border-color: #4a6a4a;
  color: #d4f2d4;
}

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

.asset-action-btn {
  min-width: 0;
  padding: 7px 10px;
  font-size: 12px;
}

.asset-action-btn.is-approved {
  border-color: #4a6a4a;
  background: rgba(70, 110, 70, 0.28);
  color: #d7f6d7;
}

.asset-action-btn.is-blocked {
  border-color: #7a5757;
  background: rgba(120, 60, 60, 0.34);
  color: #ffd7d7;
}

.asset-action-btn.is-reset {
  border-color: #5f5f5f;
  background: rgba(95, 95, 95, 0.26);
  color: #ebebeb;
}

.db-table-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  border: 1px solid var(--border-800);
  border-radius: 10px;
  background: rgba(15, 15, 15, 0.9);
}

.db-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}

.db-table th,
.db-table td {
  border-bottom: 1px solid var(--border-800);
  padding: 8px 10px;
  vertical-align: top;
  text-align: left;
  color: var(--text-300);
  white-space: nowrap;
}

#assetTable td,
#assetTable th {
  white-space: normal;
  overflow-wrap: anywhere;
}

#preparerTable td,
#preparerTable th {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#preparerTable td:nth-child(1),
#preparerTable th:nth-child(1),
#preparerTable td:nth-child(2),
#preparerTable th:nth-child(2),
#preparerTable td:nth-child(10),
#preparerTable th:nth-child(10) {
  max-width: 220px;
}

#seedTable td,
#seedTable th {
  white-space: nowrap;
}

#seedTable .collect-seed-btn {
  white-space: nowrap;
}

.db-table th {
  color: var(--text-100);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: #141414;
}

.sql-result {
  margin: 0;
  border: 1px solid var(--border-800);
  border-radius: 10px;
  background: #101010;
  color: var(--text-300);
  padding: 12px;
  min-height: 88px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}

@keyframes pageIn {
  from {
    opacity: 0;
    filter: blur(8px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .menu-right {
    justify-content: flex-start;
  }

  .card {
    grid-template-columns: 1fr;
  }

  .card img {
    height: 180px;
  }

  select,
  input,
  textarea {
    min-width: 220px;
    width: 100%;
  }
}
