/* نظام إدارة مكتب وليد — ستايل Apple.com (بار أفقي + Dark) */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  --bg:        #000000;
  --surface:   #0a0a0c;
  --surface-2: #131316;
  --card:      #1c1c1e;
  --card-2:    #232326;
  --line:      rgba(255,255,255,.09);
  --line-soft: rgba(255,255,255,.06);
  --hairline:  rgba(255,255,255,.14);

  --ink:       #f5f5f7;
  --ink-dim:   #c7c7cc;
  --muted:     #86868b;

  --accent:      #2997ff;
  --accent-2:    #0a84ff;
  --accent-glow: rgba(41,151,255,.35);
  --accent-soft: rgba(41,151,255,.14);

  --green:      #30d158;
  --green-soft: rgba(48,209,88,.14);
  --amber:      #ff9f0a;
  --amber-soft: rgba(255,159,10,.14);
  --red:        #ff453a;
  --red-soft:   rgba(255,69,58,.14);

  --radius: 18px;
  --radius-sm: 12px;
  --topnav-h: 52px;
  --shadow-card: 0 1px 1px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  --shadow-pop:  0 6px 16px rgba(0,0,0,.4), 0 20px 46px rgba(0,0,0,.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }

body {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont,
    "IBM Plex Sans Arabic", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); color: var(--ink); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.28); }

/* ================= شاشة الترحيب ================= */
.splash {
  position: fixed; inset: 0; z-index: 999;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .7s ease;
}
.splash-logo {
  height: 64px; width: auto;
  opacity: 0;
  animation: splashIn 1s ease forwards;
}
@keyframes splashIn {
  0%   { opacity: 0; transform: scale(.85); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}
.splash-out { opacity: 0; pointer-events: none; }

.app-shell { opacity: 1; transform: none; }
.app-shell.shell-ready {
  opacity: 1; transform: translateY(0);
  transition: opacity .6s ease, transform .6s ease;
}

/* ================= الشريط العلوي (Apple-style) ================= */
.topnav {
  position: sticky; top: 0; z-index: 60;
  height: var(--topnav-h);
  background: rgba(20,20,22,.72);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  height: 100%; max-width: 1400px; margin: 0 auto;
  padding: 0 28px;
  display: flex; align-items: center; gap: 26px;
}
.topnav-brand { display: flex; align-items: center; flex-shrink: 0; }
.topnav-brand .brand-logo { height: 26px; width: auto; opacity: .95; }

.topnav-groups {
  display: flex; align-items: center; gap: 6px; flex: 1;
}
.tg-link {
  color: var(--ink-dim); text-decoration: none; font-size: 13px; font-weight: 400;
  padding: 8px 14px; border-radius: 980px; transition: background .18s, color .18s;
}
.tg-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.tg-link.active { color: #fff; font-weight: 600; }

.tg { position: relative; }
.tg-trigger {
  background: none; border: none; cursor: pointer;
  color: var(--ink-dim); font-family: inherit; font-size: 13px; font-weight: 400;
  padding: 8px 14px; border-radius: 980px;
  display: flex; align-items: center; gap: 4px;
  transition: background .18s, color .18s;
}
.tg-trigger:hover { color: #fff; background: rgba(255,255,255,.06); }
.tg-trigger.active { color: #fff; font-weight: 600; }
.tg-caret { font-size: 10px; opacity: .6; transition: transform .18s; }
.tg.open .tg-caret { transform: rotate(180deg); }
.tg.open .tg-trigger { color: #fff; background: rgba(255,255,255,.09); }

.tg-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  min-width: 220px;
  background: rgba(28,28,30,.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  box-shadow: var(--shadow-pop);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
  display: flex; flex-direction: column; gap: 1px;
}
.tg.open .tg-panel { opacity: 1; visibility: visible; transform: translateY(0); }
.tg-panel a {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-dim); text-decoration: none; font-size: 14px;
  padding: 10px 12px; border-radius: 9px;
  transition: background .15s, color .15s;
}
.tg-panel a:hover { background: rgba(255,255,255,.07); color: #fff; }
.tg-panel a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.tg-ic { font-size: 15px; width: 18px; text-align: center; }

.topnav-backup {
  flex-shrink: 0; text-decoration: none; font-size: 16px;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06);
  transition: background .18s;
}
.topnav-backup:hover { background: var(--accent); }

/* ================= المحتوى ================= */
.content { max-width: 1300px; margin: 0 auto; padding: 36px 28px 60px; }

.app-foot {
  text-align: center; color: var(--muted); font-size: 11.5px;
  padding: 18px; border-top: 1px solid var(--line-soft); margin-top: 20px;
}

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 30px;
}
.page-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.5px; color: #fff; }
.muted { color: var(--muted); font-size: 13.5px; margin-top: 5px; font-weight: 400; }

/* ================= البطاقات ================= */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  transition: background .2s ease;
}
.kpi { display: flex; align-items: center; gap: 16px; }
.kpi-icon {
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
  background: rgba(255,255,255,.06);
}
.kpi-icon.blue  { background: var(--accent-soft); }
.kpi-icon.amber { background: var(--amber-soft); }
.kpi-icon.green { background: var(--green-soft); }
.kpi-icon.navy  { background: rgba(255,255,255,.06); }
.kpi-icon.red-bg{ background: var(--red-soft); }

.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; color: #fff; margin-top: 3px; letter-spacing: -.3px; }
.kpi-value small { font-size: 12.5px; color: var(--muted); font-weight: 500; }

.hint p { margin-top: 6px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: .5; }

/* ================= أزرار وجداول ================= */
.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none; border-radius: 980px; padding: 10px 22px;
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
  font-family: inherit;
  transition: background .2s ease, transform .1s ease;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(.98); }
.btn.secondary {
  background: rgba(255,255,255,.08); color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: rgba(255,255,255,.14); }

table.data {
  width: 100%; border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden;
}
table.data th {
  text-align: right; background: rgba(255,255,255,.03); color: var(--muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: .4px;
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  text-transform: uppercase;
}
table.data td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); font-size: 14px; color: var(--ink-dim); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,.025); color: var(--ink); }

.badge {
  display: inline-block; padding: 4px 12px; border-radius: 980px;
  font-size: 12px; font-weight: 600;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red   { background: var(--red-soft); color: var(--red); }
.badge.gray  { background: rgba(255,255,255,.06); color: var(--muted); }

@media (max-width: 860px) {
  .topnav-groups { display: none; }
  .content { padding: 24px 16px 60px; }
}

/* ================= العملاء ================= */
.head-actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: #e0362c; }
.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

.flash { padding: 13px 18px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.flash.success { background: var(--green-soft); color: var(--green); }
.flash.error   { background: var(--red-soft); color: var(--red); }

.toolbar { display: flex; gap: 10px; margin-bottom: 20px; }
.search {
  flex: 1; max-width: 420px; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 980px; font-size: 14px;
  font-family: inherit; background: var(--card); color: var(--ink);
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.row-actions { display: flex; gap: 12px; }
.row-actions a { color: var(--accent); text-decoration: none; font-size: 13.5px; }
.row-actions a:hover { text-decoration: underline; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.form label { display: flex; flex-direction: column; gap: 7px; font-size: 13px;
  color: var(--muted); font-weight: 500; }
.form label.full { grid-column: 1 / -1; }
.form input, .form textarea, .form select {
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 14.5px; font-family: inherit; color: var(--ink); background: var(--card);
}
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.form input::placeholder, .form textarea::placeholder { color: var(--muted); }

.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.card-title { font-size: 17px; margin-bottom: 16px; font-weight: 600; color: #fff; letter-spacing: -.2px; }
dl.info { display: grid; grid-template-columns: auto 1fr; gap: 11px 14px; font-size: 14px; }
dl.info dt { color: var(--muted); font-weight: 500; }
dl.info dd { color: var(--ink); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px; }
.tab {
  background: none; border: none; padding: 12px 18px; cursor: pointer;
  font-family: inherit; font-size: 14px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }
.pad { padding: 14px 4px; }

.warn-box { border-color: rgba(255,69,58,.3); background: linear-gradient(160deg, rgba(255,69,58,.06), var(--card)); }
.warn-head { font-size: 17px; margin-bottom: 12px; color: #fff; font-weight: 600; }
.warn-list { margin: 12px 22px; line-height: 2; color: var(--ink-dim); }
.danger-text { color: var(--red); font-weight: 600; margin-top: 8px; }

@media (max-width: 800px) {
  .form-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
}

/* ================= الطلبات والموردون ================= */
.filter {
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 980px;
  font-size: 14px; font-family: inherit; background: var(--card); color: var(--ink);
}
.inline-pay { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 0; }
.inline-pay input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: var(--card); color: var(--ink); }

.status-form select {
  padding: 9px 16px; border: 1px solid var(--accent); border-radius: 980px;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); cursor: pointer;
}

.item-form {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-soft);
}
.item-form input, .item-form select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: var(--card); color: var(--ink);
}
.item-form input[name="product_name"] { flex: 1; min-width: 140px; }

.total-row td { font-weight: 700; background: rgba(255,255,255,.03); color: #fff; }
.linkbtn-danger {
  background: none; border: none; color: var(--red); cursor: pointer;
  font-family: inherit; font-size: 13.5px; text-decoration: underline;
}
.tab-action { margin-bottom: 14px; }

/* ================= المدفوعات والأقساط ================= */
.text-red { color: var(--red); }

.collect-bar {
  position: relative; height: 30px; background: var(--card); border: 1px solid var(--line-soft);
  border-radius: 980px; overflow: hidden; margin-bottom: 20px;
}
.collect-bar-fill {
  position: absolute; top: 0; right: 0; height: 100%;
  background: var(--green); border-radius: 980px;
  transition: width .4s;
}
.collect-label {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 12.5px; font-weight: 600; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

.pay-form, .inst-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.pay-form { padding: 6px 0; }
.pay-form-title { font-weight: 600; color: var(--muted); }
.pay-form input, .pay-form select, .inst-row input {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 14px; background: var(--card); color: var(--ink);
}
.inst-row { margin-bottom: 8px; }
.inst-row input[name="label"] { width: 160px; }

.inline-form { display: flex; gap: 6px; align-items: center; }
.mini-select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 12.5px; background: var(--card); color: var(--ink);
}
.btn.small { padding: 6px 14px; font-size: 13px; }

.inst-builder { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.inst-builder summary {
  cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0;
}
.inst-builder summary:hover { text-decoration: underline; }

.inst-toolbar {
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 12px;
}
.inst-total { font-size: 14px; font-weight: 500; color: var(--ink); }
.inst-total strong { color: var(--accent); font-size: 16px; }
.inst-row .linkbtn-danger { white-space: nowrap; }
.inst-breakdown { margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* ================= الشحن والفواتير + الطباعة ================= */
.ship-form {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-soft);
}
.ship-form input, .ship-form select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: var(--card); color: var(--ink);
}
.ship-form input[name="courier_name"] { flex: 1; min-width: 150px; }

.invoice-sheet {
  background: #ffffff; color: #1c2433;
  border: 1px solid #e4e8ee; border-radius: var(--radius);
  padding: 34px 38px; max-width: 820px;
  box-shadow: var(--shadow-card);
}
.invoice-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #16243d; padding-bottom: 16px; margin-bottom: 20px;
}
.invoice-brand { font-size: 20px; font-weight: 800; color: #16243d; }
.invoice-brand { display: flex; align-items: center; gap: 12px; }
.invoice-logo { height: 46px; width: auto; flex-shrink: 0; }
.invoice-brand small { display: block; font-size: 11px; letter-spacing: 2px;
  color: #6b7689; font-weight: 600; margin-top: 2px; }
.invoice-meta { text-align: left; font-size: 13.5px; color: #6b7689; }
.invoice-meta .num { font-size: 18px; font-weight: 800; color: #1c2433; margin-bottom: 4px; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 20px; }
.invoice-sheet table.data { background: #fff; border-color: #e4e8ee; }
.invoice-sheet table.data th { background: #f0f3f8; color: #6b7689; border-color: #e4e8ee; text-transform: none; }
.invoice-sheet table.data td { color: #1c2433; border-color: #e4e8ee; }
.invoice-total-row td { font-weight: 800; background: #f0f3f8 !important; color: #1c2433 !important; }
.invoice-foot {
  margin-top: 24px; font-size: 12.5px; color: #6b7689; text-align: center;
  border-top: 1px dashed #e4e8ee; padding-top: 14px;
}

@media (max-width: 800px) { .invoice-parties { grid-template-columns: 1fr; } }

@media print {
  .topnav, .app-foot, .fab-wrap, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .content { max-width: none; padding: 0; }
  .invoice-sheet { border: none; border-radius: 0; padding: 0; max-width: none; box-shadow: none; }
  table.data th, .invoice-total-row td, table.data tr:hover td {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .app-shell { opacity: 1 !important; transform: none !important; }
}

/* ================= النسخ الاحتياطي + التقارير ================= */
.rep-range { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

/* ================= الخصم، كشوف الحساب، التفاصيل ================= */
.text-green { color: var(--green); }
.sub-line { font-size: 12px; color: var(--muted); margin-top: 2px; }

.readonly-field { background: rgba(255,255,255,.04) !important; color: var(--muted) !important; font-weight: 600; }
.field-error { border-color: var(--red) !important; box-shadow: 0 0 0 4px var(--red-soft) !important; }

a.card-link {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit;
  transition: transform .2s cubic-bezier(.2,.8,.2,1), background .2s ease;
}
a.card-link:hover { transform: translateY(-3px); background: var(--card-2); }
a.card-link::after {
  content: "‹"; margin-right: auto; color: var(--muted);
  font-size: 20px; font-weight: 400;
}

.contract-card { margin-bottom: 14px; }
.contract-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

.notice-box {
  background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 18px 20px; line-height: 1.9; font-size: 14.5px; color: var(--ink-dim);
}
.notice-box p { margin-bottom: 6px; }
.row-highlight td { background: var(--accent-soft) !important; font-weight: 600; color: #fff !important; }

@media print {
  a.card-link::after { display: none; }
  .notice-box { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ================= مسار تنقّل (Breadcrumb) ================= */
.breadcrumb {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: .5; }
.breadcrumb .current { color: var(--ink); font-weight: 500; }

/* ================= زر الإجراءات السريعة العائم ================= */
.fab-wrap {
  position: fixed; bottom: 28px; left: 28px; z-index: 70;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.fab-menu {
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.96);
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.fab-menu.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.fab-item {
  display: flex; align-items: center; gap: 10px;
  background: rgba(28,28,30,.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--line);
  color: var(--ink); text-decoration: none;
  padding: 11px 18px; border-radius: 980px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-pop);
  white-space: nowrap;
  transition: background .15s, transform .1s;
}
.fab-item:hover { background: rgba(41,151,255,.18); transform: translateX(-2px); }
.fab-ic { font-size: 15px; }

.fab-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 28px; font-weight: 300; line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 20px -4px var(--accent-glow), var(--shadow-pop);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), background .2s;
  display: flex; align-items: center; justify-content: center;
}
.fab-btn:hover { background: var(--accent-2); }
.fab-btn.open { transform: rotate(45deg); }

@media (max-width: 860px) {
  .fab-wrap { bottom: 18px; left: 18px; }
}

/* ================= بطاقات الموردين ================= */
.supplier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.supplier-card { display: flex; flex-direction: column; gap: 14px; }
.supplier-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.supplier-name { font-size: 16px; font-weight: 700; color: #fff; text-decoration: none; }
.supplier-name:hover { color: var(--accent); }
.supplier-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.supplier-stats > div { display: flex; flex-direction: column; gap: 3px; }
.supplier-stats .muted { font-size: 11.5px; }
.supplier-stats strong { font-size: 15px; color: var(--ink); font-weight: 600; }
.supplier-card-actions { display: flex; gap: 8px; align-items: center; }
.supplier-card-actions .btn { flex: 1; text-align: center; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 15px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  transition: background .15s;
}
.icon-btn.danger:hover { background: var(--red-soft); border-color: var(--red); }

/* ================= مفتاح مقسّم (segmented control) ================= */
.segmented { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 980px; padding: 3px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 8px 20px; border-radius: 980px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: background .15s, color .15s;
}
.segmented input:checked + label { background: var(--accent); color: #fff; }

/* ================= طباعة عامة لأي صفحة (كشف حساب، إلخ) ================= */
.print-only { display: none; }

@media print {
  .print-only { display: block; }
  body, .content { background: #fff !important; }
  .card, .cards .card, table.data {
    background: #fff !important; border-color: #e4e8ee !important; box-shadow: none !important;
  }
  .card *, table.data th, table.data td, .supplier-name, .kpi-label, .kpi-value {
    color: #1c2433 !important;
  }
  table.data th { background: #f0f3f8 !important; }
  .kpi-icon { background: transparent !important; }
  .badge.green { color: #1a7a41 !important; background: #e3f5e9 !important; }
  .badge.red   { color: #b3261e !important; background: #fdeceb !important; }
  .badge.amber { color: #946200 !important; background: #fff3da !important; }
  .badge.gray  { color: #555 !important; background: #eee !important; }
  .supplier-stats, .total-row td { border-color: #e4e8ee !important; }
}

/* ================= نافذة البحث العام ================= */
.search-modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  opacity: 0; visibility: hidden;
  transition: opacity .15s ease, visibility .15s;
}
.search-modal.open { opacity: 1; visibility: visible; }
.search-modal-panel {
  width: 100%; max-width: 560px; margin: 0 20px;
  background: rgba(28,28,30,.92);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  transform: translateY(-8px);
  transition: transform .15s ease;
}
.search-modal.open .search-modal-panel { transform: translateY(0); }

.search-modal-box {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
}
.search-ic { font-size: 16px; opacity: .7; }
.search-modal-box input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--ink); font-size: 16px; font-family: inherit;
}
.search-modal-box input::placeholder { color: var(--muted); }
.search-esc {
  font-size: 11px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 7px;
}

.search-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.search-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  text-decoration: none; color: var(--ink);
}
.search-result.active, .search-result:hover { background: var(--accent-soft); }
.search-result-ic { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
.search-result-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.search-result-title { font-size: 14.5px; font-weight: 600; color: #fff; }
.search-result-sub { font-size: 12.5px; color: var(--muted); }
.search-result-type { font-size: 11.5px; color: var(--accent); flex-shrink: 0; }

/* ================= chips التصنيفات بنموذج العميل ================= */
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tag-chip {
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  color: var(--ink-dim); font-family: inherit; font-size: 12.5px; font-weight: 500;
  padding: 6px 14px; border-radius: 980px; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.tag-chip:hover { border-color: var(--accent); color: #fff; }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ================= Timeline بملف العميل ================= */
.timeline { position: relative; padding: 4px 4px 4px 0; }
.timeline-item {
  display: flex; gap: 14px; position: relative; padding-bottom: 22px;
}
.timeline-item::before {
  content: ""; position: absolute; top: 34px; bottom: 0; right: 17px;
  width: 1px; background: var(--line);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; z-index: 1;
}
.timeline-body { padding-top: 6px; }
.timeline-text { font-size: 14px; color: var(--ink); }
.timeline-date { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ================= شاشة القفل ================= */
.lock-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(41,151,255,.10), transparent 60%),
    var(--bg);
  padding: 20px;
}
.lock-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  padding: 40px 34px;
  text-align: center;
  box-shadow: var(--shadow-pop);
}
.lock-logo { height: 46px; width: auto; margin-bottom: 22px; opacity: .95; }
.lock-title { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -.2px; }
.lock-sub { font-size: 13.5px; color: var(--muted); margin-top: 6px; margin-bottom: 22px; }

.lock-form { display: flex; flex-direction: column; gap: 12px; }
.lock-form input {
  padding: 13px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; color: var(--ink); background: var(--surface-2);
  text-align: center; letter-spacing: 2px;
}
.lock-form input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.lock-btn { width: 100%; padding: 13px 0; font-size: 15px; font-weight: 600; }

.lock-screen .flash { text-align: right; margin-bottom: 16px; }

/* ================= الاشتراكات الشهرية ================= */
.sub-form input[name="name"] { flex: 1; min-width: 190px; }
.sub-form input[name="notes"] { flex: 1; min-width: 150px; }
.sub-name { font-weight: 600; color: #fff; font-size: 14.5px; }
.sub-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 5px; }
.sub-meta .muted { margin-top: 0; font-size: 12.5px; }
.sub-paused td { opacity: .55; }
.sub-next { font-size: 20px; }
.sub-next small { display: block; margin-top: 2px; }
.sub-list { margin-top: 16px; overflow-x: auto; }
.row-actions form { display: inline; }
.row-actions .linkbtn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-family: inherit; font-size: 13.5px;
}
.row-actions .linkbtn:hover { text-decoration: underline; }
.sub-list td .badge { margin-inline-start: 6px; font-size: 11.5px; padding: 3px 10px; }
.sub-list .sub-meta .badge { margin-inline-start: 0; }
#tab-subs .cards { margin-top: 4px; }

/* ================= تمرير الجداول أفقياً (كل الشاشات) ================= */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ================= موبايل: عناصر التنقل مخفية على الشاشات الكبيرة ================= */
.mnav, .msheet, .msheet-backdrop { display: none; }

/* ================= نسخة الموبايل / الآيفون ================= */
@media (max-width: 860px) {
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); -webkit-text-size-adjust: 100%; }

  /* منع تكبير الصفحة تلقائياً عند الضغط على أي حقل بالآيفون */
  input, select, textarea { font-size: 16px !important; }
  button, .btn, a.btn { -webkit-tap-highlight-color: transparent; }

  /* الشريط العلوي: الشعار + البحث فقط (باقي الأدوات بقائمة "المزيد") */
  .topnav-inner { padding: 0 16px; gap: 10px; }
  .topnav-backup.hide-m { display: none; }
  .topnav-backup.search-m { margin-inline-start: auto; width: 40px; height: 40px; }

  /* شريط التنقل السفلي */
  .mnav {
    display: flex; position: fixed; right: 0; left: 0; bottom: 0; z-index: 65;
    background: rgba(20,20,22,.86);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .mnav a, .mnav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 50px; border: none; background: none; border-radius: 12px; cursor: pointer;
    color: var(--muted); font-family: inherit; font-size: 10.5px; font-weight: 500; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mnav .ic { font-size: 20px; line-height: 1; filter: grayscale(.6); opacity: .8; }
  .mnav .active { color: var(--accent); }
  .mnav .active .ic { filter: none; opacity: 1; }

  /* قائمة "المزيد" (ورقة سفلية) */
  .msheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55);
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
  }
  .msheet-backdrop.open { opacity: 1; visibility: visible; }
  .msheet {
    display: block; position: fixed; right: 0; left: 0; bottom: 0; z-index: 85;
    max-height: 84vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: rgba(28,28,30,.98); border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0; padding: 10px 16px calc(26px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  .msheet.open { transform: translateY(0); }
  .msheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); margin: 4px auto 6px; }
  .msheet h4 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 4px 8px; letter-spacing: .3px; }
  .msheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .msheet-grid a {
    display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 12px 14px;
    background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 14px;
    color: var(--ink); text-decoration: none; font-size: 14.5px;
  }
  .msheet-grid a.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }

  /* الزر العائم فوق الشريط السفلي */
  .fab-wrap { bottom: calc(80px + env(safe-area-inset-bottom)); left: 16px; }
  .fab-btn { width: 52px; height: 52px; }

  /* المحتوى */
  .content { padding: 18px 14px 24px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 20px; }
  .page-head h1 { font-size: 24px; }
  .page-head > .btn, .page-head > a.btn { align-self: flex-start; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; text-align: center; }
  .card-title { font-size: 16px; margin-bottom: 12px; }

  /* بطاقات الأرقام: عمودين وحجم مضغوط */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
  .card { padding: 16px; border-radius: 16px; }
  .kpi, a.card-link.kpi { flex-direction: column; align-items: flex-start; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; border-radius: 11px; font-size: 17px; }
  .kpi-value { font-size: 22px; }
  .kpi-value.sub-next { font-size: 17px; }
  a.card-link::after { display: none; }

  /* أزرار بحجم مناسب للمس */
  .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; }
  .btn.small { min-height: 38px; padding: 6px 16px; }

  /* نماذج الإضافة السريعة: حقل تحت حقل بعرض كامل */
  .pay-form { flex-direction: column; align-items: stretch; }
  .pay-form input, .pay-form select, .pay-form .btn { width: 100%; min-height: 46px; }
  .pay-form input[name="name"], .pay-form input[name="notes"] { min-width: 0; }
  .form-actions .btn { flex: 1; }
  .form input, .form textarea, .form select { min-height: 46px; }

  .toolbar { flex-wrap: wrap; }
  .search { max-width: none; min-height: 44px; }
  .filter { min-height: 44px; }

  /* التبويبات: تمرير أفقي إذا كثرت */
  .tabs { overflow-x: auto; white-space: nowrap; scrollbar-width: none; margin-inline: -2px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; padding: 12px 16px; }

  /* الجداول العادية: تمرير أفقي بدل القص */
  table.data { min-width: 600px; }
  table.data th, table.data td { padding: 11px 12px; }

  /* نافذة البحث */
  .search-modal { padding-top: 8vh; }
  .search-modal-panel { margin: 0 12px; }
  .search-esc { display: none; }

  /* شاشة القفل */
  .lock-card { padding: 32px 22px; }
}

/* ===== جداول تتحول لبطاقات على الموبايل (class="stack") ===== */
@media (max-width: 700px) {
  table.data.stack { min-width: 0; background: none; border: none; border-radius: 0; }
  .stack thead { display: none; }
  .stack, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack tr {
    background: var(--card); border: 1px solid var(--line-soft); border-radius: 16px;
    padding: 12px 16px; margin-bottom: 10px;
  }
  .stack tr:hover td { background: none; }
  .stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border: none; font-size: 14px; text-align: left;
  }
  .stack td[data-label]::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 500; flex-shrink: 0;
  }
  .stack td.stack-title { display: block; padding: 2px 0 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; text-align: right; }
  .stack td.stack-actions { display: block; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line-soft); }
  .stack .row-actions { justify-content: space-between; gap: 8px; }
  .stack .row-actions a, .stack .row-actions .linkbtn, .stack .row-actions .linkbtn-danger,
  .stack td.stack-actions .linkbtn-danger { min-height: 40px; padding: 0 6px; display: inline-flex; align-items: center; font-size: 14px; }
  .stack tr.total-row { background: var(--accent-soft); border-color: transparent; }
  .stack tr.total-row td { background: none; padding: 4px 0; }
  .stack tr.total-row td:empty { display: none; }
  .stack .inline-form { width: 100%; }
  .stack .inline-form .mini-select { flex: 1; min-height: 44px; }
  .stack .badge { margin-inline-start: 0; }
}

/* ---- تحسينات بطاقات الجداول على الموبايل ---- */
@media (max-width: 700px) {
  /* لا نحط بطاقات داخل بطاقة: الحاوية الخارجية تصير شفافة */
  .card:has(table.stack) { background: none; border: none; box-shadow: none; padding: 0; }
  .card:has(table.stack) > .card-title { margin-bottom: 12px; }
  .stack td > span { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  /* خانة تسجيل الدفعة: العنوان فوق والتاريخ والزر تحته بعرض كامل */
  .stack td.stack-pay { flex-wrap: wrap; }
  .stack td.stack-pay .inline-form { flex: 1 1 100%; gap: 8px; }
  .stack td.stack-pay .mini-select { flex: 1; min-width: 0; width: auto; }
  .stack td.stack-pay .btn { flex-shrink: 0; }
  .stack td.stack-pay > .badge { margin-inline-start: auto; }
}
@media (max-width: 700px) {
  table.data.stack td.stack-actions { border-bottom: none; }
  table.data.stack tr:last-child td.stack-actions { border-bottom: none; }
}

/* زر البحث العلوي (button) بدون الإطار الافتراضي للمتصفح */
button.topnav-backup { border: none; padding: 0; cursor: pointer; color: inherit; font-family: inherit; }

@media (max-width: 860px) {
  table.data:not(.stack) td:first-child, table.data:not(.stack) td:first-child a, .badge { white-space: nowrap; }
}

/* نموذج الاشتراك: عرض مناسب لخانتي المبلغ ويوم السحب على الكمبيوتر */
.sub-form input[name="amount"] { width: 150px; }
.sub-form input[name="billing_day"] { width: 175px; }
.sub-form input[name="rate"] { width: 150px; }
@media (max-width: 860px) {
  .sub-form input[name="amount"], .sub-form input[name="billing_day"], .sub-form input[name="rate"] { width: 100%; }
}
/* TypeScript migration: accessible dropdowns and a compact mobile menu. */
.ts-mobile-menu{display:none;background:#27272a;border:1px solid #383838;color:#fff;padding:7px 12px;border-radius:10px;cursor:pointer;font-size:18px}
@media(min-width:861px){.topnav-groups .tg:hover .tg-panel,.topnav-groups .tg:focus-within .tg-panel{opacity:1;visibility:visible;transform:translateY(0)}}
@media(max-width:860px){
 .ts-mobile-menu{display:block;margin-inline-start:auto}
 .topnav-inner{gap:10px;padding:0 16px;position:relative}
 .topnav-groups.ts-open{display:flex;position:absolute;top:calc(100% + 2px);left:12px;right:12px;z-index:40;flex-direction:column;align-items:stretch;background:#1a1a1e;border:1px solid #39393c;border-radius:14px;padding:12px;max-height:80vh;overflow-y:auto;box-shadow:0 8px 24px #0009}
 .topnav-groups .tg{width:100%}
 .topnav-groups .tg-panel{position:static;display:none;opacity:1;visibility:visible;transform:none;box-shadow:none;background:transparent;border:none;min-width:0;padding:0 8px}
 .topnav-groups .tg.open .tg-panel{display:flex}
 .topnav-groups .tg-trigger{width:100%;justify-content:space-between}
 .form-grid{grid-template-columns:1fr}
 .page-head{align-items:flex-start;gap:12px;flex-wrap:wrap}
}


/* Waleed original desktop toolbar restored; no account/data CSS changed. */
.topnav-legacy-tools { display:flex; flex:0 0 auto; align-items:center; gap:14px; }
.topnav-legacy-tools form { display:flex; align-items:center; margin:0; padding:0; }
.topnav-legacy-tools .topnav-backup { color:var(--ink); border:0; cursor:pointer; font-family:inherit; padding:0; }
.topnav-legacy-tools a.topnav-backup { color:inherit; }
.search-modal-footer { border-top:1px solid var(--line-soft); padding:10px 18px; text-align:left; }
.search-modal-footer a { color:var(--accent); text-decoration:none; font-size:13px; }
.search-modal-footer a:hover { text-decoration:underline; }
@media(max-width:860px){
 .topnav-legacy-tools { gap:8px; margin-inline-start:auto; }
 .topnav-legacy-tools .hide-m { display:none; }
 .topnav-legacy-tools .topnav-backup.search-m { margin-inline-start:0; }
}
