:root {
  --bg: #0f1020;
  --bg-2: #1a1f3c;
  --accent: #38bdf8;
  --accent-2: #f59e0b;
  --glass: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
}

* { box-sizing: border-box; }

body {
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -10%, #26306b 0%, transparent 60%),
              radial-gradient(900px 600px at 90% 0%, #2b6a6f 0%, transparent 55%),
              linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(500px 500px at 70% 30%, rgba(56,189,248,0.18), transparent 60%),
              radial-gradient(600px 600px at 20% 70%, rgba(245,158,11,0.12), transparent 65%);
  z-index: 0;
}

.container,
.container-fluid {
  position: relative;
  z-index: 1;
}

.app-shell {
  max-width: 1600px;
  padding-left: 24px;
  padding-right: 24px;
}

@media (max-width: 576px) {
  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.card-glass {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.card-glass h1,
.card-glass h2,
.card-glass h3,
.card-glass h4,
.card-glass h5,
.card-glass h6 {
  color: #f8fafc;
}

.header-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.api-box {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
}

.api-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.5rem 0.75rem;
}

.api-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 180px;
}

.api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.brand-logos {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
}

.product-logo {
  display: block;
  height: 28px;
  width: auto;
}

.nav-pills .nav-link {
  border-radius: 999px;
  color: #e2e8f0;
  background: rgba(255,255,255,0.06);
  margin-right: 0.5rem;
}

.nav-pills .nav-link.active {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #0b1020;
  font-weight: 600;
}

.form-control {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.2);
  color: #f8fafc;
}

.form-label {
  color: #f1f5f9;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.form-control::placeholder { color: rgba(248,250,252,0.6); }

.form-text {
  color: rgba(248,250,252,0.7);
}

.text-muted {
  color: rgba(248,250,252,0.7) !important;
}

.form-check-label {
  color: #f1f5f9;
  font-weight: 600;
}

.alert {
  border: 1px solid rgba(255,255,255,0.25);
  color: #0b1020;
  font-weight: 600;
}

.alert-success {
  background: #a7f3d0;
}

.alert-warning {
  background: #fde68a;
}

a {
  color: #7dd3fc;
}

a:hover {
  color: #38bdf8;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

#metadataBlock {
  width: 100%;
}

.response {
  background: rgba(12, 14, 30, 0.8);
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.75rem;
  min-height: 180px;
  max-height: 420px;
  overflow: auto;
}

.loading-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  color: #e2e8f0;
}

.loading-indicator.active {
  display: inline-flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(248,250,252,0.3);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

hr {
  border-color: rgba(255,255,255,0.15);
}

.train-section {
  display: none;
}

.train-section.active {
  display: block;
}

.table {
  color: #e2e8f0;
}

.table thead th {
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255,255,255,0.15);
}

.table tbody td {
  border-color: rgba(255,255,255,0.08);
}

.table tbody tr:hover {
  background: rgba(56,189,248,0.08);
}

.pdf-preview {
  border: 1px solid rgba(255,255,255,0.12);
}

#pdfCanvas {
  max-height: 520px;
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.03);
}

.chat-window {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(12, 14, 30, 0.8);
  border: 1px solid rgba(255,255,255,0.08);
}

.chat-bubble {
  padding: 0.6rem 0.8rem;
  border-radius: 0.8rem;
  margin-bottom: 0.6rem;
  color: #f8fafc;
}

.chat-user {
  background: rgba(56,189,248,0.25);
  border: 1px solid rgba(56,189,248,0.55);
  color: #e6f6ff;
}

.chat-assistant {
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  color: #f8fafc;
}

.table td .btn {
  margin-right: 0.25rem;
}

.content-cell-cut {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.source-detail-row td {
  background: rgba(15, 23, 42, 0.5);
}

.source-detail-title {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 0.45rem;
}

.source-detail-table {
  width: 100%;
  font-size: 0.92rem;
}

.source-detail-table th,
.source-detail-table td {
  padding: 0.45rem 0.5rem;
  border-color: rgba(255,255,255,0.08);
}

.chunk-preview {
  max-width: 540px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-primary {
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  border: none;
  color: #08131e;
}

.btn-success {
  background: linear-gradient(90deg, #22c55e, #10b981);
  border: none;
  color: #071b10;
}

.btn-danger {
  background: linear-gradient(90deg, #ef4444, #f97316);
  border: none;
  color: #1b0b0b;
}

@media (max-width: 992px) {
  .meta-grid { grid-template-columns: 1fr; }
  .brand-logos {
    gap: 0.6rem;
    padding: 0.35rem 0.6rem;
  }
  .product-logo {
    height: 24px;
  }
  .api-item {
    min-width: 0;
    width: 100%;
  }
  .api-actions {
    width: 100%;
  }
  .content-cell-cut,
  .chunk-preview {
    max-width: 220px;
  }
}
