:root {
  --brand: #0f766e;
  --brand-600: #0d6b63;
  --brand-100: #ccfbf1;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar: #0b1220;
  --sidebar-2: #111a2e;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Tajawal", "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

h1, h2, h3, h4, h5, .fw-bold { font-weight: 700; }

/* ---------- Admin shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #cbd5e1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 12px;
  color: #fff; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 16px;
}
.sidebar .brand .logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; font-size: 20px;
  box-shadow: 0 8px 20px -6px rgba(20,184,166,.6);
}
.sidebar .brand small { display: block; color: #94a3b8; font-size: 12px; font-weight: 400; }

.sidebar .nav-label { font-size: 11px; letter-spacing: .08em; color: #64748b; padding: 14px 12px 6px; text-transform: uppercase; }

.sidebar .nav-link {
  display: flex; align-items: center; gap: 12px;
  color: #cbd5e1; padding: 11px 14px; border-radius: 12px; margin-bottom: 4px; font-weight: 500;
  transition: all .15s ease;
}
.sidebar .nav-link i { font-size: 18px; width: 22px; text-align: center; opacity: .85; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: linear-gradient(90deg, rgba(20,184,166,.22), rgba(20,184,166,.05)); color: #fff; box-shadow: inset 3px 0 0 #14b8a6; }
.sidebar .nav-link .badge { margin-inline-start: auto; }

.sidebar .user-card {
  margin-top: auto; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
  border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #14b8a6); color: #fff; font-size: 14px; flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 68px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; background: rgba(255,255,255,.75); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 20px; font-weight: 700; margin: 0; }
.topbar .crumbs { color: var(--muted); font-size: 13px; }

.content { padding: 28px; }

@media (max-width: 991.98px) {
  .sidebar { position: fixed; inset-inline-start: -280px; z-index: 50; transition: inset-inline-start .25s ease; }
  .sidebar.open { inset-inline-start: 0; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.5); z-index: 40; display: none; }
  .sidebar-backdrop.show { display: block; }
  .main { overflow-x: hidden; }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; height: auto; min-height: 68px; flex-wrap: wrap; gap: 10px; }
  .topbar .form-select { min-width: 0 !important; max-width: 100%; }
}

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: 16px 20px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 20px; }

.stat {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 20px 22px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); height: 100%;
}
.stat .icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px;
}
.stat .value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.stat .trend { font-size: 12.5px; margin-top: 10px; color: var(--muted); }
.stat::after {
  content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%; inset-inline-end: -50px; top: -60px; opacity: .08;
  background: var(--tint, var(--brand));
}
.tint-teal { --tint: #0f766e; } .tint-teal .icon { background: #ccfbf1; color: #0f766e; }
.tint-indigo { --tint: #4f46e5; } .tint-indigo .icon { background: #e0e7ff; color: #4f46e5; }
.tint-amber { --tint: #d97706; } .tint-amber .icon { background: #fef3c7; color: #b45309; }
.tint-rose { --tint: #e11d48; } .tint-rose .icon { background: #ffe4e6; color: #be123c; }
.tint-sky { --tint: #0284c7; } .tint-sky .icon { background: #e0f2fe; color: #0369a1; }

.table { margin: 0; }
.table thead th { font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; }
.table td { vertical-align: middle; border-color: #eef2f7; }
.table-hover tbody tr:hover { background: #f8fafc; }

.btn { border-radius: 11px; font-weight: 600; padding: 9px 16px; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-soft { background: #f1f5f9; border-color: #f1f5f9; color: var(--ink); }
.btn-soft:hover { background: #e2e8f0; border-color: #e2e8f0; color: var(--ink); }
.btn-outline-brand { border-color: var(--brand); color: var(--brand); }
.btn-outline-brand:hover { background: var(--brand); color: #fff; }

.form-control, .form-select { border-radius: 11px; border-color: #dbe2ea; padding: 10px 14px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(15,118,110,.15); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.form-label { font-weight: 600; font-size: 14px; }
.form-text { color: var(--muted); }

.badge { font-weight: 600; border-radius: 8px; padding: 6px 10px; }
.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-muted { background: #f1f5f9; color: #475569; }
.badge-soft-brand { background: var(--brand-100); color: var(--brand); }
.badge-soft-indigo { background: #e0e7ff; color: #3730a3; }
.badge-soft-amber { background: #fef3c7; color: #92400e; }
.badge-soft-danger { background: #fee2e2; color: #991b1b; }

.rating-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; }

.score-bar { height: 10px; border-radius: 999px; background: #eef2f7; overflow: hidden; display: flex; }
.score-bar span { height: 100%; display: block; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty i { font-size: 44px; display: block; margin-bottom: 10px; opacity: .5; }

.alert { border-radius: 14px; border: 0; }
.alert-success { background: #dcfce7; color: #14532d; }
.alert-danger { background: #fee2e2; color: #7f1d1d; }

.dropdown-menu { border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 8px; }
.dropdown-item { border-radius: 9px; padding: 8px 12px; }

.question-row { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; display: flex; align-items: center; gap: 12px; }
.question-row .num { width: 32px; height: 32px; border-radius: 10px; background: #f1f5f9; display: grid; place-items: center; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.question-row .handle { cursor: grab; color: #cbd5e1; }
.question-row.dragging { opacity: .5; }

.page-link { border-radius: 9px !important; margin: 0 2px; border-color: var(--line); color: var(--ink); }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-art {
  background: radial-gradient(1200px 600px at 20% 10%, rgba(20,184,166,.35), transparent 60%),
              radial-gradient(800px 500px at 90% 90%, rgba(99,102,241,.35), transparent 60%),
              linear-gradient(160deg, #0b1220, #111a2e);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art .pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.08); padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.auth-art h1 { font-size: 40px; font-weight: 800; line-height: 1.25; margin: 24px 0 14px; }
.auth-art p { color: #cbd5e1; font-size: 16px; max-width: 480px; }
.auth-art .features { display: grid; gap: 14px; margin-top: 34px; }
.auth-art .features div { display: flex; align-items: center; gap: 12px; color: #e2e8f0; }
.auth-art .features i { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.08); font-size: 17px; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* ---------- Public survey ---------- */
.survey-body {
  background:
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(700px 500px at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    #f6f7fb;
  min-height: 100vh;
}
.survey-wrap { max-width: 860px; margin: 0 auto; padding: 32px 16px 80px; }
.survey-hero {
  border-radius: 24px; overflow: hidden; color: #fff; padding: 36px 34px; position: relative;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #0b1220));
  box-shadow: 0 24px 50px -24px color-mix(in srgb, var(--accent) 70%, transparent);
}
.survey-hero::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); inset-inline-end: -80px; top: -120px; }
.survey-hero::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.06); inset-inline-start: 30%; bottom: -120px; }
.survey-hero h1 { font-size: 28px; font-weight: 800; margin: 10px 0 10px; position: relative; }
.survey-hero p { color: rgba(255,255,255,.85); margin: 0; font-size: 16px; position: relative; max-width: 640px; }
.survey-hero .tag { position: relative; display: inline-flex; gap: 8px; align-items: center; background: rgba(255,255,255,.16); padding: 6px 12px; border-radius: 999px; font-size: 13px; }

.scale-legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 22px 0 8px; }
.scale-legend span { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.scale-legend b { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.q-card {
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; margin-top: 16px;
  box-shadow: var(--shadow); transition: box-shadow .2s, border-color .2s, transform .2s;
}
.q-card.answered { border-color: color-mix(in srgb, var(--accent) 45%, #fff); }
.q-card.has-error { border-color: #fca5a5; box-shadow: 0 0 0 4px rgba(239,68,68,.08); }
.q-card .q-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.q-card .q-num { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, #fff); flex-shrink: 0; }
.q-card .q-text { font-size: 17px; font-weight: 700; margin: 0; line-height: 1.5; }
.q-card .q-hint { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.q-card .req { color: #ef4444; }

.rating-group { display: grid; grid-template-columns: repeat(var(--n, 5), 1fr); gap: 10px; }
.rating-group input { position: absolute; opacity: 0; pointer-events: none; }
.rating-group label {
  cursor: pointer; border: 2px solid #e5e9f0; border-radius: 16px; padding: 14px 6px 12px; text-align: center;
  background: #fafbfd; transition: all .15s ease; user-select: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.rating-group label i { font-size: 26px; color: #94a3b8; transition: transform .15s, color .15s; }
.rating-group label span { font-size: 13.5px; font-weight: 700; color: #475569; }
.rating-group label:hover { border-color: #cbd5e1; background: #fff; transform: translateY(-2px); }
.rating-group input:checked + label { border-color: var(--rc); background: color-mix(in srgb, var(--rc) 10%, #fff); box-shadow: 0 10px 24px -14px var(--rc); }
.rating-group input:checked + label i { color: var(--rc); transform: scale(1.15); }
.rating-group input:checked + label span { color: var(--rc); }
.rating-group input:focus-visible + label { outline: 3px solid color-mix(in srgb, var(--rc) 35%, transparent); }
@media (max-width: 575.98px) {
  .rating-group { grid-template-columns: repeat(var(--n, 5), 1fr); gap: 6px; }
  .rating-group label { padding: 10px 2px 8px; border-radius: 12px; }
  .rating-group label i { font-size: 20px; }
  .rating-group label span { font-size: 11px; }
  .survey-hero { padding: 26px 22px; }
  .survey-hero h1 { font-size: 22px; }
  .q-card { padding: 18px 16px; }
}

.progress-sticky {
  position: sticky; top: 12px; z-index: 10; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; padding: 10px 18px; display: flex; align-items: center; gap: 14px; margin-top: 18px; box-shadow: var(--shadow);
}
.progress-sticky .bar { flex: 1; height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress-sticky .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; border-radius: 999px; }
.progress-sticky small { color: var(--muted); font-weight: 700; white-space: nowrap; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; padding: 14px 28px; font-size: 17px; border-radius: 14px; box-shadow: 0 14px 30px -14px var(--accent); }
.btn-accent:hover { filter: brightness(.95); color: #fff; }

.thanks-card { max-width: 560px; margin: 10vh auto; text-align: center; background: #fff; border-radius: 28px; padding: 48px 36px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.thanks-card .check { width: 92px; height: 92px; border-radius: 50%; margin: 0 auto 22px; display: grid; place-items: center; font-size: 46px; color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #0b1220)); box-shadow: 0 20px 40px -18px var(--accent); animation: pop .5s cubic-bezier(.2,.9,.3,1.4); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }

/* ---------- KPI indicators ---------- */
.kpi { border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; background: #fff; height: 100%; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--kc, #94a3b8); }
.kpi-ok { --kc: #16a34a; }
.kpi-near { --kc: #f59e0b; }
.kpi-bad { --kc: #ef4444; }
.kpi-none { --kc: #94a3b8; }
.kpi-name { font-weight: 800; font-size: 15px; }
.kpi-name i { color: var(--kc); margin-left: 4px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-status { font-size: 12px; font-weight: 700; color: var(--kc); background: color-mix(in srgb, var(--kc) 12%, #fff); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.kpi-value { font-size: 34px; font-weight: 800; line-height: 1.1; color: var(--kc); display: flex; align-items: baseline; gap: 10px; }
.kpi-value small { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.kpi-bar { position: relative; height: 10px; border-radius: 999px; background: #eef2f7; overflow: visible; }
.kpi-bar .fill { position: absolute; right: 0; top: 0; height: 100%; border-radius: 999px; background: var(--kc); transition: width .4s ease; }
.kpi-bar .target { position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px; background: #0f172a; transform: translateX(50%); }
.kpi-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.kpi-foot span:last-child { max-width: 60%; }
