/* ===================================================================
   «مكين» — الطبقة الراقية: ألوان عاجية دافئة، حبر عميق، لمسات ذهبية
   تُحمَّل بعد app.css و lite.css وتعيد تعريف الرموز والعناصر الأساسية.
   لون المحل (--primary) ولونه الثاني (--accent) يأتيان من إعداد العميل.
   =================================================================== */
:root {
  --bg: #f5f2eb;
  --surface: #fffdf9;
  --surface-2: #f8f5ef;
  --ink: #161d1b;
  --ink-2: #3d4744;
  --muted: #7b827e;
  --line: #e6e0d4;
  --line-2: #eee9df;

  --ok: #1d7350;   --ok-soft: #e5f1ea;
  --warn: #9c6408; --warn-soft: #f9efdc;
  --bad: #a8352d;  --bad-soft: #f8e7e4;
  --info: #2b5a86; --info-soft: #e8eef5;

  /* درجات اللون الأساسي */
  --primary-deep: color-mix(in srgb, var(--primary) 62%, #050a09);
  --primary-soft: color-mix(in srgb, var(--primary) 8%, var(--surface));
  --primary-line: color-mix(in srgb, var(--primary) 22%, transparent);
  --gold: color-mix(in srgb, var(--accent) 78%, #6b4f12);
  --gold-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 1px rgba(22, 29, 27, .03), 0 2px 6px rgba(22, 29, 27, .04), 0 12px 28px -14px rgba(22, 29, 27, .14);
  --shadow-lg: 0 24px 60px -18px rgba(14, 20, 18, .35), 0 4px 14px rgba(14, 20, 18, .08);
  --shadow-primary: 0 10px 26px -10px color-mix(in srgb, var(--primary) 70%, transparent);
}
/* الداكن: فحمي مخضرّ عميق، لا أسود صارخ */
:root[data-theme="dark"] {
  --bg: #0c100f; --surface: #141918; --surface-2: #181e1c; --ink: #ece9e2; --ink-2: #c4c8c3;
  --muted: #8c948f; --line: #252c2a; --line-2: #1e2523;
  --ok: #57c595; --ok-soft: #14291f; --warn: #e2ad57; --warn-soft: #2c2416;
  --bad: #ee8a80; --bad-soft: #321c1a; --info: #8db8e4; --info-soft: #172433;
  --primary-deep: color-mix(in srgb, var(--primary) 55%, #020403);
  --primary-soft: color-mix(in srgb, var(--primary) 18%, var(--surface));
  --primary-line: color-mix(in srgb, var(--primary) 45%, transparent);
  --gold: color-mix(in srgb, var(--accent) 85%, #fff);
  --gold-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --shadow: 0 1px 1px rgba(0,0,0,.25), 0 10px 26px -14px rgba(0,0,0,.6);
  --shadow-lg: 0 26px 60px -18px rgba(0,0,0,.7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c100f; --surface: #141918; --surface-2: #181e1c; --ink: #ece9e2; --ink-2: #c4c8c3;
    --muted: #8c948f; --line: #252c2a; --line-2: #1e2523;
    --ok: #57c595; --ok-soft: #14291f; --warn: #e2ad57; --warn-soft: #2c2416;
    --bad: #ee8a80; --bad-soft: #321c1a; --info: #8db8e4; --info-soft: #172433;
    --primary-deep: color-mix(in srgb, var(--primary) 55%, #020403);
    --primary-soft: color-mix(in srgb, var(--primary) 18%, var(--surface));
    --primary-line: color-mix(in srgb, var(--primary) 45%, transparent);
    --gold: color-mix(in srgb, var(--accent) 85%, #fff);
    --gold-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
    --shadow: 0 1px 1px rgba(0,0,0,.25), 0 10px 26px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 26px 60px -18px rgba(0,0,0,.7);
  }
}

/* ===== الخلفية والخط ===== */
body {
  background:
    radial-gradient(900px 420px at 100% -120px, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%),
    radial-gradient(700px 360px at -10% -80px, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  font-size: 15px;
  text-rendering: optimizeLegibility;
}
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }
.num { font-feature-settings: "tnum" 1, "lnum" 1; }

/* ===== الشريط العلوي ===== */
.topbar { padding: 20px 2px 16px; gap: 14px; }
.topbar .t-name { font-size: 1.06rem; font-weight: 700; color: var(--ink); }
.topbar .t-sub { font-size: .78rem; color: var(--muted); }
.org-mark {
  width: 46px; height: 46px; border-radius: 15px; font-size: 1.2rem;
  background: linear-gradient(150deg, color-mix(in srgb, var(--primary) 82%, #fff) 0%, var(--primary) 45%, var(--primary-deep) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), inset 0 1px 0 rgba(255,255,255,.22), var(--shadow-primary);
}
.org-mark img { border-radius: inherit; }
.demo-bar { background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 14px; margin: 0 0 16px; }
.demo-bar svg { color: var(--gold); }

/* ===== البطاقات ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 16px 20px 14px; border-bottom: 1px solid var(--line-2); }
.card-head h2, .card-head h3 { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card-head h2::before, .card-head h3::before { content: ""; width: 4px; height: 16px; border-radius: 4px; background: linear-gradient(var(--gold), color-mix(in srgb, var(--gold) 40%, transparent)); flex: none; }
.card-head a.small { color: var(--primary); text-decoration: none; font-weight: 600; }
.card-head .muted.small { font-weight: 400; }

/* البطاقة الرئيسية: لوح عميق بلون المحل مع خيط ذهبي */
.cust.hero {
  position: relative; overflow: hidden; isolation: isolate;
  color: #f7f3ea; border: 0; border-radius: 22px; padding: 22px 20px 18px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--primary) 92%, #fff) -10%, var(--primary) 30%, var(--primary-deep) 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 22px 44px -20px color-mix(in srgb, var(--primary-deep) 85%, transparent);
}
.cust.hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background:
  radial-gradient(420px 200px at 0% 0%, rgba(255,255,255,.14), transparent 60%),
  radial-gradient(300px 180px at 100% 120%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%); }
.cust.hero::after { content: ""; position: absolute; inset-inline: 20px; top: 0; height: 2px; border-radius: 0 0 2px 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .85; }
.cust.hero .c-title { font-size: .95rem; font-weight: 600; color: rgba(255,255,255,.92); }
.cust.hero .c-sub, .cust.hero .c-remain .l { color: rgba(255,255,255,.62); }
.cust.hero .c-remain .v { font-size: 2.15rem; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.mini { display: block; text-decoration: none; color: inherit; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 12px; transition: transform .15s, background .15s; }
.mini:active { transform: scale(.98); }
.mini-l { font-size: .74rem; color: var(--muted); line-height: 1.4; }
.mini-v { font-weight: 700; font-size: 1.02rem; margin-top: 2px; }
.mini.t-bad .mini-v { color: var(--bad); }
.mini.t-warn .mini-v { color: var(--warn); }
.hero .mini { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); backdrop-filter: blur(4px); }
.hero .mini:hover { background: rgba(255,255,255,.13); }
.hero .mini-l { color: rgba(255,255,255,.66); }
.hero .mini-v { color: #fff; }
.hero .mini.t-bad .mini-v { color: #ffbcb3; }
.hero .mini.t-warn .mini-v { color: #f6d38f; }

/* بطاقة المورد: غسلة خفيفة بلون المحل */
.cust.feature { background: linear-gradient(180deg, var(--primary-soft), var(--surface) 75%); border-color: var(--primary-line); }
.cust .c-title { font-size: 1.05rem; }
.cust .c-remain .v { font-size: 1.85rem; }

/* ===== الإجراءات السريعة ===== */
.qa { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s; }
.qa:hover { border-color: var(--primary-line); transform: translateY(-1px); }
.qa:active { transform: scale(.98); }
.qa-ic { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary-line); }
.qa.on { color: #fff; border-color: transparent; background: linear-gradient(155deg, color-mix(in srgb, var(--primary) 90%, #fff), var(--primary) 40%, var(--primary-deep)); box-shadow: var(--shadow-primary); }
.qa.on .qa-ic { background: rgba(255,255,255,.14); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }

/* ===== الأزرار ===== */
.btn { border-radius: 12px; padding: 10px 17px; font-weight: 600; border-color: var(--line); background: var(--surface); box-shadow: 0 1px 1px rgba(22,29,27,.03); transition: background .15s, border-color .15s, box-shadow .15s, transform .06s; }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--ink) 16%, var(--line)); }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary) 55%, color-mix(in srgb, var(--primary) 88%, #000)); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), var(--shadow-primary); }
.btn.primary:hover { background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 80%, #000)); }
.btn.ghost { box-shadow: none; }
.btn.sm { border-radius: 10px; padding: 7px 12px; }
.btn.icon { padding: 9px; }
.btn.danger.solid { background: linear-gradient(180deg, color-mix(in srgb, var(--bad) 88%, #fff), var(--bad)); border-color: transparent; }
.linkbtn { color: var(--primary); }

/* ===== النماذج ===== */
.input, select.input, textarea.input { border-radius: 12px; border-color: var(--line); background: var(--surface-2); padding: 11px 13px; }
.input:hover { border-color: color-mix(in srgb, var(--ink) 14%, var(--line)); }
.input:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 13%, transparent); }
.field > label { font-weight: 600; color: var(--ink-2); font-size: .84rem; }
.chip { border-color: var(--line); background: var(--surface); border-radius: 999px; padding: 7px 15px; transition: background .15s, border-color .15s; }
.chip:hover { border-color: var(--primary-line); }
.chip.on { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, #fff), var(--primary)); border-color: transparent; color: #fff; box-shadow: var(--shadow-primary); }
.check input { accent-color: var(--primary); }

/* ===== القوائم والحركات ===== */
.day { background: transparent; color: var(--muted); font-size: .76rem; font-weight: 600; padding: 14px 20px 6px; border-bottom: 0; display: flex; align-items: center; gap: 10px; }
.day::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.exp { padding: 12px 20px; border-bottom: 1px solid var(--line-2); transition: background .12s; }
.exp:hover, .list-item:hover { background: var(--surface-2); }
.exp .e-icon { border-radius: 13px; background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary-line); }
.exp .e-amt { font-size: 1rem; }
.list-item { padding: 13px 20px; transition: background .12s; }
.avatar { background: linear-gradient(150deg, var(--primary-soft), color-mix(in srgb, var(--primary) 16%, var(--surface))); box-shadow: inset 0 0 0 1px var(--primary-line); }
.cell-main { font-weight: 600; color: var(--ink); }

/* ===== البحث ===== */
.search-pill { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; text-decoration: none; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .92rem; transition: border-color .15s; }
.search-pill:hover { border-color: var(--primary-line); }
.search-pill svg { color: var(--primary); }
.filters { padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.search .input { padding-inline-start: 38px; border-radius: 14px; }
.search svg { color: var(--primary); }
.search-info { padding: 10px 20px; font-size: .84rem; font-weight: 600; border-bottom: 1px solid var(--line-2); background: var(--surface-2); }
.hit-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.hit { font-size: .76rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 28%, transparent); }
.hit .num { opacity: .8; font-weight: 500; }

/* ===== اختيار المناديب للمشاركة والاستيراد ===== */
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; max-height: 46vh; overflow-y: auto; }
.pick-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; transition: background .12s; }
.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--surface-2); }
.pick-row input { width: 19px; height: 19px; accent-color: var(--primary); flex: none; }
.pick-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick-main .cell-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar.sm { width: 34px; height: 34px; font-size: .9rem; }

/* ===== الصفحات الداخلية: العناوين والجداول والأرقام ===== */
.page-head { margin-bottom: 4px; }
.page-head h1 { font-size: 1.45rem; }
.page-head .sub { font-size: .86rem; }
.page-head .actions .btn.sm { background: var(--surface); }
.t th { background: var(--surface-2); color: var(--muted); font-weight: 600; }
.t tfoot td { background: var(--primary-soft); }
.kpi .k-icon { border-radius: 12px; box-shadow: inset 0 0 0 1px var(--primary-line); }
.bar { background: var(--line-2); }
.bar > span { background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 70%, var(--accent))); }
.chart .bx { fill: var(--primary); }
.chart .bx.cur { fill: var(--accent); }
.empty .e-icon { border-radius: 18px; background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.welcome h1 { font-weight: 700; }

/* ===== المستحقات: جدول مواعيد ===== */
.due-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.due-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 12px 11px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); cursor: pointer; text-align: start; position: relative; overflow: hidden; color: var(--ink); }
.due-tile::before { content: ""; position: absolute; inset-inline-start: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--tone); }
.due-tile .dt-l { font-size: .76rem; color: var(--muted); font-weight: 600; }
.due-tile .dt-v { font-size: 1.12rem; font-weight: 700; color: var(--tone); }
.due-tile .dt-c { font-size: .72rem; color: var(--muted); }
.due-tile.zero { opacity: .55; box-shadow: none; }
.t-bad { --tone: var(--bad); } .t-warn { --tone: var(--warn); } .t-info { --tone: var(--info); } .t-mute { --tone: var(--muted); }
.due-sec .due-total { font-size: 1.05rem; }
.due-sec.t-overdue .card-head { background: linear-gradient(180deg, var(--bad-soft), transparent); }
.due-sec.t-overdue .card-head h3::before { background: var(--bad); }
.due-sec.t-week .card-head h3::before { background: var(--warn); }
.due-sec.t-later .card-head h3::before { background: var(--info); }
.due-sec.t-open .card-head h3::before { background: var(--muted); }
.due-day { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 20px 6px; font-size: .82rem; font-weight: 700; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line-2); }
.due-item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); --tone: var(--muted); }
.due-item:last-child { border-bottom: 0; }
.due-item.t-overdue { --tone: var(--bad); } .due-item.t-today { --tone: var(--warn); background: color-mix(in srgb, var(--warn-soft) 55%, transparent); }
.due-item.t-week { --tone: var(--warn); } .due-item.t-later { --tone: var(--info); } .due-item.t-open { --tone: var(--muted); }
.due-date { width: 52px; height: 56px; flex: none; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; overflow: hidden;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--tone) 35%, var(--line)); box-shadow: inset 0 3px 0 var(--tone); color: var(--tone); }
.due-date b { font-size: 1.3rem; line-height: 1.1; font-weight: 700; margin-top: 3px; }
.due-date span { font-size: .66rem; font-weight: 600; color: var(--ink-2); }
.due-main { flex: 1; min-width: 0; }
.due-when { font-size: .8rem; font-weight: 700; color: var(--tone); }
.due-end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.due-amt { font-weight: 700; font-size: 1.02rem; }
@media (max-width: 520px) { .due-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .due-item { padding: 12px 14px; gap: 12px; } .due-day { padding-inline: 14px; } }

/* ===== طلب بضاعة ===== */
.order-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; max-height: 40vh; overflow-y: auto; }
.order-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; padding-inline-start: 14px; border-bottom: 1px solid var(--line-2); transition: background .12s; }
.order-row:last-child { border-bottom: 0; }
.order-row.on { background: var(--primary-soft); }
.order-name { flex: 1; font-weight: 600; }
.order-row .qty { width: 120px; padding: 8px 10px; text-align: center; }

/* ===== الشارات والتنبيهات ===== */
.badge { padding: 3px 10px; font-weight: 600; letter-spacing: 0; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent); }
.alert { border-radius: 14px; border: 1px solid color-mix(in srgb, currentColor 18%, transparent); padding: 12px 16px; }
.alert.warn { background: var(--warn-soft); }

/* ===== الشريط السفلي: لوح زجاجي عائم ===== */
/* واضح: أيقونة أكبر، اسم بحبر داكن، والصفحة الحالية في كبسولة ممتلئة بلون المحل */
.dock { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 7px 6px 6px; border: 1px solid var(--line); border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4); box-shadow: var(--shadow-lg); }
.dock-in { max-width: 740px; gap: 2px; }
.dock a { border-radius: 16px; padding: 2px 0 3px; gap: 3px; font-size: .74rem; font-weight: 600; color: var(--ink-2); transition: color .15s; -webkit-tap-highlight-color: transparent; }
.dock .dk-ic { width: 52px; height: 32px; border-radius: 999px; display: grid; place-items: center; transition: background .2s, color .2s, box-shadow .2s; }
.dock .dk-ic svg { width: 23px; height: 23px; stroke-width: 1.85; }
.dock a:hover .dk-ic { background: var(--surface-2); }
.dock a.active { color: var(--primary); font-weight: 700; }
.dock a.active .dk-ic { color: #fff; background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 85%, #fff), var(--primary)); box-shadow: var(--shadow-primary); }
.dock a.active .dk-ic svg { stroke-width: 2.1; }
:root[data-theme="dark"] .dock a.active { color: color-mix(in srgb, var(--primary) 55%, #fff); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dock a.active { color: color-mix(in srgb, var(--primary) 55%, #fff); } }
.shell { padding-bottom: 120px; }
.fab { bottom: calc(92px + env(safe-area-inset-bottom)); }

/* ===== النوافذ والتنبيهات المنبثقة ===== */
dialog.modal { border-radius: 24px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(10, 14, 13, .5); backdrop-filter: blur(4px); }
.m-head { padding: 18px 22px 16px; }
.m-head h3 { font-weight: 700; }
.m-foot { background: var(--surface-2); border-radius: 0 0 24px 24px; }
.toast { border-radius: 14px; background: color-mix(in srgb, var(--ink) 94%, var(--primary)); box-shadow: var(--shadow-lg); }

/* ===== الصفحات والترحيب ===== */
.page-head h1 { font-weight: 700; letter-spacing: -.01em; }
.crumb a { color: var(--muted); }
.hero-mark { border-radius: 22px; background: linear-gradient(150deg, color-mix(in srgb, var(--primary) 85%, #fff), var(--primary-deep)); box-shadow: var(--shadow-primary); }
.auth { background:
  radial-gradient(700px 380px at 100% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent),
  radial-gradient(700px 420px at 0% 110%, color-mix(in srgb, var(--primary) 18%, transparent), transparent), var(--bg); }
.auth-card { border-radius: 26px; box-shadow: var(--shadow-lg); }
.code-box { border-radius: 14px; border-color: var(--gold); background: var(--gold-soft); }
