:root {
  --bg: #F4F6FA;
  --card: #fff;
  --line: #E3E7EF;
  --line-2: #EEF1F6;
  --text: #0F172A;
  --text-2: #334155;
  --muted: #64748B;
  --brand: #2563EB;
  --brand-2: #1D4ED8;
  --brand-soft: #E8F0FE;
  --cyan: #22D3EE;
  --nav: #0B1220;
  --nav-2: #131C2E;
  --green: #16A34A; --green-soft: #E7F6EC;
  --amber: #B45309; --amber-soft: #FEF3C7;
  --orange: #C2410C; --orange-soft: #FFEDD5;
  --red: #DC2626; --red-soft: #FEE2E2;
  --violet: #7C3AED; --violet-soft: #EDE9FE;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  font-family: "IBM Plex Sans Arabic", "Inter", "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--text-2); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--nav); color: #CBD5E1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand img { width: 30px; height: 27px; }
.brand b { display: block; color: #fff; font-size: 16px; letter-spacing: .01em; }
.brand small { color: #7C8AA5; font-size: 11.5px; }
.side-new { margin: 4px 14px 10px; }
nav.menu { flex: 1; overflow: auto; padding: 4px 10px; }
nav.menu .sect { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5B6B88; margin: 14px 10px 6px; }
nav.menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #CBD5E1; margin-bottom: 1px; text-decoration: none; }
nav.menu a:hover { background: var(--nav-2); color: #fff; }
nav.menu a.active { background: linear-gradient(90deg, rgba(37,99,235,.9), rgba(34,211,238,.55)); color: #fff; }
[dir=rtl] nav.menu a.active { background: linear-gradient(270deg, rgba(37,99,235,.9), rgba(34,211,238,.55)); }
nav.menu a .ic { width: 20px; text-align: center; opacity: .9; }
nav.menu a .cnt { margin-inline-start: auto; background: rgba(255,255,255,.1); border-radius: 99px; font-size: 11.5px; padding: 0 8px; min-width: 22px; text-align: center; }
nav.menu a .cnt.hot { background: var(--red); color: #fff; }
.side-foot { padding: 10px 14px 14px; border-top: 1px solid #1B2539; }
.me { display: flex; gap: 10px; align-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2563EB, #22D3EE); color: #fff; display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.me b { display: block; color: #fff; font-size: 13px; }
.me small { color: #7C8AA5; font-size: 11.5px; }
.me-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.me-actions button { background: none; border: 0; color: #93A3BF; cursor: pointer; font-size: 12px; padding: 0; }
.me-actions button:hover { color: #fff; }
.lang-switch { display: inline-flex; border: 1px solid #243049; border-radius: 8px; overflow: hidden; }
.lang-switch button { background: none; border: 0; color: #93A3BF; padding: 4px 10px; cursor: pointer; font-size: 12px; font-weight: 600; }
.lang-switch button.active { background: #243049; color: #fff; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding-inline-start: 34px; background: var(--bg); border-color: transparent; }
.topbar .search::before { content: "⌕"; position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 17px; }
.bell { position: relative; background: none; border: 0; cursor: pointer; font-size: 18px; padding: 6px 8px; border-radius: 8px; }
.bell:hover { background: var(--bg); }
.bell .dot { position: absolute; top: 2px; inset-inline-end: 2px; background: var(--red); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; min-width: 16px; text-align: center; }
.notif-panel { position: absolute; top: 52px; inset-inline-end: 16px; width: 360px; max-height: 70vh; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.14); z-index: 30; }
.notif-panel .n { padding: 10px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; font-size: 13.5px; }
.notif-panel .n.unread { background: #F5F9FF; }
.notif-panel .n:hover { background: var(--bg); }
#view { flex: 1; padding: 22px 24px; }
.footer { text-align: center; padding: 14px 0 18px; }
.fz-credit { display: inline-flex; align-items: center; gap: 7px; color: #94A3B8; font-size: 12px; font-weight: 500; text-decoration: none; }
.fz-credit:hover { color: var(--text); text-decoration: none; }
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand div, nav.menu a span:not(.ic):not(.cnt), nav.menu .sect, .side-new span, .me div, .me-actions, .side-foot .lang-switch { display: none; }
  nav.menu a .cnt { display: none; }
  #view { padding: 14px; }
  .topbar { padding: 0 12px; }
}

/* ---------- building blocks ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.click { cursor: pointer; }
.kpi.click:hover { border-color: #C7D2FE; }
.kpi .v.red { color: var(--red); } .kpi .v.green { color: var(--green); } .kpi .v.amber { color: var(--amber); } .kpi .v.blue { color: var(--brand); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; background: #F1F5F9; color: #475569; }
.pill.blue { background: var(--brand-soft); color: var(--brand-2); }
.pill.cyan { background: #CFFAFE; color: #0E7490; }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.chip { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; background: #F8FAFC; margin: 1px; }
.sla { font-size: 12px; white-space: nowrap; }
.sla.ok { color: var(--green); } .sla.warn { color: var(--amber); } .sla.bad { color: var(--red); font-weight: 600; } .sla.paused { color: var(--muted); }

/* tables */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { min-width: 240px; flex: 1; max-width: 380px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { background: #F8FAFC; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #F8FAFF; }
td.subject b { display: block; color: var(--text); font-weight: 600; }
td.subject .small { margin-top: 2px; }
tr.unassigned td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
[dir=rtl] tr.unassigned td:first-child { box-shadow: inset -3px 0 0 var(--amber); }
.table-scroll { overflow: auto; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* forms */
input, select, textarea { border: 1px solid #D5DBE5; border-radius: 9px; padding: 8px 11px; background: #fff; min-width: 0; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label.f.full { grid-column: 1 / -1; }
label.f input, label.f select, label.f textarea { font-weight: 400; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.btn { border: 1px solid #D5DBE5; background: #fff; border-radius: 9px; padding: 7px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; white-space: nowrap; color: var(--text); text-decoration: none; font-weight: 500; }
.btn:hover { background: #F8FAFC; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.grad { background: linear-gradient(100deg, #2563EB, #22D3EE); border: 0; color: #fff; }
.btn.danger { color: var(--red); border-color: #FECACA; }
.btn.danger:hover { background: var(--red-soft); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.tabs button .n { background: #F1F5F9; color: var(--muted); border-radius: 99px; font-size: 11px; padding: 0 7px; margin-inline-start: 5px; }

/* ticket view */
.tv { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .tv { grid-template-columns: 1fr; } }
.tv-head { margin-bottom: 14px; }
.tv-head .num { color: var(--muted); font-weight: 600; }
.tv-head h1 { margin: 4px 0 8px; font-size: 20px; }
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.msg .who { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.msg .who .avatar { width: 30px; height: 30px; font-size: 13px; }
.msg .who.agent .avatar { background: linear-gradient(135deg, #7C3AED, #2563EB); }
.msg .body { line-height: 1.8; white-space: normal; word-wrap: break-word; color: var(--text-2); }
.msg.internal { background: #FFFBEB; border-color: #FDE68A; }
.msg.first { border-top: 3px solid var(--brand); }
.msg .files { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.file { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12.5px; background: #F8FAFC; color: var(--text-2); }
.composer { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.composer .ctabs { display: flex; border-bottom: 1px solid var(--line); background: #F8FAFC; }
.composer .ctabs button { background: none; border: 0; padding: 10px 16px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.composer .ctabs button.active { color: var(--brand); border-color: var(--brand); background: #fff; }
.composer .ctabs button.note.active { color: var(--amber); border-color: var(--amber); }
.composer textarea { width: 100%; border: 0; border-radius: 0; min-height: 120px; padding: 14px 16px; }
.composer textarea:focus { box-shadow: none; }
.composer.note textarea { background: #FFFBEB; }
.composer .cbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line-2); }
.props dl { display: grid; grid-template-columns: 110px 1fr; gap: 10px 10px; margin: 0; align-items: center; }
.props dt { color: var(--muted); font-size: 12.5px; }
.props dd { margin: 0; min-width: 0; }
.props select, .props input { width: 100%; padding: 6px 9px; font-size: 13.5px; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 12.5px; }
.timeline li { padding: 6px 0 6px 0; border-bottom: 1px dashed var(--line-2); color: var(--text-2); }
.timeline li .t { color: var(--muted); font-size: 11.5px; }
.sla-box { display: grid; gap: 8px; }
.sla-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stars { display: inline-flex; gap: 4px; direction: ltr; }
.stars button { background: none; border: 0; font-size: 30px; cursor: pointer; color: #CBD5E1; padding: 0 2px; line-height: 1; }
.stars button.on { color: #F59E0B; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; display: flex; gap: 1px; align-items: flex-end; height: 100%; min-width: 0; }
.bars .b i { display: block; flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .b i.c { background: #93C5FD; } .bars .b i.r { background: #22C55E; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 140px 1fr 40px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.hbar .track { height: 8px; background: #EEF2F7; border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: linear-gradient(90deg, #2563EB, #22D3EE); border-radius: 99px; }
.gauge { font-size: 28px; font-weight: 700; }

/* modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; justify-content: center; align-items: flex-start; padding: 6vh 12px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: min(620px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(880px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .body { padding: 18px; }
.modal footer { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #F8FAFC; border-radius: 0 0 14px 14px; flex-wrap: wrap; }
#toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast { background: #0F172A; color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }

/* KB */
.kb-list .a { display: block; padding: 14px 16px; border-bottom: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.kb-list .a:hover { background: #F8FAFF; }
.kb-list .a b { color: var(--text); }
.article { line-height: 1.9; font-size: 15px; color: var(--text-2); }
.suggest { border: 1px solid #BFDBFE; background: #EFF6FF; border-radius: 10px; padding: 10px 14px; }
.suggest a { display: block; padding: 3px 0; }
