:root {
  --ink: #161616;
  --muted: #70706f;
  --line: #e1d8c8;
  --paper: #fffefa;
  --canvas: #f7f4ed;
  --purple: #0b4035;
  --purple-dark: #062d26;
  --purple-soft: #e7f1ed;
  --orange: #d7a461;
  --orange-soft: #f8eddd;
  --green: #25935f;
  --green-soft: #e6f4ec;
  --shadow: 0 16px 50px rgba(0, 8, 11, .09);
  --radius: 20px;
}

@font-face { font-family: "Abar Mid"; src: url("/assets/fonts/AbarMid-Regular.otf") format("opentype"), local("Abar Mid Regular"), local("AbarMid-Regular"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Abar Mid"; src: url("/assets/fonts/AbarMid-SemiBold.otf") format("opentype"), local("Abar Mid SemiBold"), local("AbarMid-SemiBold"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Hajj Arabic Fallback"; src: url("/IBMPlexSansArabic-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Hajj Arabic Fallback"; src: url("/IBMPlexSansArabic-Bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Abar Mid", "Hajj Arabic Fallback", "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(215,164,97,.38); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 18px 18px; background: #fffefa;
  border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; padding: 0 8px; }
.brand > span:last-child { display: grid; align-items: baseline; gap: 1px; }
.brand strong { font-size: 22px; font-weight: 800; letter-spacing: -.6px; }
.brand small { color: var(--muted); font-weight: 600; font-size: 8px; }
.ministry-brand-logo { width: 48px; height: 48px; object-fit: contain; flex: 0 0 48px; }
.builder-ministry-mark { width: 35px; height: 35px; object-fit: contain; }
.formology-emblem { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--purple); color: var(--orange); font-size: 20px; font-weight: 800; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--purple); display: flex; flex-direction: column; gap: 4px; padding: 10px 9px; box-shadow: 0 8px 18px rgba(108,92,231,.2); }
.brand-mark i { height: 3px; border-radius: 9px; background: white; display: block; }
.brand-mark i:nth-child(2) { width: 70%; }
.brand-mark i:nth-child(3) { width: 45%; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; padding: 9px 8px; }

.main-nav { margin-top: 28px; display: grid; gap: 5px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 13px; padding: 12px 14px; background: transparent; color: #657089; text-align: right; transition: .2s ease; }
.nav-item:hover { color: var(--ink); background: #f2efe8; }
.nav-item.active { color: var(--purple-dark); background: var(--purple-soft); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; right: -18px; width: 4px; height: 23px; background: var(--purple); border-radius: 5px 0 0 5px; }
.nav-icon { font-size: 20px; width: 22px; text-align: center; }
.nav-item em { margin-right: auto; min-width: 23px; padding: 2px 6px; border-radius: 20px; background: white; color: var(--purple); font-size: 11px; font-style: normal; text-align: center; }
.sidebar-spacer { flex: 1; }
.mini-card { position: relative; overflow: hidden; padding: 18px; border-radius: 17px; background: #0b4035; color: white; margin-bottom: 16px; }
.mini-card::after { content: ""; position: absolute; width: 80px; height: 80px; border: 18px solid rgba(255,255,255,.05); border-radius: 50%; left: -30px; bottom: -38px; }
.mini-card-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: rgba(255,255,255,.12); color: #f7c381; margin-bottom: 13px; }
.mini-card strong { display: block; font-size: 13px; }
.mini-card p { color: #b9c1d1; font-size: 11px; line-height: 1.8; margin: 6px 0 9px; }
.mini-card .text-button { color: #d9d4ff; position: relative; z-index: 1; }
.profile { display: flex; align-items: center; gap: 9px; padding: 13px 7px 0; border-top: 1px solid var(--line); }
.profile > span:nth-child(2) { display: grid; gap: 2px; }
.profile strong { font-size: 12px; }
.profile small { font-size: 10px; color: var(--muted); }
.profile .icon-button { margin-right: auto; }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: #f3c791; color: #734418; font-weight: 700; }

.main-content { min-width: 0; padding: 0 44px 60px; }
.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.search-box { width: min(430px, 44vw); display: flex; align-items: center; gap: 10px; color: #9ba3b4; }
.search-box input { width: 100%; border: 0; background: transparent; color: var(--ink); font-size: 13px; }
.search-box input::placeholder { color: #a5adbb; }
kbd { direction: ltr; border: 1px solid #ded9d0; background: #fbfaf6; border-radius: 7px; padding: 4px 7px; font: 10px system-ui; box-shadow: inset 0 -1px 0 #d7d2ca; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { position: relative; border: 0; background: transparent; width: 38px; height: 38px; border-radius: 11px; color: #69758a; display: grid; place-items: center; font-size: 20px; }
.icon-button:hover { background: #ece8e0; }
.icon-button.bordered { border: 1px solid var(--line); background: white; }
.notify i { width: 7px; height: 7px; background: var(--orange); border: 2px solid var(--canvas); position: absolute; top: 8px; right: 8px; border-radius: 50%; }
.primary-button, .secondary-button, .filter-button { border-radius: 11px; border: 0; padding: 11px 17px; font-weight: 600; font-size: 12px; transition: .2s ease; }
.primary-button { color: white; background: var(--purple); box-shadow: 0 8px 18px rgba(11,64,53,.18); }
.primary-button:hover { background: var(--purple-dark); transform: translateY(-1px); }
.secondary-button, .filter-button { background: white; color: var(--ink); border: 1px solid var(--line); }
.secondary-button:hover, .filter-button:hover { border-color: #c8c1b5; background: #fff; }
.wide { width: 100%; }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 23px; }

.view { display: none; animation: viewIn .28s ease; }
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(7px); } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 45px 0 31px; }
.page-head.compact { align-items: center; }
.page-head h1 { margin: 4px 0 8px; font-size: clamp(27px, 3vw, 39px); letter-spacing: -1.6px; line-height: 1.35; }
.page-head p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--purple); font-size: 10px !important; text-transform: uppercase; letter-spacing: 1.7px; font-weight: 700; margin: 0 !important; }
.date-pill { white-space: nowrap; padding: 9px 13px; background: rgba(255,255,255,.62); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 11px; }

.metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.metric-card { display: flex; align-items: center; gap: 16px; min-height: 135px; background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 8px 30px rgba(37,31,55,.035); }
.metric-icon { width: 51px; height: 51px; flex: 0 0 51px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; }
.metric-card > div:last-child { display: grid; }
.metric-card span { color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 27px; letter-spacing: -1px; margin: 3px 0; }
.metric-card small { font-size: 9px; color: #9aa3b3; }
.metric-purple .metric-icon { background: var(--purple-soft); color: var(--purple); }
.metric-orange .metric-icon { background: var(--orange-soft); color: var(--orange); }
.metric-green .metric-icon { background: var(--green-soft); color: var(--green); }

.section-block { margin-top: 38px; }
.section-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.section-title h2 { font-size: 18px; margin: 0 0 5px; }
.section-title p { margin: 0; font-size: 11px; color: var(--muted); }
.text-button { border: 0; padding: 2px 0; background: none; color: var(--purple); font-size: 11px; font-weight: 600; }
.text-button.danger { color: #dc5b60; }
.templates-row, .templates-library { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.template-card { min-height: 172px; overflow: hidden; position: relative; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); padding: 20px; text-align: right; transition: .23s ease; }
.template-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: transparent; }
.template-card .template-icon { width: 43px; height: 43px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; margin-bottom: 22px; }
.template-card h3 { font-size: 13px; margin: 0 0 6px; }
.template-card p { color: var(--muted); font-size: 10px; line-height: 1.7; margin: 0; }
.template-card .arrow { position: absolute; top: 19px; left: 18px; color: #c1c5ce; transform: rotate(-45deg); }
.template-card[data-color="purple"] .template-icon { background: var(--purple-soft); color: var(--purple); }
.template-card[data-color="orange"] .template-icon { background: var(--orange-soft); color: var(--orange); }
.template-card[data-color="green"] .template-icon { background: var(--green-soft); color: var(--green); }
.template-card[data-color="blue"] .template-icon { background: #e7f1ff; color: #4682cd; }

.forms-table-wrap { background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.forms-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.forms-table th { color: #9ba3b4; font-size: 9px; text-align: right; font-weight: 500; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.forms-table td { padding: 14px 18px; border-bottom: 1px solid #eeeae3; }
.forms-table tr:last-child td { border-bottom: 0; }
.forms-table tbody tr { transition: .18s ease; }
.forms-table tbody tr:hover { background: #fff; }
.form-title-cell { display: flex; align-items: center; gap: 11px; }
.form-title-cell > span { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); font-size: 17px; }
.form-title-cell strong { display: block; font-size: 11px; margin-bottom: 3px; }
.form-title-cell small { color: var(--muted); font-size: 9px; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 20px; font-size: 9px; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; }
.status.published { background: var(--green-soft); color: #198160; }
.status.published::before { background: var(--green); }
.status.draft { background: #eef0f4; color: #69758a; }
.status.draft::before { background: #94a0b2; }
.table-action { border: 0; background: transparent; color: #98a0ae; font-size: 18px; }
.empty-state { min-height: 230px; display: grid; place-items: center; text-align: center; padding: 35px; }
.empty-state span { font-size: 34px; color: var(--purple); }
.empty-state h3 { margin: 8px 0; font-size: 15px; }
.empty-state p { margin: 0 0 15px; color: var(--muted); font-size: 11px; }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.segmented { padding: 4px; background: #ebe7df; border-radius: 12px; display: flex; gap: 2px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 9px; padding: 8px 16px; font-size: 10px; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 3px 9px rgba(30,35,60,.08); }
.result-count { color: var(--muted); font-size: 10px; }
.forms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-card { border-radius: 19px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; transition: .2s ease; }
.form-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.form-card-preview { height: 126px; background: linear-gradient(135deg, #f1edff, #fcfaff); padding: 20px 24px; display: grid; gap: 9px; align-content: center; border-bottom: 1px solid #ece8f3; }
.form-card-preview i { display: block; height: 8px; width: 53%; background: #a89eea; border-radius: 4px; }
.form-card-preview i:nth-child(2) { width: 90%; height: 23px; background: white; border: 1px solid #ded9f5; }
.form-card-preview i:nth-child(3) { width: 70%; height: 23px; background: white; border: 1px solid #ded9f5; }
.form-card-body { padding: 17px; }
.form-card-body h3 { margin: 0 0 7px; font-size: 13px; }
.form-card-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; }
.form-card-actions { display: flex; gap: 7px; margin-top: 14px; }
.form-card-actions button { flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: white; color: var(--ink); font-size: 9px; }
.form-card-actions button.primary-small { border-color: var(--purple); background: var(--purple); color: white; }

.template-categories { display: flex; gap: 8px; margin-bottom: 22px; overflow-x: auto; padding-bottom: 3px; }
.template-categories button { white-space: nowrap; border: 1px solid var(--line); background: rgba(255,255,255,.6); color: var(--muted); padding: 8px 14px; border-radius: 20px; font-size: 10px; }
.template-categories button.active { background: var(--ink); border-color: var(--ink); color: white; }
.templates-library { grid-template-columns: repeat(3, 1fr); }
.templates-library .template-card { min-height: 190px; }

.response-layout { display: grid; grid-template-columns: 250px 1fr; gap: 17px; min-height: 440px; }
.response-form-list, .response-content { background: rgba(255,255,255,.72); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.response-form-list button { border: 0; background: transparent; width: 100%; border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: space-between; text-align: right; color: var(--ink); }
.response-form-list button:hover, .response-form-list button.active { background: var(--purple-soft); color: var(--purple-dark); }
.response-form-list button span { display: grid; gap: 4px; }
.response-form-list button small { color: var(--muted); font-size: 8px; }
.response-content { padding: 24px; overflow-x: auto; }
.response-content h2 { font-size: 17px; margin: 0 0 5px; }
.response-content > p { color: var(--muted); font-size: 10px; margin: 0 0 18px; }
.response-item { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 10px; }
.response-item-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 9px; margin-bottom: 13px; }
.response-summary { display: grid; gap: 4px; flex: 1; }
.response-summary strong { color: var(--ink); font-size: 15px; }
.response-export-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.response-export-actions button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--gold-soft); color: var(--ink); padding: 8px 11px; font-family: inherit; font-size: 14px; font-weight: 600; }
.response-export-actions button:hover { border-color: var(--ink); background: white; transform: translateY(-1px); }
.response-export-actions button:first-child { background: var(--ink); border-color: var(--ink); color: white; }
.response-answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.response-answers div { border-right: 2px solid var(--purple-soft); padding-right: 9px; }
.response-answers small { display: block; color: var(--muted); font-size: 8px; margin-bottom: 3px; }
.response-answers strong { font-size: 10px; }

/* Builder */
.builder { display: none; position: fixed; inset: 0; z-index: 80; background: #f5f3ee; }
.builder.active { display: block; }
.builder-topbar { height: 72px; padding: 0 22px; background: white; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.builder-brand-group, .builder-actions { display: flex; align-items: center; gap: 11px; }
.builder-brand-group > div:last-child { display: grid; gap: 1px; }
.builder-name { border: 0; font-weight: 700; color: var(--ink); width: min(280px, 35vw); padding: 2px 0; }
#saveState { color: var(--green); font-size: 8px; }
.builder-body { height: calc(100vh - 72px); display: grid; grid-template-columns: 220px minmax(400px,1fr) 260px; }
.field-palette, .properties-panel { background: white; overflow-y: auto; }
.field-palette { border-left: 1px solid var(--line); padding: 21px 16px; }
.properties-panel { border-right: 1px solid var(--line); padding: 22px 18px; }
.palette-head { display: grid; gap: 4px; margin-bottom: 17px; }
.palette-head span { font-size: 13px; font-weight: 700; }
.palette-head small { font-size: 9px; color: var(--muted); }
#fieldPalette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-type { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 6px; color: var(--ink); display: grid; gap: 6px; place-items: center; font-size: 9px; }
.field-type:hover { border-color: var(--purple); background: var(--purple-soft); color: var(--purple-dark); }
.field-type span { font-size: 18px; }
.palette-tip { display: flex; gap: 9px; margin-top: 22px; padding: 13px; border-radius: 13px; background: #fff8e7; }
.palette-tip p { color: #836b36; font-size: 8px; line-height: 1.7; margin: 0; }
.palette-tip strong { display: block; color: #55431e; }
.form-canvas-wrap { overflow-y: auto; padding: 25px clamp(18px,5vw,70px) 70px; }
.canvas-tools { display: flex; justify-content: space-between; max-width: 720px; margin: 0 auto 12px; color: var(--muted); font-size: 9px; }
.form-canvas { max-width: 720px; min-height: 520px; margin: auto; background: white; border: 1px solid var(--line); border-radius: 22px; padding: clamp(23px,5vw,50px); box-shadow: 0 14px 45px rgba(40,35,55,.06); }
.canvas-header { border-top: 7px solid var(--purple); border-radius: 4px 4px 0 0; padding-top: 25px; margin-bottom: 27px; }
.canvas-title, .canvas-description { width: 100%; border: 0; background: transparent; }
.canvas-title { font-size: 25px; font-weight: 700; letter-spacing: -.8px; margin-bottom: 7px; }
.canvas-description { color: var(--muted); font-size: 11px; resize: none; line-height: 1.8; }
.canvas-field { position: relative; border: 1px solid transparent; border-radius: 14px; padding: 17px 16px; margin-bottom: 10px; transition: .16s ease; }
.canvas-field:hover { background: #faf9f6; border-color: #eeeae3; }
.canvas-field.selected { background: #f4f8f6; border-color: #7eae9d; box-shadow: 0 0 0 3px rgba(11,64,53,.07); }
.canvas-field label { display: block; font-size: 11px; font-weight: 600; margin-bottom: 10px; }
.required-star { color: var(--orange); margin-right: 3px; }
.mock-input { height: 38px; border: 1px solid #dfdbe3; border-radius: 9px; background: white; padding: 11px; color: #adb3be; font-size: 9px; }
.mock-textarea { height: 74px; }
.mock-options { display: grid; gap: 8px; color: #8d96a7; font-size: 9px; }
.mock-options span::before { content: ""; width: 13px; height: 13px; border: 1px solid #cdd1d9; border-radius: 50%; display: inline-block; vertical-align: middle; margin-left: 7px; }
.field-quick-actions { display: none; position: absolute; left: 11px; top: 10px; gap: 4px; }
.canvas-field:hover .field-quick-actions, .canvas-field.selected .field-quick-actions { display: flex; }
.field-quick-actions button { width: 27px; height: 27px; border: 0; border-radius: 8px; background: white; color: var(--muted); box-shadow: 0 2px 9px rgba(30,30,50,.09); }
.empty-canvas { min-height: 210px; display: grid; place-items: center; border: 1px dashed #d8d2ca; border-radius: 15px; text-align: center; color: var(--muted); }
.empty-canvas span { font-size: 28px; color: var(--purple); }
.empty-canvas p { margin: 6px 0 0; font-size: 10px; }
.properties-empty { min-height: 250px; display: grid; place-content: center; text-align: center; color: var(--muted); }
.properties-empty span { font-size: 27px; color: #c4bfdc; }
.properties-empty strong { color: var(--ink); font-size: 12px; margin: 8px 0 4px; }
.properties-empty p { font-size: 9px; line-height: 1.7; margin: 0; }
.properties-title { font-weight: 700; font-size: 13px; margin: 0 0 20px; }
.field-control { display: grid; gap: 7px; margin-bottom: 17px; }
.field-control > span { color: var(--muted); font-size: 9px; font-weight: 600; }
.field-control input, .field-control textarea, .field-control select { border: 1px solid var(--line); background: #fbfaf7; border-radius: 10px; padding: 10px; color: var(--ink); font-size: 10px; resize: vertical; }
.field-control textarea { min-height: 80px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); font-size: 10px; }
.toggle { position: relative; width: 38px; height: 22px; border: 0; border-radius: 20px; background: #d7d9df; padding: 0; }
.toggle::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; right: 3px; background: white; border-radius: 50%; transition: .2s ease; }
.toggle.on { background: var(--purple); }
.toggle.on::after { right: 19px; }
.property-actions { display: flex; gap: 7px; margin-top: 18px; }
.property-actions button { flex: 1; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 8px; font-size: 9px; }
.property-actions .delete { color: #d34e56; }

/* Public form + modals */
.public-form-page { min-height: 100vh; background: radial-gradient(circle at 15% 8%, #f4e5d0 0, transparent 29%), radial-gradient(circle at 90% 85%, #e3efea 0, transparent 25%), var(--canvas); padding: 42px 18px; }
.public-form-shell { width: min(820px,100%); margin: auto; }
.brand.centered { justify-content: center; margin-bottom: 30px; }
.public-form-card { background: white; border: 1px solid var(--line); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.public-form-cover { height: 9px; background: var(--purple); }
.public-form-inner { padding: clamp(25px,6vw,48px); text-align: right; }
.public-form-inner h1 { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 10px; font-size: clamp(25px,5vw,36px); }
.public-form-inner > p { color: var(--muted); font-size: 11px; line-height: 1.8; margin: 0 0 30px; }
.live-field { margin-bottom: 21px; }
.live-field > label { display: flex; align-items: center; gap: 9px; font-size: 11px; font-weight: 600; margin-bottom: 10px; }
.live-field input, .live-field textarea, .live-field select { width: 100%; border: 1px solid #ddd9e3; border-radius: 10px; background: #fff; color: var(--ink); padding: 12px; font-size: 11px; }
.live-field textarea { min-height: 90px; resize: vertical; }
.live-options { display: grid; gap: 9px; }
.live-options label { display: flex; align-items: center; gap: 8px; font-size: 10px; }
.live-options input { width: auto; accent-color: var(--purple); }
.live-field > small { display: block; color: var(--muted); font-size: 9px; margin: -4px 0 9px; }
.stars { display: inline-flex; gap: 7px; direction: rtl; justify-content: flex-start; }
.stars input { position: absolute; width: 1px; height: 1px; opacity: .01; pointer-events: none; }
.stars label { font-size: 34px; color: #d7d7dd; cursor: pointer; line-height: 1; transition: .16s ease; }
.stars input:checked ~ label, .stars label:hover, .stars label:hover ~ label { color: var(--orange); transform: translateY(-1px); }
.submit-button { width: 100%; border: 0; border-radius: 11px; background: var(--purple); color: white; padding: 13px; font-weight: 700; font-size: 11px; }
.powered-by { text-align: center; color: var(--muted); font-size: 9px; margin-top: 18px; }
.powered-by a { color: var(--purple); text-decoration: none; }
.success-card { text-align: center; padding: 55px 30px; }
.success-card .success-orbit { margin: auto; }
.success-card h2 { font-size: 22px; margin: 18px 0 8px; }
.success-card p { color: var(--muted); font-size: 11px; }

.modal { width: min(780px, calc(100% - 30px)); max-height: 88vh; border: 0; border-radius: 22px; padding: 0; box-shadow: 0 30px 100px rgba(20,19,35,.25); }
.modal::backdrop { background: rgba(22,28,45,.55); backdrop-filter: blur(4px); }
.modal-head { position: sticky; top: 0; z-index: 2; background: white; display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 4px 0 0; font-size: 18px; }
.modal-body { padding: 25px; }
.preview-body { background: var(--canvas); }
.preview-body .public-form-card { width: min(720px,100%); margin: auto; }
.share-modal { width: min(520px, calc(100% - 30px)); }
.share-modal .modal-body { text-align: center; }
.share-modal p { color: var(--muted); line-height: 1.9; font-size: 11px; max-width: 370px; margin: 12px auto 21px; }
.success-orbit { width: 64px; height: 64px; padding: 7px; border: 1px solid #bde5d7; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 0 0 9px var(--green-soft); }
.success-orbit span { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: white; font-size: 25px; }
.share-link { display: flex; direction: ltr; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; margin-bottom: 11px; }
.share-link input { min-width: 0; flex: 1; border: 0; background: #fbfaf7; padding: 12px; font-size: 10px; color: var(--muted); }
.share-link button { border: 0; background: var(--ink); color: white; padding: 0 17px; font-size: 10px; }
.toast { position: fixed; z-index: 150; bottom: 24px; left: 24px; transform: translateY(100px); opacity: 0; background: var(--ink); color: white; border-radius: 12px; padding: 12px 18px; font-size: 10px; box-shadow: 0 15px 40px rgba(20,25,40,.25); transition: .3s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.auth-modal { width: min(440px, calc(100% - 30px)); }
.auth-modal .modal-body > p { color: var(--muted); font-size: 11px; line-height: 1.8; }
.form-error { min-height: 18px; color: #d34e56 !important; }
.settings-modal { width: min(900px, calc(100% - 30px)); }
.settings-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 13px; background: var(--canvas); }
.setting-card { background: white; border: 1px solid var(--line); border-radius: 15px; padding: 16px; }
.setting-card h3 { margin: 0 0 5px; font-size: 12px; }
.setting-card > p { margin: 0 0 13px; color: var(--muted); font-size: 9px; line-height: 1.7; }
.setting-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.setting-card input, .setting-card select, .setting-card textarea { width: 100%; border: 1px solid var(--line); background: #fbfaf7; border-radius: 9px; padding: 9px; font-size: 9px; }
.setting-card label { display: grid; gap: 5px; color: var(--muted); font-size: 8px; margin-top: 8px; }
.capability-list { display: flex; flex-wrap: wrap; gap: 6px; }
.capability-list span { padding: 5px 8px; border-radius: 20px; background: var(--green-soft); color: #19765a; font-size: 8px; }
.file-drop { border: 1px dashed #bbb4d7; background: #faf9ff; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.signature-box { height: 80px; border: 1px dashed #c9c3d8; border-radius: 10px; display: grid; place-items: center; color: var(--muted); font-size: 9px; }
.matrix-table { width: 100%; border-collapse: collapse; font-size: 9px; }
.matrix-table td,.matrix-table th { border-bottom: 1px solid var(--line); padding: 7px; text-align: center; }
.matrix-table th:first-child,.matrix-table td:first-child { text-align: right; }
.progress-wrap { height: 5px; border-radius: 9px; background: #ece9e3; overflow: hidden; margin-bottom: 22px; }
.progress-wrap i { display:block; height:100%; background:var(--purple); width:100%; }
.public-meta { display:flex; justify-content:space-between; gap:10px; color:var(--muted); font-size:8px; margin-bottom:18px; }

/* Institutional experience */
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-card { background: rgba(255,255,255,.8); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.users-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.users-table th, .users-table td { text-align: right; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.users-table th { color: var(--muted); font-size: 9px; background: #fbfaf6; }
.users-table tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { flex: 0 0 36px; }
.user-cell span { display: grid; gap: 2px; }
.user-cell small { color: var(--muted); direction: ltr; text-align: right; }
.role-badge { display: inline-flex; padding: 5px 9px; border-radius: 20px; background: var(--purple-soft); color: var(--purple); font-size: 9px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 6px 9px; font-size: 9px; }
.row-actions .danger { color: #b42318; }
.user-modal { width: min(500px, calc(100% - 30px)); }
.help-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 23px; border-radius: 20px; background: linear-gradient(135deg,#0b4035,#145d4f); color: white; }
.help-hero strong { font-size: 19px; }
.help-hero p { margin: 5px 0 0; color: #d7e6e1; font-size: 11px; }
.help-hero .primary-button { background: var(--orange); color: #161616; box-shadow: none; }
.guide-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 13px; margin-top: 20px; }
.guide-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.guide-card span { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--orange); background: #0b4035; margin-bottom: 14px; font-weight: 700; }
.guide-card h3 { margin: 0 0 6px; font-size: 13px; }
.guide-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.8; }
.feature-catalog { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.feature-chip { display: flex; gap: 10px; align-items: flex-start; padding: 13px; border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.74); }
.feature-chip b { color: var(--orange); font-size: 12px; }
.feature-chip span { font-size: 10px; line-height: 1.6; }
.policy-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 17px; }
.policy-card { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 25px; }
.policy-card > span { color: var(--orange); font-size: 10px; font-weight: 700; }
.policy-card h2 { margin: 6px 0 10px; font-size: 19px; color: var(--purple); }
.policy-card p, .policy-card li { color: var(--muted); font-size: 11px; line-height: 1.9; }
.policy-card ul { padding-right: 19px; margin-bottom: 0; }
.policy-note { margin-top: 15px; padding: 13px; border-radius: 12px; background: var(--orange-soft); color: #6d522e; font-size: 10px; }
.public-policy-page { min-height: 100vh; background: var(--canvas); padding: 45px 18px; }
.public-policy-shell { width: min(780px,100%); margin: auto; }
.public-policy-shell article { background: white; border: 1px solid var(--line); border-radius: 22px; padding: clamp(25px,6vw,50px); line-height: 2; }
.public-policy-shell h1 { color: var(--purple); }
.public-policy-shell h2 { margin-top: 28px; font-size: 18px; }
.public-policy-shell p, .public-policy-shell li { color: var(--muted); }
.canvas-field[draggable="true"] { cursor: grab; padding-right: 45px; }
.canvas-field.dragging { opacity: .45; border-style: dashed; }
.canvas-field.drag-over { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(215,164,97,.18); }
.drag-handle { position: absolute; right: 13px; top: 18px; color: #aaa08f; font-size: 17px; letter-spacing: -4px; }
.field-type[draggable="true"] { cursor: grab; }
.form-canvas.drop-ready { outline: 2px dashed var(--orange); outline-offset: 5px; }
.field-quick-actions .move-field { font-size: 12px; }
.page-break-preview { border: 1px dashed var(--orange); background: var(--orange-soft); color: #7a5a2f; border-radius: 10px; padding: 13px; text-align: center; font-size: 10px; }
.heading-preview { border-right: 4px solid var(--orange); padding: 8px 12px; font-size: 17px; font-weight: 700; color: var(--purple); }
.separator-preview { height: 1px; background: var(--line); margin: 12px 0; }
.ministry-form-logo { display: block; width: 96px; height: 96px; object-fit: contain; margin: 0 auto 22px; }
.form-page[hidden] { display: none !important; }
.page-navigation { display: flex; gap: 9px; margin-top: 25px; }
.page-navigation button { flex: 1; border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: white; color: var(--purple); font-weight: 700; }
.page-navigation .next-page, .page-navigation .submit-button { background: var(--purple); color: white; border-color: var(--purple); }
.progress-label { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 9px; margin-bottom: 7px; }
.scale-options { display: flex; gap: 6px; flex-wrap: wrap; }
.scale-options label { display: grid; place-items: center; min-width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: white; }
.scale-options input { width: auto; accent-color: var(--purple); }
.consent-field { display: flex !important; align-items: flex-start; gap: 8px; }
.consent-field input { width: auto; margin-top: 4px; }
.live-heading { display: flex; align-items: center; gap: 10px; color: var(--purple); font-size: 22px; margin: 30px 0 12px; }
.live-separator { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
.form-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.form-row .live-field { margin: 0; }
.form-card-note { border: 1px solid var(--line); background: #fbfaf7; padding: 12px; border-radius: 10px; color: var(--muted); font-size: 10px; }

.repeater-preview { border: 1px solid var(--line); background: #fff; border-radius: 11px; overflow: hidden; }
.repeater-preview > div { display: grid; grid-template-columns: repeat(auto-fit,minmax(110px,1fr)); background: var(--purple-soft); color: var(--purple); }
.repeater-preview span { padding: 10px; border-left: 1px solid rgba(11,64,53,.12); font-size: 14px; }
.repeater-preview small { display: block; padding: 10px; color: var(--muted); }
.repeater-rows { display: grid; gap: 12px; margin-top: 12px; }
.repeater-row { position: relative; display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; padding: 14px 14px 14px 48px; border: 1px solid var(--line); border-radius: 13px; background: #fbfaf7; }
.repeater-row label { display: grid; gap: 7px; color: var(--muted); font-weight: 400; }
.repeater-row label > span { color: var(--ink); font-weight: 600; }
.repeater-row input, .repeater-row textarea { width: 100%; min-height: 44px; border: 1px solid #d8d2c7; border-radius: 9px; background: white; padding: 10px; resize: vertical; }
.repeater-row textarea { min-height: 78px; }
.remove-repeater-row { position: absolute; left: 10px; top: 10px; width: 30px; height: 30px; border: 1px solid #ead0cb; border-radius: 8px; background: #fff8f6; color: #b34c3d; font-size: 20px !important; line-height: 1; }
.add-repeater-row { margin-top: 11px; border: 1px dashed var(--purple); border-radius: 10px; background: var(--purple-soft); color: var(--purple); padding: 10px 15px; font-weight: 600; }
.repeater-field.layout-vertical { padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: linear-gradient(180deg,#fffdfa,#fbfaf7); }
.repeater-field.layout-vertical .repeater-rows { gap: 18px; }
.repeater-field.layout-vertical .repeater-row { grid-template-columns: 1fr; gap: 0; padding: 10px 48px 10px 10px; overflow: hidden; background: white; box-shadow: 0 8px 22px rgba(11,64,53,.045); }
.repeater-field.layout-vertical .repeater-row label { grid-template-columns: 1fr; align-items: stretch; gap: 0; border-bottom: 1px solid var(--line); }
.repeater-field.layout-vertical .repeater-row label:last-of-type { border-bottom: 0; }
.repeater-field.layout-vertical .repeater-row label > span { display: flex; align-items: center; min-height: 50px; padding: 12px 48px 12px 14px; background: var(--green-soft); border-bottom: 1px solid var(--line); color: var(--purple); }
.repeater-field.layout-vertical .repeater-row input, .repeater-field.layout-vertical .repeater-row textarea { min-height: 60px; border: 0; border-radius: 0; padding: 15px 17px; background: white; }
.repeater-field.layout-vertical .repeater-row textarea { min-height: 118px; }
.repeater-field.layout-vertical .remove-repeater-row { left: auto; right: 10px; top: 14px; z-index: 1; }
.repeater-field.layout-vertical .add-repeater-row { width: 100%; min-height: 48px; }
.auto-emoji, .form-title-emoji { display: inline-grid; place-items: center; flex: 0 0 auto; width: 31px; height: 31px; border: 1px solid rgba(215,164,97,.35); border-radius: 10px; background: linear-gradient(145deg,#fff7e9,#eef6f2); box-shadow: 0 5px 14px rgba(11,64,53,.08); font-family: "Apple Color Emoji","Noto Color Emoji",sans-serif; font-size: 18px; line-height: 1; }
.form-title-emoji { width: 46px; height: 46px; border-radius: 14px; font-size: 27px; }
.live-heading .auto-emoji { width: 38px; height: 38px; border-radius: 12px; font-size: 22px; }
.heading-preview .auto-emoji, .canvas-field > label .auto-emoji { margin-left: 7px; vertical-align: middle; }

/* مقياس قراءة أوضح: النص العادي Regular ولا توجد أوزان Thin أو Light. */
body :is(p, li, td, th, small, button, input, textarea, select, label) { font-size: 14px !important; }
body :is(.brand small, .nav-item em, .metric-card span, .metric-card small, .eyebrow, .date-pill, .section-title p, .result-count, .form-card-meta, .status, .response-item-head, .response-answers small, .response-answers strong, #saveState, .palette-head small, .field-type, .palette-tip p, .canvas-tools, .mock-input, .mock-options, .properties-empty p, .field-control > span, .toggle-row, .form-card-note, .progress-label, .public-meta, .role-badge, .feature-chip span, .policy-note, .page-break-preview) { font-size: 14px !important; }
body :is(.mini-card strong, .profile strong, .template-card h3, .form-title-cell strong, .empty-state h3, .form-card-body h3, .properties-empty strong, .setting-card h3, .guide-card h3) { font-size: 15px !important; }
.public-form-inner > p, .live-field > label, .live-field > small, .live-field input, .live-field textarea, .live-field select, .live-options label, .submit-button, .powered-by { font-size: 15px !important; }

@media (max-width: 1050px) {
  .guide-grid { grid-template-columns: repeat(2,1fr); }
  .feature-catalog { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 205px 1fr; }
  .main-content { padding-inline: 27px; }
  .templates-row { grid-template-columns: repeat(2, 1fr); }
  .forms-grid, .templates-library { grid-template-columns: repeat(2, 1fr); }
  .builder-body { grid-template-columns: 190px 1fr; }
  .properties-panel { position: fixed; left: 0; top: 72px; bottom: 0; width: 260px; z-index: 5; box-shadow: 10px 0 30px rgba(25,30,50,.1); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; right: 0; transform: translateX(105%); width: 245px; transition: .25s ease; box-shadow: -20px 0 60px rgba(20,25,40,.15); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding-inline: 17px; }
  .topbar { height: 70px; }
  .mobile-menu { display: block; }
  .search-box { display: none; }
  .topbar-actions .notify { display: none; }
  .page-head { padding-top: 32px; align-items: flex-start; }
  .date-pill { display: none; }
  .metrics-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { min-height: 105px; }
  .templates-row, .forms-grid, .templates-library { grid-template-columns: 1fr; }
  .forms-table th:nth-child(3), .forms-table td:nth-child(3) { display: none; }
  .response-layout { grid-template-columns: 1fr; }
  .response-form-list { display: flex; overflow-x: auto; }
  .response-form-list button { min-width: 180px; }
  .response-answers { grid-template-columns: 1fr; }
  .response-item-head { align-items: stretch; flex-direction: column; }
  .response-export-actions button { flex: 1; justify-content: center; }
  .builder-topbar { padding-inline: 11px; }
  .builder-brand-group .brand-mark { display: none; }
  .builder-name { width: 140px; }
  .builder-actions .secondary-button { display: none; }
  .builder-body { grid-template-columns: 1fr; }
  .field-palette { position: fixed; z-index: 6; bottom: 0; right: 0; left: 0; height: auto; border: 0; border-top: 1px solid var(--line); padding: 9px; }
  .palette-head, .palette-tip { display: none; }
  #fieldPalette { display: flex; overflow-x: auto; }
  .field-type { min-width: 74px; padding: 7px 4px; }
  .field-type span { font-size: 15px; }
  .form-canvas-wrap { padding: 17px 11px 120px; }
  .form-canvas { padding: 22px 15px; }
  .properties-panel { display: none; }
  .public-form-page { padding-top: 25px; }
  .settings-grid { grid-template-columns: 1fr; }
  .policy-grid, .feature-catalog, .guide-grid { grid-template-columns: 1fr; }
  .help-hero { align-items: flex-start; flex-direction: column; }
  .users-table th:nth-child(3), .users-table td:nth-child(3) { display: none; }
  .ministry-brand-logo { width: 42px; height: 42px; }
  .repeater-field.layout-vertical { padding: 12px; }
  .repeater-field.layout-vertical .repeater-row { padding: 48px 0 0; }
  .repeater-field.layout-vertical .repeater-row label { grid-template-columns: 1fr; }
  .repeater-field.layout-vertical .repeater-row label > span { min-height: 46px; border-left: 0; }
  .repeater-field.layout-vertical .remove-repeater-row { right: 9px; top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
