:root {
  --bg: #020617;
  --bg-elevated: #020617;
  --bg-elevated-soft: #020617;
  --border: #1f2937;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --danger: #ef4444;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 40px rgba(0, 0, 0, 0.5);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, #020617 45%, #000 100%);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.4rem 2rem 0.5rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 2fr);
  gap: 1rem;
  padding: 0 2rem 2rem;
  height: calc(100vh - 70px);
}

.panel {
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-elevated-soft));
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(31, 41, 55, 0.9);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn.primary {
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn.secondary {
  background: rgba(31, 41, 55, 0.9);
  color: var(--text);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.btn.secondary:hover {
  background: rgba(31, 41, 55, 1);
}

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed rgba(75, 85, 99, 0.9);
}

.btn.ghost:hover {
  border-style: solid;
  color: var(--text);
}

.btn.small {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.info {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.muted {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.table-wrapper {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(31, 41, 55, 0.9);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: rgba(17, 24, 39, 0.95);
}

th,
td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

tbody tr {
  background: rgba(15, 23, 42, 0.9);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.96);
}

tbody tr:hover {
  background: rgba(30, 64, 175, 0.35);
}

tbody tr.active {
  background: rgba(59, 130, 246, 0.35);
}

.editor-panel {
  min-height: 0;
}

.details-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr);
  gap: 1rem;
}

.field-group {
  margin-bottom: 0.8rem;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.input {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 0.35rem 0.6rem;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
}

.subpanel {
  background: rgba(15, 23, 42, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 0.6rem 0.7rem;
}

.subpanel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.table-sm {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.table-sm th,
.table-sm td {
  padding: 0.25rem 0.35rem;
  border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

.badge {
  display: inline-flex;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 0.7rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(960px, 100% - 3rem);
  max-height: 80vh;
  background: #020617;
  border-radius: 18px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem 0.4rem;
}

.modal-body {
  padding: 0.4rem 1rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-footer {
  padding: 0.6rem 1rem 0.8rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text);
}

.tabs {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 999px;
  padding: 0.15rem;
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.code-view {
  width: 100%;
  height: 360px;
  margin-top: 0.5rem;
  background: #020617;
  color: #e5e7eb;
  border-radius: 10px;
  border: 1px solid rgba(31, 41, 55, 0.9);
  font-family: SFMono-Regular, ui-monospace, Menlo, Monaco, Consolas, 'Liberation Mono',
    'Courier New', monospace;
  font-size: 0.8rem;
  padding: 0.6rem 0.7rem;
  resize: vertical;
}

.code-view.hidden {
  display: none;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .details-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
