:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #15202b;
  --muted: #667382;
  --line: #dce2e7;
  --accent: #2f6fed;
  --accent-soft: #eaf1ff;
  --danger: #c53d4f;
  --shadow: 0 8px 24px rgba(23, 35, 48, .08);
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
button, input, select { font: inherit; }
.topbar { height: 78px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; gap: 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--text); color: white; font-weight: 800; font-size: 19px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; gap: 8px; }
.file-button { background: var(--accent); color: white; padding: 10px 13px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; }
.file-button.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.file-button input { display: none; }
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 390px; min-height: calc(100vh - 78px); }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); padding: 18px; overflow: auto; }
.sidebar-section { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.search-wrap span, .filters label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.search-wrap input, .filters select { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 11px; color: var(--text); }
.filters label { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stats strong { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 11px; }
.hint p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.results-pane { padding: 18px 20px 28px; min-width: 0; overflow: auto; }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.results-head h2 { margin: 0; font-size: 22px; }
.results-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.view-buttons { display: flex; gap: 6px; }
.view { border: 1px solid var(--line); background: var(--surface); padding: 8px 11px; border-radius: 9px; cursor: pointer; color: var(--muted); }
.view.active { background: var(--accent-soft); color: var(--accent); border-color: #c9d8ff; font-weight: 700; }
.empty-state { min-height: 55vh; border: 1px dashed var(--line); border-radius: 16px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); background: rgba(255,255,255,.45); }
.empty-icon { width: 58px; height: 58px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 26px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); }
.empty-state p { max-width: 420px; margin: 0; font-size: 13px; }
.hidden { display: none !important; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 10px rgba(23,35,48,.03); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #edf2f7, #f8fafb); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb .placeholder { color: var(--muted); font-size: 12px; padding: 20px; text-align: center; }
.card-body { padding: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badge { font-size: 10px; line-height: 1; padding: 5px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.card h3 { margin: 0; font-size: 15px; }
.card .proposed { margin: 6px 0 0; color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; word-break: break-word; }
.card .old { margin: 5px 0 0; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { background: var(--surface-2); position: sticky; top: 0; z-index: 1; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
.detail-pane { border-left: 1px solid var(--line); background: var(--surface); padding: 20px; overflow: auto; position: relative; }
.close { position: absolute; right: 14px; top: 12px; width: 32px; height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; font-size: 20px; color: var(--muted); }
.detail-image { border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; margin-bottom: 16px; }
.detail-image img { width: 100%; height: 100%; object-fit: contain; }
.detail-pane h2 { margin: 0 40px 5px 0; font-size: 21px; }
.detail-sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-word; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.meta { border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: var(--surface-2); }
.meta label { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 3px; }
.meta div { font-size: 11px; word-break: break-word; }
.rel-section { margin-top: 17px; }
.rel-section h3 { margin: 0 0 8px; font-size: 12px; }
.rel-list { display: grid; gap: 7px; }
.rel-item { border: 1px solid var(--line); border-radius: 10px; padding: 9px; cursor: pointer; background: var(--surface); }
.rel-item:hover { background: var(--surface-2); }
.rel-item strong { display: block; font-size: 11px; }
.rel-item span { color: var(--muted); font-size: 10px; }
@media (max-width: 1150px) {
  .app-shell { grid-template-columns: 220px minmax(0,1fr); }
  .detail-pane { position: fixed; inset: 78px 0 0 auto; width: min(410px, 94vw); box-shadow: -10px 0 28px rgba(0,0,0,.12); z-index: 10; }
}
@media (max-width: 760px) {
  .topbar { height: auto; padding: 12px; align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; }
  .file-button { flex: 1; text-align: center; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Hide manual loader toolbar */
.toolbar {
  display: none !important;
}