/* ===== دراسة موردي الدهانات 2026 ===== */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --s-qanti: #2a78d6;   /* القنطي — أزرق */
  --s-blour: #eb6834;   /* بلور — برتقالي */
  --s-bazra: #1baf7a;   /* البزرة — أخضر مائي */
  --good-text: #006300;
  --shadow: 0 1px 2px rgba(11,11,11,.04), 0 4px 14px rgba(11,11,11,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --s-qanti: #3987e5;
    --s-blour: #d95926;
    --s-bazra: #199e70;
    --good-text: #0ca30c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ===== الهيدر ===== */
.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px 0;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 22px; font-weight: 700; }
.brand h1 span { color: var(--muted); font-weight: 500; }
.brand p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.partner-btn { margin-inline-start: auto; }
.partner-btn.authed { border-color: color-mix(in oklab, var(--good-text) 40%, transparent); color: var(--good-text); }
nav.tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; }
nav.tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 8px 8px 0 0;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs a:hover { background: color-mix(in oklab, var(--ink) 5%, transparent); }
nav.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.count-pill {
  background: var(--ink); color: var(--surface);
  border-radius: 99px; font-size: 11.5px; font-weight: 700;
  min-width: 19px; height: 19px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 6px;
}

main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 56px; }
footer {
  max-width: 1180px; margin: 0 auto; padding: 0 24px 40px;
  color: var(--muted); font-size: 12.5px;
}

/* ===== بطاقات عامة ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 2px; font-size: 15.5px; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.grid { display: grid; gap: 14px; }
.grid.tiles { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
section { margin-bottom: 22px; }
.section-title { font-size: 17px; font-weight: 700; margin: 26px 0 12px; }

/* ===== بلاطات الإحصاء ===== */
.tile .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.tile .value { font-size: 34px; font-weight: 700; line-height: 1.25; margin-top: 2px; }
.tile .hint { color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 99px; display: inline-block; flex: none; }

/* ===== الرسوم (أشرطة أفقية) ===== */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, max-content) 1fr; gap: 10px; align-items: center; }
.bar-row .bar-label { color: var(--ink-2); font-size: 13px; text-align: start; }
.bar-track { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.bar-fill {
  height: 20px;
  border-radius: 4px 0 0 4px; /* نهاية البيانات مدوّرة، القاعدة مربّعة */
  min-width: 3px;
}
.bar-val { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; color: var(--ink-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ===== شارات الموردين ===== */
.sup-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 700; color: var(--ink);
  white-space: nowrap;
}
.sup-qanti { background: color-mix(in oklab, var(--s-qanti) 14%, transparent); }
.sup-blour { background: color-mix(in oklab, var(--s-blour) 14%, transparent); }
.sup-bazra { background: color-mix(in oklab, var(--s-bazra) 14%, transparent); }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 500;
  background: color-mix(in oklab, var(--ink) 7%, transparent);
  color: var(--ink-2); white-space: nowrap;
}
.badge.win { background: color-mix(in oklab, var(--good-text) 14%, transparent); color: var(--good-text); font-weight: 700; }

/* ===== شريط الفلاتر ===== */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px;
  position: sticky; top: 108px; z-index: 30;
}
.filters input[type="search"], .filters select {
  font: inherit; color: var(--ink);
  background: var(--page); border: 1px solid var(--grid);
  border-radius: 8px; padding: 7px 11px; min-width: 0;
}
.filters input[type="search"] { flex: 1 1 200px; }
.filters select { max-width: 230px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--grid); background: var(--page); color: var(--ink-2);
  font: inherit; font-size: 13px; padding: 6px 13px; border-radius: 99px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--baseline); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 700; }
.result-count { color: var(--muted); font-size: 12.5px; margin-inline-start: auto; white-space: nowrap; }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  text-align: start; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--grid);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap; z-index: 5;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid color-mix(in oklab, var(--grid) 55%, transparent); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in oklab, var(--ink) 3%, transparent); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td .note { color: var(--muted); font-size: 12px; display: block; }
.name-cell { min-width: 210px; }
.cheap-cell { background: color-mix(in oklab, var(--good-text) 7%, transparent) !important; border-radius: 6px; }

/* ===== أزرار ===== */
.btn {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--grid); background: var(--surface); color: var(--ink);
  padding: 7px 14px; font-size: 13.5px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--baseline); background: color-mix(in oklab, var(--ink) 4%, var(--surface)); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); font-weight: 700; }
.btn.small { padding: 3px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.icon { padding: 3px 9px; font-weight: 700; }
.qty-ctl { display: inline-flex; align-items: center; gap: 2px; }
.qty-ctl .q { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ===== خطة الطلب ===== */
.order-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.order-head .spacer { flex: 1; }
.order-group { margin-bottom: 18px; }
.order-group .g-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px 8px; font-weight: 700;
}
.order-total {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; font-weight: 700; padding: 14px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.empty {
  text-align: center; color: var(--muted); padding: 60px 20px;
  background: var(--surface); border: 1px dashed var(--grid); border-radius: 14px;
}

/* ===== قوائم النقاط والمنهجية ===== */
.method-list { margin: 0; padding-inline-start: 20px; color: var(--ink-2); font-size: 13.5px; }
.method-list li { margin-bottom: 7px; }
.insights { list-style: none; margin: 0; padding: 0; }
.insights li { display: flex; gap: 9px; padding: 7px 0; border-bottom: 1px solid color-mix(in oklab, var(--grid) 55%, transparent); font-size: 13.5px; color: var(--ink-2); }
.insights li:last-child { border-bottom: none; }
.insights b { color: var(--ink); }

/* ===== تنبيه (toast) ===== */
#toast {
  position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%);
  background: var(--ink); color: var(--surface);
  padding: 10px 20px; border-radius: 99px; font-size: 13.5px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .25s; z-index: 90;
}
#toast.show { opacity: 1; }

/* ===== طباعة ===== */
.print-only { display: none !important; }
@media print {
  .print-only { display: block !important; }
  span.print-only { display: inline !important; }
  .top, .filters, footer, .no-print, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .card, .table-wrap, .order-total { box-shadow: none; border-color: #ccc; }
  a { text-decoration: none; color: inherit; }
}

/* ===== شريط التنقل السفلي (جوال) ===== */
.bottomnav {
  display: none;
  position: fixed; bottom: 0; inset-inline: 0; z-index: 60;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500;
  padding: 4px 0; border-radius: 10px; min-height: 48px; justify-content: center;
}
.bottomnav a.on { color: var(--ink); font-weight: 700; background: color-mix(in oklab, var(--ink) 6%, transparent); }
.bottomnav .bn-ic { font-size: 21px; line-height: 1; position: relative; }
.bottomnav .bn-pill { position: absolute; top: -6px; inset-inline-start: 14px; font-size: 10px; min-width: 16px; height: 16px; }

/* ===== نافذة منبثقة / لوح سفلي ===== */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); color: var(--ink);
  width: 100%; max-width: 560px; max-height: 84vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 40px rgba(0,0,0,.18);
}
.sheet h3 { margin: 0 0 4px; font-size: 16px; }
.sheet .sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.sheet-close { float: left; }
.sheet label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.sheet input[type="text"], .sheet input[type="password"], .sheet textarea {
  font: inherit; color: var(--ink); width: 100%;
  background: var(--page); border: 1px solid var(--grid); border-radius: 9px; padding: 9px 12px;
}
.sheet textarea { resize: vertical; min-height: 60px; }
.sheet .err { color: #d03b3b; font-size: 12.5px; min-height: 18px; margin: 6px 0 0; }
.sheet .actions-row { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
@media (min-width: 721px) {
  .overlay { align-items: center; padding: 20px; }
  .sheet { border-radius: 16px; }
}

/* ===== القرارات ===== */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .chip { min-height: 40px; }
.seg .chip.on-approve { background: color-mix(in oklab, var(--good-text) 15%, var(--surface)); border-color: var(--good-text); color: var(--good-text); font-weight: 700; }
.seg .chip.on-reject { background: color-mix(in oklab, #d03b3b 13%, var(--surface)); border-color: #d03b3b; color: #d03b3b; font-weight: 700; }
.seg .chip.on-discuss { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 700; }
.dchip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.dchip.approve { background: color-mix(in oklab, var(--good-text) 14%, transparent); color: var(--good-text); }
.dchip.reject { background: color-mix(in oklab, #d03b3b 12%, transparent); color: #d03b3b; }
.dchip.discuss { background: color-mix(in oklab, var(--ink) 9%, transparent); color: var(--ink-2); }

/* ===== التعليقات ===== */
.comments { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.comment { background: var(--page); border: 1px solid var(--grid); border-radius: 11px; padding: 8px 12px; font-size: 13.5px; }
.comment .meta { display: flex; gap: 8px; align-items: baseline; color: var(--muted); font-size: 11.5px; margin-bottom: 2px; }
.comment .meta b { color: var(--ink); font-size: 12.5px; }
.comment .meta .del { margin-inline-start: auto; cursor: pointer; background: none; border: none; color: var(--muted); font-size: 12px; padding: 2px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { flex: 1; min-height: 44px; }
.row-actions { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }

/* ===== المهام ===== */
.task { display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid color-mix(in oklab, var(--grid) 55%, transparent); }
.task:last-child { border-bottom: none; }
.task input[type="checkbox"] { width: 21px; height: 21px; accent-color: var(--good-text); flex: none; cursor: pointer; }
.task .t-text { flex: 1; font-size: 14px; }
.task.done .t-text { text-decoration: line-through; color: var(--muted); }
.task .t-by { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.task-form { display: flex; gap: 8px; margin-bottom: 10px; }
.task-form input { flex: 1; font: inherit; color: var(--ink); background: var(--page); border: 1px solid var(--grid); border-radius: 9px; padding: 9px 12px; min-width: 0; }
.lock-note {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: color-mix(in oklab, var(--s-qanti) 8%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--s-qanti) 25%, transparent);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; font-size: 13.5px;
}
.sync-note { color: var(--good-text); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }

/* ===== جوال ===== */
@media (max-width: 720px) {
  .top { padding: 12px 14px; position: static; }
  nav.tabs { display: none; }
  .bottomnav { display: flex; }
  main { padding: 14px 12px 30px; }
  body { padding-bottom: 76px; }
  .brand { gap: 6px; }
  .brand h1 { font-size: 17px; }
  .brand-sub { display: none; }
  .filters { position: static; padding: 9px 11px; }
  .filters select { flex: 1 1 40%; max-width: none; }
  .tile .value { font-size: 27px; }
  .card { padding: 14px 15px; }
  .btn.icon { min-width: 40px; min-height: 36px; justify-content: center; }
  .qty-ctl .btn { min-width: 40px; min-height: 38px; }

  /* الجداول تتحول إلى بطاقات */
  .table-wrap { overflow-x: visible; }
  .table-wrap table, .table-wrap tbody { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    display: flex; flex-direction: column; gap: 7px;
    padding: 13px 14px; border-bottom: 1px solid var(--grid);
  }
  .table-wrap tbody tr:hover td { background: none; }
  .table-wrap tbody td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 0; border: none; width: 100%;
  }
  .table-wrap tbody td:empty { display: none; }
  .table-wrap tbody td::before {
    content: attr(data-th);
    color: var(--muted); font-size: 12px; flex: none;
  }
  .table-wrap tbody td[data-th=""]::before { display: none; }
  .table-wrap tbody td.name-cell { order: -1; display: block; font-weight: 700; font-size: 14.5px; min-width: 0; }
  .table-wrap tbody td.name-cell::before { display: none; }
  .table-wrap tbody td.name-cell .note { font-weight: 400; }
  .table-wrap tbody td.actions { justify-content: flex-end; }
  .table-wrap tbody td.actions::before { display: none; }
  .cheap-cell { padding: 2px 8px !important; }
}
