:root {
  --bg: #0b1021;
  --fg: #e5e7eb;
  --fg-muted: #a3aac2;
  --card: #0f162e;
  --border: #1f2a44;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --chip: #111c3b;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}
:root[data-theme="light"] {
  --bg: #f8fafc;
  --fg: #0f172a;
  --fg-muted: #475569;
  --card: #ffffff;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --chip: #eef2ff;
  --shadow: 0 2px 10px rgba(2, 6, 23, 0.08);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji"; }
a { color: var(--accent); text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.topbar { position: sticky; top: 0; z-index: 50; padding: 8px 12px; background: var(--card); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
.topbar .inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.brand { font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions .select, .actions .input { min-width: 160px; }
.actions .btn { height: 36px; }

.container { max-width: 1200px; margin: 16px auto; padding: 0 16px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--fg); cursor: pointer; box-shadow: var(--shadow); transition: background .15s, transform .05s; }
.btn:hover { background: rgba(96, 165, 250, 0.08); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.loading { opacity: .85; pointer-events: none; }
.btn.loading .icon { animation: spin 1s linear infinite; }

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

.select, .input, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); color: var(--fg); transition: box-shadow .15s, border-color .15s; }
.input::placeholder, textarea::placeholder { color: var(--fg-muted); }
textarea { resize: vertical; min-height: 160px; }

/* Focus rings */
.select:focus-visible, .input:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.45);
  border-color: var(--accent);
}

.icon { width: 18px; height: 18px; fill: currentColor; }
.icon.xs { width: 14px; height: 14px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: var(--chip); border: 1px solid var(--border); font-size: 12px; color: var(--fg-muted); }
.muted { color: var(--fg-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.small { font-size: 12px; }

.split.responsive { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .split.responsive { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card h2 { margin: 0; font-size: 16px; }
.card .tools { display: flex; align-items: center; gap: 8px; }

.assist { display: flex; justify-content: flex-end; margin-top: 6px; }

.dropzone { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; margin-bottom: 12px; border: 2px dashed var(--border); border-radius: 12px; color: var(--fg-muted); background: transparent; }
.dropzone.dragover { background: rgba(96, 165, 250, 0.1); border-color: var(--accent); color: var(--accent); }

.tabs { margin-top: 16px; }
.tabs.hidden { display: none; }
.tablist { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tab { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
.tab.active { background: var(--accent); color: white; border-color: var(--accent-strong); }
.tab .close { margin-left: 8px; background: transparent; border: none; color: inherit; cursor: pointer; font-size: 14px; opacity: .8; }
.tab .close:hover { opacity: 1; }
.panel { display: none; }
.panel.active { display: block; }

.entities { margin-top: 16px; }
.entities-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.entities .search { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); }
.entities .search input { border: none; outline: none; background: transparent; color: var(--fg); width: 220px; }
.range-wrap { display: inline-flex; gap: 8px; align-items: center; }
.range { accent-color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.entities-table { width: 100%; border-collapse: collapse; }
.entities-table th, .entities-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; vertical-align: top; }
.entities-table thead th { background: rgba(96, 165, 250, 0.08); text-align: left; }
.entities-table tbody tr:hover { background: rgba(96, 165, 250, 0.06); }
.entities-table tbody tr.empty td { text-align: center; color: var(--fg-muted); padding: 20px; }

.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 8px; }

.toaster { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow); }
.toast.error { border-color: #ef4444; color: #fecaca; }
.toast.success { border-color: #22c55e; color: #bbf7d0; }

.link { margin-left: 8px; font-size: 12px; }
.hidden { display: none !important; }

.modal::backdrop { background: rgba(0,0,0,0.5); }
.modal { border: none; border-radius: 12px; padding: 0; }
.modal .modal-content { padding: 16px; background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; min-width: 300px; max-width: 560px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
