:root {
  --ink: #1a1a1a;
  --muted: #5c5c5c;
  --panel: #0a1f24;
  --accent: #2ec4b6;
  --accent-2: #7ee0d4;
  --accent-soft: rgba(46, 196, 182, 0.14);
  --paper: #fff;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Source Sans 3", system-ui, sans-serif;
  color: var(--ink);
  background: #071618;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea {
  font: inherit;
  touch-action: manipulation;
}

.app {
  display: grid;
  grid-template-columns: minmax(360px, 400px) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.mobile-nav,
.mobile-only {
  display: none;
}

.panel {
  background:
    radial-gradient(ellipse 80% 40% at 0% 0%, rgba(46,196,182,0.16), transparent 55%),
    linear-gradient(180deg, var(--panel), #071618 90%);
  color: #e8eef4;
  padding: 1.35rem 1.2rem calc(1.5rem + var(--safe-b));
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: auto;
  max-height: 100vh;
  max-height: 100dvh;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(46,196,182,0.28);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-pill .spark {
  color: var(--accent);
}

.panel-head .eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 600;
}

.panel-head h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 1.7rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.panel-head > p:last-child {
  margin: 0.45rem 0 1.2rem;
  color: rgba(232,238,244,0.58);
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 34ch;
}

.block {
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 1rem 0.95rem;
  margin-bottom: 0.9rem;
}

.block h2 {
  margin: 0 0 0.8rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.block-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.block-row h2 { margin: 0; }

.tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  letter-spacing: 0.04em;
}

.packages {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.packages button {
  border: 1px solid rgba(46,196,182,0.22);
  background: rgba(0,0,0,0.2);
  color: #e8eef4;
  border-radius: 12px;
  padding: 0.7rem 0.65rem;
  font-size: 0.84rem;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
  min-height: 46px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.packages button:hover,
.packages button.is-active {
  border-color: rgba(46,196,182,0.55);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.packages button:active {
  transform: scale(0.98);
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(232,238,244,0.72);
  margin-bottom: 0.65rem;
}

.field-caption {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  color: rgba(232,238,244,0.45);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
}

.chips button {
  border: 1px solid rgba(46,196,182,0.28);
  background: var(--accent-soft);
  color: var(--accent-2);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}

.chips button:active {
  transform: scale(0.98);
  background: rgba(46,196,182,0.22);
}

input, textarea {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.28);
  color: #fff;
  border-radius: 10px;
  padding: 0.72rem 0.75rem;
  min-height: 46px;
}

input[type="file"] {
  padding: 0.55rem;
  font-size: 0.85rem;
}

input:focus, textarea:focus {
  outline: 2px solid rgba(46,196,182,0.35);
  border-color: rgba(46,196,182,0.5);
}

textarea {
  resize: vertical;
  min-height: 110px;
  line-height: 1.45;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.hours {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.hours label {
  text-align: center;
  margin-bottom: 0;
  font-size: 0.75rem;
}

.hours input {
  text-align: center;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.hint {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: rgba(232,238,244,0.48);
}

.mat-row {
  display: grid;
  grid-template-columns: 1.4fr 0.55fr 0.45fr 0.65fr 0.65fr auto;
  gap: 0.4rem;
  margin-bottom: 0.55rem;
  align-items: end;
  padding: 0.55rem;
  border-radius: 10px;
  background: rgba(0,0,0,0.16);
  border: 1px solid rgba(255,255,255,0.05);
}

.mat-row label { margin-bottom: 0; }

.mat-row button {
  height: 46px;
  width: 46px;
  border: none;
  border-radius: 10px;
  background: rgba(255,80,80,0.15);
  color: #ffb0b0;
  cursor: pointer;
  font-size: 1rem;
}

.actions {
  display: grid;
  gap: 0.55rem;
  position: static;
  margin-top: 0.35rem;
  padding: 0.85rem 0 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.label-desktop { display: inline; }
.label-mobile { display: none; }

.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  padding: 0.9rem 1rem;
  min-height: 48px;
}

.btn-primary {
  background: linear-gradient(120deg, #1fa896, #2ec4b6 45%, #7ee0d4);
  color: #042a28;
  box-shadow: 0 8px 22px rgba(46,196,182,0.25);
}

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
}

.btn-ghost {
  background: transparent;
  color: var(--accent-2);
  border: 1px solid rgba(46,196,182,0.35);
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  min-height: 40px;
  white-space: nowrap;
}

.preview-wrap {
  overflow: auto;
  max-height: 100vh;
  max-height: 100dvh;
  padding: 1.1rem 1.4rem 1.5rem;
  background:
    radial-gradient(ellipse 55% 45% at 50% 0%, rgba(46,196,182,0.14), transparent 55%),
    linear-gradient(180deg, #0f2428 0%, #0a181b 100%);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: rgba(255,255,255,0.78);
  margin-bottom: 0.85rem;
  flex: 0 0 auto;
}

.preview-toolbar strong {
  display: block;
  font-size: 0.95rem;
}

.toolbar-sub {
  display: block;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.42);
  margin-top: 0.1rem;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

#zoomLabel {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  font-variant-numeric: tabular-nums;
}

#liveBadge {
  border: 1px solid rgba(46,196,182,0.45);
  color: #7ee0d4;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.35rem 0.25rem 1rem;
  overflow: auto;
}

.sheet-viewport {
  width: 100%;
  max-width: 920px;
  overflow: hidden;
  margin: 0 auto;
  flex: 0 0 auto;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04), transparent 40%),
    rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 1rem 1rem 1.15rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.sheet-zoom {
  width: 210mm;
  transform-origin: top left;
  will-change: transform;
}

.sheet {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.65) inset,
    0 18px 40px rgba(0,0,0,0.35);
  border: 1px solid rgba(15, 40, 38, 0.08);
}

@media screen and (min-width: 901px) {
  .app {
    grid-template-columns: minmax(340px, 380px) minmax(0, 1fr);
  }
}

/* ===== Mobile (screen only — must NOT affect print/PDF) ===== */
@media screen and (max-width: 900px) {
  .mobile-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    height: calc(var(--nav-h) + var(--safe-b));
    padding: 0.45rem 0.7rem var(--safe-b);
    gap: 0.45rem;
    background: rgba(10, 16, 22, 0.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .nav-btn {
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: rgba(255,255,255,0.7);
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 46px;
  }

  .nav-btn.is-active {
    background: linear-gradient(120deg, #1fa896, #2ec4b6 45%, #7ee0d4);
    color: #042a28;
    border-color: transparent;
  }

  .nav-ico {
    font-size: 0.95rem;
    line-height: 1;
  }

  .mobile-only { display: grid; }

  .app {
    display: block;
    padding-bottom: calc(var(--nav-h) + var(--safe-b));
  }

  .panel,
  .preview-wrap {
    max-height: none;
    min-height: calc(100dvh - var(--nav-h) - var(--safe-b));
  }

  .app[data-view="form"] .preview-wrap { display: none; }
  .app[data-view="preview"] .panel { display: none; }

  .panel {
    border-right: none;
    padding: calc(1rem + var(--safe-t)) 1rem 1.25rem;
  }

  .panel-head > p:last-child {
    max-width: none;
    margin-bottom: 1rem;
  }

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

  .hours {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .mat-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .mat-row label:first-child {
    grid-column: 1 / -1;
  }

  .mat-row label:nth-child(5) {
    grid-column: 1 / -1;
  }

  .mat-row button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: 0.5rem;
    padding: 0.75rem 0 calc(0.5rem + var(--safe-b));
    border-top: none;
    background: linear-gradient(180deg, transparent, #0c131a 28%);
  }

  .label-desktop { display: none; }
  .label-mobile { display: inline; }

  .preview-wrap {
    display: block;
    padding: 0.85rem 0.75rem 1.2rem;
  }

  .preview-stage {
    display: block;
    padding: 0;
    overflow: visible;
  }

  .sheet-viewport {
    max-width: none;
    padding: 0.55rem;
    border-radius: 8px;
  }

  .preview-actions {
    grid-template-columns: 1fr 1.2fr;
    gap: 0.55rem;
    margin-top: 1rem;
    position: sticky;
    bottom: calc(var(--nav-h) + var(--safe-b) + 0.5rem);
  }

  .sheet-viewport {
    width: 100%;
  }

  .sheet {
    box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  }
}

@media screen and (max-width: 420px) {
  .panel-head h1 { font-size: 1.4rem; }
  .hours label { font-size: 0.7rem; }
  .btn-primary, .btn-secondary { font-size: 0.92rem; }
}

@media print {
  .panel,
  .preview-toolbar,
  .mobile-nav,
  .preview-actions,
  .mobile-only,
  .nav-btn {
    display: none !important;
  }

  .app,
  .preview-wrap,
  .sheet-viewport,
  .sheet-zoom {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 210mm !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    background: #fff !important;
    transform: none !important;
  }

  .sheet {
    box-shadow: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 0;
  }
}
