:root {
  --bg: #f3f3f3;
  --surface: #ffffff;
  --ink: #202223;
  --muted: #6d7175;
  --line: #e1e3e5;
  --green: #0b6e4f;
  --green-dark: #085541;
  --green-soft: #e3f1ea;
  --amber: #b98900;
  --amber-soft: #fff4d6;
  --red: #d72c0d;
  --red-soft: #fbeae5;
  --blue: #2c6ecb;
  --radius: 12px;
  --shadow: 0 1px 0 rgba(22, 29, 37, .05), 0 8px 24px rgba(22, 29, 37, .06);
  --nav: 248px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Naskh Arabic", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

#app { min-height: 100vh; }

.shell {
  display: grid;
  grid-template-columns: var(--nav) 1fr;
  min-height: 100vh;
}

.nav {
  background: #1a1c19;
  color: #f6f6f7;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 18px;
}
.brand svg { flex-shrink: 0; }
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; font-size: 12px; color: #b5b7b3; font-weight: 400; }
.nav a {
  color: #e3e4e2;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.nav a:hover, .nav a.active { background: #2d312c; color: #fff; }
.nav .spacer { flex: 1; }
.nav-toggle {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: #1a1c19;
  color: #fff;
  border: 0;
  width: 100%;
  padding: 12px 16px;
  font-weight: 700;
  text-align: start;
}

.main { padding: 24px; max-width: 1120px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head p { margin: 0; color: var(--muted); }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi, .card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.kpi { padding: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.hero { background: var(--green); color: #fff; border: 0; }
.kpi.hero .label, .kpi.hero .hint { color: rgba(255,255,255,.8); }

.opportunity {
  background: linear-gradient(135deg, #0b6e4f 0%, #147a56 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.opportunity .label { font-size: 15px; font-weight: 650; line-height: 1.4; max-width: 52rem; }
.opportunity .value { font-size: 36px; font-weight: 800; margin: 8px 0 6px; }
.opportunity p { margin: 0; color: rgba(255,255,255,.85); font-size: 13px; }

.chip {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #6b4f00;
  font-size: 11px;
  font-weight: 650;
  white-space: normal;
}
td.wrap, .cell-help { white-space: normal; max-width: 280px; }
.cell-help { color: var(--muted); font-size: 11px; margin-top: 4px; font-weight: 500; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 28, 25, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}
.modal { max-width: 420px; width: 100%; }
.modal h2 { margin: 0 0 8px; font-size: 18px; }

.feat-list { list-style: none; padding: 0; margin: 8px 0 14px; font-size: 13px; }
.feat-list li { padding: 4px 0 4px 18px; position: relative; }
.feat-list li.ok::before { content: "✓"; position: absolute; inset-inline-start: 0; color: var(--green); font-weight: 800; }
.feat-list li.miss { color: var(--muted); }
.feat-list li.miss::before { content: "–"; position: absolute; inset-inline-start: 0; }

.bill-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.bill-toggle button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}
.bill-toggle button.on { border-color: var(--green); background: var(--green-soft); }
.save-tag { color: var(--green); font-weight: 700; font-size: 13px; margin: 0 0 8px; }
.mod.muted { opacity: .75; cursor: default; background: #fafafa; }
.channels { display: grid; gap: 10px; }

.card { padding: 18px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--green);
  color: #fff;
  font-weight: 650;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: var(--green-dark); }
.btn.secondary { background: #fff; color: var(--ink); border-color: #c9ccc6; }
.btn.secondary:hover { background: #f6f6f7; }
.btn.danger { background: var(--red); }
.btn.ghost { background: transparent; color: var(--green); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 650; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  background: #f1f2f3;
}
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: #916a00; }
.badge.bad { background: var(--red-soft); color: var(--red); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 650; }
input[type=text], input[type=email], input[type=number], select, textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #c9ccc6;
  border-radius: 8px;
  background: #fff;
}
.mods { display: grid; gap: 10px; }
.mod {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.mod.active { border-color: var(--green); background: var(--green-soft); }
.mod small { color: var(--muted); font-weight: 400; display: block; }

.steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.steps span { padding: 6px 10px; border-radius: 999px; background: #eee; font-size: 12px; font-weight: 700; }
.steps span.on { background: var(--green); color: #fff; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.plan { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.plan.featured { border-color: var(--green); box-shadow: var(--shadow); }
.plan h3 { margin: 0; }
.plan .price { font-size: 32px; font-weight: 800; margin: 8px 0; }
.plan .price span { font-size: 14px; font-weight: 600; color: var(--muted); }
.toast {
  position: fixed;
  bottom: 16px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: #1a1c19;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
}
.empty { color: var(--muted); padding: 12px 0; }
.score { font-weight: 800; }
.score.high { color: var(--red); }
.score.mid { color: var(--amber); }
.score.low { color: var(--green); }

[dir=rtl] th, [dir=rtl] td { text-align: start; }
[dir=rtl] .toast { transform: translateX(50%); }

@media (max-width: 980px) {
  .kpis, .plans, .form-grid { grid-template-columns: 1fr 1fr; }
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; height: auto; position: static; }
  .nav.open { display: flex; height: auto; }
  .nav-toggle { display: block; }
}
@media (max-width: 640px) {
  .main { padding: 14px; }
  .kpis, .plans, .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 20px; }
  .opportunity .value { font-size: 28px; }
}
@media print {
  .nav, .nav-toggle, .no-print, .toast, .modal-backdrop { display: none !important; }
  .shell { display: block; }
  .main { max-width: none; padding: 0; }
  .opportunity, .kpi.hero { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
