:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --primary: #0e7c5a;
  --primary-dark: #0a5f45;
  --primary-light: #e7f5ef;
  --text: #16202b;
  --muted: #64748b;
  --border: #e6eaef;
  --warn-bg: #fff4e5;
  --warn-text: #b45309;
  --warn-border: #fdd9a8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Tajawal', system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { width: min(1120px, 92%); margin-inline: auto; }

/* ===== Header ===== */
.site-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(10, 95, 69, .25);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo { font-size: 30px; line-height: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .2)); }
.site-title { font-size: 1.15rem; margin: 0; font-weight: 800; letter-spacing: -.2px; }
.site-subtitle { margin: .25rem 0 0; font-size: .82rem; opacity: .9; font-weight: 400; }
.lang-btn {
  flex: none;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  padding: .5rem 1.05rem;
  font-weight: 700;
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
}
.lang-btn:hover { background: rgba(255, 255, 255, .28); }

/* ===== Controls ===== */
.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}
.search-row { display: flex; gap: 10px; margin-bottom: 14px; }
.search {
  flex: 1;
  min-width: 0;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface-2);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: #fff;
}
.reset-btn {
  flex: none;
  padding: .75rem 1.1rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s, border-color .2s;
}
.reset-btn:hover { color: var(--text); border-color: var(--muted); }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.field select {
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: .95rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== Meta / disclaimer ===== */
.meta-row { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; }
.count { font-weight: 700; color: var(--muted); font-size: .95rem; }
.disclaimer {
  font-size: .82rem;
  color: var(--warn-text);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: .6rem .85rem;
  margin: 0 0 16px;
}

/* ===== Grid / cards ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 26px rgba(16, 24, 40, .10);
  border-color: #d4dde6;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { margin: 0; font-size: 1.06rem; font-weight: 800; color: var(--text); }
.name-sub { font-size: .82rem; color: var(--muted); font-weight: 500; }
.rank {
  flex: none;
  background: linear-gradient(135deg, #fff7e6, #ffedcc);
  color: #92600a;
  border: 1px solid #f7dca0;
  border-radius: 999px;
  padding: .2rem .6rem;
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: .76rem;
  font-weight: 600;
  padding: .28rem .6rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.chip-field { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.chip-sector { background: var(--primary-light); color: var(--primary-dark); border-color: #cdeadd; }
.chip-loc { background: #eef2f7; color: #475569; border-color: #e0e6ee; }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.disc-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.disc {
  font-size: .72rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  border: 1px solid #d8e0e8;
  border-radius: 6px;
  padding: .14rem .45rem;
}
.addr { margin: 0; font-size: .86rem; color: var(--muted); }
.card-foot { margin-top: auto; padding-top: 6px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: .55rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
  transition: background .2s, transform .1s;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: scale(.98); }
.muted { color: var(--muted); font-size: .86rem; font-style: italic; }

/* ===== Empty ===== */
.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 36px;
}

/* ===== Footer ===== */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: 18px;
  margin-top: 20px;
}
.site-footer p { margin: 0; text-align: center; color: var(--muted); font-size: .82rem; }
.site-footer code {
  background: var(--surface-2);
  padding: .1rem .4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: .8rem;
}

/* ===== Responsive ===== */
@media (max-width: 680px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .site-title { font-size: 1rem; }
  .site-subtitle { display: none; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .filters { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; }
  .reset-btn { width: 100%; }
}

/* ===== Card as link (home) ===== */
a.card { text-decoration: none; color: inherit; }
.card-details { margin-top: auto; padding-top: 6px; font-weight: 700; font-size: .9rem; color: var(--primary); }
.card:hover .card-details { color: var(--primary-dark); }

/* ===== Detail page (company.html) ===== */
.brand-link { text-decoration: none; color: inherit; }
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin: 22px 0 32px;
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.detail-name { margin: 0; font-size: 1.5rem; font-weight: 800; color: var(--text); }
.detail-name-en { font-size: .95rem; color: var(--muted); font-weight: 500; }
.detail-section { margin-top: 20px; }
.detail-label {
  margin: 0 0 10px;
  font-size: .82rem;
  font-weight: 800;
  color: var(--primary-dark);
  border-inline-start: 3px solid var(--primary);
  padding-inline-start: 8px;
}
.detail-desc { margin: 0; font-size: 1rem; line-height: 1.9; color: #374151; }
.info-rows { display: flex; flex-direction: column; gap: 10px; }
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem .9rem;
}
.info-icon { font-size: 1.1rem; line-height: 1.4; flex: none; }
.info-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.info-key { font-size: .76rem; color: var(--muted); font-weight: 700; }
.info-val { font-size: .95rem; color: var(--text); word-break: break-word; }
.info-val.link { color: var(--primary); text-decoration: none; }
.info-val.link:hover { text-decoration: underline; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #eef2f7; }
.notfound {
  text-align: center;
  padding: 48px 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin: 22px 0;
}
.notfound h2 { margin: 0 0 8px; color: var(--text); }
.notfound p { margin: 0 0 18px; color: var(--muted); }
