:root {
  --bg: #0f1419;
  --panel: #161d26;
  --panel-2: #1c2633;
  --line: #2a3645;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #d4a017;
  --accent-2: #f0c14b;
  --danger: #e35d6a;
  --safe: rgba(212, 160, 23, 0.18);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font-ui: "DM Sans", "Space Grotesk", sans-serif;
  --mm: 3.7795275591px;
  --a4-w: calc(210 * var(--mm));
  --a4-h: calc(297 * var(--mm));
  --header-h: 64px;
}

.pdf-busy {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: grid;
  place-items: center;
  background: rgba(6, 10, 16, 0.72);
  backdrop-filter: blur(3px);
}

.pdf-busy[hidden] {
  display: none !important;
}

.pdf-busy-card {
  width: min(320px, 90vw);
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a2432 0%, #121a24 100%);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.pdf-busy-card p {
  margin: 0 0 14px;
  font-weight: 600;
  font-size: 0.95rem;
}

.pdf-busy-bar {
  height: 6px;
  border-radius: 999px;
  background: #243041;
  overflow: hidden;
}

.pdf-busy-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pin-gate {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(212, 160, 23, 0.18), transparent 50%),
    linear-gradient(160deg, #0c1219 0%, #15202c 55%, #0a0f14 100%);
}

body:not(.pin-locked) .pin-gate {
  display: none !important;
}

body.pin-locked .app {
  visibility: hidden;
  pointer-events: none;
}

.pin-card {
  width: min(360px, 100%);
  padding: 28px 24px 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a2432 0%, #121a24 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.pin-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pin-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pin-field {
  display: block;
  margin-bottom: 12px;
}

.pin-field input {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f1620;
  color: var(--text);
  font-size: 1.35rem;
  letter-spacing: 0.35em;
  text-align: center;
  outline: none;
}

.pin-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.18);
}

.pin-error {
  margin: 0 0 12px;
  color: #ffb3bb;
  font-size: 0.85rem;
  font-weight: 600;
}

.pin-submit {
  width: 100%;
  height: 44px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

button, input, select {
  font: inherit;
  color: inherit;
}

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #18202b 0%, #121820 100%);
  border-right: 1px solid var(--line);
}

.panel-header {
  flex-shrink: 0;
  height: var(--header-h);
  min-height: var(--header-h);
  max-height: var(--header-h);
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  background:
    linear-gradient(135deg, var(--accent) 0%, #8a6a0a 100%),
    repeating-linear-gradient(90deg, transparent, transparent 6px, rgba(0,0,0,.15) 6px, rgba(0,0,0,.15) 7px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15);
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.notes-btn {
  flex-shrink: 0;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #243041;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}

.notes-btn:hover {
  border-color: var(--accent);
  background: #2c3a4d;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.project-current {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
}

.project-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}

.project-actions .btn {
  margin-top: 0;
}

.projects-page {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at top, rgba(212, 160, 23, 0.08), transparent 45%),
    linear-gradient(180deg, #10161e 0%, #0b1016 100%);
}

.projects-page[hidden] {
  display: none !important;
}

.projects-page-bar {
  flex-shrink: 0;
  min-height: var(--header-h);
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(16, 22, 30, 0.92);
}

.projects-page-bar h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.projects-page-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.projects-page-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.projects-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(22, 29, 38, 0.86);
}

.projects-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.projects-table th,
.projects-table td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.projects-table th {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #18202b;
}

.projects-table tbody tr:last-child td {
  border-bottom: 0;
}

.projects-table tbody tr:hover {
  background: rgba(212, 160, 23, 0.06);
}

.projects-table tbody tr.is-active {
  background: rgba(212, 160, 23, 0.12);
}

.projects-name {
  font-weight: 700;
  color: var(--text);
}

.projects-meta {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.projects-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn.btn-sm {
  width: auto;
  margin-top: 0;
  padding: 7px 10px;
  font-size: 0.76rem;
}

.projects-empty {
  margin: 28px auto 0;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.panel-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 16px 20px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.panel-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.section {
  padding: 16px 0;
  border-bottom: 1px solid rgba(42, 54, 69, 0.8);
}

.section h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.hint-nowrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
}

.size-grid,
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.size-btn,
.tool-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  text-align: left;
}

.tool-btn {
  align-items: center;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.tool-btn svg {
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  opacity: 0.9;
}

.size-btn strong {
  font-size: 0.95rem;
}

.size-btn span {
  color: var(--muted);
  font-size: 0.75rem;
}

.size-btn:hover,
.orient-btn:hover,
.tool-btn:hover,
.size-btn.active,
.orient-btn.active {
  border-color: var(--accent);
  background: #243041;
}

.size-btn.active,
.orient-btn.active {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.size-btn.custom-size-btn {
  grid-column: 1 / -1;
}

.custom-size-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.custom-size-row[hidden] {
  display: none;
}

.custom-size-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.custom-size-row input {
  width: 100%;
  padding: 9px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f151d;
  color: var(--text);
  outline: none;
}

.custom-size-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.18);
}

.custom-size-modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 12px;
}

.custom-size-modal-row .field input {
  height: 48px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.custom-size-error {
  margin: 0 0 12px;
  color: #ffb3bb;
  font-size: 0.82rem;
  font-weight: 600;
}

.orient-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
}

.orient-btn strong {
  font-size: 0.95rem;
}

.orient-btn span {
  color: var(--muted);
  font-size: 0.75rem;
}

.margin-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.margin-row label,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 0;
}

.margin-row input,
.field input {
  width: 100%;
  padding: 9px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0f151d;
  outline: none;
}

  .field input[readonly] {
    opacity: 0.85;
    cursor: default;
    color: var(--accent-2);
    border-color: rgba(212, 160, 23, 0.35);
  }

/* Custom dropdown */
.field select,
select.ui-select-source {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.ui-select {
  position: relative;
  width: 100%;
}

.ui-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #182231 0%, #101820 100%);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}

.ui-select-trigger:hover,
.ui-select.open .ui-select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(212, 160, 23, 0.25);
}

.ui-select-trigger .chev {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
  flex-shrink: 0;
  transition: transform .15s;
}

.ui-select.open .ui-select-trigger .chev {
  transform: rotate(225deg);
  margin-top: 2px;
  border-color: var(--accent);
}

.ui-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  display: none;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #15202c;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  scrollbar-width: none;
}

.ui-select-menu::-webkit-scrollbar {
  display: none;
}

.ui-select.open .ui-select-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ui-select-option {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
}

.ui-select-option:hover {
  background: #243041;
}

.ui-select-option.active {
  background: rgba(212, 160, 23, 0.16);
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(212, 160, 23, 0.35);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  padding: 9px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #121922;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
}

.tab.active {
  color: var(--text);
  border-color: var(--accent);
  background: #243041;
}

.btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #1a1405;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.danger {
  background: rgba(227, 93, 106, 0.12);
  border-color: rgba(227, 93, 106, 0.45);
  color: #ffb3bb;
}

.btn.danger.is-active {
  background: rgba(227, 93, 106, 0.28);
  border-color: #e07068;
  color: #ffe3e0;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 160px;
  overflow: auto;
}

.layer-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #121922;
  font-size: 0.8rem;
  cursor: pointer;
}

.layer-list li.active {
  border-color: var(--accent);
  background: #243041;
}

.panel-footer {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.7);
}

.panel-footer .btn {
  margin-top: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(212, 160, 23, 0.08), transparent 45%),
    linear-gradient(180deg, #10161e 0%, #0b1016 100%);
}

.workspace-bar {
  flex-shrink: 0;
  height: var(--header-h);
  min-height: var(--header-h);
  max-height: var(--header-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}

.status {
  font-size: 0.9rem;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.reset-btn {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #243041;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent-2);
}

.preview-btn {
  background: rgba(212, 160, 23, 0.14);
  border-color: rgba(212, 160, 23, 0.45);
}

.preview-btn:hover {
  background: rgba(212, 160, 23, 0.22);
}

.preview-btn.is-active {
  background: rgba(212, 160, 23, 0.28);
  border-color: var(--accent);
  color: var(--accent-2);
}

.delete-btn {
  background: rgba(220, 80, 70, 0.14);
  border-color: rgba(220, 80, 70, 0.45);
  color: #f0b4ae;
}

.delete-btn:hover {
  background: rgba(220, 80, 70, 0.24);
  border-color: rgba(220, 80, 70, 0.7);
  color: #ffd0cb;
}

.delete-btn.is-active {
  background: rgba(220, 80, 70, 0.32);
  border-color: #e07068;
  color: #ffe3e0;
}

.sheet-select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.sheet-select-bar[hidden] {
  display: none !important;
}

body.is-sheet-picking .a4-page-label {
  pointer-events: auto;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  top: -22px;
  background: rgba(36, 48, 65, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

body.is-sheet-picking .a4-page-label:hover {
  border-color: rgba(220, 80, 70, 0.65);
  color: #ffd0cb;
}

body.is-sheet-picking .a4-page-label.is-selected {
  background: rgba(220, 80, 70, 0.28);
  border-color: #e07068;
  color: #ffe3e0;
}

body.is-sheet-picking .sheet-cell {
  cursor: pointer;
  transition: outline-color .12s ease, box-shadow .12s ease;
}

body.is-sheet-picking .sheet-cell:hover {
  outline: 1.5px solid rgba(220, 80, 70, 0.55);
  outline-offset: -1px;
}

body.is-sheet-picking .sheet-cell.is-selected {
  outline: 2px solid #e07068;
  outline-offset: -1px;
  box-shadow: inset 0 0 0 999px rgba(220, 80, 70, 0.12);
}

body.is-previewing .safe-area {
  opacity: 0 !important;
  pointer-events: none !important;
}

body.is-previewing .handle {
  display: none !important;
}

body.is-previewing .element.selected {
  outline: none !important;
}

body.is-previewing .element {
  outline: none !important;
  cursor: default !important;
  pointer-events: none !important;
}

body.is-previewing .metal-piece {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14);
}

body.is-previewing .a4-page-label {
  opacity: 0.55;
}

body.is-previewing .sheet-cell {
  outline: none !important;
  box-shadow: none !important;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #161d26;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
}

.zoom-controls button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #243041;
  cursor: pointer;
  font-size: 1.1rem;
}

#zoomLabel {
  min-width: 52px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.canvas-wrap {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 16px 24px;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.canvas-wrap::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.a4-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: max-content;
}

.a4-stage {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
  margin-top: 8px;
}

.a4-sheet {
  width: var(--a4-w);
  height: var(--a4-h);
  background:
    linear-gradient(180deg, #ffffff 0%, #f7f7f5 100%);
  color: #111;
  box-shadow: var(--shadow);
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  overflow: hidden;
}

.a4-page-label {
  position: absolute;
  left: 0;
  top: -16px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
}

.design-stage {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  padding: 4mm;
  background:
    radial-gradient(circle at 20% 15%, rgba(0,0,0,.03), transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 19px, rgba(0,0,0,.035) 19px, rgba(0,0,0,.035) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, rgba(0,0,0,.035) 19px, rgba(0,0,0,.035) 20px);
}

.design-stage[hidden],
.sheet-grid[hidden] {
  display: none !important;
}

.metal-piece {
  position: relative;
  margin: 0;
  background: #fff;
  border: 1px dashed #b8c0cc;
  box-shadow: 0 10px 28px rgba(0,0,0,.08);
  overflow: hidden;
  touch-action: none;
}

.safe-area {
  position: absolute;
  border: 1px dashed rgba(212, 160, 23, 0.7);
  background: var(--safe);
  pointer-events: none;
  z-index: 1;
}

.element {
  position: absolute;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: grab;
  outline: 1px solid transparent;
  pointer-events: auto;
  overflow: visible;
}

.element[data-type="logo"] .element-clip {
  background: transparent !important;
  overflow: visible !important;
}

.element[data-type="logo"] img {
  object-fit: contain !important;
  object-position: center;
  background: transparent !important;
  image-rendering: auto;
  width: 100% !important;
  height: 100% !important;
}

.element[data-type="qr"] img {
  object-fit: contain !important;
  object-position: center;
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
}

.element-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
}

.element:active {
  cursor: grabbing;
}

.element.selected {
  outline: 1.5px solid #d4a017;
  outline-offset: 1px;
  z-index: 5;
}

.metal-piece.has-multi .element.selected .handle {
  display: none;
}

.group-bounds {
  position: absolute;
  z-index: 8;
  box-sizing: border-box;
  border: 1.5px dashed #d4a017;
  pointer-events: none;
}

.group-bounds .handle {
  display: block;
  pointer-events: auto;
}

.marquee-select {
  position: absolute;
  z-index: 9;
  border: 1px solid rgba(212, 160, 23, 0.95);
  background: rgba(212, 160, 23, 0.15);
  pointer-events: none;
  box-sizing: border-box;
}

.element-clip img,
.element-clip .social-row,
.element-clip .text-node {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  background: transparent;
}

.element .text-node {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  line-height: 1;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

.element .social-row {
  display: flex;
  align-items: center;
  gap: 0.35em;
  justify-content: center;
  overflow: hidden;
  max-width: 100%;
  max-height: 100%;
}

.element .social-row svg {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}

.element .social-row svg.brand-icon {
  overflow: visible;
}

.element .social-row span {
  line-height: 1;
  white-space: nowrap;
}

.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #d4a017;
  border: 1.5px solid #fff;
  border-radius: 2px;
  z-index: 6;
  display: none;
}

.element.selected .handle {
  display: block;
}

.handle.nw { left: -5px; top: -5px; cursor: nwse-resize; }
.handle.ne { right: -5px; top: -5px; cursor: nesw-resize; }
.handle.sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.handle.se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.handle.n { left: 50%; top: -5px; transform: translateX(-50%); cursor: ns-resize; }
.handle.s { left: 50%; bottom: -5px; transform: translateX(-50%); cursor: ns-resize; }
.handle.e { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.handle.w { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.sheet-grid {
  width: 100%;
  height: 100%;
  padding: 4mm;
  display: grid;
  grid-auto-flow: row;
  gap: 1.5mm;
  align-content: start;
  justify-content: start;
  justify-items: start;
  align-items: start;
  background: #fff;
}

.sheet-cell {
  position: relative;
  border: 0.35mm solid #111;
  overflow: hidden;
  background: #fff;
  page-break-inside: avoid;
  box-sizing: border-box;
}

body.is-printing .a4-stage {
  width: var(--a4-w) !important;
  height: var(--a4-h) !important;
}

body.is-printing .a4-sheet {
  transform: none !important;
  -webkit-transform: none !important;
}

.sheet-cell .clone-root {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.sheet-cell .clone-root-bg {
  background-color: #fff;
}

.a4-stage.extra-page {
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

.sheet-cell .clone-root .text-node,
.sheet-cell .clone-root .social-row {
  font-size: inherit;
}

.sheet-cell .clone-root .element {
  outline: none !important;
}

.sheet-cell .clone-root .handle,
.sheet-cell .clone-root .safe-area {
  display: none !important;
}

.sheet-number {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  line-height: 1;
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 10, 16, 0.62);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-overlay[hidden] {
  display: grid !important;
  pointer-events: none;
}

.modal-overlay.open[hidden] {
  pointer-events: auto;
}

.modal-card {
  width: min(460px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a2432 0%, #121a24 100%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(18px) scale(0.94);
  opacity: 0;
  transition: transform .32s cubic-bezier(.2, .9, .2, 1), opacity .28s ease;
}

.modal-overlay.open .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #243041;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--accent);
}

.modal-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-block {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 21, 29, 0.7);
}

.info-block strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-2);
  font-size: 0.86rem;
}

.info-block p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.info-block.accent {
  border-color: rgba(212, 160, 23, 0.45);
  background: rgba(212, 160, 23, 0.1);
}

.info-block.accent p {
  color: var(--text);
}

.modal-card-sm {
  width: min(380px, 100%);
}

.confirm-message {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.confirm-actions .btn {
  min-width: 96px;
}

.confirm-actions.pdf-export-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.confirm-actions.pdf-export-actions .btn {
  width: 100%;
  justify-content: center;
}

.btn.danger-solid {
  background: #c43c4e;
  border-color: #c43c4e;
  color: #fff;
}

.btn.danger-solid:hover {
  background: #a83242;
}

.logo-modal-hint {
  margin: 0;
}

.logo-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.logo-pick-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 21, 29, 0.7);
  cursor: pointer;
  text-align: left;
  color: inherit;
  transition: border-color .15s, transform .15s, background .15s;
}

.logo-pick-card:hover {
  border-color: var(--accent);
  background: rgba(212, 160, 23, 0.08);
  transform: translateY(-1px);
}

.logo-pick-thumb {
  display: grid;
  place-items: center;
  height: 72px;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #d8dde6 25%, transparent 25%) 0 0 / 12px 12px,
    linear-gradient(-45deg, #d8dde6 25%, transparent 25%) 0 6px / 12px 12px,
    linear-gradient(45deg, transparent 75%, #d8dde6 75%) 6px -6px / 12px 12px,
    linear-gradient(-45deg, transparent 75%, #d8dde6 75%) -6px 0 / 12px 12px,
    #f4f6f9;
  overflow: hidden;
}

.logo-pick-thumb img {
  max-width: 92%;
  max-height: 58px;
  object-fit: contain;
  display: block;
}

.logo-pick-card strong {
  font-size: 0.86rem;
  font-weight: 700;
}

.logo-pick-card span {
  font-size: 0.75rem;
  color: var(--muted);
}

.logo-upload-btn {
  width: 100%;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 168px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #1a2330;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.context-menu[hidden] {
  display: none !important;
}

.context-menu .logo-only[hidden],
.context-menu .qr-only[hidden],
.context-menu .single-only[hidden],
.context-menu .multi-only[hidden] {
  display: none !important;
}

.context-menu button {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}

.context-menu button:hover {
  background: #2a3645;
}

.context-menu button.danger {
  color: #ffb3bb;
}

.context-menu button.danger:hover {
  background: rgba(227, 93, 106, 0.18);
}

.context-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 45vh 1fr;
  }

  .panel {
    height: 100%;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media print {
  html,
  body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body.is-printing .a4-stage,
  .a4-stage {
    width: var(--a4-w) !important;
    height: var(--a4-h) !important;
    min-width: var(--a4-w) !important;
    min-height: var(--a4-h) !important;
    content-visibility: visible !important;
  }

  body.is-printing .a4-sheet,
  .a4-sheet {
    transform: none !important;
    -webkit-transform: none !important;
  }

  .panel,
  .workspace-bar,
  .group-bounds,
  .context-menu,
  .modal-overlay,
  .projects-page {
    display: none !important;
  }

  .app {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    grid-template-columns: none !important;
  }

  .workspace,
  .canvas-wrap {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    position: static !important;
  }

  .a4-stack {
    display: block !important;
    gap: 0 !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
  }

  @page {
    margin: 0;
  }

  .a4-stage {
    position: relative !important;
    display: block !important;
    width: var(--a4-w) !important;
    height: var(--a4-h) !important;
    min-width: var(--a4-w) !important;
    min-height: var(--a4-h) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .a4-stage:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .a4-page-label {
    display: none !important;
  }

  .a4-sheet {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: var(--a4-w) !important;
    height: var(--a4-h) !important;
    margin: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    -webkit-transform: none !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  .design-stage {
    background: #fff !important;
  }

  .metal-piece {
    border: none !important;
    box-shadow: none !important;
  }

  /* Kesim çizgileri — PDF’de net siyah */
  .sheet-cell {
    border: 0.4mm solid #000000 !important;
    outline: none !important;
    box-shadow: none !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sheet-grid {
    background: #fff !important;
  }

  .safe-area,
  .handle,
  .element.selected {
    outline: none !important;
    border-color: transparent !important;
    background: transparent !important;
  }

  body.is-sheet-picking .sheet-cell.is-selected,
  body.is-sheet-picking .sheet-cell:hover,
  body.is-previewing .sheet-cell {
    outline: none !important;
    box-shadow: none !important;
    border: 0.4mm solid #000000 !important;
  }
}
