* {margin: 0;
  padding: 0;
  box-sizing: border-box;
  text-align: center;
  font-family: Helvetica, Arial, sans-serif;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
}

/* ============================================================
   ESCALA TIPOGRÁFICA
   O reset acima forçava bold + oblique em tudo, o que anulava
   qualquer hierarquia. Aqui o peso volta só onde tem função.
   ============================================================ */
h1, h2, h3, h4, h5, h6 { font-weight: 700; }
strong, b { font-weight: 600; }

.page-title    { font-weight: 700; }
.page-subtitle { font-weight: 400; }
.card-title    { font-weight: 700; }
.field-label   { font-weight: 600; }
.botaomenu     { font-weight: 600; }
.button        { font-weight: 600; }
.encarte-title { font-weight: 600; }
.muted         { font-weight: 500; }
th             { font-weight: 700; }

input, select, textarea, .selecao, .input {
  font-weight: 400;
  font-style: normal;
}
input.precos { font-weight: 600; }

/* Textos corridos ganham entrelinha legível (o reset zera em 1) */
.page-subtitle,
.help-text,
.feedback,
.encarte-meta,
.montagem-flow-step .help-text { line-height: 1.45; }

body {
  background-color:blanchedalmond;
  display: flex;
  flex-direction: column;
  align-items: center;
}

header {
    background-color: #FFB100;
    height: max-content;
    box-shadow: 2px 2px 30px rgb(138, 133, 115);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.menu{
    font-size: 80px;
    display: flex;
    flex-direction: row;
    align-items: center;
}

.botaomenu {
    padding: 32px;
    margin: 64px;
    color: white;
    text-shadow: 3px 3px 5px rgb(72, 55, 0);
    border: 10px double white;
    border-radius: 40px;
}

.main {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 80px;
    margin: 80px;
}

.selecao { 
    font-size: 25px;
    padding: 16px;
    height: 40px;
    background-color: white;
    border-radius: 40px;
    box-shadow:5px 5px 40px rgb(200, 193, 172);
    margin: 32px;
    width: 1040px;
}

.precos {
    width: 160px;
    font-size: 48px;
    height: 80px;
    background-color: white;
    border-radius: 40px;
    box-shadow:5px 5px 40px rgb(200, 193, 172);
    margin: 32px 0px 32px 0px;
}

.button {
    width: max-content;
    height:max-content;
    font-size: 80px;
    padding: 32px;
    margin: 48px;
    background-color: #ffb100;
    border-radius: 40px;
    border: none;
    text-align: center;
    color: white;
    text-shadow: 3px 3px 5px rgb(72, 55, 0);
    border: 10px double white;
}

.imagem {
    margin: 8px 0;
    font-size: 16px;
    background-color: white;
    padding: 12px 16px;
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: auto;
    box-shadow: 5px 5px 40px rgb(200, 193, 172);
}

.tabela {
    display: flex;
    flex-direction: row;
    align-items:first baseline;
    background-color: rgb(255, 255, 255);
}

.elemento {
    padding: 40px 600px 40px 600px;
    display: flex;
    flex-direction: column;
    align-items:first baseline;
}

p {
    font-size: 48px;
}

/* New styles for backend integrated flow */

.card-item, .card-bg {
  position: relative;
  background-color: white;
  border-radius: 20px;
  box-shadow: 3px 3px 15px rgba(0,0,0,0.2);
  overflow: hidden;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 16px;
  margin: 16px;
  width: 250px;
}

.card-item img, .card-bg img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  object-fit: cover;
}

.card-item .name, .card-bg .name {
  margin-top: 12px;
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

.card-item .delete-btn, .card-bg .delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: #ff4d4d;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 1px 1px 5px rgba(0,0,0,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
}

#itemsGrid, #bgGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(250px,1fr));
  gap: 24px;
  padding: 16px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 48px auto;
}

#encarteList {
  list-style: none;
  max-width: 800px;
  margin: 0 auto 48px auto;
  padding: 0;
}

#encarteList li {
  background-color: white;
  border-radius: 12px;
  padding: 12px 24px;
  margin: 12px 0;
  font-size: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
}

#encarteList li button {
  background-color: #ff4d4d;
  border: none;
  color: white;
  font-weight: bold;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 1px 1px 5px rgba(0,0,0,0.3);
}

#preview {
  max-width: 90%;
  height: auto;
  border-radius: 20px;
  box-shadow: 5px 5px 30px rgba(0,0,0,0.3);
  margin: 32px auto;
  display: block;
}

#downloadBtn {
  background-color: #ffb100;
  color: white;
  font-size: 32px;
  font-weight: bolder;
  padding: 16px 48px;
  border-radius: 40px;
  border: none;
  cursor: pointer;
  text-shadow: 3px 3px 5px rgb(72, 55, 0);
  box-shadow: 2px 2px 15px rgba(138, 133, 115, 0.7);
  margin: 24px auto;
  display: block;
}

/* Responsive adjustments */

@media (max-width: 1000px) {
  .selecao, .imagem {
    width: auto;
    max-width: 90%;
  }
}

/* Botão de excluir no card do item */
#items-grid .item {
  position: relative;              /* garante posicionamento do X */
}

#items-grid .item .del {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  width: 24px;
  height: 24px;
  line-height: 24px;
  font-size: 16px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;                      /* fica invisível até o hover */
  transition: opacity .2s ease, transform .1s ease;
}

#items-grid .item:hover .del {
  opacity: 1;                      /* aparece ao passar o mouse */
}

#items-grid .item .del:active {
  transform: scale(0.95);
}

/* se preferir SEM precisar de hover, substitua as duas regras acima por: */
/* #items-grid .item .del { opacity: 1; } */
/* Botão de excluir no card do tema */
#backgrounds-grid .item {
  position: relative;
}
#backgrounds-grid .item .del {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  width: 24px;
  height: 24px;
  line-height: 24px;
  font-size: 16px;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s ease, transform .1s ease;
}
#backgrounds-grid .item:hover .del { opacity: 1; }
#backgrounds-grid .item .del:active { transform: scale(0.95); }
/* Se quiser sempre visível: */
/* #backgrounds-grid .item .del { opacity: 1; } */

/* ==========================
   Styles for item list view
   (search bar, list layout, miniaturas, botao excluir)
   ==========================
*/

/* Visually hidden (accessible) label */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: visible;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Search container (above the list) */
.search-container {
  max-width: 1200px;
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
}

#item-search, .selecao.search {
  flex: 1 1 auto;
  min-width: 220px;
  max-width: 100%;
  height: 56px;
  font-size: 20px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid rgba(0,0,0,0.06);
  background: #fff;
  box-shadow: 2px 2px 18px rgba(0,0,0,0.06);
  text-align: left;
}

#search-clear {
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
}

/* Lista de itens */
#items-list {
  max-width: 1200px;
  margin: 0 auto 48px auto;
  padding: 0 16px;
}

#items-list li.item-row,
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 2px 2px 12px rgba(0,0,0,0.06);
}

#items-list li.item-row .item-left,
.item-row .item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.item-thumbnail {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 56px;
  background: linear-gradient(180deg,#f6f6f6,#e9e9e9);
}

.item-name {
  font-size: 20px;
  font-weight: 700;
  color: #222;
}

button.delete-item {
  background: #ff4d4d;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 1px 1px 8px rgba(0,0,0,0.12);
}

#items-list li.vazio {
  padding: 18px;
  text-align: center;
  color: #666;
  background: transparent;
  box-shadow: none;
}

/* Pequenas melhorias responsivas */
@media (max-width: 700px) {
  .search-container { padding: 0 12px; gap: 8px; }
  #item-search { height: 48px; font-size: 16px; }
  .item-thumbnail { width: 48px; height: 48px; }
  .item-name { font-size: 18px; }
  button.delete-item { padding: 6px 10px; font-size: 14px; }
  .montagem-flow-step,
  .montagem-final-summary-item,
  .montagem-setup-col {
    padding: 14px;
  }
}

/* Força que itens antigos em #items-grid não quebrem layout ao coexistir */
#items-grid, #bgGrid { display: none; }

/* ==========================
   Meus Encartes (menuEncartes.html)
   ========================== */

.encartes-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.encartes-toolbar-main {
  display: grid;
  grid-template-columns: minmax(320px, 1.8fr) minmax(220px, 1fr);
  gap: 14px;
  flex: 1 1 720px;
}

.encartes-toolbar .field {
  min-width: 0;
}

.encartes-toolbar .input,
.encartes-toolbar .selecao {
  width: 100%;
  height: 54px;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  background: #fff;
  text-align: left;
  outline: none;
}

.encartes-toolbar .input::placeholder {
  color: rgba(29,29,31,0.42);
}

.encartes-toolbar .input:focus,
.encartes-toolbar .selecao:focus {
  border-color: rgba(255,177,0,0.65);
  box-shadow: 0 0 0 4px rgba(255,177,0,0.14), 0 8px 20px rgba(0,0,0,0.06);
}

.encartes-toolbar-actions {
  display: flex;
  align-items: end;
  flex: 0 0 auto;
}

.encartes-toolbar-actions .button {
  min-height: 54px;
  white-space: nowrap;
}

.encartes-list-wrap {
  width: 100%;
}

.encartes-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- Estados da lista: vazio, carregando, erro ---- */
.list-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 24px;
  border-radius: 16px;
  border: 1px dashed rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.5);
  text-align: center;
}
.list-state__icon {
  font-size: 30px;
  line-height: 1;
  opacity: 0.55;
}
.list-state__title {
  font-size: 17px;
  font-weight: 600;
  color: rgba(29,29,31,0.82);
}
.list-state__body {
  font-size: 14px;
  line-height: 1.45;
  color: rgba(29,29,31,0.55);
  max-width: 42ch;
}
.list-state .button { margin-top: 4px; }

.list-state--error {
  border-color: rgba(150,40,26,0.28);
  border-style: solid;
  background: rgba(255,246,244,0.9);
}
.list-state--error .list-state__title { color: #96281A; }

/* Esqueleto de carregamento */
.skeleton-row {
  height: 92px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  background: linear-gradient(
    100deg,
    rgba(255,255,255,0.55) 30%,
    rgba(255,255,255,0.9) 50%,
    rgba(255,255,255,0.55) 70%
  );
  background-size: 220% 100%;
  animation: skeleton-slide 1.15s ease-in-out infinite;
}
@keyframes skeleton-slide {
  from { background-position: 180% 0; }
  to   { background-position: -40% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
}

.encarte-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}

.encarte-card-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.encarte-thumb {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  flex: 0 0 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255,177,0,0.22), rgba(255,255,255,0.95));
  border: 1px solid rgba(255,177,0,0.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}

.encarte-thumb-label {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  color: rgba(72,55,0,0.85);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.encarte-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.encarte-info-top {
  min-width: 0;
}

.encarte-title {
  font-size: 22px;
  line-height: 1.15;
  color: #1d1d1f;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.encarte-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  font-size: 14px;
  color: rgba(29,29,31,0.62);
  padding: 0;
}

.encarte-meta-item {
  text-align: left;
}

.encarte-meta-item strong {
  color: rgba(29,29,31,0.85);
}

.encarte-meta-sep {
  color: rgba(29,29,31,0.32);
}

.encarte-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.encarte-actions .button {
  min-height: 44px;
  padding: 12px 14px;
}

.button.button-small {
  font-size: 15px;
  padding: 9px 14px;
  border-radius: 10px;
}

/* ---- Hierarquia de ações ----------------------------------
   primária  = .button          (sólida, ação principal)
   secundária= .button-secondary (contorno, ações de apoio)
   destrutiva= .button-danger    (discreta até o hover)
   ------------------------------------------------------- */
.button.button-secondary {
  background: #fff;
  color: rgba(29,29,31,0.78);
  border: 1px solid rgba(0,0,0,0.14);
  text-shadow: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.button.button-secondary:hover {
  background: #fffdf8;
  border-color: rgba(0,0,0,0.24);
  color: #1d1d1f;
}

.button.button-danger {
  background: #fff;
  color: rgba(150, 40, 26, 0.85);
  border: 1px solid rgba(150, 40, 26, 0.22);
  text-shadow: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.button.button-danger:hover {
  background: #B4331F;
  border-color: #B4331F;
  color: #fff;
}

/* Botão só-ícone (excluir) */
.button.button-icon {
  width: 38px;
  padding: 0;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  line-height: 1;
}

@media (max-width: 900px) {
  .encartes-toolbar-main {
    grid-template-columns: 1fr;
  }

  .encarte-card {
    flex-direction: column;
    align-items: stretch;
  }

  .encarte-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .encarte-actions .button {
    flex: 1 1 160px;
  }
  .encarte-actions .button.button-icon {
    flex: 0 0 38px;
  }
    .price-inputs {
    flex-wrap: wrap;
  }

  input.precos {
    width: 84px;
  }
}

@media (max-width: 700px) {
  .encarte-card {
    padding: 12px;
    border-radius: 16px;
  }

  .encarte-thumb {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
    border-radius: 14px;
  }

  .encarte-title {
    font-size: 18px;
  }

  .encarte-meta {
    font-size: 13px;
  }
}

/* ==========================
   Layout novo: Criar Encarte (montagemEncarte.html)
   - deixa mais "sistema", organizado e moderno
   - mantém identidade (amarelo Rede Sol)
   ========================== */

:root {
  --brand: #FFB100;
  --ink: #1d1d1f;
  --muted: rgba(29,29,31,0.65);
  --card: rgba(255,255,255,0.88);
  --stroke: rgba(0,0,0,0.08);
  --shadow: 0 12px 30px rgba(0,0,0,0.12);
  --shadow-soft: 0 10px 24px rgba(0,0,0,0.08);
  --radius: 22px;
}

body {
  background: radial-gradient(circle at 20% 0%, rgba(255,177,0,0.18), transparent 35%),
              radial-gradient(circle at 80% 20%, rgba(255,177,0,0.14), transparent 40%),
              #f7eedc;
}

/* Topbar */
header.topbar {
  background-color: var(--brand);
  width: 100%;
  box-shadow: 0 10px 30px rgba(138, 133, 115, 0.45);
}

header.topbar .menu {
  gap: 2px;
  padding: 0 16px;
  max-width: 1200px;
  width: 100%;
  justify-content: flex-start;
  font-size: 15px;
}

header.topbar .botaomenu {
  margin: 0;
  padding: 15px 16px;
  border: none;
  border-radius: 0;
  text-shadow: none;
  color: rgba(72, 55, 0, 0.72);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  transition: color .12s ease, background-color .12s ease;
}

header.topbar .botaomenu:hover {
  color: rgba(72, 55, 0, 1);
  background: rgba(255, 255, 255, 0.22);
}

/* Item ativo: sublinhado sólido, sem caixa */
header.topbar .botaomenu[aria-current="page"] {
  color: #4a3700;
  font-weight: 700;
  background: transparent;
  box-shadow: none;
}
header.topbar .botaomenu[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 0;
  height: 3px;
  background: #4a3700;
  border-radius: 2px 2px 0 0;
}

/* "Sair" (injetado pelo auth.js) vai para a direita, discreto */
header.topbar .botaomenu.btn-logout {
  margin-left: auto;
  color: rgba(72, 55, 0, 0.55) !important;
  border: none !important;
  background: transparent !important;
  font-weight: 500;
}
header.topbar .botaomenu.btn-logout:hover {
  color: rgba(72, 55, 0, 0.95) !important;
  background: rgba(255, 255, 255, 0.22) !important;
}

/* Main container */
main.main {
  width: 100%;
  margin: 34px auto 70px auto;
  padding: 0 18px;
  font-size: 22px; /* override do antigo 80px */
}

.page-header {
  width: 100%;
  text-align: left;
  margin: 10px 0 22px 0;
}

.page-title {
  text-align: left;
  font-size: 40px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-subtitle {
  text-align: left;
  font-size: 18px;
  padding: 0;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.35;
}

/* Cards */
.card {
  position: relative;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: visible;
  margin: 6px 0;
}

.card[aria-labelledby="step-2-title"] {
  z-index: 30;
}

.card[aria-labelledby="step-3-title"] {
  z-index: 10;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 0 18px;
}

.step-pill {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,177,0,0.22);
  border: 1px solid rgba(255,177,0,0.35);
  color: rgba(72,55,0,0.95);
  font-weight: 900;
  font-size: 18px;
  text-shadow: none;
}

.card-title {
  text-align: left;
  font-size: 24px;
  color: var(--ink);
}

.card-content {
  position: relative;
  overflow: visible;
  padding: 9px;
}

.field-label {
  display: block;
  text-align: left;
  font-weight: 800;
  color: rgba(29,29,31,0.85);
  margin: 6px 0 8px 0;
  font-size: 16px;
}

.help-text {
  text-align: left;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  padding: 0;
}

.muted {
  color: rgba(29,29,31,0.55);
  font-weight: 700;
  font-size: 14px;
}

/* Selects */
select.selecao {
  width: 100%;
  max-width: 100%;
  height: 54px;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  margin: 0;
  text-align: left;
}

/* ==========================
   Blocos auxiliares da montagem
   ========================== */

.montagem-intro,
.montagem-flow-note,
.montagem-final-note,
.montagem-line-editor-head {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.58);
  border: 1px solid rgba(0,0,0,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55);
}

.montagem-intro .help-text,
.montagem-flow-note .help-text,
.montagem-final-note .help-text,
.montagem-line-editor-head .help-text {
  margin-top: 0;
}

.montagem-setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

.montagem-setup-col {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.68);
  box-shadow: 0 10px 24px rgba(0,0,0,0.05);
}

.montagem-setup-col .field-label {
  margin-top: 0;
}

.montagem-setup-col .selecao {
  width: 100%;
  margin: 0;
}

#encarte-name {
  width: 100%;
  height: 54px;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  background: #fff;
  text-align: left;
  outline: none;
}

#encarte-name::placeholder {
  color: rgba(29,29,31,0.42);
}

#encarte-name:focus {
  border-color: rgba(255,177,0,0.65);
  box-shadow: 0 0 0 4px rgba(255,177,0,0.14), 0 8px 20px rgba(0,0,0,0.06);
}

.montagem-flow-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.montagem-flow-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 10px 24px rgba(0,0,0,0.05);
}

.montagem-flow-step .step-pill {
  flex: 0 0 34px;
}

.montagem-flow-step strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
  color: #1d1d1f;
  text-align: left;
}

.montagem-flow-step .help-text {
  margin-top: 6px;
}

.montagem-lines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 8px 0;
}

.montagem-lines-header .card-title {
  margin: 0;
}

.montagem-final-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.montagem-final-summary-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 10px 24px rgba(0,0,0,0.05);
}

.montagem-final-summary-item strong,
.montagem-final-summary-item span {
  text-align: left;
}

.montagem-final-summary-item strong {
  font-size: 15px;
  color: rgba(29,29,31,0.85);
}

.montagem-final-summary-item span {
  font-size: 14px;
  color: rgba(29,29,31,0.60);
  line-height: 1.35;
}

/* ==========================
   Linha do encarte: layout em tabela
   ========================== */

.linha-tabela {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.linha-tabela-head {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  font-size: 13px;
  color: rgba(29,29,31,0.55);
  text-align: left;
}

.linha-tabela-head span {
  text-align: left;
}

.linha-tabela-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 18px;
  background: rgba(255,255,255,0.72);
  box-shadow: 0 10px 24px rgba(0,0,0,0.05);
  overflow: visible;
}

.linha-tabela-cell {
  min-width: 0;
}

.linha-tabela-item .selecao {
  width: 100%;
  margin: 0;
}

.item-picker {
  position: relative;
  width: 100%;
  z-index: 80;
}

.item-picker-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 8px;
}

.item-picker-input {
  width: 100%;
  height: 54px;
  font-size: 18px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  background: #fff;
  text-align: left;
  outline: none;
}

.item-picker-input::placeholder {
  color: rgba(29,29,31,0.42);
}

.item-picker-input:focus {
  border-color: rgba(255,177,0,0.65);
  box-shadow: 0 0 0 4px rgba(255,177,0,0.14), 0 8px 20px rgba(0,0,0,0.06);
}

.item-picker-toggle {
  width: 46px;
  height: 54px;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.item-picker.is-open .item-picker-toggle {
  border-color: rgba(255,177,0,0.65);
}

.item-picker-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 120;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.96);
  box-shadow: 0 18px 40px rgba(0,0,0,0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.item-picker-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
  
}

.item-picker-option {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  cursor: pointer;
}

.item-picker-option:hover,
.item-picker-option.is-active {
  border-color: rgba(255,177,0,0.4);
  background: rgba(255,177,0,0.15);
  outline: 2px solid rgba(255,177,0,0.5);
}

.item-picker-option-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  background: linear-gradient(180deg,#f6f6f6,#e9e9e9);
  border: 1px solid rgba(0,0,0,0.05);
}

.item-picker-option-name {
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  color: #1d1d1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-picker-empty {
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.72);
  color: rgba(29,29,31,0.55);
  font-size: 14px;
  text-align: left;
}

.linha-tabela-price {
  display: flex;
  align-items: center;
}

.linha-tabela-action {
  display: flex;
  justify-content: flex-end;
}

.linha-tabela-action .button {
  min-width: 120px;
  white-space: nowrap;
}

.linha-itens-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.linha-itens-preview-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 2fr) minmax(110px, 1fr) minmax(110px, 1fr) auto;
  gap: 12px;
  padding: 0 6px;
  font-size: 13px;
  color: rgba(29,29,31,0.55);
}

.linha-itens-preview-head span {
  text-align: left;
}

.linha-itens-preview-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.linha-item-row {
  display: grid;
  grid-template-columns: auto 72px minmax(0, 2fr) minmax(110px, 1fr) minmax(110px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 18px;
  background: rgba(255,255,255,0.62);
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.linha-item-cell {
  min-width: 0;
  text-align: left;
}

.linha-item-thumb-cell {
  display: flex;
  align-items: center;
}

.linha-item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  background: linear-gradient(180deg,#f6f6f6,#e9e9e9);
  border: 1px solid rgba(0,0,0,0.05);
}

.linha-item-desc {
  font-size: 16px;
  font-weight: 700;
  color: #1d1d1f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linha-item-price {
  font-size: 15px;
  color: rgba(29,29,31,0.82);
}

.linha-item-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.linha-item-actions button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.88);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.linha-item-actions button:hover {
  transform: translateY(-1px);
}

.linha-item-actions button[data-action="item-remove"] {
  color: #b42318;
  border-color: rgba(180,35,24,0.18);
  background: rgba(255,240,239,0.95);
}

details.linha {
  border: none;
  background: transparent;
}

summary.linha-summary {
  list-style: none;
  cursor: pointer;
}

summary.linha-summary::-webkit-details-marker {
  display: none;
}

@media (max-width: 900px) {
  .linha-tabela-head {
    display: none;
  }

  .linha-tabela-row {
    grid-template-columns: 1fr;
  }

  .linha-tabela-action {
    justify-content: flex-start;
  }

  .linha-tabela-action .button {
    width: 100%;
  }
  .linha-itens-preview-head {
    display: none;
  }

  .linha-item-row {
    grid-template-columns: 56px 1fr;
    gap: 10px;
  }

  .linha-item-thumb-cell {
    grid-row: span 2;
  }

  .linha-item-price {
    font-size: 14px;
  }

  .linha-item-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: 4px;
  }

  .item-picker-control {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .item-picker-toggle {
    width: 42px;
    height: 52px;
  }

  .item-picker-panel {
    position: static;
    margin-top: 8px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  }
}

/* Prices */
.price-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.price-block {
  padding: 12px 12px;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 16px;
  background: rgba(255,255,255,0.70);
}

.price-inputs {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: nowrap;
}

.price-sep {
  font-weight: 900;
  color: rgba(29,29,31,0.75);
}

input.precos {
  width: 72px;
  height: 52px;
  font-size: 18px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 8px 20px rgba(0,0,0,0.06);
  margin: 0;
  text-align: center;
  background: #fff;
  outline: none;
}

input.precos:focus {
  border-color: rgba(255,177,0,0.65);
  box-shadow: 0 0 0 4px rgba(255,177,0,0.14), 0 8px 20px rgba(0,0,0,0.06);
}

/* Linha de ações */
.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 8px;
}

button.button {
  font-size: 20px;
  padding: 14px 18px;
  margin: 0;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.65);
  background: linear-gradient(180deg, rgba(255,177,0,1), rgba(231,103,0,0.95));
  box-shadow: 0 10px 22px rgba(72,55,0,0.18);
  transition: transform .12s ease, box-shadow .12s ease;
}

button.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(72,55,0,0.22);
}

button.button:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(72,55,0,0.18);
}

.feedback {
  text-align: left;
  margin-top: 10px;
  font-size: 14px;
  color: rgba(29,29,31,0.75);
}

/* Container de linhas (vai receber conteúdo via JS) */
.linhas-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

/* Responsivo */
@media (max-width: 900px) {
  header.topbar .menu { font-size: 20px; flex-wrap: wrap; }
  .page-title { font-size: 30px; }
  .price-grid { grid-template-columns: 1fr; }
    .montagem-setup,
  .montagem-flow-steps,
  .montagem-final-summary {
    grid-template-columns: 1fr;
  }
  .montagem-lines-header {
    align-items: flex-start;
  }

  .item-picker-input {
    font-size: 16px;
  }
}

.linha-updated {
  outline: 2px solid rgba(255,177,0,0.55);
  box-shadow: 0 0 0 6px rgba(255,177,0,0.12);
  border-radius: 18px;
  transition: box-shadow 0.2s ease, outline 0.2s ease;
}

/* ---- Drag and drop de itens ---- */
.drag-handle {
  cursor: grab;
  color: #bbb;
  font-size: 20px;
  padding: 0 8px;
  user-select: none;
  flex-shrink: 0;
  line-height: 1;
}
.drag-handle:active { cursor: grabbing; }

.linha-item-row.is-dragging { opacity: 0.3; }

.drag-indicator {
  height: 3px;
  background: #4285f4;
  border-radius: 2px;
  margin: 1px 4px;
  pointer-events: none;
}

.linha-itens-preview-body.drag-active {
  background: rgba(66, 133, 244, 0.06);
  border-radius: 8px;
  outline: 2px dashed rgba(66, 133, 244, 0.4);
}
/* ============================================================
   MOBILE — melhorias gerais de UX (max-width: 600px)
   ============================================================ */

@media (max-width: 600px) {

  /* Topbar nav: quebra linha, fonte menor, padding menor */
  header.topbar .menu {
    font-size: 14px !important;
    flex-wrap: wrap;
    gap: 4px !important;
    padding: 8px 10px !important;
    justify-content: flex-start;
  }

  header.topbar .botaomenu {
    padding: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    border-width: 1.5px !important;
  }

  /* Cards e formulários */
  .card-header  { padding: 14px 14px 0 !important; }
  .card-content { padding: 10px 14px 14px !important; }
  .card-title   { font-size: 18px !important; }

  .page-title    { font-size: 26px !important; }
  .page-subtitle { font-size: 15px !important; }

  /* Inputs e selects */
  select.selecao,
  input.selecao,
  #encarte-name,
  .item-picker-input {
    height: 48px !important;
    font-size: 16px !important;
  }

  /* Botões de ação */
  button.button, a.button {
    font-size: 15px !important;
    padding: 12px 14px !important;
  }

  /* Meus Encartes: toolbar empilha */
  .encartes-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .encartes-toolbar-main {
    grid-template-columns: 1fr !important;
    /* o flex-basis de 720px vira ALTURA quando a toolbar empilha em
       coluna — sem isso abre um vão enorme entre "Buscar" e "Fundo" */
    flex: 0 0 auto !important;
  }
  .encartes-toolbar-actions {
    width: 100%;
  }
  .encartes-toolbar-actions .button {
    width: 100%;
  }

  /* Card de encarte: mais compacto */
  .encarte-card { padding: 10px !important; gap: 10px !important; }
  .encarte-title { font-size: 16px !important; }
  .encarte-thumb { width: 48px !important; height: 48px !important; flex-basis: 48px !important; }
  .encarte-actions { flex-wrap: wrap; gap: 6px !important; }
  .encarte-actions .button { flex: 1 1 auto; min-width: 0; font-size: 13px !important; padding: 9px 8px !important; }
  .encarte-actions .button.button-icon { flex: 0 0 34px !important; width: 34px; padding: 0 !important; font-size: 16px !important; }

  /* Cadastro: grid de items em coluna única */
  #itemsGrid, #bgGrid { grid-template-columns: 1fr !important; }

  /* Preços: inputs menores */
  input.precos {
    width: 60px !important;
    height: 44px !important;
    font-size: 16px !important;
  }

  /* Montagem: o posicionamento da linha do item é definido no
     montagemEncarte.html, que coloca alça, miniatura, nome, preços e
     ações em colunas explícitas. Aqui só o que não conflita. */
  .linha-item-thumb { width: 44px !important; height: 44px !important; }
  .linha-itens-preview-head { display: none !important; }

  /* item picker panel: estático (não absoluto) para não sair da tela */
  .item-picker-panel {
    position: static !important;
    margin-top: 6px;
  }
}

/* ============================================================
   MOBILE — Editor de Encarte (montagemEncarte.html)
   Abas no topo para alternar entre formulário e preview
   ============================================================ */

@media (max-width: 700px) {

  /* Empilha sidebar + canvas */
  .editor-wrapper {
    flex-direction: column !important;
    overflow: visible !important;
  }

  .editor-sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 2px solid #dedad2;
    overflow: visible !important;
    max-height: none !important;
  }

  .editor-canvas-wrap {
    width: 100% !important;
    min-height: 320px;
  }

  .editor-canvas {
    padding: 16px 8px 32px !important;
  }

  /* iframe do preview: escala menor para caber */
  .encarte-canvas-frame {
    max-width: 100%;
    overflow: hidden;
  }
}

/* ============================================================
   MOBILE — Toolbar do encarte-template.html
   ============================================================ */

@media (max-width: 700px) {
  .export-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 8px !important;
    padding: 8px 12px !important;
  }

  .export-toolbar .btn-toolbar,
  .export-toolbar button.btn-toolbar {
    font-size: 12px !important;
    padding: 6px 10px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .export-title { display: none; }
}

/* ============================================================
   MOBILE — Importar planilha
   ============================================================ */

@media (max-width: 600px) {
  /* Tabela de preview: scroll horizontal */
  .linha-block { overflow-x: auto; }
  table { min-width: 520px; }

  /* Upload area menor */
  .upload-area { padding: 20px 14px !important; }

  /* Config row em coluna */
  .config-row { flex-direction: column !important; }
}
