:root {
  --primary: #7b2d6e; --primary-d: #5e1f54; --primary-l: #b06aa3; --primary-bg: #f7ecf5;
  --accent: #c9a24a; --accent-d: #9a7a2e;
  --bg: #faf7fb; --card: #ffffff; --border: #e9e0e8; --text: #2a1f29; --muted: #6b5c69;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- forms / buttons ---- */
input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], select, textarea {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 9px 12px; font-family: inherit; font-size: 14px; background: var(--card); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-l); }
.btn { border: 0; border-radius: 10px; padding: 9px 16px; font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: .15s; text-decoration: none; }
.btn-p { background: var(--primary); color: #fff; } .btn-p:hover { background: var(--primary-d); }
.btn-o { background: var(--card); color: var(--text); border: 1.5px solid var(--border); } .btn-o:hover { border-color: var(--primary-l); }
.btn-d { background: #fde8e8; color: #b23b37; } .btn-d:hover { background: #f9d2d2; }
.btn-s { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: 13px; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; font-size: 14px; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }
.alert { padding: 12px 14px; border-radius: 12px; font-weight: 700; margin-bottom: 14px; font-size: 14px; }
.alert-err { background: #fde8e8; color: #b23b37; }
.alert-ok { background: #e3f6ea; color: #1f7a44; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-weight: 700; white-space: nowrap; }
.score { display: inline-block; min-width: 46px; text-align: center; padding: 3px 8px; border-radius: 8px; font-weight: 800; font-size: 13px; color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---- survey ---- */
.s-wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; min-height: calc(100vh - 50px); }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 0 8px; text-align: center; }
.brand img, .brand svg { height: 76px; max-width: 220px; object-fit: contain; }
.brand h1 { font-size: 22px; font-weight: 800; color: var(--primary); margin: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; max-width: 440px; line-height: 1.7; }
.anon { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-bg); color: var(--primary); font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px; box-shadow: 0 6px 24px rgba(60,20,60,.06); margin-top: 18px; }
.step-title { font-weight: 800; font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.step-title .num { background: var(--primary); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.branches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.branch { position: relative; }
.branch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.branch span { display: block; border: 2px solid var(--border); border-radius: 14px; padding: 16px 12px; text-align: center; font-weight: 700; background: var(--card); transition: .15s; font-size: 15px; }
.branch:hover span { border-color: var(--primary-l); }
.branch input:checked + span { border-color: var(--primary); background: var(--primary-bg); color: var(--primary); }
.card textarea { width: 100%; border-radius: 12px; padding: 12px; font-size: 15px; resize: vertical; min-height: 90px; border-width: 2px; }
.btn-big { width: 100%; padding: 14px 22px; font-size: 16px; font-weight: 800; border-radius: 14px; }
.thanks { text-align: center; padding: 30px 10px; }
.thanks .check { width: 84px; height: 84px; border-radius: 50%; background: #e3f6ea; color: #1f7a44; display: inline-flex; align-items: center; justify-content: center; font-size: 42px; margin-bottom: 14px; }
.thanks h2 { margin: 0 0 8px; font-size: 22px; color: var(--primary); }
.thanks p { color: var(--muted); margin: 0 0 22px; }
.closed { text-align: center; padding: 40px 10px; color: var(--muted); font-size: 17px; font-weight: 700; }
footer.s-foot { text-align: center; color: var(--muted); font-size: 12px; padding: 14px; }

/* ---- survey wizard ---- */
.survey-body { background: var(--bg); }
.brand.compact { flex-direction: row; justify-content: center; padding: 2px 0 0; gap: 10px; }
.brand.compact img, .brand.compact svg { height: 38px; max-width: 120px; }
.brand.compact h1 { font-size: 15px; }
.wizard.js .step { display: none; }
.wizard.js .step.on { display: block; animation: stepIn .35s ease both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.wiz-top { position: sticky; top: 0; z-index: 10; margin: 0 -16px; padding: 10px 16px 2px; background: rgba(250, 247, 251, .94); backdrop-filter: blur(6px); }
.wiz-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.wiz-meta span:first-child { color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wiz-meta span:last-child { white-space: nowrap; flex-shrink: 0; }
.progress { height: 8px; background: var(--border); border-radius: 8px; overflow: hidden; margin: 6px 0 8px; }
.progress > div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transform: scaleX(0); transform-origin: right; transition: transform .35s; }
.intro-text { margin: 0; line-height: 1.85; font-size: 15px; text-align: center; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.facts div { background: var(--primary-bg); border-radius: 14px; padding: 12px 6px; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--primary); line-height: 1.5; }
.facts b { display: block; font-size: 22px; margin-bottom: 4px; }
.step-head { display: flex; gap: 14px; align-items: center; margin: 16px 0 4px; }
.step-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-bg); font-size: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-count { font-size: 12px; font-weight: 700; color: var(--accent-d); }
.step-head h2 { margin: 0; font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1.4; }
.step-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.q.card { margin-top: 12px; padding: 18px; transition: border-color .2s, background-color .2s; }
.q-n { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.q-n .opt { background: var(--bg); padding: 1px 8px; border-radius: 999px; }
.q .txt { font-weight: 700; font-size: 16px; line-height: 1.75; margin-bottom: 14px; }
.q.missing { border-color: #f0b4b2; background: #fffafa; }
.q-err { color: #b23b37; font-size: 13px; font-weight: 700; margin-top: 10px; }
.st, .yn label, .opt-i { position: relative; }
.st input, .yn input, .opt-i input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.stars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.st span { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 0; text-align: center; }
.st svg { width: 46px; height: 46px; fill: #e6dde5; transition: transform .15s, fill .15s; }
.st em { font-style: normal; font-size: 11.5px; font-weight: 700; line-height: 1.35; color: var(--muted); }
.stars[data-v="1"] .st:nth-child(-n+1) svg, .stars[data-v="2"] .st:nth-child(-n+2) svg, .stars[data-v="3"] .st:nth-child(-n+3) svg,
.stars[data-v="4"] .st:nth-child(-n+4) svg, .stars[data-v="5"] .st:nth-child(-n+5) svg { fill: #f5b301; }
.st input:checked + span svg { transform: scale(1.15); }
.st input:checked + span em { color: var(--text); font-weight: 800; }
@media (hover: hover) {
  .stars:hover .st svg { fill: #f8cf5a; }
  .stars .st:hover ~ .st svg { fill: #e6dde5; }
}
.st input:focus-visible + span, .yn input:focus-visible + span, .opt-i input:focus-visible + span, .branch input:focus-visible + span { outline: 3px solid var(--primary-l); outline-offset: 2px; border-radius: 10px; }
.opts .opt-i.excl { flex-basis: 100%; margin-top: 6px; }
.opt-i.excl span { border-color: #2e9e5b; color: #1f7a44; background: #eef8f1; }
.opt-i.excl input:checked + span { background: #2e9e5b; border-color: #2e9e5b; color: #fff; }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.yn span { display: flex; align-items: center; justify-content: center; height: 56px; border: 2px solid var(--border); border-radius: 14px; font-weight: 800; font-size: 17px; background: var(--card); transition: border-color .15s, background-color .15s; }
.yn label:hover span { border-color: var(--primary-l); }
.yn .yes input:checked + span { background: #e3f6ea; border-color: #2e9e5b; color: #1f7a44; }
.yn .no input:checked + span { background: #fde8e8; border-color: #c0392b; color: #a5281c; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-i span { display: inline-block; border: 2px solid var(--border); border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 14px; background: var(--card); transition: border-color .15s, background-color .15s, opacity .15s; }
.opt-i:hover span { border-color: var(--primary-l); }
.opt-i input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.multi .opt-i input:checked + span::before { content: "\2713  "; }
.opt-i.dim span { opacity: .45; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 10px; font-weight: 700; }
.hint .cnt { color: var(--primary); margin-inline-start: 6px; }
.q .other-in { width: 100%; margin-top: 10px; border-width: 2px; border-radius: 12px; padding: 11px 12px; font-size: 15px; }
.q textarea { width: 100%; border: 2px solid var(--border); border-radius: 12px; padding: 12px; font-family: inherit; font-size: 15px; resize: vertical; min-height: 110px; }
.wiz-nav { position: sticky; bottom: 0; z-index: 9; display: flex; gap: 10px; margin-top: 18px; padding: 14px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 72%, rgba(250, 247, 251, 0)); }
.wiz-nav .btn { padding: 14px 18px; font-size: 16px; font-weight: 800; border-radius: 14px; }
.wiz-nav #nextBtn { flex: 1; }
.wiz-nav .send { background: #2e9e5b; }
.wiz-nav .send:hover { background: #25804a; }
.cheer { position: fixed; top: 16px; right: 50%; transform: translate(50%, -20px); z-index: 50; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: 14px; white-space: nowrap; opacity: 0; pointer-events: none; }
.cheer.show { animation: cheer 2.4s ease forwards; }
@keyframes cheer { 0% { opacity: 0; transform: translate(50%, -20px); } 12%, 80% { opacity: 1; transform: translate(50%, 0); } 100% { opacity: 0; transform: translate(50%, -10px); } }
@media (prefers-reduced-motion: reduce) { .wizard.js .step.on, .cheer.show { animation-duration: .01s; } .progress > div { transition: none; } }
@media (max-width: 480px) {
  .card { padding: 16px 14px; }
  .stars { gap: 2px; }
  .st svg { width: 40px; height: 40px; }
  .st em { font-size: 10.5px; }
  .step-head h2 { font-size: 18px; }
}

/* ---- login ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .box { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 10px 30px rgba(60,20,60,.08); }
.login .box img, .login .box svg { height: 70px; max-width: 200px; object-fit: contain; margin-bottom: 8px; }
.login h1 { font-size: 20px; margin: 4px 0 20px; color: var(--primary); }
.login input { width: 100%; text-align: center; }

/* ---- admin layout ---- */
.app { display: flex; min-height: 100vh; }
aside.side { width: 240px; background: var(--card); border-left: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
aside .logo { display: flex; align-items: center; justify-content: center; padding: 6px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
aside .logo img, aside .logo svg { height: 56px; max-width: 180px; object-fit: contain; }
aside a, aside button.link { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 15px; cursor: pointer; background: none; border: 0; font-family: inherit; width: 100%; text-align: right; }
aside a:hover, aside button.link:hover { background: var(--bg); color: var(--text); }
aside a.on { background: var(--primary-bg); color: var(--primary); }
aside .spacer { flex: 1; }
aside .small { font-size: 13px; }
main.main { flex: 1; padding: 22px 26px 40px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 22px; font-weight: 800; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 700; }
.kpi .v { font-size: 30px; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.kpi .v.sm { font-size: 17px; line-height: 1.5; }
.kpi .s { font-size: 13px; color: var(--muted); margin-top: 4px; }
.cols2 { grid-template-columns: 1fr 1fr; } .cols32 { grid-template-columns: 3fr 2fr; }
@media (max-width: 1000px) { .cols2, .cols32 { grid-template-columns: 1fr; } }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel h3 small { color: var(--muted); font-weight: 600; font-size: 12px; }
.chart { position: relative; height: 300px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 10px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 13px; background: var(--bg); }
tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 3px; }
.heat th { background: transparent; font-size: 12px; }
.heat td { border: 0; border-radius: 8px; text-align: center; font-weight: 800; font-size: 13px; color: #fff; min-width: 54px; padding: 10px 6px; }
.heat td.e { background: var(--bg); color: var(--muted); font-weight: 400; }
.heat th.q { text-align: right; font-weight: 700; color: var(--text); max-width: 260px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-left: 4px; }
.weak-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.weak-item:last-child { border-bottom: 0; }
.weak-item .t { flex: 1; } .weak-item .t b { display: block; } .weak-item .t span { color: var(--muted); font-size: 12px; }
.dist { display: flex; height: 10px; border-radius: 6px; overflow: hidden; min-width: 120px; background: var(--border); }
.dist i { display: block; height: 100%; }
.list-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item form.inline { display: contents; }
.list-item input[type=text] { flex: 1; min-width: 120px; }
.list-item input.cat { flex: 0 0 140px; }
.list-item.off input[type=text] { opacity: .55; text-decoration: line-through; }
.comment-box { padding: 10px 12px; border-radius: 10px; background: var(--bg); margin-bottom: 8px; font-size: 14px; }
.comment-box .m { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.toast { position: fixed; bottom: 22px; right: 50%; transform: translateX(50%); background: #2a1f29; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 14px; z-index: 99; animation: toast 3.5s forwards; }
.toast.err { background: #b23b37; }
@keyframes toast { 0% { opacity: 0; transform: translate(50%, 10px); } 10%, 85% { opacity: 1; transform: translate(50%, 0); } 100% { opacity: 0; } }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); text-decoration: none; font-size: 13px; font-weight: 700; color: var(--text); }
.pager .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .disabled span { opacity: .4; }
.mob-nav { display: none; }
@media (max-width: 800px) {
  aside.side { display: none; }
  .mob-nav { display: flex; gap: 4px; overflow-x: auto; background: var(--card); border-bottom: 1px solid var(--border); padding: 8px; position: sticky; top: 0; z-index: 5; }
  .mob-nav a, .mob-nav button { white-space: nowrap; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--muted); text-decoration: none; background: none; border: 0; font-family: inherit; }
  .mob-nav a.on { background: var(--primary-bg); color: var(--primary); }
  main.main { padding: 14px; }
}
@media print { aside.side, .filters, .no-print, .mob-nav { display: none !important; } main.main { padding: 0; } .panel { break-inside: avoid; } body { background: #fff; } }

/* ---- choice breakdown bars ---- */
.cbar { display: grid; grid-template-columns: minmax(120px, 2fr) 3fr 78px; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.cbar .cl { font-weight: 700; line-height: 1.4; }
.cbar .ct { height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.cbar .ct i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: 6px; transform-origin: right; }
.cbar .cn { text-align: left; white-space: nowrap; }
.cbar .cn small { color: var(--muted); margin-inline-start: 4px; }
.cbar.zero { opacity: .5; }
.cbar:first-of-type .ct i { background: var(--accent-d); }
.cbar.excl .cl { color: #1f7a44; }
.cbar.excl .ct i { background: #2e9e5b; }
.sec-row th { background: var(--primary-bg) !important; color: var(--primary) !important; font-weight: 800 !important; font-size: 13px !important; text-align: right; }
details.resp-d summary { cursor: pointer; font-weight: 700; color: var(--primary); font-size: 13px; }
.resp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; margin-top: 10px; font-size: 13px; }
.resp-grid .rs { grid-column: 1 / -1; font-weight: 800; color: var(--primary); margin-top: 8px; }
.resp-grid .ra { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 3px 0; }
.resp-grid .ra b { white-space: nowrap; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
.qr-box svg { width: 170px; height: 170px; display: block; }
.qr-box .t { font-weight: 800; font-size: 14px; }
.qr-box .u { font-size: 11px; color: var(--muted); direction: ltr; word-break: break-all; text-align: center; }
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.q-admin { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--card); }
.q-admin.off { opacity: .6; }
.q-admin .row { gap: 8px; }
.q-admin textarea { width: 100%; font-size: 13px; }
.type-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--primary-bg); color: var(--primary); font-weight: 700; white-space: nowrap; }
