:root {
  --studio-ink: #18212f;
  --studio-muted: #667085;
  --studio-line: #d9dee7;
  --studio-soft: #f5f7fa;
  --studio-brand: #087f73;
  --studio-danger: #b42318;
}

.print-designer-page .app-wrapper {
  align-items: stretch;
}

.print-designer-page .app-content {
  min-width: 0;
  padding: 0;
}

.print-studio {
  min-height: calc(100vh - 58px);
  background: #eef1f5;
  color: var(--studio-ink);
  direction: rtl;
}

body.showcase-page .print-studio {
  min-height: calc(100vh - 104px);
}

body.showcase-page .studio-workspace {
  height: calc(100vh - 248px);
}

@media (min-width: 1025px) {
  .print-designer-page .erp-side-panel,
  .print-designer-page .inv-sidebar {
    height: calc(100vh - 58px);
    min-height: calc(100vh - 58px);
  }

  body.showcase-page.print-designer-page .erp-side-panel,
  body.showcase-page.print-designer-page .inv-sidebar {
    height: calc(100vh - 104px);
    min-height: calc(100vh - 104px);
  }
}

.studio-toolbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--studio-line);
}

.studio-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.studio-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  background: #e6f4f2;
  color: var(--studio-brand);
  font-size: 21px;
}

.studio-heading h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.studio-heading p {
  margin: 3px 0 0;
  color: var(--studio-muted);
  font-size: 12px;
}

.studio-doc-switch {
  display: flex;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--studio-line);
  border-radius: 7px;
  background: var(--studio-soft);
}

.studio-doc-switch button {
  min-width: 132px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--studio-muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.studio-doc-switch button i {
  margin-left: 6px;
}

.studio-doc-switch button.active {
  background: #fff;
  color: var(--studio-ink);
  box-shadow: 0 1px 4px rgba(16, 24, 40, .12);
}

.studio-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
}

.icon-button,
.save-button {
  height: 38px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  background: #fff;
  color: var(--studio-ink);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  display: inline-grid;
  place-items: center;
  font-size: 16px;
}

.icon-button:hover {
  border-color: #98a2b3;
  background: var(--studio-soft);
}

.icon-button.danger {
  color: var(--studio-danger);
}

.save-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  border-color: var(--studio-brand);
  background: var(--studio-brand);
  color: #fff;
  font: inherit;
  font-weight: 800;
}

.template-bar {
  min-height: 68px;
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--studio-line);
}

.template-bar label:not(.switch-field) {
  width: 260px;
}

.template-bar .template-name-field {
  flex: 1;
  max-width: 420px;
}

.template-bar label > span:first-child,
.control-group label > span:first-child {
  display: block;
  margin-bottom: 5px;
  color: var(--studio-muted);
  font-size: 11px;
  font-weight: 700;
}

.studio-workspace {
  height: calc(100vh - 202px);
  min-height: 590px;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  direction: rtl;
}

.studio-inspector {
  min-width: 0;
  background: #fff;
  border-left: 1px solid var(--studio-line);
  overflow: hidden;
}

.inspector-tabs {
  height: 58px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--studio-line);
}

.inspector-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: #fff;
  color: var(--studio-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.inspector-tabs button i {
  display: block;
  margin-bottom: 3px;
  font-size: 16px;
}

.inspector-tabs button.active {
  border-bottom-color: var(--studio-brand);
  color: var(--studio-brand);
  font-weight: 800;
}

.inspector-scroll {
  height: calc(100% - 58px);
  overflow: auto;
}

.inspector-panel {
  display: none;
  padding: 16px;
}

.inspector-panel.active {
  display: block;
}

.control-group {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--studio-line);
}

.control-group:last-child {
  border-bottom: 0;
}

.control-group h2,
.panel-intro h2 {
  margin: 0 0 13px;
  font-size: 14px;
  letter-spacing: 0;
}

.control-group label {
  display: block;
  margin-top: 13px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-grid label {
  margin-top: 0;
}

.control-grid label:nth-child(n+3) {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.control-group input[type="range"],
.preview-controls input[type="range"] {
  width: 100%;
  accent-color: var(--studio-brand);
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 13px;
}

.color-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 7px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
}

.color-grid input {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

.color-grid span {
  margin: 0 !important;
  color: var(--studio-ink) !important;
  font-size: 11px !important;
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  cursor: pointer;
}

.switch-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: #cfd5df;
  transition: .2s;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .25);
  transition: .2s;
}

.switch-field input:checked + .switch-ui {
  background: var(--studio-brand);
}

.switch-field input:checked + .switch-ui::after {
  transform: translateX(-16px);
}

.switch-field.compact {
  margin-top: 14px;
}

.panel-intro {
  margin-bottom: 14px;
}

.panel-intro p {
  margin: 0;
  color: var(--studio-muted);
  font-size: 11px;
  line-height: 1.6;
}

.sortable-list {
  display: grid;
  gap: 8px;
}

.sort-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px 9px;
  border: 1px solid var(--studio-line);
  border-radius: 6px;
  background: #fff;
}

.sort-row.dragging {
  opacity: .45;
  border-color: var(--studio-brand);
}

.drag-handle {
  color: #98a2b3;
  cursor: grab;
  text-align: center;
}

.sort-row strong {
  font-size: 12px;
}

.column-editor {
  min-width: 0;
}

.column-editor input {
  height: 31px;
  padding: 4px 7px;
  font-size: 11px;
}

.column-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 6px;
}

.column-width {
  text-align: center;
}

.symbol-note {
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 1px solid #b7ded9;
  border-radius: 6px;
  background: #eff9f7;
  color: #16675f;
}

.symbol-note i {
  font-size: 19px;
}

.symbol-note p {
  margin: 0;
  font-size: 11px;
  line-height: 1.65;
}

.preview-stage {
  min-width: 0;
  display: grid;
  grid-template-rows: 50px minmax(0, 1fr);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 16px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--studio-line);
}

.preview-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-toolbar span {
  color: var(--studio-muted);
  font-size: 11px;
}

.preview-controls input {
  width: 130px;
}

.preview-viewport {
  overflow: auto;
  padding: 28px;
  direction: ltr;
}

.document-preview {
  --preview-scale: .7;
  --doc-primary: #0f766e;
  --doc-ink: #111827;
  --doc-muted: #6b7280;
  --doc-line: #d1d5db;
  --doc-soft: #f3f4f6;
  width: 794px;
  min-height: 1123px;
  padding: 48px;
  margin: 0 auto;
  direction: rtl;
  background: #fff;
  color: var(--doc-ink);
  box-shadow: 0 10px 35px rgba(16, 24, 40, .16);
  transform: scale(var(--preview-scale));
  transform-origin: top center;
  font-family: Tahoma, Arial, sans-serif;
  font-size: 12px;
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 16px;
  border-bottom: 3px solid var(--doc-ink);
}

.preview-header.center {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.preview-company {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-header.center .preview-company {
  flex-direction: column;
}

.preview-logo {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  border: 1px solid var(--doc-line);
  border-radius: 6px;
  background: var(--doc-soft);
  color: var(--doc-primary);
  font-size: 20px;
  font-weight: 900;
}

.preview-company h3,
.preview-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.preview-company h3 {
  font-size: 21px;
}

.preview-company p,
.preview-title p {
  margin: 4px 0 0;
  color: var(--doc-muted);
}

.preview-title {
  text-align: left;
}

.preview-header.center .preview-title {
  text-align: center;
}

.preview-title h2 {
  font-size: 27px;
}

.preview-symbol {
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-symbol img {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.preview-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.preview-meta div,
.preview-party-grid div {
  padding: 9px;
  border: 1px solid var(--doc-line);
  border-radius: 5px;
}

.preview-meta span,
.preview-party-grid span {
  display: block;
  color: var(--doc-muted);
  font-size: .85em;
}

.preview-panel {
  margin: 14px 0;
  border: 1px solid var(--doc-line);
  border-radius: 6px;
  overflow: hidden;
}

.preview-panel-title {
  padding: 8px 10px;
  background: var(--doc-soft);
  font-weight: 800;
}

.preview-party-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
}

.preview-table {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  table-layout: fixed;
}

.preview-table th {
  background: var(--doc-ink);
  color: #fff;
  white-space: normal;
}

.preview-table th,
.preview-table td {
  padding: 6px;
  border: 1px solid var(--doc-line);
  overflow-wrap: anywhere;
}

.preview-table.striped tbody tr:nth-child(even) td {
  background: #fafafa;
}

.preview-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
  margin-top: 16px;
}

.preview-notes,
.preview-totals {
  border: 1px solid var(--doc-line);
  border-radius: 6px;
  overflow: hidden;
}

.preview-notes p {
  min-height: 66px;
  margin: 0;
  padding: 10px;
  color: var(--doc-muted);
}

.preview-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--doc-line);
}

.preview-total:last-child {
  border: 0;
  background: var(--doc-primary);
  color: #fff;
  font-weight: 800;
}

.preview-signatures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 34px;
}

.preview-signatures div {
  min-height: 55px;
  padding-top: 7px;
  border-top: 1px solid var(--doc-ink);
  text-align: center;
  color: var(--doc-muted);
}

.preview-footer {
  margin-top: 18px;
  color: var(--doc-muted);
  text-align: center;
  white-space: pre-line;
}

.studio-toast {
  position: fixed;
  z-index: 1200;
  left: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 11px 16px;
  border-radius: 6px;
  background: #18212f;
  color: #fff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .24);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .2s;
}

.studio-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.studio-toast.error {
  background: var(--studio-danger);
}

@media (max-width: 1180px) {
  .studio-toolbar {
    grid-template-columns: 1fr auto;
  }

  .studio-doc-switch {
    order: 3;
    grid-column: 1 / -1;
    justify-self: center;
  }

  .studio-workspace {
    height: calc(100vh - 246px);
    grid-template-columns: 340px minmax(0, 1fr);
  }

  body.showcase-page .studio-workspace {
    height: calc(100vh - 292px);
  }
}

@media (max-width: 820px) {
  .studio-toolbar {
    grid-template-columns: 1fr;
  }

  .studio-actions {
    justify-content: stretch;
  }

  .save-button {
    flex: 1;
    justify-content: center;
  }

  .studio-doc-switch {
    width: 100%;
    grid-column: auto;
  }

  .studio-doc-switch button {
    min-width: 0;
    flex: 1;
  }

  .template-bar {
    flex-wrap: wrap;
  }

  .template-bar label:not(.switch-field),
  .template-bar .template-name-field {
    width: calc(50% - 7px);
    max-width: none;
    flex: none;
  }

  .studio-workspace {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .studio-inspector {
    height: 620px;
    border-left: 0;
    border-bottom: 1px solid var(--studio-line);
  }

  .preview-stage {
    height: 720px;
  }
}
