/* ===== نظام آفاق — متجاوب RTL ===== */
:root {
  --brand: #5A1773;      /* بنفسجي */
  --brand-700: #4A1260;
  --brand-100: #E2CDEA;
  --accent: #C19349;     /* ذهبي */
  --info: #004477;       /* تركواز/أزرق */
  --bg: #FBF8F2;         /* كريمي خلفية */
  --surface: #FDFBF6;    /* كريمي سطح */
  --sunken: #F5EFE2;
  --line: #E6DFCE;       /* حدود */
  --text: #1F1A24;
  --muted: #6B6470;
  --success: #205A3A;
  --success-bg: #E5F0EA;
  --danger: #B23A2E;
  --danger-bg: #F7E4E1;
  --warn: #92400E;
  --warn-bg: #FAEFD6;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(31, 26, 36, .07);
  font-family: "Segoe UI", "Cairo", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
a { color: var(--info); }

/* ===== أزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--brand); color: #fff; transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.accent { background: var(--accent); }
.btn.info { background: var(--info); }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

/* ===== الحقول ===== */
label { display: block; font-size: 13px; font-weight: 700; color: var(--brand); margin: 0 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text); font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 10px; }
@media (min-width: 640px) { .row.cols-2 { grid-template-columns: 1fr 1fr; } .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* ===== التخطيط ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; box-shadow: var(--shadow);
}
.topbar .title { font-weight: 800; font-size: 17px; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.container { max-width: 920px; margin: 0 auto; padding: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 16px; color: var(--brand); display: flex; align-items: center; justify-content: space-between; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }

/* ===== شارات الحالة ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.draft { background: var(--sunken); color: var(--muted); }
.badge.submitted { background: var(--warn-bg); color: var(--warn); }
.badge.saved { background: var(--success-bg); color: var(--success); }

/* ===== الإجماليات (KPIs) ===== */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.kpi .k-label { font-size: 12px; color: var(--muted); }
.kpi .k-value { font-size: 17px; font-weight: 800; margin-top: 2px; }
.kpi.remaining .k-value { color: var(--success); }
.kpi.tax .k-value { color: var(--accent); }

/* ===== قوائم الصفوف (موبايل أولاً) ===== */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.item .main { min-width: 0; }
.item .main .t { font-weight: 700; }
.item .main .s { font-size: 12px; color: var(--muted); }
.item .amt { font-weight: 800; white-space: nowrap; }
.item .ops { display: flex; gap: 6px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); }
.pill.clip { background: var(--brand-100); color: var(--brand); }

/* جدول للمدير (شاشات أكبر) */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: var(--sunken); color: var(--text); font-weight: 800; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--brand-100); }

/* ===== شاشة الدخول ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 18px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 26px; }
.login-card .logo { text-align: center; font-size: 22px; font-weight: 800; color: var(--brand); margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }

/* ===== المودال ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(31,26,36,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
@media (min-width: 640px) { .modal-bg { align-items: center; } }
.modal {
  background: var(--surface); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0;
  max-height: 92vh; overflow-y: auto; padding: 18px;
}
@media (min-width: 640px) { .modal { border-radius: 16px; } }
.modal h3 { margin: 0 0 14px; color: var(--brand); }
.modal .actions { display: flex; gap: 8px; margin-top: 8px; }

/* ===== تنبيهات ===== */
.toast { position: fixed; bottom: 16px; right: 16px; left: 16px; z-index: 100; display: flex; justify-content: center; pointer-events: none; }
.toast .msg { background: var(--text); color: #fff; padding: 11px 18px; border-radius: 10px; box-shadow: var(--shadow); max-width: 480px; }
.toast .msg.err { background: var(--danger); }
.toast .msg.ok { background: var(--success); }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 22px; }
.attach-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.attach-thumbs .a { font-size: 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; cursor: pointer; }
