/* ============================================================
   Madinet Masr — design system
   ============================================================ */
:root {
  --red: #d6232a;
  --red-dark: #a81a20;
  --ink: #14161a;
  --ink-2: #2a2e35;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-soft-2: #eef1f5;
  --green: #16a34a;
  --shadow-sm: 0 1px 2px rgba(16, 18, 22, .06), 0 1px 3px rgba(16, 18, 22, .08);
  --shadow-md: 0 4px 16px rgba(16, 18, 22, .08);
  --shadow-lg: 0 18px 50px rgba(16, 18, 22, .16);
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1200px;
  --header-h: 68px;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .4em; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .76rem; font-weight: 700; color: var(--red); margin-bottom: .8rem; }
section { padding: 72px 0; }
.section-tight { padding: 48px 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  padding: .8em 1.4em; border-radius: 999px; font-weight: 600; font-size: .95rem;
  border: 1px solid transparent; cursor: pointer; transition: .18s ease; white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-light { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.btn-light:hover { background: rgba(255,255,255,.22); }

/* ---- Header / Nav ---- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; letter-spacing: -.02em; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: var(--red); color: #fff; font-weight: 800; font-size: .95rem; letter-spacing: -.04em;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  padding: .5em .9em; border-radius: 8px; font-weight: 500; font-size: .94rem; color: var(--ink-2); transition: .15s;
}
.nav-links a:hover { background: var(--bg-soft); color: var(--ink); }
.nav-links a.active { color: var(--red); font-weight: 600; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 24px; height: 2px; background: var(--ink); border-radius: 2px; transition: .2s; }

/* ---- Hero ---- */
.hero {
  position: relative; color: #fff; padding: 0; overflow: hidden;
  min-height: 78vh; display: flex; align-items: center;
}
.hero::before {
  content: ''; position: absolute; inset: 0; z-index: 0;
  background:
    linear-gradient(115deg, rgba(20,22,26,.92) 0%, rgba(20,22,26,.55) 55%, rgba(214,35,42,.35) 100%),
    url('https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?auto=format&fit=crop&w=1920&q=80') center/cover;
}
.hero .container { position: relative; z-index: 1; padding-top: 80px; padding-bottom: 80px; }
.hero h1 { color: #fff; max-width: 16ch; }
.hero .lede { font-size: 1.2rem; max-width: 48ch; color: rgba(255,255,255,.85); margin-bottom: 2rem; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 40px; margin-top: 3.5rem; flex-wrap: wrap; }
.hero-stats .stat b { font-size: 2rem; display: block; font-weight: 800; letter-spacing: -.03em; }
.hero-stats .stat span { color: rgba(255,255,255,.7); font-size: .88rem; }

/* ---- KPI cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.kpi {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.kpi .k-label { color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .k-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.kpi .k-sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* ---- Cards / grids ---- */
.grid { display: grid; gap: 22px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.panel { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; }
.panel h3 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel .hint { font-size: .8rem; color: var(--muted); font-weight: 400; }

/* ---- Project card ---- */
.project-card {
  border-radius: var(--radius); overflow: hidden; background: var(--bg);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: .22s ease; display: flex; flex-direction: column;
}
.project-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.project-card .pc-img { aspect-ratio: 16/10; position: relative; overflow: hidden; }
.project-card .pc-img img { width: 100%; height: 100%; object-fit: cover; transition: .4s; }
.project-card:hover .pc-img img { transform: scale(1.06); }
.project-card .pc-badge {
  position: absolute; top: 14px; left: 14px; background: rgba(20,22,26,.78); color: #fff;
  padding: 5px 12px; border-radius: 999px; font-size: .78rem; font-weight: 600; backdrop-filter: blur(4px);
}
.project-card .pc-body { padding: 20px; display: flex; flex-direction: column; flex: 1; }
.project-card .pc-loc { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.project-card .pc-name { font-size: 1.3rem; font-weight: 700; }
.project-card .pc-tag { color: var(--muted); font-size: .92rem; margin: 6px 0 16px; }
.project-card .pc-stats { display: flex; gap: 18px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.project-card .pc-stats .s b { display: block; font-weight: 800; font-size: 1.05rem; }
.project-card .pc-stats .s span { font-size: .76rem; color: var(--muted); }

/* ---- Pills / chips ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; background: var(--bg-soft-2); font-size: .76rem; font-weight: 600; color: var(--ink-2); }

/* ---- Phase (sub-project) cards ---- */
.phase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 18px; }
.phase-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); transition: .18s; font-size: .88rem;
}
.phase-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #d8dbe0; }
.phase-card .ph-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.phase-card .ph-top b { font-size: 1.02rem; }
.phase-card .ph-foot { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 600; }

/* ---- Page header band ---- */
.page-band { background: var(--ink); color: #fff; padding: 56px 0 48px; }
.page-band h1 { color: #fff; margin-bottom: .3rem; }
.page-band p { color: rgba(255,255,255,.7); max-width: 60ch; margin: 0; }

/* ---- Filters (listings) ---- */
.listings-layout { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }
.filters { position: sticky; top: calc(var(--header-h) + 16px); }
.filters .fgroup { margin-bottom: 20px; }
.filters label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.filters select, .filters input[type=text], .filters input[type=number], .filters input[type=search] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: .92rem; font-family: inherit; background: var(--bg); color: var(--ink);
}
.filters select:focus, .filters input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(214,35,42,.12); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; cursor: pointer;
  background: var(--bg); transition: .15s; user-select: none;
}
.chip:hover { border-color: var(--ink); }
.chip.on { background: var(--red); color: #fff; border-color: var(--red); }
.range-row { display: flex; gap: 8px; align-items: center; }
.range-row input { flex: 1; }

/* ---- Listings results ---- */
.results-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.results-bar .count b { font-size: 1.1rem; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.unit-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--bg);
  box-shadow: var(--shadow-sm); transition: .18s; cursor: pointer; display: flex; flex-direction: column;
}
.unit-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #d8dbe0; }
.unit-card .uc-top { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 10px; }
.unit-card .uc-type { font-weight: 700; font-size: 1.05rem; }
.unit-card .uc-proj { color: var(--muted); font-size: .84rem; }
.unit-card .uc-price { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; margin: 8px 0; }
.unit-card .uc-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.unit-card .uc-meta span b { font-weight: 700; }
.uc-id { font-size: .72rem; color: var(--muted); margin-top: 8px; font-family: ui-monospace, monospace; }

.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 32px; }
.pager button { padding: 8px 14px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; cursor: pointer; font-weight: 600; }
.pager button:hover:not(:disabled) { border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .pinfo { font-size: .9rem; color: var(--muted); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: var(--bg-soft); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); position: sticky; top: 0; }
table.data tbody tr:hover { background: var(--bg-soft); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,18,22,.55); backdrop-filter: blur(3px); z-index: 100; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 22px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: start; }
.modal-body { padding: 24px; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.spec-grid .spec span { display: block; font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.spec-grid .spec b { font-size: 1.05rem; }

/* ---- Dashboard ---- */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; font-size: .85rem; }
.legend .li { display: flex; align-items: center; gap: 7px; }
.barlist .bl-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; margin-bottom: 10px; font-size: .88rem; }
.barlist .bl-track { background: var(--bg-soft-2); border-radius: 6px; height: 14px; overflow: hidden; }
.barlist .bl-fill { height: 100%; border-radius: 6px; }
.barlist .bl-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.barlist .bl-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Misc ---- */
.split { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: start; }
.feature-list li::before { content: '✓'; color: var(--green); font-weight: 800; }
.cta-band { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 48px; text-align: center; }
.cta-band h2 { color: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .82rem; font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-family: inherit; font-size: .95rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(214,35,42,.12); }
.full { grid-column: 1 / -1; }
.notice { padding: 14px 18px; border-radius: var(--radius-sm); background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; font-weight: 500; }

/* ---- Footer ---- */
.site-footer { background: var(--ink); color: rgba(255,255,255,.72); margin-top: 80px; padding: 56px 0 28px; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.2fr; gap: 32px; }
.footer-grid h4 { color: #fff; font-size: .92rem; margin-bottom: 14px; }
.footer-grid a { display: block; color: rgba(255,255,255,.7); padding: 4px 0; font-size: .9rem; transition: .15s; }
.footer-grid a:hover { color: #fff; }
.footer-brand .brand-text { color: #fff; }
.footer-bottom { margin-top: 36px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.12); font-size: .82rem; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .listings-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .split { grid-template-columns: 1fr; gap: 28px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: #fff; border-bottom: 1px solid var(--line); padding: 12px; gap: 2px; display: none; box-shadow: var(--shadow-md);
  }
  body.nav-open .nav-links { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  section { padding: 48px 0; }
  .cta-band { padding: 32px 20px; }
}
