/* ============ نظام متابعة تعويض النفقات — design system ============ */
/* Dark navy identity: bg #07111f, surfaces #0d1b2e, glassmorphism-lite.  */

@font-face {
  font-family: 'Tajawal'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/tajawal-arabic-400-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+08A0-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Tajawal'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/tajawal-arabic-500-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+08A0-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Tajawal'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('/fonts/tajawal-arabic-700-normal.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+08A0-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/tajawal-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/tajawal-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF; }
@font-face { font-family: 'Tajawal'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/tajawal-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF; }

:root {
  --bg: #07111f;
  --surface: #0d1b2e;
  --surface-2: #122238;
  --surface-3: #16283f;
  --line: rgba(120, 170, 255, 0.12);
  --line-strong: rgba(120, 170, 255, 0.22);
  --text: #e8f0fb;
  --text-dim: #8fa3bd;
  --green: #00B050;
  --red: #FF4444;
  --amber: #B8860B;
  --amber-bright: #e0a821;
  --pink: #FFC7CE;
  --cyan: #38bdf8;
  --blue: #3b82f6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --glow-green: 0 0 18px rgba(0, 176, 80, 0.35);
  --glow-cyan: 0 0 18px rgba(56, 189, 248, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  background: radial-gradient(1200px 600px at 85% -10%, #0e2440 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(56, 189, 248, 0.3); }

h1, h2, h3 { font-weight: 700; line-height: 1.4; }
a { color: var(--cyan); text-decoration: none; }
small, .dim { color: var(--text-dim); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  background: rgba(7, 17, 31, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-inline-start: 8px; }
.nav a {
  color: var(--text-dim); padding: 7px 14px; border-radius: 999px; font-weight: 500;
  transition: color .2s, background .2s, box-shadow .2s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: #fff; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; color: var(--text-dim); font-size: .9rem; }

main { max-width: 1200px; margin: 0 auto; padding: 28px 20px 80px; }

/* ---------- cards / glass ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0)) , var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.glass {
  background: rgba(13, 27, 46, 0.72);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; color: #fff;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, background .2s, border-color .2s;
  user-select: none;
}
.btn:hover { transform: translateY(-1px) scale(1.02); box-shadow: var(--glow-cyan); border-color: rgba(56,189,248,.4); }
.btn:active { transform: translateY(0) scale(0.97); box-shadow: none; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, #0ea5e9, #2563eb); border-color: transparent; }
.btn-primary:hover { box-shadow: 0 0 22px rgba(37, 99, 235, .5); }
.btn-green { background: linear-gradient(135deg, #00B050, #068a44); border-color: transparent; }
.btn-green:hover { box-shadow: var(--glow-green); }
.btn-red { background: linear-gradient(135deg, #ef4444, #b91c1c); border-color: transparent; }
.btn-red:hover { box-shadow: 0 0 18px rgba(255, 68, 68, .45); }
.btn-amber { background: linear-gradient(135deg, #d19a1e, #96700f); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: .85rem; border-radius: 8px; font-weight: 500; }

/* ---------- inputs ---------- */
.input, textarea.input, select.input {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.input::placeholder { color: #5b7089; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: .9rem; color: var(--text-dim); margin-bottom: 6px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-radius: 999px; font-weight: 700; font-size: 1rem;
  border: 1px solid transparent;
}
.badge .dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.badge-green { color: #4ade80; background: rgba(0, 176, 80, .12); border-color: rgba(0, 176, 80, .4); }
.badge-green .dot { box-shadow: 0 0 0 0 rgba(0, 176, 80, .6); animation: pulse 2s infinite; }
.badge-red { color: #ff7b7b; background: rgba(255, 68, 68, .1); border-color: rgba(255, 68, 68, .38); }
.badge-amber { color: var(--amber-bright); background: rgba(184, 134, 11, .12); border-color: rgba(184, 134, 11, .45); }
.badge-pink { color: var(--pink); background: rgba(255, 199, 206, .08); border-color: rgba(255, 199, 206, .3); }
.badge-lg { font-size: 1.15rem; padding: 9px 22px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 176, 80, .55); }
  70% { box-shadow: 0 0 0 9px rgba(0, 176, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 176, 80, 0); }
}

/* ---------- lock screen ---------- */
.lock-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.lock-card { width: min(430px, 94vw); text-align: center; padding: 40px 34px; animation: rise .45s ease both; }
.lock-card img { width: 74px; height: 74px; border-radius: 18px; margin-bottom: 14px; box-shadow: var(--glow-green); }
.lock-card h1 { font-size: 1.35rem; margin-bottom: 4px; }
.lock-card .sub { color: var(--text-dim); margin-bottom: 26px; font-size: .95rem; }
.lock-card .input { text-align: center; font-size: 1.2rem; letter-spacing: 2px; }

/* ---------- inquiry hero ---------- */
.hero { text-align: center; padding: 40px 0 26px; animation: rise .4s ease both; }
.hero h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); margin-bottom: 8px; }
.hero p { color: var(--text-dim); margin-bottom: 30px; }
.searchbox { display: flex; gap: 10px; max-width: 560px; margin: 0 auto; }
.searchbox .input { font-size: 1.5rem; text-align: center; padding: 14px 18px; font-weight: 700; direction: ltr; }
.searchbox .btn { font-size: 1.15rem; padding: 0 34px; }

/* ---------- result card / timeline ---------- */
.result { max-width: 760px; margin: 26px auto 0; animation: rise .4s ease both; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 6px; }
.file-num { font-size: 1.9rem; font-weight: 700; direction: ltr; }
.result .meta { display: flex; flex-wrap: wrap; gap: 10px 26px; color: var(--text-dim); margin: 12px 0 4px; font-size: .98rem; }
.result .meta b { color: var(--text); font-weight: 500; }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 14px 0;
  font-size: .95rem; line-height: 1.8;
}
.banner-amber { background: rgba(184, 134, 11, .1); border: 1px solid rgba(184, 134, 11, .4); color: #ecd9a8; }
.banner-red { background: rgba(255, 68, 68, .08); border: 1px solid rgba(255, 68, 68, .3); color: #ffc9c9; }

.timeline { list-style: none; margin: 18px 4px 0; position: relative; padding-inline-start: 26px; }
.timeline::before {
  content: ''; position: absolute; top: 10px; bottom: 10px; inset-inline-start: 7px;
  width: 2px; background: linear-gradient(180deg, var(--cyan), rgba(56,189,248,.05));
}
.timeline li { position: relative; padding: 10px 6px 10px 0; animation: rise .35s ease both; }
.timeline li::before {
  content: ''; position: absolute; inset-inline-start: -26px; top: 20px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--cyan);
}
.timeline li:first-child::before { background: var(--cyan); box-shadow: 0 0 12px rgba(56,189,248,.7); }
.timeline li:first-child .tl-date { color: #fff; font-weight: 700; }
.tl-date { font-weight: 500; }
.tl-sub { color: var(--text-dim); font-size: .88rem; }
.tl-note { color: #b9c9de; font-size: .88rem; background: var(--surface-2); border-radius: 8px; padding: 3px 10px; display: inline-block; margin-top: 4px; }
.tl-actions { position: absolute; inset-inline-end: 0; top: 12px; display: flex; gap: 6px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .95rem; }
th, td { padding: 11px 14px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface-2); color: var(--text-dim); font-weight: 500; position: sticky; top: 0; cursor: pointer; user-select: none; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tr.tint-green td { background: rgba(0, 176, 80, .07); }
tr.tint-red td { background: rgba(255, 68, 68, .06); }
tr.tint-amber td { background: rgba(184, 134, 11, .08); }
tbody tr.clickable { cursor: pointer; }

/* ---------- chips / filters ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  font: inherit; font-size: .9rem; color: var(--text-dim); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px;
  transition: all .2s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { color: #fff; background: var(--surface-3); border-color: var(--cyan); box-shadow: 0 0 10px rgba(56,189,248,.25); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 18px 0; }
.kpi { padding: 18px; position: relative; overflow: hidden; }
.kpi .label { color: var(--text-dim); font-size: .88rem; }
.kpi .val { font-size: 2rem; font-weight: 700; line-height: 1.3; }
.kpi .delta { font-size: .85rem; font-weight: 700; }
.kpi .delta.up { color: #4ade80; }
.kpi .delta.down { color: #ff7b7b; }
.kpi.k-green .val { color: #4ade80; }
.kpi.k-red .val { color: #ff7b7b; }
.kpi.k-amber .val { color: var(--amber-bright); }
.kpi.clickable { cursor: pointer; transition: transform .15s, box-shadow .2s; }
.kpi.clickable:hover { transform: translateY(-2px); box-shadow: var(--glow-cyan); }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.chart-card h3 { font-size: 1rem; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chart-box { width: 100%; height: 320px; }

/* ---------- toast / modal ---------- */
#toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 12px 18px; box-shadow: var(--shadow); animation: rise .3s ease both; max-width: 420px;
}
.toast.ok { border-color: rgba(0,176,80,.5); }
.toast.err { border-color: rgba(255,68,68,.5); }

.modal-back {
  position: fixed; inset: 0; z-index: 60; background: rgba(3, 8, 16, .7);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 18px;
  animation: fade .2s ease both;
}
.modal {
  width: min(720px, 96vw); max-height: 90vh; overflow-y: auto;
  animation: rise .28s ease both;
}
.modal h2 { font-size: 1.2rem; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.modal .x { cursor: pointer; color: var(--text-dim); font-size: 1.4rem; background: none; border: 0; }

/* ---------- skeleton ---------- */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- misc ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } .searchbox { flex-direction: column; } .searchbox .btn { padding: 12px; } }
.mt { margin-top: 18px; } .mb { margin-bottom: 18px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.tag { font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-dim); }
.tag.exempt { color: var(--amber-bright); border-color: rgba(184,134,11,.5); }
.count-pill { background: var(--surface-3); border-radius: 999px; padding: 2px 12px; font-size: .85rem; color: var(--text-dim); }
code.mono { direction: ltr; display: inline-block; background: var(--surface-2); padding: 2px 8px; border-radius: 6px; font-size: .85em; }

.entry-result { border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 8px; border: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; animation: rise .3s ease both; }
.entry-result.ok { border-color: rgba(0,176,80,.4); background: rgba(0,176,80,.06); }
.entry-result.warn { border-color: rgba(255,199,206,.4); background: rgba(255,199,206,.05); }
.entry-result.exempt { border-color: rgba(184,134,11,.45); background: rgba(184,134,11,.07); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- maintenance ---------- */
.maint { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 20px; }
.maint .card { max-width: 520px; padding: 46px 36px; }
.maint h1 { font-size: 1.5rem; margin: 14px 0 10px; }

/* ---------- print (patients list) ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .topbar, .nav, .btn, .chips, #toasts, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; background: #fff; padding: 0; }
  .table-wrap { border: none; overflow: visible; }
  table { background: #fff; color: #000; }
  th, td { border: 1px solid #999; color: #000; background: #fff !important; padding: 5px 8px; }
  tr.tint-green td { background: #e2f5e9 !important; -webkit-print-color-adjust: exact; }
  tr.tint-red td { background: #fde8e8 !important; -webkit-print-color-adjust: exact; }
  tr.tint-amber td { background: #f7edd3 !important; -webkit-print-color-adjust: exact; }
}
