/* ======================================================================
   منظومة "إنجاز" — نظام إدارة وتحصيل الإعلانات والإشغالات
   عزبة البرج | تصميم مدني حديث بروح ساحلية
   ====================================================================== */

:root{
  --navy-950:#06232b;
  --navy-900:#0a3540;
  --navy-800:#0e4652;
  --teal-700:#116670;
  --teal-500:#178a8f;
  --teal-400:#2aa7a3;
  --gold-600:#b9862c;
  --gold-500:#d3a13f;
  --gold-300:#e8c576;
  --sand-50:#f7f4ec;
  --sand-100:#efe8d6;
  --sand-200:#e4d9bd;
  --ink-900:#152524;
  --ink-700:#334543;
  --ink-500:#5c6e6c;
  --ink-300:#93a09e;
  --line:#dfd7c2;
  --white:#ffffff;
  --green-600:#1c8a53;
  --green-50:#e9f6ee;
  --red-600:#c8492f;
  --red-50:#fbeae5;
  --amber-50:#fbf1e0;
  --shadow-sm:0 1px 2px rgba(10,40,45,.06);
  --shadow-md:0 6px 20px -6px rgba(10,53,64,.18);
  --shadow-lg:0 20px 45px -18px rgba(6,35,43,.35);
  --radius-lg:20px;
  --radius-md:14px;
  --radius-sm:10px;
  --font-display:'Cairo', 'Tajawal', sans-serif;
  --font-body:'Tajawal', 'Cairo', sans-serif;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  font-family:var(--font-body);
  background:var(--sand-50);
  color:var(--ink-900);
  direction:rtl;
  min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4,.font-display{ font-family:var(--font-display); }
button{ font-family:inherit; }
::selection{ background:var(--gold-300); color:var(--navy-950); }

/* focus visibility */
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible{
  outline:2.5px solid var(--teal-500);
  outline-offset:2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration:0.001ms !important; animation-iteration-count:1 !important; transition-duration:0.001ms !important; }
}

.hidden{ display:none !important; }
.app-shell{ min-height:100vh; display:flex; flex-direction:column; }

/* ---------------------------------------------------------------- */
/* Wave motif — signature element, echoes the coastal town           */
/* ---------------------------------------------------------------- */
.wave-divider{ display:block; width:100%; line-height:0; }
.wave-divider svg{ width:100%; height:auto; display:block; }

/* ---------------------------------------------------------------- */
/* Gate screen                                                       */
/* ---------------------------------------------------------------- */
.gate{
  min-height:100vh;
  background:
    radial-gradient(1100px 480px at 12% -10%, rgba(211,161,63,.18), transparent 60%),
    linear-gradient(160deg, var(--navy-950), var(--navy-900) 55%, var(--teal-700));
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:48px 20px 0;
  color:var(--white);
  position:relative;
  overflow:hidden;
}
.gate-emblem{
  width:84px; height:84px; border-radius:50%;
  background:radial-gradient(circle at 35% 30%, var(--gold-300), var(--gold-600) 70%);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 0 0 6px rgba(255,255,255,.08), var(--shadow-lg);
  margin-bottom:22px;
}
.gate-emblem svg{ width:42px; height:42px; }
.gate-eyebrow{
  font-size:13px; letter-spacing:.14em; color:var(--gold-300);
  text-transform:uppercase; font-weight:700; margin-bottom:6px;
}
.gate h1{
  font-size:clamp(28px,5vw,40px); margin:0 0 6px; font-weight:800;
  text-align:center;
}
.gate p.gate-sub{
  color:rgba(255,255,255,.72); margin:0 0 34px; text-align:center; max-width:420px;
  font-size:15px; line-height:1.7;
}
.gate-cards{
  display:grid; grid-template-columns:1fr 1fr; gap:16px; width:100%;
  max-width:520px; margin-bottom:40px;
}
@media (max-width:520px){ .gate-cards{ grid-template-columns:1fr; } }
.gate-card{
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.14);
  border-radius:var(--radius-lg);
  padding:26px 18px;
  text-align:center;
  cursor:pointer;
  color:var(--white);
  backdrop-filter:blur(6px);
  transition:transform .18s ease, background .18s ease, border-color .18s ease;
}
.gate-card:hover{ transform:translateY(-4px); background:rgba(255,255,255,.1); border-color:rgba(211,161,63,.55); }
.gate-card .gc-icon{
  width:52px; height:52px; margin:0 auto 14px; border-radius:14px;
  background:linear-gradient(145deg, var(--teal-400), var(--teal-700));
  display:flex; align-items:center; justify-content:center;
}
.gate-card.admin .gc-icon{ background:linear-gradient(145deg, var(--gold-300), var(--gold-600)); }
.gate-card .gc-icon svg{ width:26px; height:26px; stroke:var(--white); }
.gate-card h3{ margin:0 0 4px; font-size:17px; }
.gate-card p{ margin:0; font-size:12.5px; color:rgba(255,255,255,.62); }
.gate .wave-divider{ position:absolute; bottom:0; right:0; left:0; opacity:.9; }
.gate .wave-fill{ fill:var(--sand-50); }

/* ---------------------------------------------------------------- */
/* Login                                                              */
/* ---------------------------------------------------------------- */
.login-screen{
  min-height:100vh; background:var(--sand-50);
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.login-card{
  width:100%; max-width:380px; background:var(--white);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-lg);
  overflow:hidden; border:1px solid var(--line);
}
.login-top{
  background:linear-gradient(135deg, var(--navy-900), var(--teal-700));
  padding:26px 24px 22px; color:var(--white); position:relative;
}
.login-top button.back-btn{
  position:absolute; top:16px; right:16px; background:rgba(255,255,255,.14);
  border:none; color:var(--white); width:32px; height:32px; border-radius:50%;
  display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.login-top h2{ margin:6px 0 2px; font-size:19px; }
.login-top p{ margin:0; font-size:12.5px; color:rgba(255,255,255,.7); }
.login-body{ padding:22px 24px 26px; }
.field{ margin-bottom:16px; }
.field label{
  display:block; font-size:12.5px; font-weight:700; color:var(--ink-700);
  margin-bottom:6px; letter-spacing:.01em;
}
.field .hint{ font-size:11.5px; color:var(--ink-300); margin-top:4px; }
input, select, textarea{
  width:100%; padding:11px 13px; border-radius:var(--radius-sm);
  border:1.5px solid var(--line); font-size:14.5px; color:var(--ink-900);
  background:var(--white); font-family:inherit; text-align:right;
  transition:border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus{
  border-color:var(--teal-500); box-shadow:0 0 0 3px rgba(23,138,143,.14); outline:none;
}
input[readonly]{ background:var(--sand-100); color:var(--ink-500); cursor:not-allowed; }
select{ appearance:none; -webkit-appearance:none;
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c6e6c' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat:no-repeat; background-position:left 12px center; padding-left:34px;
}

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:12px 18px; border-radius:var(--radius-sm); border:none;
  font-weight:700; font-size:14.5px; cursor:pointer; width:100%;
  transition:filter .15s ease, transform .1s ease;
}
.btn:active{ transform:scale(.98); }
.btn-primary{ background:var(--teal-700); color:var(--white); }
.btn-primary:hover{ filter:brightness(1.08); }
.btn-gold{ background:linear-gradient(135deg, var(--gold-500), var(--gold-600)); color:var(--white); }
.btn-gold:hover{ filter:brightness(1.06); }
.btn-outline{ background:transparent; border:1.5px solid var(--line); color:var(--ink-700); }
.btn-outline:hover{ background:var(--sand-100); }
.btn-success{ background:var(--green-600); color:var(--white); }
.btn-success:hover{ filter:brightness(1.08); }
.btn-danger{ background:var(--red-600); color:var(--white); }
.btn-sm{ width:auto; padding:8px 14px; font-size:13px; }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn svg{ width:17px; height:17px; }

.login-demo-note{
  margin-top:16px; background:var(--amber-50); border:1px dashed var(--gold-500);
  border-radius:var(--radius-sm); padding:10px 12px; font-size:12px; color:var(--gold-600); text-align:center;
}

/* ---------------------------------------------------------------- */
/* App bar (shared)                                                   */
/* ---------------------------------------------------------------- */
.app-bar{
  background:linear-gradient(120deg, var(--navy-950), var(--navy-800));
  color:var(--white); position:sticky; top:0; z-index:40;
  box-shadow:var(--shadow-md);
}
.app-bar-inner{
  max-width:1180px; margin:0 auto; padding:12px 18px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}
.app-bar-brand{ display:flex; align-items:center; gap:10px; }
.app-bar-mark{
  width:36px; height:36px; border-radius:10px;
  background:linear-gradient(145deg, var(--gold-300), var(--gold-600));
  display:flex; align-items:center; justify-content:center; flex:none;
}
.app-bar-mark svg{ width:19px; height:19px; }
.app-bar-titles{ line-height:1.15; }
.app-bar-titles strong{ display:block; font-size:15px; font-family:var(--font-display); }
.app-bar-titles span{ font-size:11px; color:rgba(255,255,255,.6); }
.app-bar-user{ display:flex; align-items:center; gap:10px; }
.role-badge{
  background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.18);
  padding:6px 12px; border-radius:999px; font-size:12.5px; display:flex; align-items:center; gap:6px;
}
.role-badge svg{ width:14px; height:14px; }
.icon-btn{
  background:rgba(255,255,255,.1); border:1px solid rgba(255,255,255,.16); color:var(--white);
  width:34px; height:34px; border-radius:10px; display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.icon-btn:hover{ background:rgba(255,255,255,.18); }
.icon-btn svg{ width:17px; height:17px; }

.page{ max-width:1180px; margin:0 auto; padding:20px 16px 90px; width:100%; }

/* ---------------------------------------------------------------- */
/* Cards, sections                                                    */
/* ---------------------------------------------------------------- */
.card{
  background:var(--white); border-radius:var(--radius-lg); border:1px solid var(--line);
  box-shadow:var(--shadow-sm); padding:20px; margin-bottom:18px;
}
.card-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:10px; flex-wrap:wrap; }
.card-head h3{ margin:0; font-size:16px; display:flex; align-items:center; gap:8px; }
.card-head h3 svg{ width:18px; height:18px; stroke:var(--teal-700); }
.section-label{
  font-size:11.5px; font-weight:800; letter-spacing:.08em; color:var(--gold-600);
  text-transform:uppercase; margin:22px 0 10px; display:flex; align-items:center; gap:8px;
}
.section-label:first-child{ margin-top:0; }
.section-label::after{ content:''; flex:1; height:1px; background:var(--line); }
.grid-2{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.grid-3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; }
@media (max-width:640px){ .grid-2, .grid-3{ grid-template-columns:1fr; } }

.chip{
  display:inline-flex; align-items:center; gap:6px; padding:4px 10px; border-radius:999px;
  font-size:11.5px; font-weight:700;
}
.chip-premium{ background:var(--amber-50); color:var(--gold-600); border:1px solid var(--gold-300); }
.chip-standard{ background:var(--sand-100); color:var(--ink-500); border:1px solid var(--line); }

/* Info banner inside collector form for last-collection lookup */
.info-banner{
  border-radius:var(--radius-sm); padding:10px 12px; font-size:12.5px; margin:-4px 0 14px;
  display:flex; align-items:center; gap:8px;
}
.info-banner.ok{ background:var(--green-50); color:var(--green-600); }
.info-banner.warn{ background:var(--red-50); color:var(--red-600); }
.info-banner svg{ width:15px; height:15px; flex:none; }

.highlight-box{
  background:var(--navy-950); color:var(--white); border-radius:var(--radius-md);
  padding:14px 16px; display:flex; align-items:center; justify-content:space-between; margin-top:4px;
}
.highlight-box .hb-label{ font-size:12px; color:rgba(255,255,255,.65); }
.highlight-box .hb-value{ font-family:var(--font-display); font-weight:800; font-size:22px; color:var(--gold-300); }

.photo-upload{
  border:1.5px dashed var(--line); border-radius:var(--radius-sm); padding:14px;
  text-align:center; cursor:pointer; font-size:12.5px; color:var(--ink-500);
  background:var(--sand-50); position:relative; overflow:hidden;
}
.photo-upload.has-img{ padding:0; border-style:solid; }
.photo-upload img{ width:100%; max-height:160px; object-fit:cover; display:block; }
.photo-upload input[type=file]{ position:absolute; inset:0; opacity:0; cursor:pointer; }
.photo-upload .pu-remove{
  position:absolute; top:6px; left:6px; background:rgba(6,35,43,.7); color:#fff; border:none;
  width:26px; height:26px; border-radius:50%; display:flex; align-items:center; justify-content:center; cursor:pointer; z-index:2;
}

/* sticky save bar (collector, mobile) */
.save-bar{
  position:sticky; bottom:0; background:linear-gradient(0deg, var(--sand-50) 60%, rgba(247,244,236,0));
  padding:14px 0 6px; margin-top:-6px;
}

/* history table */
.table-wrap{ overflow-x:auto; border-radius:var(--radius-md); border:1px solid var(--line); }
table{ width:100%; border-collapse:collapse; font-size:13px; min-width:560px; }
thead th{
  background:var(--navy-950); color:rgba(255,255,255,.85); text-align:right; padding:10px 12px;
  font-size:11.5px; letter-spacing:.03em; font-weight:700; white-space:nowrap;
}
tbody td{ padding:10px 12px; border-bottom:1px solid var(--line); color:var(--ink-700); white-space:nowrap; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:var(--sand-50); cursor:pointer; }
.empty-row td{ text-align:center; color:var(--ink-300); padding:26px; cursor:default; }
.empty-row:hover{ background:transparent; }

/* ---------------------------------------------------------------- */
/* Admin dashboard                                                    */
/* ---------------------------------------------------------------- */
.kpi-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:14px; margin-bottom:18px; }
@media (max-width:900px){ .kpi-grid{ grid-template-columns:1fr 1fr; } }
@media (max-width:480px){ .kpi-grid{ grid-template-columns:1fr; } }
.kpi-card{
  background:var(--white); border:1px solid var(--line); border-radius:var(--radius-lg);
  padding:18px; box-shadow:var(--shadow-sm); position:relative; overflow:hidden;
}
.kpi-card::before{
  content:''; position:absolute; inset:0 0 auto 0; height:3px;
  background:linear-gradient(90deg, var(--teal-500), var(--gold-500));
}
.kpi-icon{
  width:36px; height:36px; border-radius:10px; background:var(--sand-100);
  display:flex; align-items:center; justify-content:center; margin-bottom:10px;
}
.kpi-icon svg{ width:18px; height:18px; stroke:var(--teal-700); }
.kpi-value{ font-family:var(--font-display); font-size:24px; font-weight:800; color:var(--navy-950); }
.kpi-label{ font-size:12px; color:var(--ink-500); margin-top:2px; }

.filters-row{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.filters-row select, .filters-row input{ width:auto; min-width:140px; flex:1; }

.progress-track{ background:var(--sand-100); border-radius:999px; height:8px; overflow:hidden; }
.progress-fill{ height:100%; background:linear-gradient(90deg, var(--teal-500), var(--gold-500)); border-radius:999px; }

/* modal */
.modal-overlay{
  position:fixed; inset:0; background:rgba(6,26,32,.55); display:flex; align-items:center;
  justify-content:center; padding:20px; z-index:100; backdrop-filter:blur(2px);
}
.modal-box{
  background:var(--white); border-radius:var(--radius-lg); width:100%; max-width:460px;
  max-height:88vh; overflow-y:auto; box-shadow:var(--shadow-lg);
}
.modal-head{
  background:linear-gradient(135deg, var(--navy-900), var(--teal-700)); color:var(--white);
  padding:18px 20px; border-radius:var(--radius-lg) var(--radius-lg) 0 0; position:relative;
}
.modal-head .modal-close{
  position:absolute; top:14px; left:16px; background:rgba(255,255,255,.14); border:none; color:#fff;
  width:28px; height:28px; border-radius:50%; cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.modal-head h3{ margin:0 0 3px; font-size:17px; }
.modal-head p{ margin:0; font-size:12px; color:rgba(255,255,255,.7); }
.modal-body{ padding:18px 20px 22px; }
.receipt-seal{
  width:64px; height:64px; margin:0 auto 10px; border-radius:50%;
  border:2px dashed var(--gold-500); display:flex; align-items:center; justify-content:center; color:var(--gold-600);
}
.receipt-seal svg{ width:30px; height:30px; }
.detail-row{ display:flex; justify-content:space-between; padding:9px 0; border-bottom:1px dashed var(--line); font-size:13.5px; gap:12px; }
.detail-row:last-child{ border-bottom:none; }
.detail-row .dr-label{ color:var(--ink-500); flex:none; }
.detail-row .dr-value{ font-weight:700; color:var(--ink-900); text-align:left; }
.detail-photo{ width:100%; border-radius:var(--radius-sm); margin-top:12px; border:1px solid var(--line); }

.toast-wrap{ position:fixed; top:16px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; width:min(92vw,380px); }
.toast{
  background:var(--navy-950); color:#fff; padding:12px 16px; border-radius:var(--radius-sm);
  font-size:13.5px; box-shadow:var(--shadow-lg); display:flex; align-items:center; gap:10px;
  animation:toast-in .25s ease;
}
.toast.success{ background:var(--green-600); }
.toast.error{ background:var(--red-600); }
.toast svg{ width:16px; height:16px; flex:none; }
@keyframes toast-in{ from{ opacity:0; transform:translateY(-8px);} to{ opacity:1; transform:translateY(0);} }

.loading-screen{
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  background:var(--sand-50); gap:14px; color:var(--ink-500); font-size:13px;
}
.spinner{
  width:34px; height:34px; border-radius:50%; border:3px solid var(--sand-200); border-top-color:var(--teal-500);
  animation:spin 0.8s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }

footer.app-footer{
  text-align:center; font-size:11.5px; color:var(--ink-300); padding:18px; border-top:1px solid var(--line);
}

.mode-note{
  display:flex; align-items:flex-start; gap:10px; background:var(--sand-100); border:1px solid var(--line);
  border-radius:var(--radius-sm); padding:10px 12px; font-size:12px; color:var(--ink-500); margin-bottom:16px;
}
.mode-note svg{ width:16px; height:16px; flex:none; margin-top:1px; stroke:var(--teal-700); }

/* ---------------------------------------------------------------- */
/* Facility registry — Excel-linked shop profile (collector side)     */
/* ---------------------------------------------------------------- */
.registry-card{
  border:1px solid var(--line); border-radius:var(--radius-md); background:var(--sand-50);
  padding:14px; margin:-2px 0 16px; display:flex; gap:14px;
}
.registry-card .rc-photo{
  width:84px; height:84px; border-radius:var(--radius-sm); object-fit:cover; flex:none;
  border:1px solid var(--line); background:var(--sand-100);
}
.registry-card .rc-photo-empty{
  width:84px; height:84px; border-radius:var(--radius-sm); flex:none; background:var(--sand-100);
  border:1px dashed var(--line); display:flex; align-items:center; justify-content:center; color:var(--ink-300);
}
.registry-card .rc-photo-empty svg{ width:26px; height:26px; }
.registry-card .rc-body{ flex:1; min-width:0; }
.registry-card .rc-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; margin-bottom:4px; }
.registry-card .rc-name{ font-family:var(--font-display); font-weight:800; font-size:14.5px; color:var(--navy-950); }
.registry-card .rc-owner{ font-size:12.5px; color:var(--ink-500); margin-bottom:6px; }
.registry-card .rc-meta{ display:flex; flex-wrap:wrap; gap:6px; font-size:11.5px; }
.registry-source{
  display:flex; align-items:center; gap:6px; font-size:11px; color:var(--teal-700); font-weight:700; margin-bottom:8px;
}
.registry-source svg{ width:13px; height:13px; }

.risk-badge{ display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:999px; font-size:11px; font-weight:700; }
.risk-low{ background:var(--green-50); color:var(--green-600); }
.risk-mid{ background:var(--amber-50); color:var(--gold-600); }
.risk-high{ background:var(--red-50); color:var(--red-600); }
.risk-unknown{ background:var(--sand-100); color:var(--ink-500); }
.env-badge{ display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:999px; font-size:11px; font-weight:700; }
.env-badge-ok{ background:var(--green-50); color:var(--green-600); }
.env-badge-warn{ background:var(--amber-50); color:var(--gold-600); }

/* facility directory (admin) */
.facility-toolbar{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.facility-toolbar select, .facility-toolbar input{ flex:1; min-width:140px; }
.facility-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(190px,1fr)); gap:12px; }
.facility-card{
  border:1px solid var(--line); border-radius:var(--radius-md); overflow:hidden; cursor:pointer;
  background:var(--white); transition:transform .15s ease, box-shadow .15s ease;
}
.facility-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow-md); }
.facility-card .fc-photo{ width:100%; height:110px; object-fit:cover; display:block; background:var(--sand-100); }
.facility-card .fc-photo-empty{
  width:100%; height:110px; display:flex; align-items:center; justify-content:center; background:var(--sand-100); color:var(--ink-300);
}
.facility-card .fc-photo-empty svg{ width:30px; height:30px; }
.facility-card .fc-body{ padding:10px 12px 12px; }
.facility-card .fc-name{ font-size:13px; font-weight:800; color:var(--navy-950); margin-bottom:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.facility-card .fc-owner{ font-size:11.5px; color:var(--ink-500); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-bottom:6px; }
.facility-empty-note{ text-align:center; color:var(--ink-300); font-size:13px; padding:30px 10px; }
.detail-photo-lg{ width:100%; border-radius:var(--radius-sm); margin-bottom:14px; border:1px solid var(--line); max-height:220px; object-fit:cover; }
