:root {
  /* Fat2Fit identity (repo_identity fat1fit): primary #502360, secondary #9A2B87, black, white */
  --pink: #9A2B87;
  --pink-soft: #F7EEF5;
  --purple: #502360;
  --purple-dark: #200E26;
  --ink: #000000;
  --muted: #666666;
  --line: #E3DCE6;
  --bg: #F1EDF2;
  --card: #fff;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 12px;
  color-scheme: light; /* native dropdowns stay light even in a dark-mode Mac */
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pink); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 220px; flex-shrink: 0; background: linear-gradient(180deg, #000000 0%, var(--purple-dark) 100%);
  color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 8px 20px; margin-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 150px; height: auto; display: block; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: #CD95C3; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #E3DCE6; text-decoration: none; cursor: pointer; border: 0; background: none; text-align: right; width: 100%; }
.nav:hover { background: rgba(255,255,255,.08); }
.nav.on { background: var(--pink); color: #fff; font-weight: 600; }
.nav .count { margin-inline-start: auto; background: var(--pink); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; }
.nav.on .count { background: #fff; color: var(--pink); }
.side .me { margin-top: auto; padding: 10px 12px; font-size: 13px; opacity: .85; border-top: 1px solid rgba(255,255,255,.12); }
.side .me button { background: none; border: 0; color: #DFBBD9; cursor: pointer; padding: 0; margin-inline-start: 6px; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
h1 { font-size: 20px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; color: var(--purple); }
h1 .sub { font-size: 13px; color: var(--muted); font-weight: 400; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.kpi { cursor: pointer; padding: 12px 14px; }
.kpi:hover { border-color: #C7B9CC; }
.kpi .n { font-size: 24px; font-weight: 700; color: var(--purple); }
.kpi .l { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 240px; }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=tel], select, textarea {
  border: 1px solid #C7B9CC; border-radius: 10px; padding: 8px 11px; background: #fff; min-height: 38px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(80,35,96,.14); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.btn { border: 0; border-radius: 10px; padding: 8px 14px; min-height: 38px; cursor: pointer; background: #E3DCE6; color: var(--purple); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--purple); color: #fff; }
.btn.primary:hover { background: var(--pink); filter: none; }
.btn.wa { background: #22c55e; color: #fff; }
.btn.call { background: #3b82f6; color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* table */
.tbl { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: right; font-weight: 600; color: var(--purple); font-size: 12.5px; background: #F1EDF2; padding: 9px 10px; white-space: nowrap; }
.tbl td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tr.row { cursor: pointer; }
.tbl tr.row:hover td { background: var(--pink-soft); }
.tbl .num { white-space: nowrap; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.muted { color: var(--muted); }
/* quick actions next to the customer name */
.name-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qa { display: inline-flex; gap: 5px; align-items: center; }
.ic { width: 34px; height: 34px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; flex-shrink: 0; padding: 0; }
.ic.wa { background: #22c55e; color: #fff; }
.ic.call { background: #3b82f6; color: #fff; }
.ic.info { background: #F1EDF2; color: var(--purple); font-weight: 700; font-size: 15px; border: 1px solid #C7B9CC; }
.ic:hover { filter: brightness(.92); }
.ic.wa svg { width: 20px; height: 20px; }
.ic.call svg { width: 18px; height: 18px; }
.qa { gap: 6px; }
/* status colours (classes, because the CSP blocks inline styles) */
/* Faisal 2/12: every status has its own colour (dot + tinted field), so none look alike */
.s-new            { --sdot: #94a3b8; --sbg: #ffffff; --sbd: #cbd5e1; --stx: #475569; }
.s-no_answer, .s-callback { --sdot: #f97316; --sbg: #ffedd5; --sbd: #fdba74; --stx: #9a3412; }
.s-whatsapp_sent  { --sdot: #22c55e; --sbg: #dcfce7; --sbd: #86efac; --stx: #166534; }
.s-interested     { --sdot: #2563eb; --sbg: #dbeafe; --sbd: #93c5fd; --stx: #1e40af; }
.s-rejoined       { --sdot: #9A2B87; --sbg: #f7e4f3; --sbd: #dfa3d3; --stx: #6e1a60; }
.s-not_interested { --sdot: #78716c; --sbg: #e7e5e4; --sbd: #a8a29e; --stx: #44403c; }
.s-wrong_number   { --sdot: #dc2626; --sbg: #fee2e2; --sbd: #fca5a5; --stx: #991b1b; }
.s-do_not_contact { --sdot: #111827; --sbg: #e5e7eb; --sbd: #9ca3af; --stx: #111827; }
.dot[class*="s-"] { background: var(--sdot); }
.st-btn[class*="s-"], .pill[class*="s-"] { background: var(--sbg); border: 1px solid var(--sbd); color: var(--stx); font-weight: 600; }
.st-btn.s-new { border-style: dashed; }
.st-btn[class*="s-"] .car { color: var(--stx); opacity: .7; }
.st-menu button[class*="s-"] { color: var(--stx); font-weight: 500; }
.st-menu button[class*="s-"]:hover, .st-menu button[class*="s-"].on { background: var(--sbg); color: var(--stx); }
.status-picks button[class*="s-"] { color: var(--stx); }
.status-picks button[class*="s-"].on { background: var(--sbg); border-color: var(--sdot); }
.st-menu button .dot { width: 10px; height: 10px; }
/* Faisal 2/12: every employee (المسؤولة) has her own colour */
.a-0 { --adot: #0d9488; --abg: #ccfbf1; --abd: #5eead4; --atx: #115e59; }
.a-1 { --adot: #db2777; --abg: #fce7f3; --abd: #f9a8d4; --atx: #9d174d; }
.a-2 { --adot: #ca8a04; --abg: #fef9c3; --abd: #fde047; --atx: #854d0e; }
.a-3 { --adot: #4f46e5; --abg: #e0e7ff; --abd: #a5b4fc; --atx: #3730a3; }
.a-4 { --adot: #0891b2; --abg: #cffafe; --abd: #67e8f9; --atx: #155e75; }
.a-5 { --adot: #65a30d; --abg: #ecfccb; --abd: #bef264; --atx: #3f6212; }
.a-6 { --adot: #e11d48; --abg: #ffe4e6; --abd: #fda4af; --atx: #9f1239; }
.a-7 { --adot: #7c3aed; --abg: #ede9fe; --abd: #c4b5fd; --atx: #5b21b6; }
.a-8 { --adot: #ea580c; --abg: #fff7ed; --abd: #fdba74; --atx: #9a3412; }
.a-9 { --adot: #475569; --abg: #f1f5f9; --abd: #94a3b8; --atx: #1e293b; }
.a-none { --adot: #cbd5e1; --abg: #ffffff; --abd: #e3dce6; --atx: #666666; }
.av { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0; background: var(--adot); color: #fff; font-size: 11px; font-weight: 700; font-style: normal; line-height: 1; }
.as-btn[class*="a-"], .as-pill { background: var(--abg); border: 1px solid var(--abd); color: var(--atx); font-weight: 600; }
.as-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 4px; border-radius: 99px; font-size: 12.5px; white-space: nowrap; }
.as-btn.a-none { border-style: dashed; font-weight: 400; }
.as-btn[class*="a-"] .car { color: var(--atx); opacity: .7; }
.st-menu button[class*="a-"] { color: var(--atx); font-weight: 500; }
.st-menu button[class*="a-"]:hover, .st-menu button[class*="a-"].on { background: var(--abg); color: var(--atx); }
/* status field in the list + its light menu right under it */
.st-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 3px 10px; font-size: 13px; border-radius: 99px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; max-width: 170px; }
.st-btn:hover { border-color: var(--pink); }
.st-btn span { overflow: hidden; text-overflow: ellipsis; }
.st-btn .car { color: var(--muted); font-size: 11px; margin-inline-start: auto; font-weight: 400; }
.st-btn:disabled { opacity: .6; cursor: wait; }
.st-menu { position: fixed; z-index: 50; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(32,14,38,.18); padding: 5px; display: flex; flex-direction: column; color-scheme: light; max-height: 70vh; overflow-y: auto; }
.st-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: start; font-size: 13.5px; cursor: pointer; }
.st-menu button:hover { background: var(--pink-soft); }
.st-menu button.on { background: #F1EDF2; color: var(--purple); font-weight: 600; }
.st-menu .tick { margin-inline-start: auto; color: var(--purple); }
.drawer.mini { width: min(420px, 100vw); }
/* Faisal 1/12: «لا ترد» + «معاودة اتصال» = one status, same colour */
/* notes column (last column, on the left) */
.tbl td.note-cell { width: 28%; min-width: 180px; }
.note-btn { display: block; width: 100%; text-align: start; background: #FAF7FB; border: 1px dashed #D9CCDD; border-radius: 8px; padding: 6px 9px; font: inherit; font-size: 13px; color: var(--ink); cursor: text; line-height: 1.5; max-height: 3.2em; overflow: hidden; white-space: normal; }
.note-btn:hover { border-color: var(--pink); background: #fff; }
.note-btn.blank { color: var(--muted); }
.tbl td.hide-m { white-space: nowrap; }
.notes-big { min-height: 160px; }
.tbl tr.row { cursor: default; }
.mt { margin-top: 10px; display: block; }
.mb { margin-bottom: 16px; }
.h3 { margin: 0 0 10px; }
.h1-tools { margin-inline-start: auto; display: flex; gap: 6px; }
a.kpi.plain { text-decoration: none; color: inherit; }
.bar-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
progress.pbar { width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: #E3DCE6; appearance: none; -webkit-appearance: none; display: block; }
progress.pbar::-webkit-progress-bar { background: #E3DCE6; border-radius: 99px; }
progress.pbar::-webkit-progress-value { background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: 99px; }
progress.pbar::-moz-progress-bar { background: linear-gradient(90deg, var(--purple), var(--pink)); border-radius: 99px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500; white-space: nowrap; background: #F1EDF2; }
.late { color: var(--danger); font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; }

/* drawer */
.overlay { position: fixed; inset: 0; background: rgba(32,14,38,.45); z-index: 20; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(520px, 100vw); background: #fff; z-index: 21; overflow-y: auto; box-shadow: 0 0 40px rgba(0,0,0,.15); display: flex; flex-direction: column; }
.drawer header { padding: 18px 20px 12px; border-bottom: 3px solid var(--purple); position: sticky; top: 0; background: #fff; z-index: 1; }
.drawer header h2 { margin: 0 0 4px; font-size: 18px; display: flex; gap: 8px; align-items: center; color: var(--purple); }
.drawer .x { position: absolute; left: 14px; top: 14px; background: #F1EDF2; border: 0; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.drawer section { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer h3 { font-size: 14px; margin: 0 0 10px; color: var(--pink); font-weight: 600; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.status-picks button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-picks button.on { border-color: var(--purple); background: #F7EEF5; font-weight: 600; }
.row2 { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { color: var(--muted); font-size: 12px; }
.chan { display: inline-flex; gap: 4px; }
.chan button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.chan button.on { background: var(--purple); color: #fff; border-color: var(--purple); }
.dnc { background: #000000; color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 13px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; background: radial-gradient(circle at 15% 10%, rgba(154,43,135,.45), transparent 45%), radial-gradient(circle at 85% 90%, rgba(80,35,96,.75), transparent 50%), #000000; padding: 16px; }
.login-logo { width: min(260px, 70vw); height: auto; display: block; }
.login { width: min(380px, 100%); padding: 28px; border: 0; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.login h2 { margin: 0 0 4px; font-size: 18px; color: var(--purple); text-align: center; }
.login label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.login input { width: 100%; }
.login .btn { width: 100%; justify-content: center; margin-top: 18px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* forms */
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: end; }
.form label { font-size: 12.5px; color: var(--muted); display: grid; gap: 4px; }
.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--purple); color: #fff; padding: 10px 18px; border-radius: 10px; transition: transform .25s; z-index: 50; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.check { width: 18px; height: 18px; accent-color: var(--purple); }
.bar { height: 8px; border-radius: 99px; background: #E3DCE6; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--pink)); }

/* mobile */
.topbar { display: none; }
@media (max-width: 860px) {
  .side { display: none; }
  .side.open { display: flex; position: fixed; z-index: 30; right: 0; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #000000; color: #fff; position: sticky; top: 0; z-index: 10; }
  .topbar img { height: 30px; width: auto; display: block; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .shell { flex-direction: column; }
  .main { padding: 14px 16px 60px; }
  .split { grid-template-columns: 1fr; }
  .hide-m { display: none; }
}
/* Faisal 1/12: small "!" right next to the name; WhatsApp + call in their own column after the name */
.name-line { flex-wrap: nowrap; gap: 6px; }
.name-line b { white-space: nowrap; }
.ic.info { width: 22px; height: 22px; font-size: 12px; }
.tbl td.qa-cell, .tbl th.qa-cell { width: 1%; white-space: nowrap; text-align: center; }
.qa-cell .qa { flex-wrap: nowrap; }
.as-btn { min-width: 120px; }
.as-big { width: 100%; }

/* Faisal 1/12: «إضافة عميلة» form */
.add-form { display: grid; gap: 14px; }
.add-form label { display: block; font-weight: 600; }
.add-form label .muted { font-weight: 400; font-size: 12px; }
.add-form input, .add-form select, .add-form textarea { display: block; width: 100%; margin-top: 6px; }
.add-form .btn { justify-self: start; min-width: 120px; }
/* Faisal 1/12: the add page opens on the right side (same side as its button) */
.drawer.right { left: auto; right: 0; }
/* the status field in the add page = same light menu as the list */
.add-form .lbl { display: block; font-weight: 600; }
.add-form .lbl .muted { font-weight: 400; font-size: 12px; }
.add-form .add-st { display: flex; width: 100%; max-width: none; margin-top: 6px; min-height: 42px; border-radius: 10px; border-color: #C7B9CC; font-size: 15px; font-weight: 600; padding: 8px 12px; }
.add-form .add-st:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(80,35,96,.14); outline: none; }
.add-form .add-st[class*="s-"] { border-color: var(--sbd); color: var(--stx); }
@media (max-width: 640px) { h1 { flex-wrap: wrap; } }
/* Faisal 2/12: every native dropdown is replaced by a light button + light menu (no dark browser popup) */
.pickbtn { min-height: 38px; border-radius: 10px; border-color: #C7B9CC; padding: 6px 12px; font-size: 13.5px; min-width: 130px; max-width: 220px; }
.pickbtn.pick-on { border-color: var(--purple); color: var(--purple); font-weight: 600; background: #F7EEF5; }
.drawer .pickbtn, .form .pickbtn { max-width: none; }
.form .pickbtn, .as-big + .pickbtn { width: 100%; }
/* Faisal 2/12: delete employee account (admin only) */
.btn.danger { background: transparent; border: 1px solid #F5C2C2; color: var(--danger); }
.btn.danger:hover { background: #FDECEC; filter: none; }
.form input, .form select { width: 100%; min-width: 0; }
