/* ══════════════════════════════════════
   EasyDekorutleie – «Blomst»
══════════════════════════════════════ */
:root {
  --bg:      #FCEFF3;
  --ink:     #231A22;
  --muted:   #6E5D66;
  --faint:   #8E7A84;
  --line:    #F3E2E8;
  --field:   #FFF9FB;
  --white:   #FFFFFF;
  --pink:    #FFB8CC;
  --lilac:   #C9B6FF;
  --peach:   #FFD3B0;
  --good:    #17784E;
  --font: 'Bricolage Grotesque', -apple-system, 'Segoe UI', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ══════════════════════════════════════
   HEADER
══════════════════════════════════════ */
.hero {
  position: relative;
  padding: 26px 22px 24px;
  border-radius: 32px;
  background: var(--ink);
  color: #FFF4F7;
  overflow: hidden;
}
.hero .dot { position: absolute; border-radius: 999px; }
.hero .dot-1 { right: -30px; top: -40px; width: 150px; height: 150px; background: var(--pink); }
.hero .dot-2 { right: 70px;  top: 54px;  width: 64px;  height: 64px;  background: var(--lilac); }
.hero .dot-3 { right: 24px;  top: 104px; width: 34px;  height: 34px;  background: var(--peach); }
.hero h1 {
  position: relative;
  font-size: 44px;
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.04em;
  max-width: 220px;
}
.hero p {
  position: relative;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 500;
  color: #E8D3DB;
}

/* ══════════════════════════════════════
   CARDS / FIELDS
══════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: 28px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card h2 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%;
  height: 50px;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 500;
  background: var(--field);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s;
}
.field textarea {
  width: 100%;
  min-height: 84px;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: inherit;
  background: var(--field);
  outline: none;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .15s;
}
.field textarea:focus { border-color: var(--pink); }
.field input[type="date"] { padding: 0 10px; font-size: 15px; }
.field input:focus { border-color: var(--pink); }

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

/* ══════════════════════════════════════
   CATEGORY (each has its own --tint / --cat-ink)
══════════════════════════════════════ */
#pos { display: flex; flex-direction: column; gap: 20px; }

.category {
  background: var(--tint);
  border-radius: 30px;
  padding: 18px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
}
.category-header h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--cat-ink);
}
.cat-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--cat-ink);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.items { display: flex; flex-direction: column; gap: 6px; }

/* ══════════════════════════════════════
   ITEM ROW
══════════════════════════════════════ */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  border-radius: 20px;
  background: var(--white);
  transition: box-shadow .15s;
}
.item.active { box-shadow: 0 0 0 2px var(--cat-ink); }

.item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-name { font-size: 15px; font-weight: 700; line-height: 1.25; word-break: break-word; }
.item-meta { font-size: 13px; font-weight: 500; color: var(--muted); }

.item-subtotal {
  font-size: 14px;
  font-weight: 800;
  color: var(--cat-ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.qty-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  background: #F6EEF1;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px;
  transition: background .15s, color .15s;
}
.item.active .qty-wrap { background: var(--ink); color: var(--white); }
.qty-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.qty-btn:active { transform: scale(0.88); background: rgba(255, 255, 255, 0.15); }
.qty-num {
  min-width: 22px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════
   SUMMARY – a ticket
══════════════════════════════════════ */
.ticket { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.ticket-top {
  background: var(--white);
  border-radius: 30px 30px 0 0;
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket-top h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.sum-row { display: flex; justify-content: space-between; font-size: 16px; font-weight: 500; }
.sum-row span:first-child { color: var(--muted); }

.rabatt-row { display: flex; justify-content: space-between; font-size: 16px; font-weight: 800; color: var(--good); }
.rabatt-row.hidden { display: none; }

.perforation { position: relative; height: 24px; background: var(--white); }
.perforation::before,
.perforation::after {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--bg);
}
.perforation::before { left: -12px; }
.perforation::after  { right: -12px; }
.perforation span {
  position: absolute;
  left: 20px; right: 20px; top: 11px;
  border-top: 2px dashed #F0D9E1;
}

.ticket-bottom {
  background: var(--white);
  border-radius: 0 0 30px 30px;
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket-bottom label { font-size: 15px; font-weight: 700; color: var(--muted); }
.total-input-wrap { display: flex; align-items: baseline; gap: 8px; }
.total-input {
  flex: 1;
  min-width: 0;
  height: 64px;
  border: 2px dashed var(--pink);
  border-radius: 18px;
  padding: 0 14px;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: #FFF6F9;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -moz-appearance: textfield;
}
.total-input::-webkit-outer-spin-button,
.total-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.total-input:focus { border-style: solid; }
.total-input-kr { font-size: 26px; font-weight: 800; }
.total-edit-hint { font-size: 13px; font-weight: 500; color: var(--faint); }

.btn {
  width: 100%;
  border: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(0.97); }
.btn-save {
  margin-top: 6px;
  height: 56px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
}
.btn-reset {
  height: 44px;
  background: transparent;
  color: var(--faint);
  font-size: 15px;
  font-weight: 700;
}
.btn-reset:hover { color: var(--ink); }

button:focus-visible, input:focus-visible { outline: 3px solid var(--lilac); outline-offset: 2px; }

/* ══════════════════════════════════════
   RECEIPT (off-screen, saved as image)
══════════════════════════════════════ */
.print-receipt {
  display: none;
  position: fixed;
  left: -9999px;
  top: 0;
  width: 420px;
  background: var(--bg);
  padding: 20px;
  font-family: var(--font);
  color: var(--ink);
}
.print-receipt.visible { display: block; }

.pr-hero {
  position: relative;
  background: var(--ink);
  color: #FFF4F7;
  border-radius: 26px;
  padding: 22px 20px 20px;
  overflow: hidden;
}
.pr-hero .dot { position: absolute; border-radius: 999px; }
.pr-hero .dot-1 { right: -26px; top: -34px; width: 110px; height: 110px; background: var(--pink); }
.pr-hero .dot-2 { right: 60px;  top: 40px;  width: 40px;  height: 40px;  background: var(--lilac); }
.pr-hero .dot-3 { right: 24px;  top: 78px;  width: 22px;  height: 22px;  background: var(--peach); }
.pr-hero h1 { position: relative; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.pr-hero .pr-tag { position: relative; margin-top: 6px; font-size: 12px; font-weight: 600; color: #E8D3DB; }

.pr-meta {
  margin-top: 12px;
  background: var(--white);
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.pr-kunde { font-size: 16px; font-weight: 800; color: var(--ink); }
.pr-dates { text-align: right; line-height: 1.6; }
.pr-dates strong { color: var(--ink); }

.pr-cat {
  margin-top: 10px;
  border-radius: 20px;
  padding: 12px 12px 8px;
}
.pr-cat-name { font-size: 14px; font-weight: 800; letter-spacing: -0.01em; margin: 0 4px 6px; }
.pr-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  background: var(--white);
  border-radius: 12px;
  padding: 8px 10px;
  margin-bottom: 4px;
  font-size: 12px;
}
.pr-line .pr-name { font-weight: 700; }
.pr-line .pr-calc { color: var(--muted); font-size: 11px; }
.pr-line .pr-sum { font-weight: 800; white-space: nowrap; }

.pr-totals {
  margin-top: 12px;
  background: var(--white);
  border-radius: 20px;
  padding: 14px 16px;
}
.pr-tot-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.pr-tot-row span:first-child { color: var(--muted); }
.pr-tot-row.rabatt, .pr-tot-row.rabatt span:first-child { color: var(--good); font-weight: 800; }
.pr-tot-row.grand {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 2px dashed #F0D9E1;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.pr-tot-row.grand span:first-child { color: var(--ink); font-size: 15px; align-self: center; }

.pr-comment {
  margin-top: 12px;
  background: var(--white);
  border-radius: 20px;
  padding: 14px 16px;
}
.pr-comment-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.pr-comment-text {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pr-footer {
  margin-top: 12px;
  font-size: 10px;
  line-height: 1.6;
  color: var(--faint);
  text-align: center;
}

/* ══════════════════════════════════════
   IMAGE SHEET (share / long-press to save)
══════════════════════════════════════ */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(35, 26, 34, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.image-modal[hidden] { display: none; }
.image-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--white);
  border-radius: 30px 30px 0 0;
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.image-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.image-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.image-close {
  width: 44px; height: 44px;
  border: 0;
  border-radius: 999px;
  background: #F6EEF1;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
}
.image-hint { font-size: 14px; line-height: 1.45; color: var(--muted); }
.image-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-radius: 20px;
  padding: 10px;
}
.image-scroll img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  -webkit-touch-callout: default;
  -webkit-user-select: auto;
  user-select: auto;
}
.image-sheet .btn-save { margin-top: 2px; }

/* ══════════════════════════════════════
   SAVE OVERLAY
══════════════════════════════════════ */
#save-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(35, 26, 34, 0.6);
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
#save-overlay.show { display: flex; }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--pink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .spinner { animation-duration: 2s; }
}

.dep-row { margin-top: 4px; }
