:root {
  color: #14213d;
  background:
    radial-gradient(circle at top left, rgba(174, 211, 255, 0.65), transparent 28%),
    linear-gradient(135deg, #f6f2e9 0%, #eef7f6 48%, #e6edf8 100%);
  font-family: "Manrope", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
}

body.auth-required {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

textarea {
  width: 100%;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.designer-shell {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
  position: relative;
  transition: grid-template-columns 180ms ease;
}

.designer-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(174, 211, 255, 0.32), transparent 30%),
    rgba(20, 33, 61, 0.28);
  backdrop-filter: blur(10px);
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(20, 33, 61, 0.2);
  border: 1px solid rgba(20, 33, 61, 0.1);
}

.auth-card h1 {
  margin: 0 0 8px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(18px);
  border-right: 1px solid rgba(20, 33, 61, 0.1);
  transition: transform 180ms ease, opacity 180ms ease, padding 180ms ease;
}

.designer-shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.sidebar-scroll {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-fab {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 14;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(20, 33, 61, 0.16);
}

.designer-shell:not(.sidebar-collapsed) .sidebar-fab {
  display: none;
}

.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header-panel {
  margin-bottom: 0;
  position: relative;
  z-index: 2;
  padding: 14px 16px;
}

.session-strip {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
}

#sidebar-collapse {
  width: auto;
}

#sidebar-sections {
  display: block;
}

.sidebar-footer {
  margin-top: 14px;
  padding-bottom: 8px;
}

.panel,
.preview-toolbar,
.json-panel {
  margin-bottom: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(20, 33, 61, 0.08);
}

.panel h1,
.panel h2,
.json-panel h2 {
  margin: 0 0 8px;
}

.app-header-panel h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  white-space: nowrap;
}

.panel p,
.preview-toolbar p,
.empty-state,
.helper-copy {
  margin: 0;
  color: #4b5a7a;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #dff3ef;
  color: #0f6c5f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-pill.subtle {
  background: #eef3f9;
  color: #4b5a7a;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.session-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(20, 33, 61, 0.04), rgba(15, 108, 95, 0.08));
  border: 1px solid rgba(15, 108, 95, 0.12);
}

label {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

label span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #4b5a7a;
}

input,
select,
textarea,
button,
.secondary-button {
  width: 100%;
  border-radius: 12px;
}

input,
select,
textarea {
  padding: 10px 12px;
  border: 1px solid rgba(20, 33, 61, 0.14);
  background: #fff;
}

button,
.secondary-button {
  border: 0;
  padding: 10px 14px;
  background: #0f6c5f;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.ghost-button {
  width: auto;
  background: #e7eff7;
  color: #14213d;
}

.secondary-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.secondary-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.danger {
  background: #b42318;
  margin-top: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.session-locked {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.15);
}

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.row.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.component-palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.palette-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 10px 8px;
  border-radius: 12px;
  background: linear-gradient(135deg, #14213d 0%, #0f6c5f 100%);
  color: #fff;
  font-weight: 700;
  text-align: center;
  cursor: grab;
  user-select: none;
  box-shadow: 0 10px 20px rgba(20, 33, 61, 0.12);
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.palette-chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 20px;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0.03em;
}

.palette-chip-hint {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.88;
}

.palette-chip-text {
  background: linear-gradient(135deg, #1d3557 0%, #457b9d 100%);
}

.palette-chip-text-value {
  background: linear-gradient(135deg, #1f6f78 0%, #4ecdc4 100%);
}

.palette-chip-copy-label {
  background: linear-gradient(135deg, #5f0f40 0%, #9a031e 100%);
}

.palette-chip-barcode {
  background: linear-gradient(135deg, #3d405b 0%, #20242f 100%);
}

.palette-chip-qr {
  background: linear-gradient(135deg, #264653 0%, #2a9d8f 100%);
}

.palette-chip-image {
  background: linear-gradient(135deg, #6d597a 0%, #b56576 100%);
}

.palette-chip-horizontal-line {
  background: linear-gradient(135deg, #2b2d42 0%, #5c677d 100%);
}

.palette-chip-table {
  background: linear-gradient(135deg, #8c6a00 0%, #c98b00 100%);
}

.palette-chip-page-number {
  background: linear-gradient(135deg, #495057 0%, #6c757d 100%);
}

.palette-chip-absolute-area {
  background: linear-gradient(135deg, #7f5539 0%, #b08968 100%);
}

.layers {
  display: grid;
  gap: 8px;
}

.sidebar-group {
  margin-bottom: 14px;
}

.sidebar-group-card {
  padding: 10px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.44);
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.sidebar-group-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  background: transparent;
  color: #14213d;
  font-weight: 800;
  text-align: left;
}

.sidebar-group-toggle strong,
.sidebar-group-toggle span {
  pointer-events: none;
}

.sidebar-group-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(20, 33, 61, 0.08);
  color: #14213d;
  font-size: 18px;
}

.sidebar-group-body {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.sidebar-group.collapsed .sidebar-group-body {
  display: none;
}

.section-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0;
  margin: 0;
  background: transparent;
  color: #14213d;
}

.section-toggle h2 {
  margin: 0;
  text-align: left;
}

.section-toggle-mark {
  font-size: 18px;
  color: #4b5a7a;
}

.panel-section .section-body {
  margin-top: 12px;
}

.panel-section.collapsed .section-body {
  display: none;
}

.locked-panel {
  opacity: 0.72;
}

.layer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(20, 33, 61, 0.08);
  border-radius: 14px;
  background: #f6f9fb;
  color: #14213d;
}

.layer.active {
  background: #14213d;
  color: #fff;
}

.surface-chip {
  border-left: 4px solid #e85f2b;
}

.component-inspector {
  position: fixed;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(420px, calc(100vw - 48px));
  padding: 18px;
  border-radius: 26px;
  background: rgba(247, 250, 253, 0.98);
  border: 1px solid rgba(20, 33, 61, 0.1);
  box-shadow: 0 26px 70px rgba(20, 33, 61, 0.2);
  overflow: auto;
  z-index: 12;
}

.component-inspector.hidden {
  display: none;
}

.component-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.component-inspector-head h2 {
  margin: 0;
}

.component-inspector .ghost-button {
  width: auto;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  padding: 20px;
  min-height: 0;
  overflow: hidden;
}

.preview-toolbar {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.surface-control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.surface-control-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(247, 250, 253, 0.96), rgba(236, 243, 251, 0.96));
  border: 1px solid rgba(20, 33, 61, 0.08);
  box-shadow: 0 12px 34px rgba(20, 33, 61, 0.08);
}

.surface-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.surface-control-head h2 {
  margin: 0;
  font-size: 15px;
}

.surface-control-card .ghost-button {
  width: auto;
}

.surface-control-card .row.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.component-palette-surface {
  margin-top: 2px;
}

.compact-layers {
  gap: 8px;
}

.zoom-controls {
  display: inline-flex;
  gap: 8px;
}

.zoom-controls button {
  width: auto;
  min-width: 48px;
}

.preview-surface {
  min-height: 0;
  overflow: auto;
  padding: 28px;
  border-radius: 28px;
  background:
    linear-gradient(rgba(20, 33, 61, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 33, 61, 0.05) 1px, transparent 1px),
    #e7eff7;
  background-size: 24px 24px;
}

.page-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100%;
  padding: 12px 0 36px;
}

.page {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 33, 61, 0.18);
  outline: none;
  transform-origin: top center;
}

.page::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(20, 33, 61, 0.14);
  pointer-events: none;
}

.drop-hint {
  position: absolute;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(20, 33, 61, 0.06);
  color: #4b5a7a;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

#absolute-drop-hint {
  top: 10px;
  right: 10px;
}

.page.is-drop-target,
.relative-area.is-drop-target {
  box-shadow: 0 0 0 4px rgba(15, 108, 95, 0.18);
}

.relative-area {
  position: absolute;
  border: 2px dashed rgba(232, 95, 43, 0.8);
  background: rgba(232, 95, 43, 0.06);
}

.relative-area-banner {
  position: absolute;
  top: -14px;
  left: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e85f2b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#relative-drop-hint {
  top: 10px;
  right: 10px;
}

.element {
  position: absolute;
  cursor: move;
  border: 1px dashed rgba(15, 108, 95, 0.35);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.85);
}

.element.selected {
  outline: 3px solid rgba(232, 95, 43, 0.85);
  box-shadow: 0 16px 40px rgba(232, 95, 43, 0.18);
}

.element.relative {
  border-color: rgba(232, 95, 43, 0.45);
}

.text-element,
.code-element,
.image-element,
.line-element,
.table-element,
.box-element {
  width: 100%;
  height: 100%;
}

.text-element {
  white-space: pre-wrap;
}

.code-element {
  display: grid;
  place-items: center;
  padding: 4px;
  text-align: center;
}

.barcode-preview {
  align-content: center;
  justify-items: stretch;
  gap: 4px;
  padding: 4px 6px;
}

.barcode-preview.label-top {
  align-content: start;
}

.barcode-preview.label-bottom {
  align-content: center;
}

.qr-preview {
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 4px 6px;
}

.barcode-bars {
  width: 100%;
  min-height: 18px;
  border-radius: 2px;
}

.barcode-label-preview {
  color: #14213d;
  line-height: 1.05;
}

.qr-grid {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(90deg, #111 20%, transparent 20% 30%, #111 30% 50%, transparent 50% 60%, #111 60%),
    linear-gradient(#111 20%, transparent 20% 30%, #111 30% 50%, transparent 50% 60%, #111 60%);
  background-size: 24px 24px;
  border: 3px solid #111;
}

.image-element {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed rgba(20, 33, 61, 0.28);
  background: linear-gradient(135deg, #eff5fb 0%, #dce7f5 100%);
  color: #4b5a7a;
  text-align: center;
  padding: 10px;
}

.line-element {
  background: #111;
  border-radius: 999px;
}

.line-element.vertical {
  min-width: 100%;
}

.table-element {
  overflow: hidden;
  background: #fff;
}

.table-element table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.table-element th,
.table-element td {
  padding: 4px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-element thead {
  background: #eef4fb;
}

.table-element tbody tr.striped {
  background: #f8fbff;
}

.json-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-columns-panel {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: #f6f9fb;
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.font-import-panel,
.custom-fonts-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.custom-font-chip,
.column-body-panel {
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(20, 33, 61, 0.1);
}

.table-columns-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.table-columns-head .ghost-button {
  width: auto;
}

.table-columns-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.table-column-card {
  padding: 0;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(20, 33, 61, 0.1);
}

.table-column-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px;
  cursor: pointer;
}

.table-column-summary {
  margin-top: 4px;
  color: #4b5a7a;
  font-size: 12px;
  font-weight: 600;
}

.table-column-head button {
  width: auto;
  padding: 8px 12px;
  background: #b42318;
}

.table-column-body {
  padding: 0 12px 12px;
}

.table-column-card.collapsed .table-column-body {
  display: none;
}

.fixed-row-card {
  border-color: rgba(232, 95, 43, 0.18);
  background: linear-gradient(180deg, #fff 0%, #fff8f5 100%);
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.selected-group {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  background: #f7fafd;
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.selected-group-title {
  margin: 0 0 4px;
  color: #14213d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.json-panel pre {
  overflow: auto;
  margin: 12px 0 0;
  max-height: 280px;
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 33, 61, 0.42);
}

.modal-card {
  position: relative;
  margin: 4vh auto;
  width: min(1100px, calc(100vw - 40px));
  max-height: 92vh;
  overflow: auto;
  padding: 20px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 33, 61, 0.2);
}

.bucket-modal-card {
  background:
    radial-gradient(circle at top left, rgba(174, 211, 255, 0.18), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.modal-section {
  padding: 16px;
  border-radius: 16px;
  background: rgba(248, 251, 255, 0.96);
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.modal-section h3 {
  margin: 0 0 12px;
}

#processing-function-editor {
  font-family: "Courier New", monospace;
  min-height: 320px;
}

.bucket-browser {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: 420px;
  overflow: auto;
}

.bucket-browser-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.bucket-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bucket-breadcrumb {
  width: auto;
  padding: 8px 10px;
  border-radius: 999px;
  background: #eef3f9;
  color: #14213d;
  font-size: 12px;
  font-weight: 700;
}

.bucket-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(20, 33, 61, 0.1);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.bucket-entry:hover {
  border-color: rgba(15, 108, 95, 0.25);
  box-shadow: 0 10px 30px rgba(20, 33, 61, 0.08);
  transform: translateY(-1px);
}

.bucket-entry.selected {
  border-color: rgba(15, 108, 95, 0.42);
  box-shadow: 0 0 0 3px rgba(15, 108, 95, 0.12);
}

.bucket-entry-copy {
  display: grid;
  gap: 4px;
}

.bucket-entry-kind {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f9;
  color: #4b5a7a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bucket-entry strong,
.bucket-entry span {
  display: block;
}

.bucket-entry button {
  width: auto;
  white-space: nowrap;
}

.bucket-selected-file-card,
.bucket-empty-state {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 108, 95, 0.08), rgba(174, 211, 255, 0.14));
  border: 1px solid rgba(15, 108, 95, 0.12);
}

.bucket-selected-label {
  display: inline-block;
  margin-bottom: 6px;
  color: #4b5a7a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.readonly-message {
  color: #b54708;
}

@media (max-width: 980px) {
  .modal-grid {
    grid-template-columns: 1fr;
  }

  .surface-control-grid {
    grid-template-columns: 1fr;
  }
}

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

  .designer-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  body {
    overflow: auto;
  }

  .sidebar,
  .workspace {
    min-height: auto;
  }

  .sidebar-scroll,
  .preview-surface {
    overflow: visible;
  }

  .preview-toolbar {
    position: static;
  }

  .surface-control-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .component-inspector {
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(420px, calc(100vw - 24px));
  }

  .sidebar-fab {
    position: fixed;
  }
}
