:root {
  --cop-blue: #283380;
  --cop-orange: #f39321;
  --cop-ink: #1f2937;
  --cop-muted: #667085;
  --cop-line: #d9e2ef;
  --cop-bg: #f6f8fb;
  --cop-card: #ffffff;
  --cop-danger: #d92d20;
}

.cop-tool-error {
  padding: 14px 16px;
  border: 1px solid #f0b8b8;
  background: #fff5f5;
  color: #8a1f1f;
  border-radius: 12px;
}

.cop-document-tool,
.cop-admin-shell,
.cop-admin-builder {
  font-family: "Open Sans", "PT Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cop-ink);
}

.cop-theme-navy-orange { --scene-a:#283380; --scene-b:#f39321; --accent:#f39321; --accent-2:#283380; }
.cop-theme-green-community { --scene-a:#0f7a55; --scene-b:#78c850; --accent:#1f8f5f; --accent-2:#0b5b44; }
.cop-theme-sunset { --scene-a:#db4d2f; --scene-b:#f3a321; --accent:#e05b38; --accent-2:#9b2d1d; }
.cop-theme-violet { --scene-a:#382a83; --scene-b:#a35fd1; --accent:#6a45b8; --accent-2:#382a83; }
.cop-theme-sky { --scene-a:#0a69a8; --scene-b:#35b9d7; --accent:#0a7ac2; --accent-2:#07598f; }
.cop-theme-graphite { --scene-a:#111827; --scene-b:#64748b; --accent:#334155; --accent-2:#111827; }
.cop-theme-berry { --scene-a:#7f1d1d; --scene-b:#db2777; --accent:#be185d; --accent-2:#7f1d1d; }
.cop-theme-sand { --scene-a:#92400e; --scene-b:#fbbf24; --accent:#b45309; --accent-2:#78350f; }
.cop-theme-aqua { --scene-a:#0f766e; --scene-b:#22d3ee; --accent:#0891b2; --accent-2:#0f766e; }
.cop-theme-red { --scene-a:#991b1b; --scene-b:#fb7185; --accent:#dc2626; --accent-2:#7f1d1d; }
.cop-theme-olive { --scene-a:#365314; --scene-b:#a3e635; --accent:#65a30d; --accent-2:#365314; }
.cop-theme-indigo { --scene-a:#312e81; --scene-b:#818cf8; --accent:#4f46e5; --accent-2:#312e81; }
.cop-theme-mono { --scene-a:#374151; --scene-b:#d1d5db; --accent:#4b5563; --accent-2:#111827; }

/* Frontend */
.cop-doc-wrap {
  border: 1px solid var(--cop-line);
  border-radius: 24px;
  overflow: hidden;
  background: var(--cop-card);
  box-shadow: 0 18px 45px rgba(29, 41, 57, 0.12);
  margin: 24px 0;
}

.cop-scene,
.cop-builder-hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, var(--scene-a, #283380), var(--scene-b, #f39321));
}

.cop-scene { padding: 34px; }
.cop-builder-hero { padding: 26px; border-radius: 22px; display:flex; justify-content:space-between; gap:20px; align-items:flex-start; }

.cop-scene::after,
.cop-builder-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  top: -80px;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  border: 42px solid rgba(255, 255, 255, .12);
}

.cop-scene__kicker,
.cop-builder-hero span {
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .9;
}

.cop-scene h2,
.cop-builder-hero h2 {
  color: #fff;
  margin: 10px 0 8px;
  font-weight: 800;
  line-height: 1.15;
}

.cop-scene p,
.cop-builder-hero p { max-width: 850px; margin: 0; opacity: .94; }

.cop-scene__badge,
.cop-builder-hero strong {
  position: relative;
  z-index: 1;
  display: inline-flex;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25);
  font-weight: 800;
  white-space: nowrap;
}

.cop-doc-toolbar,
.cop-builder-actions,
.cop-doc-toolbarline,
.cop-subtoolbar,
.cop-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.cop-doc-toolbar {
  padding: 18px;
  background: #fff;
  border-bottom: 1px solid var(--cop-line);
}

.cop-doc-wrap button,
.cop-admin-builder button,
.cop-builder-actions button,
.cop-modal-actions button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  background: var(--accent, #283380);
  color: #fff;
  box-shadow: 0 8px 18px rgba(29, 41, 57, .14);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.cop-doc-wrap button:hover,
.cop-admin-builder button:hover,
.cop-builder-actions button:hover,
.cop-modal-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(29, 41, 57, .18);
}

.cop-doc-wrap button.secondary,
.cop-admin-builder button.secondary,
.cop-builder-actions button.secondary,
.cop-modal-actions button.secondary {
  background: #eef2f7;
  color: var(--cop-ink);
  box-shadow: none;
}

.cop-doc-wrap button.danger,
.cop-admin-builder button.danger { background: var(--cop-danger); }

.cop-doc-wrap button.small,
.cop-admin-builder button.small {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.cop-doc-wrap button:disabled,
.cop-admin-builder button:disabled { opacity: .45; cursor: not-allowed; transform:none; }

.cop-progress {
  position: relative;
  height: 28px;
  background: #eef2f7;
  border-bottom: 1px solid var(--cop-line);
}
.cop-progress span { display:block; height:100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s ease; }
.cop-progress strong { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#111827; font-size:12px; }

.cop-document-output {
  padding: 26px;
  background: var(--cop-bg);
}

.cop-document-output h1,
.cop-document-output h2,
.cop-document-output h3,
.cop-document-output h4 { color: var(--accent-2); }
.cop-export-title { margin-top: 0; }
.cop-export-description { color: var(--cop-muted); }
.cop-paragraph p { margin: 0 0 10px; }
.cop-block { margin: 0 0 18px; }
.cop-block[hidden] { display:none !important; }
.cop-divider { border:0; border-top:1px solid var(--cop-line); margin: 24px 0; }

.cop-form-field,
.cop-calc-card,
.cop-form-table {
  padding: 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--cop-line);
}

.cop-form-field label,
.cop-admin-builder label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}

.cop-form-field .required { color: var(--cop-danger); }
.cop-help { color: var(--cop-muted); margin-top: -4px; }

.cop-form-field input,
.cop-form-field textarea,
.cop-form-field select,
.cop-form-table input,
.cop-form-table textarea,
.cop-form-table select,
.cop-admin-builder input,
.cop-admin-builder textarea,
.cop-admin-builder select,
.cop-modal input,
.cop-modal textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #cfd7e4;
  border-radius: 10px;
  padding: 9px 10px;
  background: #fff;
  color: var(--cop-ink);
  font: inherit;
}

.cop-check { display:flex !important; flex-direction:row; align-items:center; gap:8px; font-weight:600 !important; }
.cop-check input { width:auto; }

.cop-table-scroll,
.cop-admin-table-shell { overflow-x:auto; border: 1px solid var(--cop-line); border-radius: 16px; background:#fff; margin: 12px 0; }
.cop-form-table table,
.cop-admin-mini-table { width:100%; border-collapse: collapse; min-width: 760px; }
.cop-form-table th,
.cop-admin-mini-table th { background:#50545c; color:#fff; padding:10px; text-align:left; font-size:13px; }
.cop-form-table td,
.cop-admin-mini-table td { border-bottom:1px solid #edf0f5; padding:8px; vertical-align:middle; }
.cop-form-table tfoot td { background:#fff7e8; font-weight:900; }
.cop-number { text-align:right; font-variant-numeric: tabular-nums; }
.cop-control-col { width:1%; white-space:nowrap; }
.cop-doc-actions { display:flex; gap:6px; justify-content:center; white-space:nowrap; }

.cop-calc-card span { color: var(--cop-muted); font-weight:800; }
.cop-calc-card strong { display:block; color: var(--accent-2); font-size:28px; line-height:1.1; margin-top:4px; }
.cop-calc-card small { display:block; color: var(--cop-muted); margin-top:6px; }

/* Admin builder */
.cop-admin-shell { margin-top: 8px; }
.cop-admin-builder { padding: 18px; border: 1px solid var(--cop-line); border-radius: 22px; background: #fff; }
.cop-builder-actions { margin: 14px 0; }

.cop-admin-tabs { display:flex; gap:8px; flex-wrap:wrap; border-bottom:1px solid var(--cop-line); margin: 16px 0; }
.cop-admin-tabs button { background:#eef2f7; color:var(--cop-ink); box-shadow:none; border-radius:12px 12px 0 0; }
.cop-admin-tabs button.active { background: var(--accent); color:#fff; }

.cop-panel { background:#f8fafc; border:1px solid var(--cop-line); border-radius: 20px; padding: 18px; }
.cop-panel h3 { margin-top:0; }
.cop-admin-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.cop-admin-grid.compact { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cop-admin-grid .wide,
.cop-full-label { grid-column: 1 / -1; }
.cop-full-label { display:block; }
.checkline { display:flex !important; align-items:center; gap:8px; margin-top: 28px; }
.checkline input { width:auto; }
.cop-check-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:10px; }
.cop-check-grid label { display:flex; align-items:center; gap:8px; background:#fff; border:1px solid var(--cop-line); padding:10px; border-radius:12px; }
.cop-check-grid input { width:auto; }

.cop-doc-toolbarline { justify-content:space-between; margin-bottom:16px; }
.cop-doc-toolbarline h3,
.cop-doc-toolbarline p { margin:0; }
.cop-doc-toolbarline p { color: var(--cop-muted); max-width: 780px; }
.cop-add-block { display:flex; gap:8px; align-items:center; }
.cop-add-block select { min-width: 190px; }

.cop-block-card { background:#fff; border:1px solid var(--cop-line); border-radius:18px; padding:14px; margin: 12px 0; }
.cop-block-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:12px; }
.cop-block-type { display:inline-flex; padding:4px 8px; border-radius:999px; background:#eef2f7; color:var(--cop-muted); font-size:11px; text-transform:uppercase; letter-spacing:.04em; font-weight:900; margin-bottom:5px; }
.cop-inline-actions { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
.cop-subtoolbar { justify-content:space-between; background:#f8fafc; border:1px dashed var(--cop-line); padding:10px; border-radius:14px; margin:12px 0 8px; }
.cop-table-builder { display:grid; gap:8px; }
.cop-column-row { display:grid; grid-template-columns: 1fr 1.5fr 1fr 1.5fr auto; gap:8px; align-items:center; }
.cop-empty-state { text-align:center; padding:26px; color:var(--cop-muted); background:#fff; border:1px dashed var(--cop-line); border-radius:18px; }
.cop-empty-state strong { display:block; color: var(--cop-ink); }

.cop-logic-row { display:grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 1.4fr auto; gap:10px; align-items:end; background:#fff; border:1px solid var(--cop-line); border-radius:16px; padding:12px; margin:10px 0; }

.cop-import-card { display:flex; gap:10px; flex-wrap:wrap; background:#fff; border:1px solid var(--cop-line); padding:14px; border-radius:16px; margin: 12px 0; }
.cop-json-textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.cop-raw-json-box { margin-top:16px; background:#fff; border:1px solid var(--cop-line); border-radius:16px; padding:12px; }
.cop-raw-json-box summary { cursor:pointer; font-weight:800; }

.cop-modal-backdrop { position:fixed; inset:0; z-index:100000; background:rgba(15,23,42,.55); display:flex; align-items:center; justify-content:center; padding:20px; }
.cop-modal-backdrop[hidden] { display:none; }
.cop-modal { width:min(820px, 100%); max-height: 88vh; overflow:auto; background:#fff; border-radius:22px; padding:20px; box-shadow:0 24px 80px rgba(0,0,0,.28); }
.cop-modal-head { display:flex; justify-content:space-between; align-items:center; gap:14px; }
.cop-modal-head h3 { margin:0; }
.cop-modal input[type="file"] { margin: 10px 0; }
.cop-modal-actions { justify-content:flex-end; margin-top:12px; }

@media (max-width: 900px) {
  .cop-admin-grid,
  .cop-admin-grid.compact,
  .cop-check-grid,
  .cop-logic-row,
  .cop-column-row { grid-template-columns: 1fr; }
  .cop-builder-hero,
  .cop-block-head,
  .cop-doc-toolbarline { flex-direction:column; align-items:stretch; }
  .cop-add-block { flex-direction:column; align-items:stretch; }
}

@media (max-width: 680px) {
  .cop-scene { padding: 24px 18px; }
  .cop-document-output { padding: 16px; }
  .cop-doc-toolbar { padding: 14px; }
  .cop-form-field, .cop-calc-card, .cop-form-table { padding: 14px; }
}

@media print {
  .cop-doc-toolbar,
  .cop-progress,
  .cop-doc-actions,
  .cop-form-table button { display:none !important; }
  .cop-doc-wrap { box-shadow:none; border:0; }
  .cop-scene { color:#000; background:#fff; border-bottom:1px solid #ddd; }
  .cop-scene h2 { color:#000; }
  .cop-document-output { background:#fff; padding:0; }
  .cop-form-field, .cop-calc-card, .cop-form-table { border:0; padding:0; }
}


/* Visual scene variants */
.cop-scene--split,
.cop-builder-hero--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
}
.cop-scene--split .cop-scene__badge,
.cop-builder-hero--split strong {
  position: relative;
  z-index: 1;
  padding: 16px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.cop-scene--minimal,
.cop-builder-hero--minimal {
  background: #fff;
  color: var(--cop-ink);
  border-bottom: 4px solid var(--accent, #f39321);
  box-shadow: inset 0 0 0 1px var(--cop-line);
}
.cop-scene--minimal::after,
.cop-builder-hero--minimal::after { display:none; }
.cop-scene--minimal .cop-scene__kicker,
.cop-builder-hero--minimal span { color: var(--accent-2, #283380); opacity: 1; }
.cop-scene--minimal .cop-scene__badge,
.cop-builder-hero--minimal strong { color: #fff; background: var(--accent, #f39321); }
.cop-scene--card,
.cop-builder-hero--card {
  margin: 18px;
  border-radius: 24px;
  box-shadow: 0 16px 36px rgba(15,23,42,.18);
}
.cop-scene--ribbon,
.cop-builder-hero--ribbon {
  background: #fff;
  color: var(--cop-ink);
  border-left: 14px solid var(--accent, #f39321);
  box-shadow: inset 0 0 0 1px var(--cop-line);
}
.cop-scene--ribbon::after,
.cop-builder-hero--ribbon::after { display:none; }
.cop-scene--ribbon .cop-scene__kicker,
.cop-builder-hero--ribbon span { color: var(--accent-2, #283380); opacity: 1; }
.cop-scene--ribbon .cop-scene__badge,
.cop-builder-hero--ribbon strong { color: #fff; background: var(--accent-2, #283380); }
@media (max-width: 700px) {
  .cop-scene--split,
  .cop-builder-hero--split { grid-template-columns: 1fr; }
}

/* v4: stable tabs and richer visual controls */
.cop-admin-tabs {
  position: relative;
  align-items: flex-end;
  padding: 0 4px;
}
.cop-admin-tabs button,
.cop-admin-tabs button:focus,
.cop-admin-tabs button:active {
  border: 1px solid var(--cop-line) !important;
  border-bottom: 0 !important;
  outline: none;
}
.cop-admin-tabs button.active,
.cop-admin-tabs button.is-active,
.cop-admin-tabs button[aria-selected="true"] {
  background: var(--accent, #283380) !important;
  color: #fff !important;
  border-color: var(--accent, #283380) !important;
  box-shadow: 0 -1px 0 var(--accent, #283380), 0 8px 18px rgba(29,41,57,.16) !important;
  transform: translateY(1px);
  opacity: 1 !important;
  visibility: visible !important;
}
.cop-tab-content {
  min-height: 180px;
}
.cop-toggle {
  display: flex !important;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--cop-line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 !important;
  font-weight: 800;
}
.cop-toggle input {
  width: auto !important;
  min-width: 18px;
  height: 18px;
  margin: 0;
}
.cop-toggle span {
  line-height: 1.25;
}
.cop-table-visual-box {
  margin: 14px 0;
  padding: 14px;
  border: 1px dashed var(--cop-line);
  border-radius: 18px;
  background: #fbfcfe;
}
.cop-table-visual-box .cop-subtoolbar {
  margin-top: 0;
}

/* Frontend appearance controls */
.cop-width-narrow { max-width: 820px; margin-left: auto; margin-right: auto; }
.cop-width-normal { max-width: 1040px; margin-left: auto; margin-right: auto; }
.cop-width-wide { max-width: 1280px; margin-left: auto; margin-right: auto; }
.cop-width-full { max-width: none; width: 100%; }

.cop-surface-flat { border-color: transparent; box-shadow: none; background: transparent; }
.cop-surface-flat .cop-document-output { background: transparent; }
.cop-surface-soft { background: #f8fafc; }
.cop-surface-glass { background: rgba(255,255,255,.82); backdrop-filter: blur(10px); }

.cop-radius-sharp { border-radius: 0; }
.cop-radius-sharp .cop-form-field,
.cop-radius-sharp .cop-form-table,
.cop-radius-sharp .cop-calc-card,
.cop-radius-sharp .cop-table-scroll,
.cop-radius-sharp button,
.cop-radius-sharp input,
.cop-radius-sharp textarea,
.cop-radius-sharp select { border-radius: 2px; }
.cop-radius-soft { border-radius: 14px; }
.cop-radius-soft .cop-form-field,
.cop-radius-soft .cop-form-table,
.cop-radius-soft .cop-calc-card,
.cop-radius-soft .cop-table-scroll { border-radius: 12px; }
.cop-radius-rounded { border-radius: 24px; }
.cop-radius-pill .cop-form-field,
.cop-radius-pill .cop-form-table,
.cop-radius-pill .cop-calc-card,
.cop-radius-pill .cop-table-scroll { border-radius: 28px; }
.cop-radius-pill button { border-radius: 999px; }

.cop-shadow-none { box-shadow: none; }
.cop-shadow-soft { box-shadow: 0 18px 45px rgba(29,41,57,.12); }
.cop-shadow-strong { box-shadow: 0 28px 80px rgba(15,23,42,.22); }

.cop-density-compact .cop-document-output { padding: 18px; }
.cop-density-compact .cop-block { margin-bottom: 12px; }
.cop-density-compact .cop-form-field,
.cop-density-compact .cop-form-table,
.cop-density-compact .cop-calc-card { padding: 12px; }
.cop-density-compact .cop-doc-toolbar { padding: 12px; }
.cop-density-spacious .cop-document-output { padding: 38px; }
.cop-density-spacious .cop-block { margin-bottom: 26px; }
.cop-density-spacious .cop-form-field,
.cop-density-spacious .cop-form-table,
.cop-density-spacious .cop-calc-card { padding: 26px; }
.cop-density-spacious .cop-doc-toolbar { padding: 24px; }

.cop-font-small { font-size: 14px; }
.cop-font-normal { font-size: 16px; }
.cop-font-large { font-size: 18px; }

.cop-field-filled input,
.cop-field-filled textarea,
.cop-field-filled select { background: #f3f6fb; border-color: transparent; }
.cop-field-underline input,
.cop-field-underline textarea,
.cop-field-underline select {
  border: 0;
  border-bottom: 2px solid #cfd7e4;
  border-radius: 0;
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}
.cop-buttons-pill button { border-radius: 999px; }
.cop-buttons-square button { border-radius: 6px; }
.cop-toolbar-compact .cop-doc-toolbar { gap: 6px; padding: 10px 12px; }
.cop-toolbar-compact .cop-doc-toolbar button { padding: 8px 10px; font-size: 13px; }
.cop-toolbar-floating .cop-doc-toolbar { margin: 14px 18px; border: 1px solid var(--cop-line); border-radius: 18px; box-shadow: 0 10px 24px rgba(29,41,57,.10); }
.cop-scene-size-compact .cop-scene { padding: 22px 26px; }
.cop-scene-size-large .cop-scene { padding: 52px 42px; }
.cop-scene-size-large .cop-scene h2 { font-size: clamp(30px, 4vw, 48px); }

/* Table visual controls */
.cop-form-table.has-rounded .cop-table-scroll { border-radius: 16px; overflow: auto; }
.cop-form-table.no-rounded .cop-table-scroll { border-radius: 0; }
.cop-form-table.no-borders .cop-table-scroll,
.cop-form-table.no-borders table,
.cop-form-table.no-borders th,
.cop-form-table.no-borders td { border-color: transparent !important; }
.cop-form-table.has-zebra tbody tr:nth-child(even) td { background: #fafcff; }
.cop-form-table.cop-table-density-compact th,
.cop-form-table.cop-table-density-compact td { padding: 6px; }
.cop-form-table.cop-table-density-spacious th,
.cop-form-table.cop-table-density-spacious td { padding: 14px 12px; }
.cop-table-header-dark th { background: #50545c; color: #fff; }
.cop-table-header-accent th { background: var(--accent-2, #283380); color: #fff; }
.cop-table-header-light th { background: #eef3fb; color: var(--cop-ink); }
.cop-table-header-minimal th { background: #fff; color: var(--accent-2); border-bottom: 2px solid var(--accent); }
.cop-table-align-left .cop-number,
.cop-table-align-left td.cop-number input { text-align: left; }
.cop-table-align-center .cop-number,
.cop-table-align-center td.cop-number input { text-align: center; }
.cop-table-align-right .cop-number,
.cop-table-align-right td.cop-number input { text-align: right; }
.cop-table-input-filled input,
.cop-table-input-filled textarea,
.cop-table-input-filled select { background: #f3f6fb; border-color: transparent; }
.cop-table-input-underline input,
.cop-table-input-underline textarea,
.cop-table-input-underline select {
  border: 0;
  border-bottom: 1px solid #cfd7e4;
  border-radius: 0;
  background: transparent;
  padding-left: 0;
  padding-right: 0;
}
.cop-table-style-clean { border: 0; background: transparent; padding-left: 0; padding-right: 0; }
.cop-table-style-clean .cop-table-scroll { border-left: 0; border-right: 0; border-radius: 0; }
.cop-table-style-card tbody tr { border-bottom: 8px solid #fff; }
.cop-table-style-card tbody td { background: #f8fafc; border-bottom: 0; }
.cop-table-style-spreadsheet .cop-table-scroll { border-radius: 4px; }
.cop-table-style-spreadsheet table { font-size: 14px; }
.cop-table-style-report tfoot td { background: var(--accent-2); color: #fff; }
.cop-table-controls-icons .cop-doc-actions button,
.cop-table-controls-icons .cop-add-row-btn { min-width: 34px; padding: 7px 10px; }
.cop-table-controls-minimal .cop-doc-actions button,
.cop-table-controls-minimal .cop-add-row-btn { background: transparent; color: var(--accent-2); box-shadow: none; border: 1px solid var(--cop-line); }
.cop-form-table.has-sticky-header thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

@media print {
  .cop-toolbar-floating .cop-doc-toolbar { display:none !important; }
  .cop-form-table.has-zebra tbody tr:nth-child(even) td { background: #fff !important; }
}

/* v7: compact frontend structure editing */
.cop-frontend-structure-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px dashed var(--cop-line);
  border-radius: 12px;
  background: rgba(40, 51, 128, .035);
  font-size: 13px;
}
.cop-frontend-structure-controls--compact {
  border-style: solid;
  background: rgba(255,255,255,.74);
  box-shadow: 0 8px 20px rgba(15,23,42,.04);
}
.cop-structure-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1 1 260px;
}
.cop-structure-title strong {
  display: inline-block;
  max-width: min(520px, 56vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
  color: var(--cop-ink);
}
.cop-structure-badge {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent-2, #283380);
  background: rgba(40,51,128,.08);
  border: 1px solid rgba(40,51,128,.12);
  border-radius: 999px;
  padding: 6px 8px;
}
.cop-structure-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.cop-structure-icon-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 34px;
  height: 32px;
  padding: 6px 9px !important;
  border-radius: 999px !important;
  line-height: 1 !important;
  font-weight: 800 !important;
}
.cop-structure-icon-btn.icon-only {
  width: 32px;
  min-width: 32px;
  padding: 0 !important;
}
.cop-structure-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 15px;
  line-height: 1;
  font-weight: 900;
}
.cop-structure-button-text {
  font-size: 12px;
  line-height: 1;
}
.cop-custom-unit-input {
  margin-top: 6px;
  width: 100%;
}
.cop-column-row.expanded {
  grid-template-columns: minmax(90px, .8fr) minmax(140px, 1fr) 120px minmax(180px, 1fr) 110px 80px auto auto auto auto;
  align-items: start;
}
.cop-column-row.expanded .wide {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .cop-column-row.expanded { grid-template-columns: 1fr; }
  .cop-frontend-structure-controls { align-items: stretch; }
  .cop-structure-title { width: 100%; flex-basis: 100%; }
  .cop-structure-title strong { max-width: calc(100vw - 150px); }
  .cop-structure-actions { justify-content: flex-start; }
}


/* v8: no duplicated editable labels; inline pencil and single-cell custom selects */
.cop-frontend-structure-controls--actions-only {
  justify-content: flex-end;
  padding: 0;
  margin: 0 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.cop-frontend-structure-controls--actions-only .cop-structure-actions {
  margin-left: auto;
}
.cop-editable-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cop-editable-label .cop-structure-icon-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0 !important;
  border-radius: 50% !important;
  font-size: 13px;
  transform: translateY(0);
}
.cop-form-table h3.cop-editable-label {
  margin-bottom: 14px;
}
.cop-form-table input[list] {
  width: 100%;
}

/* v9: budget table mode — original table UX, current visual system */
.cop-budget-block {
  margin-bottom: 0;
}
.cop-budget-panel {
  padding: 0;
  overflow: hidden;
}
.cop-budget-panel .cop-budget-scroll {
  margin: 0;
  border-radius: 16px;
}
.cop-budget-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  background: #fff;
}
.cop-budget-table th {
  background: var(--accent-2, #283380);
  color: #fff;
  font-weight: 900;
  text-align: left;
  padding: 12px 10px;
  white-space: nowrap;
}
.cop-budget-table td {
  border-bottom: 1px solid var(--cop-line);
  border-right: 1px solid var(--cop-line);
  padding: 8px 9px;
  vertical-align: middle;
}
.cop-budget-table tr td:last-child,
.cop-budget-table tr th:last-child {
  border-right: 0;
}
.cop-budget-num {
  width: 54px;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cop-budget-label {
  font-weight: 900;
  color: var(--cop-ink);
}
.cop-budget-label strong {
  display: inline-block;
  margin-right: 8px;
}
.cop-budget-label .cop-structure-icon-btn {
  margin-left: 4px;
  vertical-align: middle;
}
.cop-budget-section-row td {
  background: #fbfcff;
  font-size: 18px;
}
.cop-budget-section-row .cop-budget-total,
.cop-budget-subsection-row .cop-budget-total {
  font-size: 18px;
  color: var(--cop-ink);
}
.cop-budget-subsection-row td {
  background: #fff;
  font-size: 15px;
}
.cop-budget-item-row td {
  background: #fff;
}
.cop-budget-item-row:nth-child(even) td {
  background: #fcfdff;
}
.cop-budget-table input,
.cop-budget-table select {
  min-height: 38px;
  border-radius: 10px;
}
.cop-budget-table input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cop-budget-sum,
.cop-budget-total,
.cop-budget-grand-total,
.cop-budget-grand-label {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cop-budget-add-row td,
.cop-budget-add-table td {
  background: #fff;
  border-bottom: 1px solid var(--cop-line);
}
.cop-budget-add-row .cop-budget-control {
  text-align: right;
  white-space: nowrap;
}
.cop-budget-add-table button,
.cop-budget-final-row button {
  margin: 4px 0;
}
.cop-budget-final-row td {
  background: #99ccff;
  border-color: rgba(40,51,128,.18);
  font-size: 18px;
  font-weight: 900;
}
.cop-budget-grand-label {
  text-align: right;
}
.cop-budget-grand-total {
  color: var(--accent-2, #283380);
}
.cop-plus-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  margin-right: 5px;
  font-size: 16px;
  line-height: 1;
}
.cop-budget-control {
  width: 1%;
  white-space: nowrap;
}
.cop-budget-table .cop-doc-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.cop-budget-table .cop-doc-actions button.secondary {
  background: #eef2f7;
  color: var(--cop-ink);
}
.cop-budget-table .cop-doc-actions button.danger,
.cop-budget-label button.danger {
  background: var(--cop-danger);
  color: #fff;
}
.cop-budget-label .cop-structure-icon-btn.icon-only {
  width: 30px;
  height: 30px;
  min-width: 30px;
}
@media print {
  .cop-budget-table button,
  .cop-budget-control,
  .cop-control-col,
  .cop-budget-table .cop-doc-actions { display: none !important; }
  .cop-budget-panel { border: 0; padding: 0; }
  .cop-budget-panel .cop-budget-scroll { border: 0; }
  .cop-budget-table { min-width: 0; }
}

/* v1.11 budget table fixes */
.cop-budget-unit-cell select,
.cop-budget-unit-cell input.cop-combo-custom {
  width: 100%;
}
.cop-combo-cell {
  display: grid;
  gap: 6px;
}
.cop-combo-custom[hidden] {
  display: none !important;
}
.cop-budget-table-total-row td,
.cop-budget-section-total-row td {
  background: #f8fafc;
  font-weight: 900;
}
.cop-budget-section-total-row td {
  background: #eef3fb;
}
.cop-budget-subtotal-label {
  text-align: right;
  color: var(--cop-ink);
}
.cop-budget-table .cop-doc-actions button.icon-only,
.cop-budget-label .cop-structure-icon-btn.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 10px;
  line-height: 1;
}
.cop-budget-table .cop-doc-actions button.icon-only {
  font-size: 17px;
}
.cop-budget-section-row .cop-budget-control,
.cop-budget-subsection-row .cop-budget-control {
  background: inherit;
}


/* =========================================================
   Denys Sobol Unified Interface Patch
   Scope: visual layer only. Logic, post types, shortcodes and JSON structures are unchanged.
   ========================================================= */
:root {
  --ds-blue: #283380;
  --ds-blue-900: #202965;
  --ds-orange: #f39321;
  --ds-ink: #172033;
  --ds-muted: #667085;
  --ds-line: #d7deea;
  --ds-soft-line: #e7edf6;
  --ds-bg: #f5f7fb;
  --ds-card: #ffffff;
  --ds-success: #16a34a;
  --ds-danger: #dc2626;
  --ds-radius-xs: 8px;
  --ds-radius-sm: 12px;
  --ds-radius-md: 16px;
  --ds-radius-lg: 22px;
  --ds-shadow-sm: 0 6px 18px rgba(23,32,51,.08);
  --ds-shadow-md: 0 18px 45px rgba(23,32,51,.12);
  --ds-focus: 0 0 0 3px rgba(243,147,33,.22);
}

.cop-document-tool,
.cop-assessment,
.cop-admin-shell,
.cop-admin-builder {
  --cop-blue: var(--ds-blue);
  --cop-orange: var(--ds-orange);
  --cop-ink: var(--ds-ink);
  --cop-muted: var(--ds-muted);
  --cop-line: var(--ds-line);
  --cop-bg: var(--ds-bg);
  --cop-card: var(--ds-card);
}

.cop-admin-shell,
.cop-admin-builder,
.cop-doc-wrap,
.cop-assessment-wrap {
  border-radius: var(--ds-radius-lg) !important;
}

.cop-admin-builder,
.cop-json-panel,
.cop-raw-json-box,
.cop-admin-card,
.cop-question-card,
.cop-result-card,
.cop-category-card,
.cop-block,
.cop-budget-shell,
.cop-table-wrap {
  border-color: var(--ds-line) !important;
  box-shadow: none;
}

.cop-admin-field label,
.cop-field-label,
.cop-question-meta,
.cop-scene__kicker,
.cop-builder-hero span {
  color: var(--ds-blue) !important;
  font-weight: 800 !important;
  letter-spacing: .04em;
}

.cop-admin-builder input,
.cop-admin-builder select,
.cop-admin-builder textarea,
.cop-document-tool input,
.cop-document-tool select,
.cop-document-tool textarea,
.cop-assessment input,
.cop-assessment select,
.cop-assessment textarea {
  border: 1px solid var(--ds-line) !important;
  border-radius: var(--ds-radius-sm) !important;
  background: #fff !important;
  color: var(--ds-ink) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7) !important;
}

.cop-admin-builder input:focus,
.cop-admin-builder select:focus,
.cop-admin-builder textarea:focus,
.cop-document-tool input:focus,
.cop-document-tool select:focus,
.cop-document-tool textarea:focus,
.cop-assessment input:focus,
.cop-assessment select:focus,
.cop-assessment textarea:focus {
  border-color: var(--ds-orange) !important;
  box-shadow: var(--ds-focus) !important;
  outline: none !important;
}

.cop-admin-tabs {
  gap: 8px !important;
  border-bottom: 1px solid var(--ds-soft-line) !important;
}

.cop-admin-tabs button,
.cop-admin-actions button,
.cop-doc-toolbar button,
.cop-toolbar button,
.cop-nav button,
.cop-answerstyle-buttons .cop-answer,
.cop-budget-control button,
.cop-budget-add-row button,
.cop-budget-add-table button,
.cop-budget-final-row button {
  border-radius: 999px !important;
  font-weight: 800 !important;
}

.cop-admin-tabs button.is-active,
.cop-admin-tabs button[aria-selected="true"] {
  background: var(--ds-blue) !important;
  color: #fff !important;
  box-shadow: var(--ds-shadow-sm) !important;
}

.cop-admin-actions button,
.cop-doc-toolbar button,
.cop-toolbar button,
.cop-nav button {
  min-height: 38px;
}

.cop-admin-actions button:not(.danger),
.cop-doc-toolbar button:not(.danger),
.cop-toolbar button:not(.danger),
.cop-nav button:not(.danger) {
  background: var(--ds-orange) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.cop-admin-actions button.secondary,
.cop-doc-toolbar button.secondary,
.cop-toolbar button.secondary,
.cop-nav button.secondary {
  background: #eef3fb !important;
  color: var(--ds-ink) !important;
}

.cop-admin-actions button.danger,
.cop-doc-toolbar button.danger,
.cop-toolbar button.danger,
.cop-nav button.danger,
button.danger {
  background: var(--ds-danger) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.cop-doc-table th,
.cop-budget-table th {
  background: var(--ds-blue) !important;
  color: #fff !important;
  font-weight: 900 !important;
}

.cop-budget-table,
.cop-doc-table {
  border-radius: var(--ds-radius-md) !important;
  overflow: hidden;
}

.cop-budget-section-row,
.cop-budget-subsection-row,
.cop-budget-subtotal-row,
.cop-budget-section-total-row,
.cop-budget-final-row {
  background: #f8fafc;
}

.cop-budget-final-row {
  background: #d9ecff !important;
}

.cop-edit-icon,
.cop-icon-button,
.cop-budget-control button,
.cop-structure-actions button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 999px !important;
}

.cop-scene,
.cop-builder-hero {
  border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
}

.cop-json-textarea {
  border-radius: var(--ds-radius-md) !important;
  background: #0f172a !important;
  color: #e5e7eb !important;
}
