.certificate-projects-modal { z-index: 2300; }
.certificate-row-actions {
  position: fixed;
  z-index: 4000;
  width: max-content;
  max-width: min(360px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 9px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px #0f172a30;
}
.certificate-row-actions[hidden], .certificate-row-action-choices[hidden], .certificate-name-duplicate-setup[hidden] { display: none; }
.certificate-row-action-choices, .certificate-duplicate-actions { display: flex; gap: 7px; }
.certificate-row-actions .btn { min-height: 40px; padding-inline: 12px; white-space: nowrap; }
.certificate-name-duplicate-setup { display: grid; gap: 8px; width: min(320px, calc(100vw - 38px)); }
.certificate-name-duplicate-setup strong { color: #475569; font-size: 12px; }
.certificate-duplicate-summary { margin: 0; color: #475569; font-size: 12px; font-weight: 700; }
.certificate-duplicate-actions .btn:disabled { opacity: .5; cursor: not-allowed; }
.certificate-duplicate-text-options { display: grid; gap: 5px; max-height: 180px; overflow: auto; }
.certificate-duplicate-text-option { padding: 8px 9px; border: 1px solid #d5dce6; border-radius: 8px; background: #f8fafc; color: #334155; font: inherit; font-size: 12px; text-align: start; overflow-wrap: anywhere; cursor: pointer; }
.certificate-duplicate-text-option[aria-pressed="true"] { border-color: #16a34a; background: #ecfdf3; color: #166534; box-shadow: inset 0 0 0 1px #16a34a; }
.certificate-duplicate-actions .btn { flex: 1; }
@media (max-width: 520px) {
  .certificate-row-actions { padding: 7px; }
  .certificate-row-actions .btn { min-height: 44px; padding-inline: 10px; }
}
.certificate-modal {
  z-index: 2200;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  background: rgba(20, 24, 32, .76);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.certificate-editor {
  isolation: isolate;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  color: #1f2937;
  background: #f4f5f7;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  direction: rtl;
}
.certificate-header {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #dce1e8;
}
.certificate-header h2 { flex: 0 0 auto; font-size: 19px; }
.certificate-header-actions { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: flex-start; gap: 9px; overflow: visible; }
.certificate-menu-trigger,
.certificate-dropdown > summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #f8fafc;
  color: #263449;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  white-space: nowrap;
  list-style: none;
  box-shadow: 0 4px 0 #9eafc5, inset 0 1px 0 #fff;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.certificate-menu-trigger:active,
.certificate-dropdown > summary:active { transform: translateY(2px); box-shadow: 0 2px 0 #9eafc5, inset 0 1px 0 #fff; }
.certificate-menu-trigger:hover,
.certificate-dropdown > summary:hover { background: #eef3fa; border-color: #9eafc5; }
.certificate-dropdown { position: relative; flex: 0 0 auto; }
.certificate-dropdown > summary::-webkit-details-marker { display: none; }
.certificate-dropdown[open] > summary { background: #e8effc; border-color: #7398d7; }
.certificate-dropdown-panel {
  position: fixed;
  top: 12px;
  left: 12px;
  right: auto;
  bottom: auto;
  z-index: 3500;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 14px;
  background: linear-gradient(155deg, #fff 0%, #f5f8fd 100%);
  border: 1px solid #cad4e2;
  border-radius: 14px;
  box-shadow: 0 18px 0 #9daec3, 0 20px 36px #0f1d3038, inset 0 1px 0 #fff;
  animation: certificate-pop-in .16s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes certificate-pop-in {
  from { opacity: 0; transform: translateY(-7px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.certificate-project-menu .btn { min-height: 42px; }
.certificate-project-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.certificate-project-actions .btn { min-width: 0; min-height: 42px; padding: 7px; font-size: 12px; }
.certificate-print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.certificate-print-grid label, .certificate-custom-paper label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #526176;
  font-size: 12px;
  font-weight: 800;
}
.certificate-print-grid input, .certificate-print-grid select, .certificate-custom-paper input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 7px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fbfcfe;
  color: #172033;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
}
.certificate-custom-paper { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.certificate-custom-paper[hidden] { display: none; }
.certificate-print-hint { color: #64748b; font-size: 11px; line-height: 1.6; }
.certificate-print-menu > .btn { min-height: 44px; }
.certificate-workspace { position: relative; isolation: isolate; flex: 1; min-height: 0; display: flex; gap: 14px; padding: 14px; }
.certificate-tools {
  position: fixed;
  z-index: 3500;
  top: 12px;
  left: 12px;
  right: auto;
  bottom: auto;
  width: min(390px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(155deg, #fff 0%, #f5f8fd 100%);
  border: 1px solid #cad4e2;
  border-radius: 14px;
  box-shadow: 0 18px 0 #9daec3, 0 20px 36px #0f1d3038, inset 0 1px 0 #fff;
  animation: certificate-pop-in .16s cubic-bezier(.2,.8,.2,1) both;
  pointer-events: auto;
  user-select: text;
}
.certificate-tools.is-collapsed { display: none; }
.certificate-tools-heading { display: flex; align-items: center; justify-content: space-between; color: #23334a; }
.certificate-tools-heading strong { font-size: 15px; }
.certificate-tools-heading button { width: 34px; height: 34px; border: 1px solid #d6dee8; border-radius: 8px; background: #f7f9fc; cursor: pointer; }
.certificate-tool-section { border: 1px solid #e0e5ec; border-radius: 10px; background: #fbfcfe; }
.certificate-tool-section > summary { padding: 10px 12px; color: #35465d; font-size: 13px; font-weight: 800; cursor: pointer; }
.certificate-tool-content { display: flex; flex-direction: column; gap: 10px; padding: 0 12px 12px; }
.certificate-edit-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.certificate-edit-controls label { display: flex; flex-direction: column; gap: 5px; }
.certificate-label { color: #475569; font-size: 12px; font-weight: 800; }
.certificate-tools textarea, .certificate-tools select, .certificate-tools input[type="number"], .certificate-tools input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: #172033;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  outline-color: #4b83e6;
  pointer-events: auto;
}
.certificate-tools textarea { min-height: 92px; resize: vertical; user-select: text; }
#certificateNames { min-height: 132px; }
.certificate-add-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.certificate-field-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.certificate-add-row .btn, .certificate-field-actions .btn { min-width: 0; min-height: 44px; padding: 8px 10px; font-size: 12px; white-space: normal; }
.certificate-style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.certificate-style-grid label { min-width: 0; display: flex; flex-direction: column; gap: 5px; color: #64748b; font-size: 11px; font-weight: 700; }
.certificate-style-grid input[type="color"] { width: 100%; height: 40px; padding: 3px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.certificate-style-toggles { display: flex; flex-wrap: wrap; gap: 14px; color: #475569; font-size: 12px; }
.certificate-style-toggles label { display: inline-flex; align-items: center; gap: 6px; }
.certificate-style-toggles input { accent-color: #3168ce; }
.certificate-status { min-height: 42px; padding: 9px; color: #516178; background: #f3f6fb; border-radius: 8px; font-size: 11px; line-height: 1.5; }
.certificate-field-floating-panel[hidden] { display: none; }
.certificate-field-floating-panel {
  position: fixed; z-index: 3600; top: 50%; right: 10px; transform: translateY(-50%);
  width: 66px; max-height: calc(100dvh - 28px); overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 7px;
  background: linear-gradient(155deg, #fff 0%, #f3f6fb 100%); border: 1px solid #cbd5e1;
  border-radius: 14px; box-shadow: 0 10px 28px #0f1d3038, inset 0 1px 0 #fff;
}
.certificate-editor.has-field-tools .certificate-stage-wrap { margin-right: 78px; }
.certificate-floating-close, .certificate-floating-action, .certificate-floating-toggle, .certificate-floating-control {
  flex: 0 0 auto; width: 48px; min-height: 42px; display: flex; align-items: center; justify-content: center;
  border: 1px solid #d5dce6; border-radius: 10px; background: #fff; color: #344256;
}
.certificate-floating-close { min-height: 30px; width: 30px; align-self: flex-end; font-size: 20px; line-height: 1; cursor: pointer; }
.certificate-floating-control { position: relative; flex-direction: column; gap: 3px; padding: 4px; }
.certificate-floating-control > span, .certificate-floating-toggle > span { font-size: 13px; font-weight: 900; line-height: 1; }
.certificate-floating-control input[type="color"] { width: 34px; height: 28px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 7px; background: #fff; cursor: pointer; }
.certificate-floating-control select { width: 54px; height: 26px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #263449; font-family: inherit; font-size: 9px; }
.certificate-floating-font { min-height: 62px; }
.certificate-floating-size { min-height: 132px; }
.certificate-floating-size output { color: #475569; font-size: 10px; font-weight: 800; }
.certificate-size-actions { display: flex; flex-direction: column; gap: 4px; }
.certificate-size-actions button { width: 30px; height: 30px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #24344a; font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; }
.certificate-size-actions button:hover { border-color: #7398d7; background: #eaf1ff; }
.certificate-size-actions button:disabled { opacity: .45; cursor: not-allowed; }
.certificate-floating-align { min-height: 62px; }
.certificate-floating-toggle { min-height: 36px; cursor: pointer; }
.certificate-floating-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.certificate-floating-toggle:has(input:checked) { border-color: #7398d7; background: #eaf1ff; color: #254e8a; }
.certificate-floating-action { font-size: 22px; cursor: pointer; }
.certificate-floating-close:hover, .certificate-floating-action:hover { border-color: #789bd0; background: #eef3fa; }
.certificate-stage-wrap { position: relative; z-index: 0; flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.certificate-stage {
  flex: 1; min-height: 0; min-width: 0; display: block; overflow-x: auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 0; direction: ltr; touch-action: pan-x pan-y; scrollbar-gutter: stable; scroll-snap-type: y mandatory;
  scrollbar-width: auto; scrollbar-color: #8c9bb0 #e7eaf0;
  background-color: #e7eaf0;
  background-image: linear-gradient(45deg,#d9dee7 25%,transparent 25%),linear-gradient(-45deg,#d9dee7 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#d9dee7 75%),linear-gradient(-45deg,transparent 75%,#d9dee7 75%);
  background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0;
  border: 1px solid #d0d6df; border-radius: 12px;
}
.certificate-stage.is-zoomed { scroll-snap-type: none; }
.certificate-stage.is-dragging-pan .certificate-preview-canvas { cursor: grabbing; }
.certificate-stage::-webkit-scrollbar { width: 12px; height: 12px; }
.certificate-stage::-webkit-scrollbar-track { background: #e7eaf0; border-radius: 8px; }
.certificate-stage::-webkit-scrollbar-thumb { background: #8c9bb0; border: 3px solid #e7eaf0; border-radius: 8px; }
.certificate-preview-list { width: 100%; min-width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.certificate-preview-card { position: relative; flex: 0 0 auto; width: 100%; display: flex; align-items: center; justify-content: center; padding: 38px 20px 12px; scroll-snap-align: start; box-sizing: border-box; }
.certificate-preview-card.is-entering { animation: certificate-card-in .28s cubic-bezier(.2,.75,.25,1) both; animation-delay: calc(var(--certificate-order, 0) * 45ms); will-change: opacity, transform; }
@keyframes certificate-card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.certificate-preview-label { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); z-index: 1; box-sizing: border-box; max-width: calc(100% - 20px); min-width: 120px; overflow: hidden; text-overflow: ellipsis; padding: 5px 12px; border: 1px solid #cad3df; border-radius: 999px; background: linear-gradient(#fff,#edf1f6); box-shadow: 0 3px 0 #b3bfce; color: #526176; font-size: 12px; font-weight: 800; text-align: center; direction: rtl; white-space: nowrap; }
.certificate-preview-card.is-active .certificate-preview-label { border-color: #6d91cd; background: linear-gradient(#f5f8ff,#dce8fc); color: #254e8a; box-shadow: 0 3px 0 #8ea9d3; }
.certificate-preview-card.is-active .certificate-preview-frame { outline: 2px solid #789bd0; outline-offset: 3px; }
.certificate-preview-card.is-active.has-text-selection .certificate-preview-frame { outline-color: #16a34a; }
.certificate-preview-card.is-active.is-image-selected .certificate-preview-frame { outline-color: #dc2626; }
.certificate-preview-frame { position: relative; flex: 0 0 auto; overflow: hidden; border: 1px solid #c7ced8; border-radius: 3px; background: #fff; box-shadow: 0 12px 28px #1e293b30, 0 3px 0 #bdc7d4; touch-action: none; }
.certificate-background-layer, .certificate-preview-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.certificate-background-layer { object-fit: contain; pointer-events: none; user-select: none; animation: certificate-layer-in .28s ease-out .08s both; }
.certificate-preview-canvas { z-index: 1; background: transparent; cursor: crosshair; touch-action: none; user-select: none; animation: certificate-layer-in .24s ease-out .16s both; }
@keyframes certificate-layer-in { from { opacity: 0; } to { opacity: 1; } }
.certificate-stage.is-dragging-pan .certificate-preview-frame { cursor: grabbing; }
@media (prefers-reduced-motion: reduce) {
  .certificate-preview-card.is-entering, .certificate-background-layer, .certificate-preview-canvas { animation: none; will-change: auto; }
}
.certificate-stage-hint { text-align: center; color: #64748b; font-size: 11px; }
@media (max-width: 800px) {
  .certificate-modal { padding: 0; align-items: stretch; }
  .certificate-editor { width: 100%; height: 100vh; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .certificate-header { min-height: 54px; padding: 6px 8px; gap: 6px; }
  .certificate-header h2 { font-size: 14px; }
  .certificate-header-actions { gap: 6px; }
  .certificate-menu-trigger, .certificate-dropdown > summary { min-height: 38px; padding: 6px 8px; font-size: 11px; }
  .certificate-dropdown-panel { width: min(390px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
  .certificate-workspace { gap: 8px; padding: 8px; }
  .certificate-tools { width: min(390px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 10px; gap: 9px; }
  .certificate-stage { padding: 0; }
  .certificate-editor.has-field-tools .certificate-stage-wrap { margin-right: 72px; }
  .certificate-field-floating-panel { right: 6px; width: 62px; padding: 5px; gap: 6px; }
  .certificate-floating-control, .certificate-floating-action, .certificate-floating-toggle { width: 46px; }
  .certificate-floating-control select { width: 50px; }
  .certificate-preview-card { padding: 38px 10px 10px; }
  .certificate-preview-label { font-size: 11px; }
  .certificate-stage-hint { font-size: 10px; line-height: 1.45; padding-inline: 4px; }
}
.certificate-page-label-short, .certificate-export-label-short { display: none; }
@media (max-width: 520px) {
  .certificate-page-label-full, .certificate-export-label-full { display: none; }
  .certificate-page-label-short, .certificate-export-label-short { display: inline; }
  .certificate-header h2 { display: none; }
  .certificate-header-actions { justify-content: space-between; gap: 4px; }
  .certificate-menu-trigger, .certificate-dropdown > summary { min-height: 36px; padding: 5px 6px; font-size: 10px; }
  .certificate-close { padding-inline: 6px; }
  .certificate-print-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .certificate-print-grid label, .certificate-custom-paper label { font-size: 11px; }
  .certificate-add-row, .certificate-field-actions { grid-template-columns: 1fr; gap: 10px; }
  .certificate-project-actions { grid-template-columns: 1fr; gap: 9px; }
  .certificate-add-row .btn, .certificate-field-actions .btn { min-height: 46px; font-size: 13px; }
}
