:root {
  --ink: #17211d;
  --muted: #68756f;
  --line: #dfe6e2;
  --paper: #ffffff;
  --canvas: #f3f6f3;
  --green: #176b4b;
  --green-dark: #0e5138;
  --green-soft: #e7f2ec;
  --amber: #a45b16;
  --shadow: 0 18px 48px rgba(26, 45, 36, .09);
  font-family: Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; background: #10281f; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; margin: 0 8px 42px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; background: #d8aa5b; color: #183126; font-size: 22px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 20px; }
.brand small { color: #a9bdb4; margin-top: 3px; }
.nav-title { padding: 0 12px; color: #829a90; font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.nav-item { width: 100%; border: 0; background: transparent; color: #b9c9c2; padding: 13px 14px; display: flex; align-items: center; gap: 11px; border-radius: 11px; text-align: right; margin-bottom: 6px; }
.nav-item span { font-size: 22px; }
.nav-item small { margin-right: auto; color: #759084; }
.nav-item.active { background: rgba(255,255,255,.1); color: #fff; }
.privacy-note { margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; display: flex; gap: 10px; align-items: center; }
.privacy-note strong, .privacy-note small { display: block; }
.privacy-note strong { font-size: 13px; }
.privacy-note small { color: #91a89e; margin-top: 3px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #56d89b; box-shadow: 0 0 0 5px rgba(86,216,155,.12); }
main { width: min(1500px, 100%); padding: 38px 44px 70px; margin: 0 auto; }
.topbar, .section-heading, .search-actions, .results-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.topbar { margin-bottom: 28px; }
.eyebrow { margin: 0 0 5px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.03em; }
h2 { margin-bottom: 6px; font-size: 20px; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: 14px; }
code { direction: ltr; display: inline-block; background: #edf1ef; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; }
.dataset-badge { border: 1px solid var(--line); padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.72); color: var(--muted); font-size: 13px; }
.search-card, .results-card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.search-card { padding: 24px; margin-bottom: 24px; }
.filters { display: grid; gap: 10px; margin: 22px 0 18px; }
.filter-row { display: grid; grid-template-columns: minmax(190px, .75fr) minmax(260px, 1.5fr) 40px; gap: 10px; align-items: end; }
label > span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin: 0 4px 6px; }
select, input { width: 100%; height: 44px; border: 1px solid #ccd7d1; border-radius: 9px; background: #fff; padding: 0 12px; color: var(--ink); outline: none; }
select:focus, input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,75,.11); }
.remove-filter, .icon-button { border: 0; background: transparent; color: #7d8883; font-size: 25px; border-radius: 8px; }
.remove-filter { height: 44px; }
.remove-filter:hover, .icon-button:hover { background: #f0f3f1; color: #b43c32; }
.primary-button, .secondary-button, .ghost-button { min-height: 42px; border-radius: 9px; padding: 0 17px; font-weight: 700; border: 1px solid transparent; }
.primary-button { background: var(--green); color: #fff; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .6; }
.secondary-button { background: var(--green-soft); border-color: #c9e0d4; color: var(--green-dark); }
.ghost-button { background: transparent; color: var(--muted); }
.search-actions { justify-content: flex-start; flex-wrap: wrap; border-top: 1px solid #edf0ee; padding-top: 18px; }
.example { color: var(--muted); font-size: 12px; margin-right: auto; }
.results-card { overflow: hidden; }
.results-heading { padding: 22px 24px; }
.right-click-hint { padding: 7px 10px; border-radius: 7px; background: #f4eee4; color: #7e521e; font-size: 12px; }
.table-wrap { overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 1050px; text-align: right; }
th { padding: 12px 15px; color: var(--muted); background: #f7f9f7; font-size: 12px; white-space: nowrap; }
td { padding: 13px 15px; border-top: 1px solid #edf0ee; font-size: 13px; vertical-align: top; }
tbody tr[data-row-id] { cursor: default; }
tbody tr[data-row-id]:hover { background: #f5faf7; }
.person-name { font-weight: 800; white-space: nowrap; }
.subtle { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.row-action { border: 0; background: transparent; color: var(--green); font-size: 18px; border-radius: 6px; }
.empty-row td { text-align: center; padding: 65px 20px; color: var(--muted); }
.empty-row strong, .empty-row span { display: block; }
.empty-row strong { color: var(--ink); margin: 8px 0 5px; }
.empty-icon { font-size: 35px; color: #a6b7af; }
.load-more-wrap { text-align: center; padding: 16px; border-top: 1px solid var(--line); }
.backdrop { position: fixed; inset: 0; background: rgba(10, 24, 18, .45); z-index: 20; backdrop-filter: blur(2px); }
.drawer { position: fixed; z-index: 21; inset: 0 0 0 auto; width: min(620px, 96vw); background: #fff; transform: translateX(105%); transition: transform .22s ease; box-shadow: -20px 0 60px rgba(0,0,0,.2); overflow: auto; }
.drawer.open { transform: translateX(0); }
.drawer-header { position: sticky; top: 0; z-index: 2; padding: 24px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(8px); }
.drawer-header h2 { font-size: 25px; margin: 0; }
.drawer-body { padding: 24px; }
.details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.detail { background: #fff; padding: 13px; min-height: 70px; }
.detail span { display: block; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.detail b { word-break: break-word; }
.relation-section { margin-bottom: 26px; }
.relation-section h3 { margin: 0 0 10px; }
.relation-card { border: 1px solid var(--line); border-radius: 10px; padding: 13px; margin-bottom: 8px; background: #fff; }
.relation-card button { float: left; border: 0; background: var(--green-soft); color: var(--green); border-radius: 6px; padding: 5px 9px; }
.relation-empty { padding: 20px; border: 1px dashed #ccd7d1; border-radius: 10px; color: var(--muted); text-align: center; }
.evidence { padding: 11px; background: #f5f7f5; color: var(--muted); border-radius: 8px; font-size: 12px; margin-bottom: 18px; }
.context-menu { position: fixed; z-index: 30; width: 240px; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 16px 42px rgba(0,0,0,.2); }
.context-menu button { display: block; width: 100%; border: 0; background: transparent; padding: 10px 11px; text-align: right; border-radius: 7px; color: var(--ink); }
.context-menu button:hover { background: var(--green-soft); color: var(--green-dark); }
.context-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px; }
.token-dialog { border: 0; border-radius: 18px; box-shadow: 0 25px 80px rgba(0,0,0,.3); padding: 0; }
.token-dialog::backdrop { background: rgba(8, 20, 15, .7); backdrop-filter: blur(5px); }
.token-dialog form { width: min(390px, 90vw); padding: 32px; text-align: center; }
.token-dialog input, .token-dialog button { margin-top: 13px; width: 100%; }
.token-dialog small { display: block; min-height: 18px; color: #ad332b; margin-top: 10px; }
.lock-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: auto auto 16px; background: var(--green-soft); color: var(--green); border-radius: 50%; }
.toast { position: fixed; z-index: 40; bottom: 24px; left: 24px; max-width: 420px; padding: 13px 17px; border-radius: 9px; background: #17211d; color: #fff; box-shadow: var(--shadow); }
.skeleton { height: 14px; border-radius: 7px; background: linear-gradient(90deg,#edf1ef,#f8faf9,#edf1ef); background-size: 200% 100%; animation: shimmer 1.2s infinite; margin: 12px 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 850px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 15px 18px; flex-direction: row; align-items: center; }
  .brand { margin: 0; }
  .sidebar nav, .privacy-note { display: none; }
  main { padding: 25px 16px 50px; }
  .topbar { align-items: flex-start; }
  .dataset-badge { display: none; }
  .filter-row { grid-template-columns: 1fr 40px; }
  .filter-row label:first-child, .value-label { grid-column: 1; }
  .remove-filter { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .section-heading { align-items: flex-start; }
  .right-click-hint, .example { display: none; }
  .details-grid { grid-template-columns: 1fr; }
}
