:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #142033;
  --ink-2: #4a5a70;
  --muted: #8494a8;
  --line: #e2e8f0;
  --brand: #0f6e8c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2f7;
  --side: #0d1b2e;
  --side-ink: #c4d0e0;
  --ok: #138a4f;
  --ok-soft: #e1f5ea;
  --warn: #b26b00;
  --warn-soft: #fff3df;
  --bad: #c0392b;
  --bad-soft: #fde8e6;
  --spectrum: linear-gradient(90deg, #6a3df0, #2f6fe8, #10a3b8, #2bb673, #e8c11a, #f08a24, #e2453c);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .06), 0 4px 16px rgba(16, 30, 54, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 22px 20px 18px; }
.brand-name { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: .3px; direction: ltr; text-align: right; }
.brand-name span { color: #5fd0e4; }
.brand-bar { height: 3px; border-radius: 3px; background: var(--spectrum); margin-top: 8px; }
.brand-sub { font-size: 12px; color: #7f91aa; margin-top: 6px; }
.nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; color: #64778f; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-ink); font-size: 14.5px;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(95, 208, 228, .14); color: #fff; }
.nav a .ic { width: 18px; text-align: center; opacity: .85; }
.nav .badge { margin-inline-start: auto; }
.side-user { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-user strong { color: #fff; display: block; font-size: 14px; }
.side-user .row { display: flex; gap: 8px; margin-top: 8px; }
.side-user a, .side-user button {
  color: var(--side-ink); background: rgba(255,255,255,.07); border: 0; border-radius: 6px;
  padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.side-user a:hover, .side-user button:hover { background: rgba(255,255,255,.14); text-decoration: none; }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat .label { color: var(--ink-2); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12.5px; }

.progress { height: 8px; background: #e8edf3; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.progress.ok > i { background: var(--ok); }
.progress.warn > i { background: #e39a1c; }
.progress.bad > i { background: var(--bad); }
.progress.sm { height: 6px; margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-weight: 600; color: var(--ink-2); font-size: 12.5px; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcfe; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.inactive td { opacity: .55; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef2f7; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.stage-new { background: #eef2f7; color: #4a5a70; }
.stage-contacted { background: #e6efff; color: #2a5bd7; }
.stage-needs { background: #efe8ff; color: #6a3df0; }
.stage-quote { background: #fff3df; color: #b26b00; }
.stage-negotiation { background: #ffe9dc; color: #c25510; }
.stage-won { background: var(--ok-soft); color: var(--ok); }
.stage-lost { background: var(--bad-soft); color: var(--bad); }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cfd8e3; border-radius: 8px; padding: 9px 11px; min-height: 40px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,110,140,.25); border-color: var(--brand); }
input[type=checkbox] { width: 17px; height: 17px; min-height: 0; vertical-align: middle; accent-color: var(--brand); }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.fields .full { grid-column: 1 / -1; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 2px; margin: 6px 0 16px; }
legend { font-weight: 700; font-size: 14px; padding: 0 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; padding: 8px 16px; min-height: 40px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #cfd8e3; }
.btn.ghost { background: transparent; color: var(--brand); border-color: transparent; padding-inline: 8px; }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.wa { background: #1fa855; }
.btn.sm { padding: 4px 11px; min-height: 32px; font-size: 13px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .f { flex: 1 1 150px; }
.filters .f.wide { flex: 2 1 240px; }

/* ---------- alerts ---------- */
.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash.success { background: var(--ok-soft); color: #0d6b3c; }
.flash.error { background: var(--bad-soft); color: #9b2b20; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; font-size: 14px; }

/* ---------- customer page ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 22px 16px 0; border-right: 2px solid var(--line); margin-right: 6px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; right: -7px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline .meta { font-size: 12.5px; color: var(--muted); }
.timeline .body { margin-top: 3px; white-space: pre-wrap; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: -4px 0 14px; }
.tabs button { background: none; border: 0; font: inherit; font-weight: 600; color: var(--ink-2); padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab-pane { display: none; }
.tab-pane.on { display: block; }

/* ---------- pipeline ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #e9eef4; border-radius: var(--radius); padding: 12px; min-height: 200px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.col-head .sum { font-size: 12px; color: var(--ink-2); }
.deal-card { background: #fff; border-radius: 9px; padding: 10px 12px; margin-bottom: 9px; box-shadow: 0 1px 2px rgba(16,30,54,.08); font-size: 13.5px; }
.deal-card a { font-weight: 600; color: var(--ink); }
.deal-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.deal-card form { margin-top: 8px; }
.deal-card select { min-height: 30px; padding: 3px 8px; font-size: 12.5px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 80% -10%, #12365a 0%, transparent 60%), var(--side); }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-box .brand-name { color: var(--ink); font-size: 26px; text-align: center; }
.login-box .brand-name span { color: var(--brand); }
.login-box .brand-bar { width: 120px; margin: 10px auto 6px; }
.login-box p.lead { text-align: center; color: var(--ink-2); margin: 0 0 22px; font-size: 14px; }

.rank-list { list-style: none; padding: 0; margin: 0; }
.rank-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rank-list li:last-child { border: 0; }
.rank-list .me { font-weight: 700; color: var(--brand); }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav .cur { font-weight: 700; padding: 0 6px; direction: ltr; }
.pager { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.mono { font-variant-numeric: tabular-nums; }
.mt0 { margin-top: 0; }

/* ---------- mobile ---------- */
.menu-btn { display: none; }
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: sticky; top: 0; z-index: 20; }
  .brand { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; }
  .brand-bar, .brand-sub { display: none; }
  .menu-btn { display: inline-block; background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; }
  .nav, .side-user { display: none; }
  .sidebar.open .nav, .sidebar.open .side-user { display: block; }
  .main { padding: 18px 16px 50px; }
  .g2, .g3, .g4, .fields { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .kv { grid-template-columns: 110px 1fr; }
}
