@import "tailwindcss";

:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #5b6472;
  --subtle: #f4f6f8;
  --panel: #ffffff;
  --line: #d9dee7;
  --blue: #0b4aa2;
  --blue-soft: #e8f0ff;
  --orange: #c2410c;
  --green: #047857;
  --red: #b42318;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  background: #e9edf3;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.hidden {
  display: none !important;
}

.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;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 10px);
  gap: 3px;
  padding: 8px;
  border-radius: 8px;
  background: var(--blue);
}

.brand-mark span {
  width: 10px;
  height: 8px;
  border-radius: 2px;
  background: #fff;
}

.brand-mark span:nth-child(2),
.brand-mark span:nth-child(3) {
  opacity: 0.72;
}

.brand-mark span:nth-child(4) {
  opacity: 0.46;
}

.brand-copy h1,
.brand-copy p {
  margin: 0;
}

.brand-copy h1 {
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
}

.brand-copy p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.header-spacer {
  flex: 1;
}

.status-chip,
.counter-chip,
.mini-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--subtle);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.status-chip svg,
.toolbar-button svg,
.export-button svg,
.action-button svg,
.icon-toggle svg,
.drop-zone svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.toolbar-button,
.export-button,
.action-button,
.text-button,
.icon-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.toolbar-button,
.export-button,
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.toolbar-button:hover,
.icon-toggle:hover {
  border-color: #98a5b8;
  background: #f8fafc;
}

.toolbar-button.primary-soft {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #b8caf0;
}

.toolbar-button.danger {
  color: var(--red);
}

.export-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 18px rgba(11, 74, 162, 0.22);
}

.export-button.dark {
  border-color: #1f2937;
  background: #1f2937;
  box-shadow: none;
}

.export-button:hover,
.action-button:hover {
  transform: translateY(-1px);
}

.export-button.is-busy {
  color: rgba(255, 255, 255, 0.85);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.control-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading p,
.modal-header p,
.preview-kicker {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-heading h2,
.modal-header h2,
.preview-toolbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
  font-weight: 850;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f8;
}

.mode-button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mode-button.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.mode-panel {
  display: grid;
  gap: 10px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.input-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.35;
}

.input-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11, 74, 162, 0.14);
}

.input-control.compact {
  min-height: 38px;
  padding: 8px 10px;
}

.input-control.tall {
  min-height: 132px;
  resize: vertical;
}

.input-control.editor {
  min-height: 150px;
  resize: vertical;
}

.input-control.search {
  margin-bottom: 14px;
}

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 112px;
  padding: 18px;
  border: 1.5px dashed #a9b4c4;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.drop-zone strong {
  color: var(--ink);
  font-size: 14px;
}

.drop-zone span {
  font-size: 12px;
  font-weight: 650;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.compact-drop {
  min-height: 92px;
}

.field-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-pill {
  border: 1px solid #c6ceda;
  border-radius: 8px;
  background: #f8fafc;
  color: #243142;
  padding: 6px 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.field-pill:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-soft);
}

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

.button-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.icon-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 9px;
  font-weight: 850;
}

.icon-toggle.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.text-toggle {
  font-size: 12px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 2px 0;
  font-size: 12px;
  font-weight: 800;
}

.preview-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #d8dee8;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 12px 18px;
  background: #111827;
  color: #fff;
  border-bottom: 1px solid #020617;
}

.preview-toolbar h2 {
  color: #fff;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zoom-select {
  min-height: 34px;
  border: 1px solid #354152;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
}

.sheet-preview {
  flex: 1;
  overflow: auto;
  padding: 36px;
}

#pagesContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  transform-origin: top center;
}

.page-sheet {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  background: #fff;
  border: 1px solid #cfd6e2;
  box-shadow: var(--shadow);
}

.label-cell {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 2pt;
  overflow: hidden;
  border: 0;
  outline: 1px dashed #cbd5e1;
  background: #fff;
  color: #111827;
  padding: 5pt;
  text-align: left;
  white-space: pre-wrap;
}

.label-cell:hover {
  z-index: 2;
  outline: 2px solid var(--blue);
  box-shadow: inset 0 0 0 2px rgba(11, 74, 162, 0.08);
}

.label-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 3pt;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
}

.label-text {
  position: relative;
  z-index: 1;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.label-cell em {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  border-radius: 4px;
  background: #fde68a;
  color: #78350f;
  padding: 1px 4px;
  font-size: 7px;
  font-style: normal;
  font-weight: 900;
}

.label-cell.customized {
  outline: 2px solid #f59e0b;
}

.label-cell.skipped {
  background: #f8fafc;
}

.label-cell.skipped::after {
  content: "SKIPPED";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #a5afbf;
  font-size: 9pt;
  font-weight: 900;
  transform: rotate(-28deg);
}

.label-cell.ghost {
  opacity: 0.48;
}

.align-left {
  align-items: flex-start;
  text-align: left;
}

.align-center {
  align-items: center;
  text-align: center;
}

.align-right {
  align-items: flex-end;
  text-align: right;
}

.valign-top {
  justify-content: flex-start;
}

.valign-middle {
  justify-content: center;
}

.valign-bottom {
  justify-content: flex-end;
}

.label-logo {
  position: relative;
  z-index: 0;
  object-fit: contain;
  flex: 0 0 auto;
}

.logo-layout-above,
.logo-layout-below {
  align-items: center;
}

.logo-layout-left,
.logo-layout-right {
  flex-direction: row;
  align-items: center;
  height: 100%;
}

.logo-layout-right {
  flex-direction: row-reverse;
}

.logo-layout-below {
  flex-direction: column-reverse;
}

.logo-layout-left .label-text,
.logo-layout-right .label-text {
  flex: 1 1 auto;
}

.logo-layout-watermark {
  display: block;
  position: static;
}

.logo-watermark {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  opacity: 0.15;
  pointer-events: none;
}

.preview-note {
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.55);
}

.modal-card,
.export-card {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.35);
}

.modal-card {
  padding: 18px;
}

.modal-card.wide {
  width: min(940px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.template-section-title {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.template-section-title.secondary {
  margin-top: 8px;
}

.template-card {
  display: grid;
  gap: 6px;
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  text-align: left;
}

.template-card:hover,
.template-card.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.template-card.catalog-only {
  border-style: dashed;
  background: #f8fafc;
  cursor: default;
}

.template-card.catalog-only:hover {
  border-color: var(--line);
  background: #f8fafc;
}

.template-card.catalog-only em {
  color: #8a5a00;
  border-color: #efd59a;
  background: #fff8e5;
}

.template-card strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.2;
}

.template-card span,
.template-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.template-card em {
  align-self: end;
  justify-self: start;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #ccd6e4;
  padding: 4px 7px;
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: #f8fafc;
  font-weight: 750;
}

.modal-editor {
  min-height: 210px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.export-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  width: min(460px, 100%);
  padding: 18px;
}

.export-card h2,
.export-card p {
  margin: 0;
}

.export-card h2 {
  font-size: 17px;
  font-weight: 850;
}

.export-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid #dbe4f0;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.progress-track span {
  display: block;
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 160ms ease;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid #c7d2e2;
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 760;
}

.toast[data-tone="success"] {
  border-left-color: var(--green);
}

.toast[data-tone="error"] {
  border-left-color: var(--red);
}

.site-footer {
  display: flex;
  justify-content: center;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.site-footer a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.howto-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.56);
}

.howto-modal {
  width: min(560px, 100%);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 28px 70px rgba(2, 6, 23, 0.35);
  padding: 20px;
  outline: none;
}

.howto-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.howto-modal-header p {
  margin: 0 0 4px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.howto-modal-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 850;
}

.howto-modal-description {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 650;
}

.howto-modal-steps {
  display: grid;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: howto-step;
}

.howto-modal-steps li {
  position: relative;
  min-height: 48px;
  padding: 10px 12px 10px 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.howto-modal-steps li::before {
  counter-increment: howto-step;
  content: counter(howto-step);
  position: absolute;
  left: 12px;
  top: 10px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.howto-modal-steps strong,
.howto-modal-steps span {
  display: block;
}

.howto-modal-steps strong {
  font-size: 14px;
  line-height: 1.25;
}

.howto-modal-steps span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 650;
}

.howto-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1120px) {
  .app-header {
    flex-wrap: wrap;
  }

  .header-spacer {
    display: none;
  }

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

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-panel {
    min-height: 720px;
  }
}

@media (max-width: 720px) {
  .app-header {
    align-items: stretch;
  }

  .brand-copy {
    flex: 1 1 calc(100% - 48px);
  }

  .toolbar-button,
  .export-button {
    flex: 1 1 calc(50% - 8px);
  }

  .panel-section,
  .sheet-preview {
    padding: 14px;
  }

  .preview-toolbar,
  .preview-actions,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
