:root {
  --bg: #f4f6fb;
  --bg-accent: #eef2ff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1e40af;
  --border: #e2e8f0;
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, #dbeafe, transparent 45%),
    radial-gradient(circle at 80% 10%, #e0f2fe, transparent 40%),
    radial-gradient(circle at 50% 80%, #fef3c7, transparent 45%);
  z-index: -1;
}

.container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 16px 20px 32px;
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-dark);
  margin: 0 0 8px;
}

h1 {
  font-size: clamp(28px, 3vw, 40px);
  margin: 0 0 8px;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 520px;
}

.file-card {
  background: var(--card);
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 260px;
  display: grid;
  gap: 8px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#file-upload {
  display: none;
}

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

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 12px;
  color: #0f172a;
}

.recent-meta {
  color: #475569;
  font-size: 11px;
}

.recent-actions {
  display: flex;
  gap: 6px;
}

.file-card label {
  font-size: 13px;
  color: var(--muted);
}

select,
input[type="search"],
input[type="text"],
input[type="number"] {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  width: 100%;
}

.status {
  font-size: 12px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.card-header {
  font-size: 14px;
  font-weight: 600;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

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

button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

button.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.ghost {
  background: #f1f5f9;
  color: var(--text);
}

button.ghost:hover {
  background: #e2e8f0;
}

#filters {
  display: grid;
  gap: 8px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.4fr auto;
  gap: 8px;
  align-items: center;
}

.filter-row input {
  width: 100%;
}

.filter-actions,
.columns-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.columns-list {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  gap: 6px;
  background: #f8fafc;
}

.column-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.column-info {
  margin-left: auto;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 9px;
  font-weight: 700;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.column-info:hover {
  background: #dbeafe;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.table-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  min-height: 520px;
  height: calc(100vh - 180px);
  display: grid;
  grid-template-rows: auto 1fr;
}

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

.table-header h2 {
  margin: 0;
  font-size: 18px;
}

.table-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.loading {
  font-size: 13px;
  color: var(--accent-dark);
  display: none;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-paging {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.table-paging label {
  white-space: nowrap;
}

.table-paging select {
  width: auto;
  padding: 8px 10px;
}

.table-paging .pagination {
  gap: 8px;
}

.table-wrapper {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  min-height: 0;
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#data-table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
}

#data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#data-table tbody tr:nth-child(2n) {
  background: #f9fafb;
}

.cell-object {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cell-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #1e3a8a;
}

.cell-view {
  border: none;
  background: #e2e8f0;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.cell-view:hover {
  background: #cbd5f5;
}

.sort-indicator {
  font-size: 11px;
  margin-left: 6px;
  color: var(--accent-dark);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  width: min(900px, 92vw);
  max-height: 80vh;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.35);
  display: grid;
  grid-template-rows: auto 1fr;
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-title {
  font-weight: 600;
  font-size: 15px;
}

.modal-subtitle {
  font-size: 12px;
  color: #94a3b8;
}

.modal-header button {
  background: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}

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

.modal-content {
  margin: 0;
  padding: 20px;
  overflow: auto;
  color: #e2e8f0;
}

.recent-card {
  width: min(560px, 92vw);
  max-height: 70vh;
}

.modal-text {
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", monospace;
}

.modal-tree {
  font-size: 12px;
  line-height: 1.4;
  font-family: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.type-tree {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.type-tree ul {
  list-style: none;
  margin: 6px 0 0 12px;
  padding-left: 12px;
  border-left: 1px dashed rgba(148, 163, 184, 0.35);
}

.type-tree li {
  margin: 4px 0;
}

.type-tree span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.modal-json {
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", monospace;
  font-size: 12px;
  line-height: 1.5;
}

.json-raw {
  white-space: pre;
}

.type-tree details {
  display: inline-block;
}

.type-tree summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.type-tree summary::-webkit-details-marker {
  display: none;
}

.type-row {
  position: relative;
  padding-left: 14px;
  display: inline-flex;
  align-items: center;
}

.type-tree summary.type-row::before {
  content: "▸";
  font-size: 10px;
  color: #cbd5f5;
  position: absolute;
  left: 0;
}

.type-tree details[open] > summary.type-row::before {
  content: "▾";
}

.json-line {
  position: relative;
  padding-left: 14px;
  display: block;
}

.json-line::-webkit-details-marker {
  display: none;
}

summary.json-line::before {
  content: "▸";
  font-size: 10px;
  color: rgba(148, 163, 184, 0.7);
  position: absolute;
  left: 0;
}

details[open] > summary.json-line::before {
  content: "▾";
}

.type-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.type-field {
  font-weight: 600;
}

.type-kind {
  font-size: 11px;
  opacity: 0.8;
  text-transform: lowercase;
}

@media (max-width: 900px) {
  .control-row {
    grid-template-columns: 1fr;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .table-card {
    height: auto;
  }
}
