/* منصة مور الداخلية — هوية مور: رملي #F4EFE6 · بني #1C1814 · ذهبي #C49454 */
@font-face { font-family: 'Thmanyah Sans'; src: url('/assets/fonts/thmanyahsans-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url('/assets/fonts/thmanyahsans-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url('/assets/fonts/thmanyahsans-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Thmanyah Sans'; src: url('/assets/fonts/thmanyahsans-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Thmanyah Serif'; src: url('/assets/fonts/thmanyahserifdisplay-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Thmanyah Serif'; src: url('/assets/fonts/thmanyahserifdisplay-Black.woff2') format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --sand: #F4EFE6; --ink: #1C1814; --gold: #C49454; --gold-dark: #a87c40;
  --muted: #8f8471; --line: #E8DFCE; --line-soft: #E0D5C0; --card: #fff;
  --green: #1f7a45; --red: #b3402e; --radius: 14px;
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--sand); color: var(--ink);
  font-family: 'Thmanyah Sans', system-ui, sans-serif; font-weight: 300;
  font-size: 15px; line-height: 1.65; min-height: 100vh;
}
h1, h2, h3 { font-family: 'Thmanyah Serif', serif; font-weight: 900; line-height: 1.3; }
a { color: inherit; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: #fff; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 9px 12px; width: 100%; outline: none; transition: border-color .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: vertical; min-height: 74px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 400; }
.field { margin-bottom: 14px; }

/* ---------- شاشة الدخول ---------- */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, #1C1814 0%, #2a231b 60%, #3a2f22 100%);
}
.login-card {
  background: var(--sand); border-radius: 22px; padding: 44px 40px; width: 100%; max-width: 400px;
  text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.login-card img { height: 74px; margin-bottom: 14px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .tagline { color: var(--gold-dark); font-size: 13.5px; margin-bottom: 26px; }
.login-card form { text-align: right; }
.login-error { color: var(--red); font-size: 13px; min-height: 20px; margin-bottom: 8px; text-align: center; }

/* ---------- الهيكل ---------- */
#app { display: none; min-height: 100vh; }
#app.ready { display: grid; grid-template-columns: 230px 1fr; }
aside {
  background: var(--ink); color: var(--sand); padding: 26px 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
aside .brand { display: flex; align-items: center; gap: 12px; padding: 0 22px 22px; border-bottom: 1px solid rgba(244,239,230,.12); }
aside .brand img { height: 42px; }
aside .brand b { font-family: 'Thmanyah Serif'; font-weight: 900; font-size: 16px; }
aside .brand span { display: block; font-size: 11px; color: #b7ad9c; font-weight: 300; }
aside nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 3px; }
aside nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  text-decoration: none; font-size: 14.5px; color: #cfc6b5; transition: background .18s, color .18s;
}
aside nav a:hover { background: rgba(196,148,84,.14); color: var(--sand); }
aside nav a.active { background: var(--gold); color: var(--ink); font-weight: 500; }
aside .user { padding: 16px 22px 0; border-top: 1px solid rgba(244,239,230,.12); font-size: 13px; color: #b7ad9c; }
aside .user b { color: var(--sand); font-weight: 500; display: block; }
aside .user button { background: none; border: none; color: var(--gold); font-size: 12.5px; padding: 4px 0; }

main { padding: clamp(20px, 3.5vw, 42px); max-width: 1120px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: clamp(22px, 3vw, 30px); }
.page-head .sub { color: var(--muted); font-size: 13px; }

/* ---------- مكونات ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: none; border-radius: 10px;
  padding: 9px 18px; font-size: 14px; font-weight: 500; text-decoration: none;
  background: var(--gold); color: var(--ink); transition: background .18s, transform .18s;
}
.btn:hover { background: var(--gold-dark); color: #fff; transform: translateY(-1px); }
.btn.ghost { background: transparent; border: 1px solid var(--line-soft); color: var(--ink); }
.btn.ghost:hover { border-color: var(--gold); color: var(--gold-dark); background: transparent; }
.btn.dark { background: var(--ink); color: var(--sand); }
.btn.danger { background: transparent; border: 1px solid #dcb4ab; color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn.wa { background: #25D366; color: #fff; }
.btn.wa:hover { background: #1eb356; }
.btn.sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.stat { text-align: center; padding: 22px 14px; }
.stat .num { font-family: 'Thmanyah Serif'; font-weight: 900; font-size: 34px; color: var(--gold-dark); }
.stat .lbl { font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background .15s; }
tr.clickable:hover { background: #faf6ee; }

.badge {
  display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 500;
  background: #eee7d8; color: var(--muted); white-space: nowrap;
}
.badge.st-جديد { background: #e8e2f2; color: #5b4a8a; }
.badge.st-تواصل { background: #e2ecf5; color: #2c5a80; }
.badge.st-عرض-سعر { background: #f5edd9; color: #8a6d1f; }
.badge.st-قيد-التنفيذ { background: #f9e9d2; color: var(--gold-dark); }
.badge.st-تسليم { background: #ddeee3; color: var(--green); }
.badge.st-مكتمل { background: #d9ead9; color: var(--green); }
.badge.st-ملغي { background: #f2dcd8; color: var(--red); }
.badge.st-مسودة { background: #eee7d8; color: var(--muted); }
.badge.st-مرسل { background: #e2ecf5; color: #2c5a80; }
.badge.st-مقبول { background: #d9ead9; color: var(--green); }
.badge.st-مرفوض { background: #f2dcd8; color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }
.gold { color: var(--gold-dark); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* ---------- نافذة منبثقة ---------- */
#modal-backdrop {
  position: fixed; inset: 0; background: rgba(28,24,20,.55); display: none;
  align-items: flex-start; justify-content: center; padding: 5vh 18px; z-index: 50; overflow-y: auto;
}
#modal-backdrop.open { display: flex; }
.modal {
  background: var(--sand); border-radius: 18px; padding: 28px; width: 100%; max-width: 560px;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
}
.modal h2 { font-size: 20px; margin-bottom: 18px; color: var(--ink); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- إشعار ---------- */
#toast {
  position: fixed; bottom: 26px; right: 50%; transform: translateX(50%) translateY(90px);
  background: var(--ink); color: var(--sand); padding: 11px 26px; border-radius: 999px;
  font-size: 14px; transition: transform .3s; z-index: 99; box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
#toast.show { transform: translateX(50%) translateY(0); }
#toast.err { background: var(--red); color: #fff; }

/* بنود عرض السعر */
.quote-item-row { display: grid; grid-template-columns: 1fr 90px 110px 110px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.quote-item-row .del { background: none; border: none; color: var(--red); font-size: 17px; }
.quote-totals { border-top: 1px solid var(--line-soft); margin-top: 14px; padding-top: 14px; font-size: 15px; }
.quote-totals .row { justify-content: space-between; }
.quote-totals .grand { font-family: 'Thmanyah Serif'; font-weight: 900; font-size: 20px; color: var(--gold-dark); }

@media (max-width: 860px) {
  html, body { overflow-x: hidden; }
  #app.ready { grid-template-columns: 1fr; }
  #app.ready > *, .grid > *, aside nav { min-width: 0; }
  aside nav { max-width: 100%; }
  main { max-width: 100vw; }
  aside {
    position: sticky; top: 0; z-index: 40; height: auto;
    flex-direction: column; padding: 0;
    box-shadow: 0 6px 18px rgba(28,24,20,.25);
  }
  aside .brand {
    padding: 10px 16px 8px; border-bottom: none;
    display: flex; align-items: center; gap: 10px;
  }
  aside .brand img { height: 30px; }
  aside .brand b { font-size: 14px; }
  aside .brand span { font-size: 10px; }
  aside .user {
    position: absolute; top: 10px; left: 14px;
    border: none; padding: 0; text-align: left; font-size: 11px;
  }
  aside .user b { font-size: 11.5px; }
  aside .user button { font-size: 11px; }
  aside nav {
    flex-direction: row; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0 10px 10px; gap: 6px; scrollbar-width: none;
  }
  aside nav::-webkit-scrollbar { display: none; }
  aside nav a {
    white-space: nowrap; flex-shrink: 0;
    padding: 7px 13px; font-size: 13px;
  }
  main { padding: 16px 14px 40px; }
  .page-head { margin-bottom: 18px; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .stat { padding: 14px 8px; }
  .stat .num { font-size: 26px; }
  .card { padding: 14px 14px; overflow-x: auto; }
  table { min-width: 0; }
  th, td { padding: 8px 6px; font-size: 13px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .form-row { grid-template-columns: 1fr; }
  .quote-item-row { grid-template-columns: 1fr 52px 72px 72px 26px; gap: 5px; }
  .quote-item-row input { padding: 7px 6px; font-size: 13px; }
  .modal { padding: 20px 16px; }
  .login-card { padding: 32px 22px; }
}
