/* =====================================================================
 * ofek.css — هوية «أُفق» المشتركة لكل الصفحات
 * فاتح افتراضياً (أبيض + ذهبي) · كحلي + ذهبي فقط لما الجهاز بالوضع الليلي
 * Tailwind للتنسيق (flex/grid/gap...)، وهون الألوان والمكوّنات.
 * ===================================================================== */
/* ترتيب الطبقات نفس Tailwind: أدوات Tailwind (utilities) بتغلب مكوّناتنا عند التعارض */
@layer theme, base, components, utilities;
@layer components {

:root {
  --bg: #ffffff;
  --surface: #faf8f3;
  --card: #ffffff;
  --line: #ebe4d4;
  --line-2: #f3eee3;
  --text: #1c2333;
  --muted: #6b7280;
  --gold: #a8832f;
  --gold-2: #c9a24d;
  --gold-ink: #ffffff;
  --gold-soft: #f7f0de;
  --ok: #2f7d55;
  --ok-soft: #e6f3ec;
  --warn: #a66a00;
  --warn-soft: #fbf1dc;
  --danger: #b3412e;
  --danger-soft: #fbe9e5;
  --info: #2f5d8a;
  --info-soft: #e7eef6;
  --shadow: 0 1px 2px rgba(28, 35, 51, .05), 0 4px 16px rgba(28, 35, 51, .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1829;
    --surface: #0f1d33;
    --card: #14253f;
    --line: #22395a;
    --line-2: #1a2e4b;
    --text: #e8ecf3;
    --muted: #9aa7bd;
    --gold: #d4b264;
    --gold-2: #e2c47f;
    --gold-ink: #0d1829;
    --gold-soft: rgba(212, 178, 100, .13);
    --ok: #6cc59a;
    --ok-soft: rgba(108, 197, 154, .13);
    --warn: #e5b356;
    --warn-soft: rgba(229, 179, 86, .13);
    --danger: #ef8a78;
    --danger-soft: rgba(239, 138, 120, .13);
    --info: #8db8e3;
    --info-soft: rgba(141, 184, 227, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .2);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); text-decoration: none; }
.num, .mono, input[type=number], input[inputmode=decimal] { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.hidden { display: none !important; }
.strike { text-decoration: line-through; opacity: .55; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: var(--gold-ink);
  font-weight: 700; font-size: 18px;
}
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); line-height: 1.2; }

.demo-bar {
  background: var(--gold-soft); color: var(--text); font-size: 13px;
  border-bottom: 1px solid var(--line); padding: 6px 16px;
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
}
.demo-bar button { background: none; border: 0; color: var(--gold); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---------- البطاقات ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px; }
.card-click { cursor: pointer; transition: border-color .15s, transform .15s; }
.card-click:hover { border-color: var(--gold-2); }
.card-click:active { transform: scale(.995); }
.section-title { font-weight: 700; font-size: 16px; margin: 0; display: flex; align-items: center; gap: 8px; }
.section-title svg { color: var(--gold); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--gold-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn-soft { background: var(--gold-soft); border-color: transparent; color: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--gold-soft); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-sm { min-height: 34px; padding: 0 10px; border-radius: 10px; font-size: 13px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-block { width: 100%; }
.btn-big {
  flex-direction: column; min-height: 84px; gap: 6px; border-radius: 16px; font-size: 14px;
}
.btn-big svg { width: 26px; height: 26px; color: var(--gold); }

/* ---------- الحقول ---------- */
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.input.ltr { direction: ltr; text-align: left; }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.with-mic { position: relative; }
.with-mic .mic-tools { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; }
.with-mic .textarea { padding-left: 84px; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 4px; cursor: pointer; border-radius: 10px; }
.check:hover { background: var(--line-2); }
.check input { width: 20px; height: 20px; accent-color: var(--gold); margin-top: 2px; flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; padding: 3px; background: var(--bg); gap: 2px; }
.seg button { border: 0; background: none; font: inherit; color: var(--muted); padding: 6px 12px; border-radius: 9px; cursor: pointer; min-height: 34px; }
.seg button.on { background: var(--gold-soft); color: var(--text); font-weight: 600; }

/* ---------- شارات ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; background: var(--line-2); color: var(--muted); white-space: nowrap; line-height: 1.8;
}
.chip svg { width: 13px; height: 13px; }
.chip-gold { background: var(--gold-soft); color: var(--gold); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-danger { background: var(--danger-soft); color: var(--danger); }
.chip-info { background: var(--info-soft); color: var(--info); }

/* ---------- تبويبات بتمرير أفقي ---------- */
.tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  border-bottom: 1px solid var(--line); scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; min-height: 46px; white-space: nowrap;
}
.tab svg { width: 17px; height: 17px; }
.tab.on { color: var(--text); border-bottom-color: var(--gold); font-weight: 600; }
.tab.on svg { color: var(--gold); }

/* ---------- نسبة الإنجاز ---------- */
.bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.bar.thin { height: 5px; }
.pring { position: relative; display: inline-grid; place-items: center; }
.pring svg { transform: rotate(-90deg); }
.pring b { position: absolute; font-family: 'IBM Plex Mono', monospace; font-weight: 500; }
.stage-steps { display: flex; gap: 4px; }
.stage-steps i { flex: 1; height: 6px; border-radius: 4px; background: var(--line-2); }
.stage-steps i.done { background: var(--gold); }
.stage-steps i.cur { background: linear-gradient(90deg, var(--gold-2), var(--line-2)); }

/* ---------- قوائم وجداول ---------- */
.list > * + * { border-top: 1px solid var(--line-2); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl input.input { min-height: 36px; padding: 5px 8px; border-radius: 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty svg { width: 34px; height: 34px; color: var(--gold-2); opacity: .7; display: block; margin: 0 auto 8px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 500; direction: ltr; text-align: right; }

/* ---------- نافذة منبثقة + تنبيهات ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 60; background: rgba(13, 24, 41, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
  animation: fade .15s ease;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 20px 20px 0 0; border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: up .2s ease;
}
@media (min-width: 640px) {
  .modal-back { align-items: center; padding: 16px; }
  .modal { border-radius: 20px; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 1; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); flex-wrap: wrap; }
.modal-foot .btn { flex: 1; }
.modal.wide { max-width: 860px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: 18px; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast {
  pointer-events: auto; background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; display: flex; gap: 8px; align-items: center; animation: up .2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok svg { color: var(--gold-2); }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin .8s linear infinite; display: inline-block; }
.loading { display: grid; place-items: center; padding: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- صور ---------- */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--line-2); position: relative; }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .cap { padding: 6px 8px; font-size: 12px; }
.thumb .pending { position: absolute; top: 6px; right: 6px; }

/* ---------- زر عائم ---------- */
.fab {
  position: fixed; z-index: 40; bottom: 18px; left: 18px; width: 56px; height: 56px; border-radius: 18px;
  background: var(--gold); color: var(--gold-ink); border: 0; display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(168, 131, 47, .35); cursor: pointer;
}

/* ---------- تسجيل صوتي ---------- */
.rec-on { color: var(--danger) !important; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
audio { width: 100%; height: 36px; }

/* ---------- كروكي ---------- */
.sketch { width: 100%; height: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.sketch .edge { stroke: var(--gold); stroke-width: 2; fill: var(--gold-soft); }
.sketch .pt { fill: var(--text); }
.sketch text { fill: var(--text); font-family: 'IBM Plex Mono', monospace; }
.sketch .dim { fill: var(--muted); }

/* ---------- طباعة (تقارير وعروض أسعار) ---------- */
.doc-print { background: #fff; color: #1c2333; padding: 28px; font-size: 13px; direction: rtl; }
.doc-print h1 { font-size: 20px; margin: 0 0 4px; }
.doc-print table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.doc-print th, .doc-print td { border: 1px solid #e5dccb; padding: 6px 8px; text-align: start; }
.doc-print th { background: #f7f0de; }
.doc-print .head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #a8832f; padding-bottom: 10px; margin-bottom: 14px; }
.doc-print .tot { font-size: 16px; font-weight: 700; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  body { background: #fff; }
}
.print-area { display: none; }

/* ---------- صفحة تسجيل الدخول ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; }

/* ---------- تخطيط عام ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 16px; padding-bottom: 96px; }
.kbd { font-family: 'IBM Plex Mono', monospace; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
details.help summary { cursor: pointer; padding: 10px 0; font-weight: 500; list-style: none; display: flex; align-items: center; gap: 8px; }
details.help summary::-webkit-details-marker { display: none; }
details.help[open] summary { color: var(--gold); }
details.help + details.help { border-top: 1px solid var(--line-2); }

}
