:root {
  --bg: #08110e;
  --bg-elev: #0f1814;
  --bg-soft: #16201b;
  --line: rgba(236, 240, 232, 0.12);
  --text: #f2f5ef;
  --muted: #93a096;
  --accent: #d6ff6b;
  --accent-2: #4fd6c4;
  --warn: #ffc857;
  --radius: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: "Archivo", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
  --font-ar: "Noto Sans Arabic", "Archivo", system-ui, sans-serif;
  --page-pad-x: 1.15rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  overflow-x: clip;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
}
body.locale-ar {
  font-family: var(--font-ar);
}
body.locale-ar .brand {
  font-family: var(--font-ar);
  letter-spacing: 0;
  font-size: clamp(1.35rem, 6.2vw, 2.75rem);
  line-height: 1.08;
}
html[dir="rtl"] .search-row {
  padding: 0.35rem 1.2rem 0.35rem 0.45rem;
}
html[dir="rtl"] .loading-dot::after {
  margin-left: 0;
  margin-right: 0.45rem;
}
html[dir="rtl"] .detail-block ul {
  padding-left: 0;
  padding-right: 1.2rem;
}
html[dir="rtl"] .rel-item,
html[dir="rtl"] .rel-btn {
  text-align: right;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(100% 70% at 0% 0%, rgba(79, 214, 196, 0.18), transparent 50%),
    radial-gradient(90% 60% at 100% 10%, rgba(214, 255, 107, 0.12), transparent 45%),
    linear-gradient(180deg, #08110e 0%, #0a1411 55%, #07100d 100%);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 0.85rem;
  width: 100%;
  max-width: 100%;
  padding:
    calc(1.1rem + var(--safe-t))
    calc(var(--page-pad-x) + var(--safe-r))
    1rem
    calc(var(--page-pad-x) + var(--safe-l));
  background: linear-gradient(180deg, rgba(8,17,14,0.98), rgba(8,17,14,0.82) 75%, transparent);
}

.brand-block {
  flex: 1 1 10rem;
  min-width: 0;
  max-width: 100%;
}

.brand {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--display);
  font-size: clamp(1.85rem, 9vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-align: start;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  max-width: 100%;
}
.brand:focus-visible {
  outline: 2px solid var(--accent, #c8e6c9);
  outline-offset: 4px;
}
.tagline {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 3.6vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin-inline-start: auto;
  max-width: 100%;
}

.filter-btn, .text-btn, .primary, .clear-btn, .lang-btn, .share-btn, .country-chevron {
  font: inherit;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: inherit;
}
.lang-btn {
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  white-space: nowrap;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 800;
}
.lang-btn .flag { font-size: 1.1rem; line-height: 1; }
.lang-btn .lang-code { letter-spacing: 0.04em; }
.filter-btn {
  position: relative;
  min-height: 44px;
  padding: 0 0.9rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  white-space: nowrap;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  font-size: 0.98rem;
  font-weight: 800;
}
.share-btn {
  min-height: 48px;
  padding: 0 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  white-space: nowrap;
  background: rgba(79, 214, 196, 0.14);
  border: 1px solid rgba(79, 214, 196, 0.35);
  color: var(--accent-2);
  font-size: 0.95rem;
  font-weight: 800;
}
.sheet-close {
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  margin: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(236, 240, 232, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sheet-close span {
  display: block;
  margin-top: -0.08em;
  font-size: 1em;
  line-height: 1;
  font-weight: 800;
}
.sheet-close:active {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(0.96);
}
.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-inline-start: auto;
  max-width: none;
}
.filter-btn .badge {
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #08110e;
  font-size: 0.8rem; font-weight: 800;
  display: grid; place-items: center;
}

.shell {
  padding:
    0.15rem
    calc(var(--page-pad-x) + var(--safe-r))
    calc(1.8rem + var(--safe-b))
    calc(var(--page-pad-x) + var(--safe-l));
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 480px) {
  .lang-btn {
    min-height: 52px;
    padding: 0 0.9rem;
    font-size: 0.95rem;
  }
  .filter-btn {
    min-height: 52px;
    padding: 0 1.1rem;
    font-size: 1.05rem;
  }
}

@media (max-width: 380px) {
  .top {
    gap: 0.65rem 0.55rem;
  }
  .lang-btn {
    padding: 0 0.55rem;
    gap: 0.25rem;
  }
  .filter-btn {
    padding: 0 0.7rem;
    font-size: 0.9rem;
  }
}

.search-panel { margin-top: 0.35rem; }
.search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 72px;
  padding: 0.35rem 0.45rem 0.35rem 1.2rem;
  border-radius: 28px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(214, 255, 107, 0.28);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}
.search-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(214, 255, 107, 0.14), 0 18px 50px rgba(0,0,0,0.35);
}
#q {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 700;
  min-width: 0;
  letter-spacing: -0.02em;
}
#q::placeholder { color: #6f7b71; font-weight: 600; }
.clear-btn {
  min-height: 52px;
  padding: 0 1rem;
  border-radius: 999px;
  color: #08110e;
  background: var(--accent);
  font-size: 0.95rem;
  font-weight: 800;
}

.country-picker {
  position: relative;
  margin-top: 0.95rem;
  z-index: 15;
}
.country-label {
  display: block;
  margin: 0 0 0.45rem 0.15rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.country-combo {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 56px;
  padding: 0.2rem 0.35rem 0.2rem 1rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
html[dir="rtl"] .country-combo {
  padding: 0.2rem 1rem 0.2rem 0.35rem;
}
.country-combo:focus-within {
  border-color: rgba(79, 214, 196, 0.45);
  box-shadow: 0 0 0 3px rgba(79, 214, 196, 0.12);
}
#countrySelect {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
}
#countrySelect::placeholder { color: #6f7b71; font-weight: 600; }
.country-chevron {
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 1rem;
}
.country-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  max-height: min(46vh, 320px);
  overflow: auto;
  border-radius: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0,0,0,0.45);
  -webkit-overflow-scrolling: touch;
}
.country-option {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.country-option:hover,
.country-option.active {
  background: rgba(214, 255, 107, 0.12);
  color: var(--accent);
}
.country-option.selected {
  color: var(--accent-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 40px;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(79, 214, 196, 0.14);
  border: 1px solid rgba(79, 214, 196, 0.3);
  color: var(--accent-2);
  font-size: 0.95rem;
  font-weight: 700;
}
.chip button {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 1.25rem; line-height: 1; padding: 0 0.1rem;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.25rem 0 0.85rem;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
}
#cacheMeta { color: var(--accent-2); }

.browse-summary {
  margin: 0 0 1rem;
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(214,255,107,0.12), rgba(79,214,196,0.08));
  border: 1px solid rgba(214,255,107,0.22);
  animation: rise 0.35s ease both;
}
.browse-summary .total {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 10vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  font-weight: 700;
  color: var(--accent);
}
.browse-summary .total-label {
  margin: 0.35rem 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}
.browse-summary .breakdown {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.45;
}

.facet-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 1.1rem;
}
.facet {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 48px;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
}
.facet .n {
  min-width: 1.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--accent-2);
}
.facet.active {
  background: rgba(214, 255, 107, 0.18);
  border-color: rgba(214, 255, 107, 0.5);
  color: var(--accent);
}
.facet.active .n {
  background: rgba(8,17,14,0.35);
  color: var(--accent);
}
.facet-label {
  width: 100%;
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.rel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.rel-item, .rel-btn {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: inherit;
  font: inherit;
}
.rel-btn { cursor: pointer; }
.rel-btn:active { transform: scale(0.99); }
.rel-pred {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.rel-obj {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.rel-type {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.results { display: grid; gap: 0.75rem; }

.pager {
  margin: 1.25rem 0 0.5rem;
}
.load-more {
  width: 100%;
  min-height: 60px;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(214, 255, 107, 0.35);
  background: rgba(214, 255, 107, 0.14);
  color: var(--accent);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}
.load-more:active { transform: scale(0.98); }
.load-more:disabled {
  opacity: 0.55;
  cursor: wait;
}
.result {
  width: 100%;
  text-align: left;
  min-height: 96px;
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--line);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s;
  animation: rise 0.3s ease both;
}
.result:active { transform: scale(0.98); }
.result-name {
  margin: 0;
  font-size: clamp(1.25rem, 5.2vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}
.result-sub {
  margin: 0.65rem 0 0;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
  color: #c9d1c7;
}
.tag.type-Individual { color: #9fd4ff; border-color: rgba(159,212,255,0.28); }
.tag.type-Entity { color: var(--accent); border-color: rgba(214,255,107,0.3); }
.tag.type-Vessel, .tag.type-Aircraft { color: var(--warn); border-color: rgba(255,200,87,0.3); }

.empty {
  margin: 3rem 0.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
}

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0,0,0,0.6);
  animation: fade 0.2s ease;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  max-height: min(90vh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: 28px 28px 0 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-bottom: 0;
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: var(--safe-b);
}
.sheet.open { transform: translateY(0); }
.sheet.detail { max-height: min(94vh, 940px); }
.sheet-handle {
  width: 48px; height: 5px; border-radius: 999px;
  background: rgba(255,255,255,0.22);
  margin: 0.75rem auto 0.25rem;
}
.sheet-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 0.75rem;
  padding: 0.7rem calc(1.2rem + var(--safe-r)) 0.5rem calc(1.2rem + var(--safe-l));
  min-width: 0;
}
.sheet-head h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 5.2vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html[dir="rtl"] .sheet-head h2 {
  letter-spacing: 0;
}
.text-btn {
  color: var(--accent-2);
  font-weight: 800;
  font-size: 1.05rem;
  min-height: 44px;
  padding: 0 0.4rem;
}
.sheet-body {
  overflow: auto;
  padding: 0.5rem 1.2rem 1.2rem;
  -webkit-overflow-scrolling: touch;
}
.sheet-foot {
  padding: 0.85rem 1.2rem calc(1rem + var(--safe-b));
  border-top: 1px solid var(--line);
}
.primary {
  width: 100%;
  min-height: 60px;
  padding: 1rem;
  border-radius: 18px;
  background: var(--accent);
  color: #08110e;
  font-weight: 800;
  font-size: 1.25rem;
}

fieldset { border: 0; margin: 0 0 1.4rem; padding: 0; }
legend {
  margin-bottom: 0.7rem;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.pill-grid { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.pill-grid.compact { margin-top: 0.7rem; }
.pill {
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.pill.active {
  background: rgba(214, 255, 107, 0.18);
  border-color: rgba(214, 255, 107, 0.5);
  color: var(--accent);
}
#countryInput, #programInput {
  width: 100%;
  min-height: 56px;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  outline: none;
}
#countryInput:focus, #programInput:focus {
  border-color: rgba(79, 214, 196, 0.5);
}

.detail-grid { display: grid; gap: 1.15rem; }
.detail-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.detail-block p, .detail-block ul {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
}
.detail-block ul { padding-left: 1.2rem; color: #d8dfd4; }
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.55rem 0.85rem;
  font-size: 1.1rem;
  font-weight: 600;
}
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; word-break: break-word; }

.skeleton {
  height: 180px;
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.loading-dot::after {
  content: "";
  display: inline-block;
  width: 0.55rem; height: 0.55rem; margin-left: 0.45rem;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 0.9s ease infinite;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}
