*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg-1: #020617;
  --bg-2: #071a31;
  --bg-3: #0f172a;
  --ink: #e4f2ff;
  --muted: #9bb8ce;
  --line: rgba(149, 206, 255, 0.32);
  --line-strong: rgba(104, 230, 237, 0.72);
  --panel-a: rgba(9, 29, 52, 0.88);
  --panel-b: rgba(7, 18, 34, 0.76);
  --input-a: rgba(8, 25, 44, 0.9);
  --input-b: rgba(6, 18, 33, 0.82);
  --warning-bg: rgba(253, 224, 71, 0.16);
  --warning-line: rgba(253, 224, 71, 0.44);
  --warning-ink: #fff1c0;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-soft: 0 16px 34px rgba(0, 0, 0, 0.3);
  --shadow-strong: 0 24px 46px rgba(0, 0, 0, 0.36);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color-scheme: dark;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  line-height: 1.45;
  background:
    radial-gradient(980px 520px at 8% -14%, rgba(34, 211, 238, 0.2), transparent 63%),
    radial-gradient(840px 470px at 93% -20%, rgba(129, 140, 248, 0.17), transparent 65%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 57%, var(--bg-3));
  overflow-x: hidden;
  overflow-y: scroll;
  perspective: 1300px;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background: conic-gradient(
    from 210deg at 50% 45%,
    rgba(34, 211, 238, 0),
    rgba(34, 211, 238, 0.13),
    rgba(129, 140, 248, 0),
    rgba(34, 211, 238, 0)
  );
  filter: blur(40px);
  opacity: 0.44;
}

body::after {
  background-image:
    linear-gradient(rgba(161, 211, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(161, 211, 255, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 22%, rgba(0, 0, 0, 1), transparent 84%);
  opacity: 0.25;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.page {
  width: min(1240px, 94vw);
  margin: 1.35rem auto 1.9rem;
  display: grid;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.hero,
.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--panel-a), var(--panel-b));
  box-shadow:
    var(--shadow-soft),
    inset 0 0 0 1px rgba(173, 226, 255, 0.08);
  overflow: hidden;
  transform-style: preserve-3d;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    filter 0.22s ease;
  animation: panelIn 0.5s ease both;
}

.hero::before,
.panel::before {
  content: "";
  position: absolute;
  inset: -48%;
  background: radial-gradient(circle at center, rgba(94, 234, 212, 0.2), transparent 62%);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.hero:hover,
.panel:hover {
  border-color: var(--line-strong);
  box-shadow:
    var(--shadow-strong),
    0 0 28px rgba(94, 234, 212, 0.16),
    inset 0 0 0 1px rgba(186, 236, 255, 0.14);
  filter: brightness(1.02);
}

.hero {
  padding: 1.18rem 1.25rem 1.12rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.86rem, 3vw, 2.92rem);
  letter-spacing: 0.02em;
  position: relative;
  z-index: 2;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.45vw, 1.2rem);
  position: relative;
  z-index: 2;
}

.hero-note {
  margin-top: 0.6rem;
  padding: 0.55rem 0.72rem;
  border: 1px solid var(--warning-line);
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning-ink);
  font-size: 0.95rem;
  position: relative;
  z-index: 2;
}

.panel {
  padding: 1rem 1.05rem;
}

.controls {
  padding: 1.15rem 1.25rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem 1.2rem;
  align-items: end;
}

.controls label {
  display: grid;
  gap: 0.45rem;
}

/* IMPORTANT (servietringe/style.css):
   .controls label uses display:grid, so enforce [hidden] explicitly.
   Otherwise admin-only labels can appear for guests/customers. */
.controls label[hidden] {
  display: none !important;
}

.distance-control[hidden] {
  display: none !important;
}

.font-row,
.count-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
}

.label-text {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.controls input[type="text"],
.controls input[type="number"],
.controls select,
.sticky-controls select,
.name-cell input,
.offset-grid input,
.offset-grid select {
  height: 48px;
  border: 1px solid rgba(126, 189, 242, 0.48);
  border-radius: 10px;
  background: linear-gradient(165deg, var(--input-a), var(--input-b));
  color: var(--ink);
  padding: 0 0.8rem;
  font-size: clamp(1rem, 2vw, 1.02rem);
  box-shadow: inset 0 0 0 1px rgba(221, 244, 255, 0.04);
}

.controls select,
.sticky-controls select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color-scheme: dark;
  padding-right: 2.2rem;
  background-image:
    linear-gradient(165deg, var(--input-a), var(--input-b)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 5.5l5 5 5-5' fill='none' stroke='%23d5eeff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, 14px 14px;
  background-position: 0 0, calc(100% - 0.75rem) 50%;
}

.controls select::-ms-expand,
.sticky-controls select::-ms-expand {
  display: none;
}

.controls select option,
.sticky-controls select option {
  background: #0b223d;
  color: #e8f5ff;
}

.controls select option:checked,
.sticky-controls select option:checked {
  background: #155e91;
  color: #f4fbff;
}

.name-cell input,
.offset-grid input,
.offset-grid select {
  height: 42px;
  font-size: 0.95rem;
}

.controls input::placeholder,
.name-cell input::placeholder {
  color: rgba(185, 210, 230, 0.78);
}

.controls input[type="text"]:focus,
.controls input[type="number"]:focus,
.controls select:focus,
.sticky-controls select:focus,
.controls input[type="range"]:focus,
.name-cell input:focus,
.offset-grid input:focus,
.offset-grid select:focus {
  outline: none;
  border-color: rgba(94, 234, 212, 0.82);
  box-shadow:
    0 0 0 2px rgba(94, 234, 212, 0.2),
    0 0 0 1px rgba(94, 234, 212, 0.5) inset;
}

.secondary-btn,
.actions button,
.align-btn,
.size-modal-close {
  border: 1px solid rgba(109, 196, 255, 0.58);
  border-radius: 12px;
  background: linear-gradient(140deg, rgba(37, 111, 164, 0.44), rgba(13, 36, 66, 0.86));
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    filter 0.2s ease;
}

.secondary-btn,
.size-modal-close {
  height: 40px;
  padding: 0 0.8rem;
  font-size: 0.88rem;
  white-space: nowrap;
}

.secondary-btn:hover,
.actions button:hover,
.align-btn:hover,
.size-modal-close:hover {
  transform: translateY(-1px);
  border-color: rgba(104, 230, 237, 0.85);
  box-shadow: 0 10px 20px rgba(94, 234, 212, 0.18);
  filter: brightness(1.04);
}

.secondary-btn:focus-visible,
.actions button:focus-visible,
.align-btn:focus-visible,
.size-modal-close:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(94, 234, 212, 0.3),
    0 0 0 4px rgba(94, 234, 212, 0.14);
}

.names-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.6rem;
}

.names-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
  overflow: hidden;
}

.name-cell {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.name-cell-title {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.name-cell input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border-radius: 9px;
  padding: 0 0.7rem;
}

.slider-label .slider-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
}

.slider-label .slider-row-offset {
  grid-template-columns: auto 1fr auto auto;
  gap: 0.55rem;
}

.slider-side {
  color: rgba(206, 231, 249, 0.9);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.controls input[type="range"],
.sticky-controls input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.95), rgba(96, 165, 250, 0.92));
  cursor: pointer;
}

.controls input[type="range"]::-webkit-slider-thumb,
.sticky-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(185, 236, 255, 0.7);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), rgba(111, 223, 255, 0.9) 58%, rgba(42, 122, 199, 0.95));
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.35);
}

.controls input[type="range"]::-moz-range-thumb,
.sticky-controls input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(185, 236, 255, 0.7);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), rgba(111, 223, 255, 0.9) 58%, rgba(42, 122, 199, 0.95));
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.35);
}

.controls output {
  min-width: 6ch;
  text-align: right;
  font-size: 1.8rem;
  line-height: 1;
  color: #e8fbff;
  text-shadow: 0 0 12px rgba(125, 222, 250, 0.38);
  font-variant-numeric: tabular-nums;
}

.measure-panel {
  grid-column: 1 / 2;
  justify-self: start;
  width: min(230px, 100%);
  display: grid;
  gap: 0.45rem;
  align-self: start;
}

.size-preview-trigger {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
}

.size-preview-trigger:focus-visible {
  outline: 2px solid rgba(94, 234, 212, 0.82);
  outline-offset: 2px;
}

.size-preview {
  width: 100%;
  min-height: 108px;
  border: 1px solid rgba(117, 181, 236, 0.44);
  border-radius: 10px;
  background:
    radial-gradient(circle at 28% 22%, rgba(46, 160, 213, 0.18), transparent 54%),
    linear-gradient(160deg, rgba(7, 27, 51, 0.95), rgba(6, 18, 34, 0.88));
  box-shadow:
    inset 0 0 0 1px rgba(175, 227, 255, 0.06),
    0 10px 20px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.size-preview svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 1px rgba(209, 241, 255, 0.82));
}

.price-panel {
  grid-column: 2 / 3;
  justify-self: stretch;
  align-self: start;
  border: 1px solid rgba(255, 209, 130, 0.46);
  border-radius: 12px;
  background: linear-gradient(155deg, rgba(255, 196, 95, 0.24), rgba(56, 37, 14, 0.5));
  padding: 0.68rem 0.78rem;
  display: grid;
  gap: 0.35rem;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
  min-height: 136px;
}

.price-row,
.price-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.price-label {
  font-size: 0.92rem;
  color: #ffe3a6;
  font-weight: 700;
}

.price-row strong {
  font-size: 1.08rem;
  color: #fff5da;
}

.price-note {
  margin: 0;
  font-size: 0.83rem;
  color: #f9dfa9;
}

.price-total strong {
  font-size: 1.48rem;
  line-height: 1;
  color: #fff8e3;
  text-shadow: 0 0 10px rgba(253, 230, 138, 0.28);
}

.size-modal[hidden] {
  display: none;
}

.size-modal {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.size-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 12, 23, 0.78);
  backdrop-filter: blur(4px);
}

.size-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(980px, 94vw);
  max-height: 92vh;
  overflow: auto;
  border: 1px solid rgba(141, 204, 255, 0.5);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem 1rem;
  background: linear-gradient(160deg, rgba(9, 30, 55, 0.96), rgba(6, 18, 35, 0.9));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.size-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.size-modal-header h2 {
  margin: 0;
  font-size: 1.35rem;
  color: #e7f4ff;
}

.size-modal-close {
  background: linear-gradient(140deg, rgba(56, 132, 199, 0.48), rgba(13, 36, 66, 0.9));
  color: #eef8ff;
  border-color: rgba(109, 196, 255, 0.58);
  padding: 0.46rem 0.9rem;
}

.size-modal-note {
  margin: 0.35rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.size-preview-large {
  min-height: min(68vh, 560px);
}

body.modal-open {
  overflow: hidden;
}

.offset-details {
  grid-column: 1 / -1;
  border: 1px solid rgba(124, 188, 245, 0.44);
  border-radius: 12px;
  background: rgba(5, 18, 33, 0.58);
  padding: 0.55rem 0.76rem 0.72rem;
}

.offset-details > summary {
  cursor: pointer;
  font-weight: 700;
  color: #d3ebff;
  user-select: none;
}

.offset-grid {
  margin-top: 0.62rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.72rem 0.9rem;
}

.offset-grid label {
  display: grid;
  gap: 0.35rem;
}

.offset-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.offset-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #34d399;
}

.offset-toggle span {
  font-size: 0.92rem;
  color: #cfe7fb;
  font-weight: 600;
}

.actions {
  grid-column: 3 / 4;
  display: grid;
  grid-template-columns: minmax(190px, 240px);
  justify-content: start;
  align-content: start;
  gap: 0.7rem;
  align-self: start;
}

.actions button {
  width: 100%;
  padding: 0.78rem 1.25rem;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

#btnSvg {
  border-color: rgba(94, 234, 212, 0.74);
  background: linear-gradient(140deg, rgba(58, 174, 157, 0.38), rgba(16, 62, 70, 0.84));
}

#btnOffsetExport {
  border-color: rgba(253, 224, 71, 0.58);
  background: linear-gradient(140deg, rgba(205, 170, 58, 0.38), rgba(74, 58, 22, 0.82));
}

.actions button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  border-color: rgba(251, 113, 133, 0.62);
  background: rgba(72, 18, 33, 0.68);
  box-shadow: none;
  transform: none;
}

.sticky-controls {
  position: sticky;
  top: 0.55rem;
  z-index: 900;
  padding: 0.75rem 0.95rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.82rem 1rem;
  border-color: rgba(124, 188, 245, 0.44);
  background: linear-gradient(165deg, rgba(10, 29, 52, 0.94), rgba(8, 19, 34, 0.88));
  backdrop-filter: blur(8px);
}

.sticky-slider {
  display: grid;
  gap: 0.45rem;
}

.sticky-right {
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.sticky-font-label {
  display: grid;
  gap: 0.45rem;
}

.sticky-controls .slider-row {
  align-items: center;
}

.sticky-controls output {
  min-width: 6ch;
  font-size: 1.5rem;
  color: #e8fbff;
  text-shadow: 0 0 10px rgba(125, 222, 250, 0.38);
  font-variant-numeric: tabular-nums;
}

.align-row {
  display: flex;
  gap: 0.5rem;
}

.align-btn {
  border-radius: 9px;
  padding: 0.35rem 0.74rem;
  font-size: 0.84rem;
  background: linear-gradient(140deg, rgba(66, 108, 151, 0.44), rgba(19, 41, 71, 0.84));
}

.align-btn[aria-pressed="true"] {
  border-color: rgba(94, 234, 212, 0.82);
  background: linear-gradient(140deg, rgba(52, 211, 153, 0.36), rgba(14, 71, 58, 0.82));
  color: #eafff4;
}

.preview-panel {
  padding: 0.85rem;
}

.preview {
  position: relative;
  width: 100%;
  min-height: clamp(560px, 74vh, 900px);
  border-radius: 12px;
  border: 1px solid rgba(121, 187, 244, 0.42);
  background:
    radial-gradient(circle at 24% 20%, rgba(56, 170, 222, 0.18), transparent 56%),
    radial-gradient(circle at 78% 8%, rgba(125, 148, 249, 0.16), transparent 52%),
    linear-gradient(160deg, rgba(7, 27, 51, 0.95), rgba(6, 19, 35, 0.9));
  box-shadow:
    inset 0 0 0 1px rgba(175, 227, 255, 0.06),
    0 14px 30px rgba(0, 0, 0, 0.24);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

.preview::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(161, 211, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(161, 211, 255, 0.06) 1px, transparent 1px);
  background-size: 38px 38px;
  opacity: 0.2;
}

.preview svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 1px rgba(218, 244, 255, 0.75));
}

@media (max-width: 980px) {
  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .offset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    grid-column: 1 / -1;
    grid-template-columns: minmax(190px, 240px);
    justify-content: start;
  }

  .measure-panel {
    grid-column: 1 / -1;
  }

  .price-panel {
    grid-column: 1 / -1;
  }

  .sticky-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .page {
    width: min(1240px, 96vw);
  }

  .hero {
    padding: 1rem 0.95rem;
  }

  .controls {
    grid-template-columns: 1fr;
    padding: 1rem 0.92rem;
  }

  .offset-grid {
    grid-template-columns: 1fr;
  }

  .font-row,
  .count-row {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .actions button {
    width: 100%;
  }

  .measure-panel {
    justify-self: stretch;
    width: 100%;
  }

  .preview {
    min-height: clamp(520px, 68vh, 780px);
  }
}
