:root{
  --bg:#0b0f14;
  --panel:#0f172a;
  --panel2:#111827;
  --surface: rgba(255,255,255,0.03);
  --surface2: rgba(255,255,255,0.02);
  --line: rgba(255,255,255,0.09);
  --text:#e5e7eb;
  --muted:#9ca3af;
  --accent:#2563eb;
  --warn:#f59e0b;
  --danger:#fca5a5;
  --shadow: 0 12px 40px rgba(0,0,0,0.35);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
}
.no-scroll{overflow:hidden}

/* Top bar */
.topbar{
  border-bottom:1px solid var(--line);
  background: linear-gradient(180deg, var(--panel2), var(--bg));
}
.topbar-inner{
  max-width:1200px;
  margin:0 auto;
  padding:18px 16px;
}
h1{ margin:0 0 6px 0; font-size:20px; }
.topbar-sub{ color: var(--muted); font-size:13px; }

/* Layout */
.container{
  max-width:1200px;
  margin:0 auto;
  padding:18px 16px 40px;
}

/* Table */
.table{
  width:100%;
  border-collapse: collapse;
  background: var(--surface2);
  border:1px solid var(--line);
  border-radius: 12px;
  overflow:hidden;
}
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
  font-size:13px;
}
.table th{
  background: var(--surface);
  color: var(--muted);
  font-weight:700;
}
.row-click{cursor:pointer}
.row-click:hover{background: rgba(255,255,255,0.04)}
code{
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 7px;
}

/* Hints */
.hint{
  margin-top:12px;
  color:var(--muted);
  font-size:13px;
}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  text-decoration:none;
  cursor:pointer;
  font-size:13px;
}
.btn:hover{filter: brightness(1.08)}
.btn-primary{
  background: var(--accent);
  border-color: rgba(255,255,255,0.18);
}
.btn-ghost{ background: transparent; }
.btn-small{ padding:7px 9px; font-size:12px; border-radius:9px; }

/* Segmented toggle */
.segmented{
  display:inline-flex;
  border:1px solid var(--line);
  border-radius: 10px;
  overflow:hidden;
  background: rgba(255,255,255,0.03);
}
.seg-btn{
  border:0;
  background: transparent;
  color: var(--muted);
  padding:8px 10px;
  font-size:13px;
  cursor:pointer;
}
.seg-btn.active{
  background: rgba(37,99,235,0.22);
  color: var(--text);
}

/* Modal */
.modal-backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.68);
  display:none;
  padding:22px;
}
.modal-backdrop.open{display:flex}
.modal{
  margin:auto;
  width: min(1180px, 96vw);
  height: min(760px, 92vh);
  background: var(--panel2);
  border:1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

.modal-header{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}
.modal-title-wrap{min-width:0}
.modal-title{
  font-size:16px;
  font-weight:800;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.modal-meta{
  color: var(--muted);
  font-size:12px;
  margin-top: 3px;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
  max-width: 760px;
}
.modal-actions{display:flex; gap:10px; align-items:center}

/* Modal body grid */
.modal-body{
  flex:1;
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height:0;
}

/* Side nav */
.side-nav{
  border-right:1px solid var(--line);
  background: rgba(255,255,255,0.02);
  padding:12px;
  overflow:auto;
}
.side-nav-title{
  font-size:12px;
  color: var(--muted);
  margin-bottom:10px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.side-nav-items{display:flex; flex-direction:column; gap:6px}
.side-nav-btn{
  width:100%;
  text-align:left;
  padding:9px 10px;
  border-radius:10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  cursor:pointer;
  font-size:13px;
  line-height: 1.2;
}
.side-nav-btn:hover{background: rgba(255,255,255,0.04)}
.side-nav-btn.active{
  border-color: rgba(37,99,235,0.65);
  background: rgba(37,99,235,0.18);
}
.side-nav-btn.hidden{display:none}

/* Content panel */
.content{
  padding:12px;
  overflow:auto;
  min-height:0;
}

/* Search bar */
/* Search bar (NOT overlaying / NOT sticky) */
.searchbar{
  display:flex;
  gap:8px;
  align-items:center;
  padding:10px;
  background: rgba(255,255,255,0.02);
  border:1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
}

.search-input{
  flex:1;
  border-radius: 10px;
  border:1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding:10px 10px;
  font-size: 13px;
  outline: none;
}
.search-input:focus{
  border-color: rgba(37,99,235,0.65);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.20);
}
.status{
  min-width: 120px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}
.status.ok{ color: #86efac; }
.status.err{ color: var(--danger); }

/* Accordions */
.section{margin-bottom:10px}
.section.hidden{display:none}

.accordion{
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background: rgba(255,255,255,0.02);
}
.accordion-summary{
  cursor:pointer;
  padding:10px 12px;
  font-weight:800;
  list-style:none;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.accordion-summary::-webkit-details-marker{display:none}
.accordion-title{
  min-width: 0;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.accordion-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-shrink:0;
}
.accordion-body{
  border-top:1px solid var(--line);
  padding:12px 12px 14px;
}

/* Mini buttons inside section headers */
.mini-btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  border-radius: 9px;
  padding:6px 8px;
  font-size:12px;
  cursor:pointer;
}
.mini-btn:hover{ background: rgba(255,255,255,0.05); }
.mini-btn:disabled{
  opacity: 0.45;
  cursor:not-allowed;
}
.mini-btn-warn{
  border-color: rgba(245,158,11,0.35);
}
.tag{
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid rgba(37,99,235,0.45);
  background: rgba(37,99,235,0.16);
  color: var(--text);
}

/* Editor UI */
.editor{
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
  padding: 10px;
}
.editor-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom: 8px;
}
.editor-title{
  font-size: 12px;
  color: var(--muted);
}
.mono{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  color: var(--text);
}
.editor-actions{ display:flex; gap:8px; }
.editor-text{
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  outline: none;
}
.editor-text:focus{
  border-color: rgba(37,99,235,0.65);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.20);
}
.editor-hint{
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* States */
.loading{
  padding: 10px;
  color: var(--muted);
}
.error{
  padding: 12px;
  color: var(--danger);
  font-size:14px;
  border:1px solid rgba(252,165,165,0.25);
  border-radius: 12px;
  background: rgba(252,165,165,0.06);
}

/* Markdown typography */
.markdown{
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
}
.markdown p{margin: 0 0 10px}
.markdown h1,.markdown h2,.markdown h3,.markdown h4{
  margin: 14px 0 8px;
  line-height: 1.25;
}
.markdown h3{font-size: 15px}
.markdown h4{font-size: 14px}

.markdown strong{font-weight: 800}
.markdown em{color: rgba(229,231,235,0.95)}

.markdown ul, .markdown ol{
  margin: 8px 0 12px;
  padding-left: 22px;
}
.markdown li{margin: 6px 0}

.markdown blockquote{
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid rgba(37,99,235,0.65);
  background: rgba(37,99,235,0.08);
  border-radius: 10px;
  color: rgba(229,231,235,0.95);
}

.markdown code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 8px;
}

.markdown pre{
  margin: 10px 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  overflow:auto;
}
.markdown pre code{
  background: transparent;
  padding: 0;
}

.markdown table{
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  border:1px solid var(--line);
  border-radius: 10px;
  overflow:hidden;
}
.markdown th, .markdown td{
  border-bottom:1px solid var(--line);
  padding: 8px 10px;
  text-align:left;
  font-size: 13px;
}
.markdown th{
  background: rgba(255,255,255,0.04);
  color: var(--muted);
}
