.khaddar-sop-wrap {
  margin-left: 18px;
}

.ksb-shell,
.ksb-shell * {
  box-sizing: border-box;
}

.ksb-shell {
  --ksb-bg: #f6f3ee;
  --ksb-ink: #17211b;
  --ksb-muted: #69736d;
  --ksb-line: #ded8cf;
  --ksb-panel: #fffdf8;
  --ksb-white: #ffffff;
  --ksb-accent: #0d6f63;
  --ksb-dark: #20362f;
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
  margin-top: 18px;
  border: 1px solid var(--ksb-line);
  background: var(--ksb-bg);
  color: var(--ksb-ink);
  font-family: Arial, Tahoma, sans-serif;
}

.ksb-sidebar {
  border-left: 1px solid var(--ksb-line);
  background: #fbfaf6;
  padding: 22px;
}

.ksb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.ksb-brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: var(--ksb-accent);
  color: #fff;
  font-weight: 800;
}

.ksb-brand p,
.ksb-brand strong {
  display: block;
  margin: 0;
}

.ksb-brand p,
.ksb-role small,
.ksb-topbar label,
.ksb-guide-details label,
.ksb-actions span {
  color: var(--ksb-muted);
}

.ksb-brand strong {
  font-size: 17px;
}

.ksb-primary,
.ksb-actions button,
.ksb-empty-add {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--ksb-accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.ksb-primary {
  width: 100%;
  margin-bottom: 16px;
}

.ksb-guide-list {
  display: grid;
  gap: 9px;
}

.ksb-role {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: right;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px;
  color: var(--ksb-ink);
  cursor: pointer;
}

.ksb-role.active,
.ksb-role:hover {
  border-color: var(--ksb-line);
  background: var(--ksb-white);
}

.ksb-workspace {
  min-width: 0;
  padding: 24px clamp(18px, 4vw, 44px) 44px;
}

.ksb-topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.ksb-topbar label,
.ksb-guide-details label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
}

.ksb-shell input,
.ksb-shell textarea,
.ksb-shell select,
.khaddar-cop-editor-shortcode input,
.khaddar-cop-editor-shortcode textarea,
.khaddar-cop-editor-shortcode select {
  width: 100%;
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: var(--ksb-white);
  color: var(--ksb-ink);
  padding: 11px 12px;
  outline: none;
  font: inherit;
}

.ksb-shell textarea {
  resize: none;
  line-height: 1.7;
  overflow: hidden;
}

.ksb-shell input:focus,
.ksb-shell textarea:focus,
.ksb-shell select:focus {
  border-color: var(--ksb-accent);
  box-shadow: 0 0 0 3px rgba(13, 111, 99, 0.12);
}

.ksb-shell input:disabled,
.ksb-shell textarea:disabled,
.khaddar-cop-editor-shortcode input:disabled,
.khaddar-cop-editor-shortcode textarea:disabled {
  background: #f3f0ea;
  color: #5f6963;
  cursor: not-allowed;
}

.ksb-title-input {
  min-width: min(560px, 55vw);
  border: 0 !important;
  border-bottom: 2px solid var(--ksb-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 4px 0 9px !important;
  font-size: clamp(26px, 3.5vw, 42px) !important;
  font-weight: 800 !important;
}

.ksb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.ksb-actions button {
  background: var(--ksb-dark);
}

.ksb-actions button:last-child {
  background: #914231;
}

.ksb-actions .is-error {
  color: #b42318;
}

.ksb-guide-details {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(220px, 1fr) minmax(280px, 1.5fr);
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
}

.ksb-stages {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.ksb-stage {
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: var(--ksb-panel);
  overflow: hidden;
}

.ksb-stage-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--ksb-line);
  background: #eef5f1;
  padding: 14px;
}

.ksb-stage-header input {
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 800;
}

.ksb-mini-actions,
.ksb-block-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ksb-mini-actions button,
.ksb-block-actions button {
  min-width: 36px;
  min-height: 34px;
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: #fff;
  color: var(--ksb-ink);
  cursor: pointer;
}

.ksb-steps {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.ksb-step-block {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  position: relative;
  padding-bottom: 18px;
}

.ksb-step-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ksb-dark);
  color: #fff;
  font-weight: 800;
}

.ksb-add-below {
  position: absolute;
  bottom: -4px;
  right: 48px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--ksb-line);
  border-radius: 50%;
  background: #fff;
  color: var(--ksb-accent);
  font-weight: 900;
  cursor: pointer;
}

.ksb-empty-add {
  justify-self: start;
  background: transparent;
  color: var(--ksb-accent);
  border: 1px dashed var(--ksb-accent);
}

.ksb-preview,
.khaddar-sop-public {
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid var(--ksb-line, #ded8cf);
  border-radius: 8px;
  background: #fff;
  padding: clamp(22px, 4vw, 46px);
  box-shadow: 0 18px 45px rgba(27, 29, 25, 0.08);
}

.khaddar-cop-editor-shortcode {
  --ksb-bg: #f6f3ee;
  --ksb-ink: #17211b;
  --ksb-muted: #69736d;
  --ksb-line: #ded8cf;
  --ksb-panel: #fffdf8;
  --ksb-white: #ffffff;
  --ksb-accent: #0d6f63;
  --ksb-dark: #20362f;
  max-width: 1080px;
  margin: 0 auto;
  color: var(--ksb-ink);
  font-family: Arial, Tahoma, sans-serif;
}

body.khaddar-cop-clean-page #wpadminbar,
body.khaddar-cop-clean-page header,
body.khaddar-cop-clean-page .site-header,
body.khaddar-cop-clean-page #masthead,
body.khaddar-cop-clean-page .elementor-location-header,
body.khaddar-cop-clean-page .header,
body.khaddar-cop-clean-page .main-header {
  display: none !important;
}

body.khaddar-cop-clean-page.admin-bar {
  margin-top: 0 !important;
}

html:has(body.khaddar-cop-clean-page) {
  margin-top: 0 !important;
}

.khaddar-cop-page-shell {
  min-height: 100vh;
  padding: clamp(18px, 4vw, 38px);
  background: #f6f3ee;
}

.ksb-frontend-editor {
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: var(--ksb-bg);
  padding: clamp(16px, 3vw, 28px);
}

.ksb-frontend-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.ksb-frontend-header h2,
.ksb-frontend-header p {
  margin: 0;
}

.ksb-frontend-header h2 {
  font-size: clamp(26px, 4vw, 42px);
}

.ksb-frontend-header > div > p:last-child {
  margin-top: 6px;
  color: var(--ksb-muted);
}

.khaddar-sop-editor-message {
  max-width: 760px;
  margin: 20px auto;
  border: 1px solid #ded8cf;
  border-radius: 8px;
  background: #fffdf8;
  padding: 18px;
  color: #17211b;
  text-align: center;
  font-family: Arial, Tahoma, sans-serif;
}

.khaddar-sop-login-box {
  max-width: 460px;
  margin: 28px auto;
  border: 1px solid #ded8cf;
  border-radius: 8px;
  background: #fffdf8;
  padding: 24px;
  color: #17211b;
  font-family: Arial, Tahoma, sans-serif;
  box-shadow: 0 18px 45px rgba(27, 29, 25, 0.08);
}

.khaddar-sop-login-box h3 {
  margin: 0 0 8px;
  font-size: 24px;
}

.khaddar-sop-login-box p {
  margin: 0 0 18px;
  color: #69736d;
}

.khaddar-sop-login-box label {
  display: block;
  margin-bottom: 7px;
  font-weight: 700;
}

.khaddar-sop-login-box input[type="text"],
.khaddar-sop-login-box input[type="password"] {
  width: 100%;
  border: 1px solid #ded8cf;
  border-radius: 8px;
  padding: 11px 12px;
}

.khaddar-sop-login-box .login-submit input {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: #0d6f63;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.ksb-document-label,
.khaddar-sop-label {
  margin: 0 0 8px;
  color: var(--ksb-accent, #0d6f63);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ksb-preview h1,
.khaddar-sop-public h2 {
  margin: 0 0 16px;
  font-size: clamp(28px, 5vw, 48px);
}

.ksb-meta-grid,
.khaddar-sop-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.ksb-meta-grid span,
.khaddar-sop-meta span {
  border: 1px solid var(--ksb-line, #ded8cf);
  border-radius: 8px;
  padding: 10px;
  color: var(--ksb-muted, #69736d);
  font-size: 14px;
}

.ksb-preview section,
.khaddar-sop-public section {
  border-top: 1px solid var(--ksb-line, #ded8cf);
  padding-top: 18px;
  margin-top: 18px;
}

.ksb-preview h2,
.khaddar-sop-public h3 {
  margin: 0 0 12px;
  font-size: 20px;
}

.ksb-preview p,
.ksb-preview li,
.khaddar-sop-public p,
.khaddar-sop-public li {
  line-height: 1.8;
}

.ksb-preview ol,
.khaddar-sop-public ol {
  padding-right: 22px;
}

.ksb-empty,
.ksb-loading {
  border: 1px dashed var(--ksb-line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
  text-align: center;
}

@media (max-width: 900px) {
  .ksb-shell {
    grid-template-columns: 1fr;
  }

  .ksb-sidebar {
    border-left: 0;
    border-bottom: 1px solid var(--ksb-line);
  }

  .ksb-guide-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .ksb-topbar,
  .ksb-frontend-header,
  .ksb-guide-details {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ksb-title-input {
    min-width: 0;
  }

  .ksb-stage-header,
  .ksb-step-block,
  .ksb-meta-grid,
  .khaddar-sop-meta {
    grid-template-columns: 1fr;
  }

  .ksb-step-number {
    display: none;
  }

  .ksb-add-below {
    right: 4px;
  }
}

@media print {
  #adminmenumain,
  #wpadminbar,
  .ksb-sidebar,
  .ksb-topbar,
  .ksb-guide-details,
  .ksb-stages {
    display: none !important;
  }

  #wpcontent,
  #wpbody-content,
  .wrap,
  .ksb-workspace {
    margin: 0 !important;
    padding: 0 !important;
  }

  .ksb-shell {
    display: block;
    border: 0;
    background: #fff;
  }

  .ksb-preview {
    border: 0;
    box-shadow: none;
    max-width: none;
  }
}

/* Professional UI refresh */
.ksb-shell,
.khaddar-cop-editor-shortcode {
  --ksb-bg: #f5f7f2;
  --ksb-ink: #12221a;
  --ksb-muted: #647168;
  --ksb-line: #d9e0d6;
  --ksb-panel: #ffffff;
  --ksb-white: #ffffff;
  --ksb-accent: #0b7a3b;
  --ksb-accent-soft: #e8f5ec;
  --ksb-orange: #f28c18;
  --ksb-orange-soft: #fff4df;
  --ksb-dark: #163b2a;
}

.ksb-shell {
  border: 0;
  background:
    linear-gradient(180deg, rgba(11, 122, 59, 0.06), transparent 240px),
    var(--ksb-bg);
  box-shadow: 0 18px 60px rgba(18, 34, 26, 0.08);
}

.ksb-sidebar {
  background: #ffffff;
  border-left-color: #e3e8df;
}

.ksb-brand-mark {
  background: linear-gradient(135deg, var(--ksb-accent), #18a957);
  box-shadow: 0 8px 22px rgba(11, 122, 59, 0.25);
}

.ksb-primary,
.ksb-actions button,
.ksb-empty-add {
  border-radius: 8px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.ksb-primary,
.ksb-empty-add,
.ksb-icon-button.is-add {
  background: var(--ksb-orange);
  color: #fff;
}

.ksb-primary:hover,
.ksb-actions button:hover,
.ksb-empty-add:hover,
.ksb-icon-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(18, 34, 26, 0.12);
}

.ksb-role {
  border-radius: 8px;
  background: #f8faf6;
}

.ksb-role.active {
  border-color: rgba(11, 122, 59, 0.28);
  background: var(--ksb-accent-soft);
  box-shadow: inset 4px 0 0 var(--ksb-accent);
}

.ksb-topbar,
.ksb-frontend-header {
  border-bottom: 1px solid var(--ksb-line);
  padding-bottom: 18px;
}

.ksb-guide-details {
  border: 0;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(18, 34, 26, 0.06);
}

.ksb-stage {
  border: 0;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(18, 34, 26, 0.08);
}

.ksb-stage-header {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  background: linear-gradient(90deg, var(--ksb-accent-soft), #ffffff);
  border-bottom-color: #e5ebe2;
}

.ksb-stage-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--ksb-orange-soft);
  color: var(--ksb-orange);
  font-size: 18px;
  font-weight: 800;
}

.ksb-stage-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ksb-drag-handle,
.ksb-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--ksb-line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ksb-muted);
  cursor: grab;
  line-height: 1;
  touch-action: none;
  user-select: none;
}

.ksb-drag-handle:active {
  cursor: grabbing;
}

.ksb-icon-button {
  cursor: pointer;
  font-weight: 800;
}

.ksb-icon-button.is-danger {
  border-color: #ffe2dc;
  background: #fff7f5;
  color: #b42318;
  font-family: Arial, Tahoma, sans-serif;
  font-size: 24px;
  font-weight: 900;
  overflow: visible;
}

.ksb-section-toolbar {
  display: flex;
  justify-content: flex-start;
  margin: 12px 0 8px;
}

.ksb-section-toolbar.is-bottom {
  margin: 10px 0 0;
}

.ksb-add-stage-button {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: var(--ksb-accent);
  color: #fff;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(11, 122, 59, 0.18);
}

.ksb-add-stage-button:hover {
  background: #096732;
}

.ksb-step-block {
  grid-template-columns: 38px 38px minmax(0, 1fr) 38px;
  align-items: stretch;
  padding: 10px;
  border: 1px solid #edf1ea;
  border-radius: 8px;
  background: #fbfdf9;
}

.ksb-step-number {
  width: 36px;
  height: 36px;
  background: var(--ksb-accent);
}

.ksb-step-block textarea {
  min-height: 46px;
  border-color: transparent;
  background: #ffffff;
  overflow: hidden;
  resize: none;
}

.ksb-step-block:focus-within {
  border-color: rgba(11, 122, 59, 0.32);
  box-shadow: 0 0 0 3px rgba(11, 122, 59, 0.08);
}

.ksb-empty-add {
  background: var(--ksb-orange-soft);
  color: #a65605;
  border-color: rgba(242, 140, 24, 0.42);
}

.ksb-add-below,
.ksb-mini-actions,
.ksb-block-actions {
  display: none !important;
}

.is-dragging {
  opacity: 0.45;
}

.is-drop-target {
  outline: 2px dashed var(--ksb-orange);
  outline-offset: 3px;
}

.ksb-frontend-editor {
  border: 0;
  background:
    linear-gradient(180deg, rgba(11, 122, 59, 0.08), rgba(242, 140, 24, 0.04)),
    #ffffff;
  box-shadow: 0 18px 56px rgba(18, 34, 26, 0.1);
}

@media (max-width: 900px) {
  .ksb-stage-header {
    grid-template-columns: 36px minmax(0, 1fr) auto;
  }

  .ksb-stage-tools {
    justify-content: flex-start;
  }

  .ksb-step-block {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .ksb-step-number {
    display: none;
  }
}

/* Compact spacing */
.ksb-sidebar {
  padding: 16px;
}

.ksb-brand {
  margin-bottom: 14px;
}

.ksb-brand-mark {
  width: 40px;
  height: 40px;
}

.ksb-primary {
  margin-bottom: 12px;
}

.ksb-role {
  padding: 9px 10px;
}

.ksb-guide-list {
  gap: 6px;
}

.ksb-workspace {
  padding: 16px clamp(12px, 3vw, 28px) 28px;
}

.ksb-topbar,
.ksb-frontend-header {
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.ksb-title-input {
  padding-bottom: 5px !important;
  font-size: clamp(22px, 3vw, 34px) !important;
}

.ksb-actions {
  gap: 6px;
}

.ksb-actions button,
.ksb-primary,
.ksb-empty-add,
.ksb-add-stage-button {
  min-height: 34px;
  padding: 7px 11px;
}

.ksb-guide-details {
  gap: 10px;
  padding: 11px;
}

.ksb-shell input,
.ksb-shell textarea,
.ksb-shell select,
.khaddar-cop-editor-shortcode input,
.khaddar-cop-editor-shortcode textarea,
.khaddar-cop-editor-shortcode select {
  padding: 8px 10px;
}

.ksb-stages {
  gap: 12px;
  margin-top: 12px;
}

.ksb-stage-header {
  gap: 8px;
  padding: 9px 10px;
}

.ksb-stage-header input {
  font-size: 18px;
}

.ksb-stage-icon,
.ksb-drag-handle,
.ksb-icon-button,
.ksb-step-number {
  width: 32px;
  height: 32px;
}

.ksb-steps {
  gap: 8px;
  padding: 10px;
}

.ksb-step-block {
  grid-template-columns: 32px 32px minmax(0, 1fr) 32px;
  gap: 7px;
  padding: 7px;
}

.ksb-step-block textarea {
  min-height: 38px;
  overflow: hidden;
  resize: none;
}

.ksb-frontend-editor {
  padding: clamp(12px, 2vw, 20px);
}

.khaddar-cop-page-shell {
  padding: clamp(10px, 3vw, 22px);
}

.ksb-preview,
.khaddar-sop-public {
  padding: clamp(18px, 3vw, 32px);
}

.ksb-meta-grid,
.khaddar-sop-meta {
  gap: 7px;
  margin-bottom: 16px;
}

.ksb-preview section,
.khaddar-sop-public section {
  padding-top: 12px;
  margin-top: 12px;
}

/* Final mobile layout fix */
.ksb-step-block textarea {
  min-width: 0;
  width: 100% !important;
  display: block;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  overflow: hidden;
  resize: none;
}

.ksb-stage-header input {
  min-width: 0;
}

@media (max-width: 700px) {
  .khaddar-cop-page-shell {
    padding: 8px;
  }

  .ksb-frontend-editor {
    padding: 10px;
    border-radius: 8px;
  }

  .ksb-stage-header {
    grid-template-columns: 32px minmax(0, 1fr) 72px !important;
    align-items: center;
  }

  .ksb-stage-icon {
    grid-column: 1;
    grid-row: 1;
  }

  .ksb-stage-header input {
    grid-column: 2;
    grid-row: 1;
    font-size: 18px;
  }

  .ksb-stage-tools {
    grid-column: 3;
    grid-row: 1;
    justify-content: end;
    display: flex !important;
    gap: 6px;
  }

  .ksb-stage-tools .ksb-icon-button.is-danger,
  .ksb-step-block > .ksb-icon-button.is-danger {
    display: grid !important;
    place-items: center;
    font-size: 22px;
    line-height: 1;
    min-width: 32px;
  }

  .ksb-step-block {
    grid-template-columns: 32px minmax(0, 1fr) 32px !important;
    align-items: center;
    gap: 6px;
    direction: rtl;
  }

  .ksb-step-block > .ksb-drag-handle {
    grid-column: 1;
    grid-row: 1;
  }

  .ksb-step-block textarea {
    grid-column: 2;
    grid-row: 1;
    min-height: 42px;
    line-height: 1.55;
  }

  .ksb-step-block > .ksb-icon-button.is-danger {
    grid-column: 3;
    grid-row: 1;
  }

  .ksb-step-number {
    display: none !important;
  }
}
