.receipt-topbar {
  padding-top: 15px;
  padding-bottom: 15px;
}

.receipt-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.receipt-mode-badge {
  border-color: rgba(32, 214, 191, 0.34);
  color: var(--teal);
}

.status-dot {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 0 13px rgba(32, 214, 191, 0.78);
}

.receipt-workspace {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(460px, 1fr) minmax(320px, 372px);
  gap: 14px;
  min-height: calc(100vh - 190px);
  padding: 14px clamp(12px, 2.6vw, 36px) 24px;
}

.receipt-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(145, 160, 173, 0.22);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 160px),
    var(--panel);
  box-shadow: var(--shadow);
}

.template-sidebar,
.editor-sidebar {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  min-height: 620px;
  padding: 15px;
}

.panel-kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.category-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.category-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 58px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    rgba(7, 10, 15, 0.86);
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.category-button:hover {
  transform: translateY(-1px);
  border-color: rgba(32, 214, 191, 0.4);
  color: var(--ink);
}

.category-button.active {
  border-color: rgba(32, 214, 191, 0.64);
  background:
    linear-gradient(135deg, rgba(32, 214, 191, 0.17), rgba(244, 201, 93, 0.05)),
    rgba(9, 16, 21, 0.96);
  color: var(--ink);
  box-shadow: inset 0 -2px 0 rgba(32, 214, 191, 0.48), 0 0 18px rgba(32, 214, 191, 0.1);
}

.category-button > span:last-child {
  display: grid;
  min-width: 0;
}

.category-button strong,
.category-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-button strong {
  font-size: 12px;
}

.category-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.category-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(32, 214, 191, 0.4);
  border-radius: 7px;
  background: rgba(32, 214, 191, 0.11);
  color: var(--teal);
  font-size: 16px;
  font-weight: 900;
}

.category-icon.payout {
  border-color: rgba(244, 201, 93, 0.4);
  background: rgba(244, 201, 93, 0.1);
  color: var(--gold);
}

.category-icon.sms {
  border-color: rgba(116, 164, 255, 0.46);
  background: rgba(116, 164, 255, 0.12);
  color: #8db4ff;
  font-size: 14px;
}

.template-search-wrap,
.field-search-wrap {
  position: relative;
  display: block;
}

.template-search-wrap {
  margin-bottom: 11px;
}

.template-search-wrap > span,
.field-search-wrap > span {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 11px;
  color: var(--muted);
  font-size: 18px;
  transform: translateY(-54%);
  pointer-events: none;
}

.template-search-wrap input,
.field-search-wrap input {
  min-height: 38px;
  padding-left: 34px;
  background: rgba(7, 10, 15, 0.88);
  font-size: 12px;
}

.template-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-height: 0;
  padding: 2px 3px 10px 1px;
  overflow-y: auto;
  scrollbar-color: rgba(32, 214, 191, 0.4) transparent;
}

.template-card {
  position: relative;
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(7, 10, 15, 0.86);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.template-card:hover {
  transform: translateY(-2px);
  border-color: rgba(32, 214, 191, 0.44);
}

.template-card.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(32, 214, 191, 0.14), 0 10px 24px rgba(0, 0, 0, 0.3);
}

.template-card.active::after {
  content: "✓";
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: var(--teal);
  color: #04211e;
  font-size: 11px;
  font-weight: 1000;
  box-shadow: 0 0 14px rgba(32, 214, 191, 0.5);
}

.template-thumb {
  position: relative;
  display: block;
  height: 92px;
  overflow: hidden;
  border-radius: 6px;
  background: #e8edf0;
}

.template-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-card-title {
  display: block;
  margin: 7px 3px 2px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-card-meta {
  display: block;
  margin: 0 3px 2px;
  color: var(--muted);
  font-size: 9px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  padding: 15px;
}

.preview-head,
.preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.preview-head {
  margin-bottom: 12px;
}

.preview-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.preview-shell {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 500px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(45deg, rgba(145, 160, 173, 0.055) 25%, transparent 25%, transparent 75%, rgba(145, 160, 173, 0.055) 75%),
    linear-gradient(45deg, rgba(145, 160, 173, 0.055) 25%, transparent 25%, transparent 75%, rgba(145, 160, 173, 0.055) 75%),
    #070a0f;
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.preview-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(32, 214, 191, 0.09), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 35%);
  pointer-events: none;
}

.device-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(88%, 630px);
  height: min(90%, 720px);
  overflow: hidden;
  border: 1px solid rgba(145, 160, 173, 0.42);
  border-radius: 13px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.54), 0 0 0 5px rgba(255, 255, 255, 0.025);
}

.template-layer {
  position: absolute;
  overflow: hidden;
  background: #ffffff;
  transform-origin: center;
}

.template-layer > img,
.overlay-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.template-layer > img {
  display: block;
}

.overlay-layer {
  pointer-events: none;
}

.template-mask {
  position: absolute;
  z-index: 1;
  display: block;
  border: 0;
  pointer-events: none;
}

.editable-overlay {
  position: absolute;
  display: block;
  min-width: 1px;
  min-height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  white-space: pre-wrap;
  word-break: normal;
  pointer-events: auto;
  cursor: text;
  transition: outline-color 0.14s ease, box-shadow 0.14s ease;
}

.editable-overlay:hover {
  outline: 1px dashed rgba(32, 214, 191, 0.75);
}

.editable-overlay.active {
  z-index: 999 !important;
  outline: 2px solid var(--teal);
  box-shadow: 0 0 0 3px rgba(32, 214, 191, 0.18);
}

.preview-loading {
  position: absolute;
  z-index: 1400;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 7px;
  background: rgba(7, 10, 15, 0.92);
  color: var(--ink);
}

.preview-loading[hidden] {
  display: none;
}

.preview-loading small {
  color: var(--muted);
}

.loading-orbit {
  width: 34px;
  height: 34px;
  margin-bottom: 5px;
  border: 3px solid rgba(32, 214, 191, 0.18);
  border-top-color: var(--teal);
  border-radius: 999px;
  animation: orbit 0.8s linear infinite;
}

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

.preview-foot {
  margin-top: 11px;
  padding: 10px 12px;
  border: 1px solid rgba(145, 160, 173, 0.17);
  border-radius: 8px;
  background: rgba(7, 10, 15, 0.55);
}

.preview-foot > div {
  display: grid;
  gap: 3px;
}

.preview-foot span {
  color: var(--muted);
  font-size: 10px;
}

.preview-foot strong {
  font-size: 11px;
}

.editor-action-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(145, 160, 173, 0.18);
}

.editor-action-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.random-button {
  border-color: rgba(244, 201, 93, 0.42);
  color: var(--gold);
}

.screenshot-button {
  box-shadow: 0 0 18px rgba(32, 214, 191, 0.12);
}

.editor-title-row {
  margin-bottom: 12px;
}

.device-settings {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background:
    linear-gradient(135deg, rgba(32, 214, 191, 0.07), transparent 52%),
    rgba(7, 10, 15, 0.64);
}

.device-settings[hidden] {
  display: none;
}

.subsection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.subsection-heading h3 {
  margin: 0;
  font-size: 13px;
}

.subsection-heading span {
  color: var(--teal);
  font-family: "Lucida Sans Typewriter", Consolas, monospace;
  font-size: 10px;
  font-weight: 900;
}

.device-brand-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 9px;
  padding: 4px;
  border: 1px solid rgba(145, 160, 173, 0.16);
  border-radius: 8px;
  background: rgba(3, 5, 8, 0.62);
}

.device-brand {
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.device-brand:hover,
.device-brand.active {
  border-color: rgba(32, 214, 191, 0.38);
  background: rgba(32, 214, 191, 0.12);
  color: var(--teal);
}

.device-model-label {
  display: grid;
  gap: 6px;
}

.device-model-label > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.device-model-label select {
  min-height: 36px;
  background: rgba(7, 10, 15, 0.9);
  font-size: 11px;
}

.field-search-wrap {
  margin: 11px 0 9px;
}

.field-list {
  display: grid;
  min-height: 0;
  gap: 8px;
  padding: 1px 3px 10px 1px;
  overflow-y: auto;
  scrollbar-color: rgba(32, 214, 191, 0.4) transparent;
}

.field-row {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid rgba(145, 160, 173, 0.18);
  border-radius: 8px;
  background: rgba(7, 10, 15, 0.62);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.field-row:hover,
.field-row.active {
  border-color: rgba(32, 214, 191, 0.5);
  background: rgba(32, 214, 191, 0.065);
}

.field-row.active {
  box-shadow: 0 0 0 2px rgba(32, 214, 191, 0.11);
}

.field-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-row-head label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.field-type {
  color: var(--teal);
  font-size: 9px;
  font-weight: 900;
}

.field-row textarea {
  min-height: 38px;
  max-height: 96px;
  padding: 8px 9px;
  resize: vertical;
  background: rgba(3, 5, 8, 0.74);
  font-size: 11px;
  line-height: 1.35;
}

.field-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.receipt-toast {
  position: fixed;
  z-index: 3000;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 15px;
  border: 1px solid rgba(32, 214, 191, 0.48);
  border-radius: 9px;
  background: rgba(7, 15, 20, 0.96);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.44), 0 0 22px rgba(32, 214, 191, 0.14);
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="light"] .category-button,
:root[data-theme="light"] .template-card,
:root[data-theme="light"] .template-search-wrap input,
:root[data-theme="light"] .field-search-wrap input,
:root[data-theme="light"] .device-settings,
:root[data-theme="light"] .field-row,
:root[data-theme="light"] .preview-foot,
:root[data-theme="light"] .device-model-label select {
  background: rgba(255, 255, 255, 0.92);
}

:root[data-theme="light"] .preview-shell {
  background-color: #e9eff3;
}

:root[data-theme="light"] .preview-loading {
  background: rgba(244, 247, 251, 0.95);
}

@media (max-width: 1260px) {
  .receipt-workspace {
    grid-template-columns: 230px minmax(420px, 1fr) 326px;
    padding-inline: 12px;
  }

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

  .template-thumb {
    height: 112px;
  }
}

@media (max-width: 1040px) {
  .receipt-workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .editor-sidebar {
    grid-column: 1 / -1;
    max-height: none;
    min-height: 0;
  }

  .field-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 460px;
  }
}

@media (max-width: 720px) {
  .receipt-workspace {
    grid-template-columns: 1fr;
  }

  .template-sidebar,
  .editor-sidebar {
    max-height: none;
    min-height: 0;
  }

  .template-sidebar,
  .preview-panel,
  .editor-sidebar {
    grid-column: auto;
  }

  .template-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 420px;
  }

  .preview-shell {
    min-height: 540px;
  }

  .preview-foot {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-list {
    grid-template-columns: 1fr;
  }
}
