:root {
  --bg: #18130F;
  --surface: #221C16;
  --ticket-bg: #1C160F;
  --ink: #F3ECE1;
  --ink-muted: #9C9184;
  --line: #3D352B;
  --accent: #3D7AF5;
  --accent-soft: #1C2A40;
  --danger: #FF8A65;
  --danger-soft: #3B2419;

  --font-display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Sem isso, o Chromium renderiza <select>/popups, setas de <input
     type="number">, checkboxes desmarcados e a scrollbar com o tema claro
     padrão do sistema, mesmo com as cores acima todas escuras. */
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

/* Scrollbar (Chromium/Electron) seguindo a paleta do app */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- Tela de senha ---------- */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-box {
  width: 100%;
  max-width: 380px;
  padding: 32px;
}
.login-logo {
  display: block;
  height: 32px;
  margin: 0 auto 28px;
}
.login-form h1 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 8px;
  text-align: center;
}
.login-form .hint {
  text-align: center;
  margin-bottom: 20px;
}
.login-erro {
  color: var(--danger);
  font-size: 12.5px;
  min-height: 16px;
  margin: -6px 0 10px;
  text-align: center;
}
button.full { width: 100%; }

/* ---------- Editor do site ---------- */
.preset-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.preset-item:last-child { border-bottom: none; }
.preset-item .muted {
  display: block;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  margin-top: 2px;
}
.edit-box {
  background: var(--bg);
  border-radius: 8px;
  padding: 14px;
  margin: 0 0 10px;
}
.banner-item { margin-bottom: 14px; }
.banner-item:last-child { margin-bottom: 0; }

.thumb {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover;
  background: var(--bg); flex-shrink: 0;
}
.thumb-grande {
  width: 100%; max-width: 160px; height: 90px; border-radius: 8px;
  object-fit: cover; background: var(--bg); display: block;
}

.galeria-fotos {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px;
}
.galeria-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg); border-radius: 8px; padding: 8px; width: 100px;
}
.galeria-item img {
  width: 84px; height: 84px; object-fit: cover; border-radius: 6px;
}

/* ---------- Header / Tabs ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 22px 28px 0;
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
}

.brand-icon {
  display: block;
  height: 28px;
  width: auto;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.brand-mark sup {
  font-size: 0.5em;
}

.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.brand-sub {
  font-size: 13px;
  color: var(--ink-muted);
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px 20px 10px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--bg);
  color: var(--ink-muted);
  cursor: pointer;
  position: relative;
  top: 1px;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  border-bottom: 1px solid var(--surface);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  overflow: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 32px 28px 24px;
}

.panel { display: none; }
.panel.active { display: block; animation: fade-in 0.18s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .panel.active { animation: none; }
}

.panel-head h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.subtitle {
  color: var(--ink-muted);
  font-size: 14px;
  margin: 0 0 26px;
  max-width: 62ch;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  align-items: start;
}

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

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  margin-bottom: 20px;
}

.grid .card { margin-bottom: 0; }

.card h2 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0 0 18px;
  color: var(--ink);
}

/* "Ticket" results card with a perforated top edge */
.ticket {
  background: var(--ticket-bg);
  position: relative;
  padding-top: 30px;
  overflow: hidden;
}

.ticket::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 16px;
  background-image: radial-gradient(circle at center, var(--surface) 0 4px, transparent 4.5px);
  background-size: 16px 16px;
  background-position: 0 4px;
}

.ticket h2 { color: var(--accent); }

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-row {
  display: flex;
  gap: 14px;
}

.field-row .field { flex: 1; }

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.field-checkbox span {
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
}

input, select {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

input[readonly] {
  background: var(--bg);
  color: var(--ink-muted);
}

.hint {
  font-size: 12px;
  color: var(--ink-muted);
  margin: -4px 0 14px;
  line-height: 1.5;
}

/* ---------- Buttons ---------- */
button {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

button.primary:hover { background: var(--accent); border-color: var(--accent); }

button.ghost:hover { background: var(--bg); }

button.small { padding: 6px 12px; font-size: 12px; }

button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- Results ---------- */
.result-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
}

.result-line span {
  font-size: 13px;
  color: var(--ink-muted);
}

.result-line strong {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}

.result-line.highlight strong { font-size: 18px; }
.result-line.highlight.accent strong { color: var(--accent); }

/* Percentagem de margem ao lado dos valores de venda nos cards de Resultado */
.result-pct {
  font-size: 11px;
  color: var(--ink-muted);
  margin-left: 6px;
  white-space: nowrap;
}
.result-line.accent .result-pct { color: var(--accent); opacity: 0.75; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 10px 0 12px;
}

/* ---------- Tabela de tamanhos de rolo (Bobina) ---------- */
.size-card { margin-top: 20px; }

.size-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.size-head h2 { margin: 0; }

.size-input {
  flex: 0 0 260px;
  margin-bottom: 0;
}

.size-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

.size-table th {
  text-align: right;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.size-table th:first-child { text-align: left; }

.size-table td {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.size-table td:first-child {
  text-align: left;
  font-family: var(--font-body);
  font-weight: 700;
}

.size-table tr:last-child td { border-bottom: none; }

.size-table td.accent { color: var(--accent); font-weight: 700; }
.size-table td.muted-pct { color: var(--ink-muted); font-size: 12px; }

/* ---------- Cadastro ---------- */
.config-card { margin-bottom: 24px; }

.preset-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.preset-item strong { display: block; font-size: 14px; }

.preset-item .muted {
  display: block;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  margin-top: 2px;
}

.preset-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- Pedido summary box ---------- */
.preset-summary {
  margin-top: 16px;
  padding: 14px;
  background: var(--bg);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.8;
}

.preset-summary strong { color: var(--ink); }

/* ---------- Footer ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 28px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.accordion-head { cursor: pointer; user-select: none; }
.chevron {
  font-size: 16px;
  color: var(--ink-muted);
  transition: transform .2s;
  display: inline-block;
}
.chevron.open { transform: rotate(180deg); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 54px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.toast.show { opacity: 1; }

/* ============================================================
   TEMA CLARO
   Vale quando <html> tem data-tema="claro". As mesmas variáveis,
   outros valores — nenhuma regra abaixo precisou mudar.
   ============================================================ */
html[data-tema="claro"] {
  --bg: #F5F2ED;
  --surface: #FFFFFF;
  --ticket-bg: #FAF8F4;
  --ink: #1F1A14;
  --ink-muted: #6B6055;
  --line: #DCD5CA;
  --accent: #1F5FD8;
  --accent-soft: #E3ECFC;
  --danger: #C2410C;
  --danger-soft: #FCEAE0;

  color-scheme: light;
}

/* No claro, o contorno dos cartões some no fundo branco: uma sombra
   discreta devolve a separação que a borda dava no escuro. */
html[data-tema="claro"] .card,
html[data-tema="claro"] .login-box {
  box-shadow: 0 1px 3px rgba(31, 26, 20, .08);
}

html[data-tema="claro"] .topbar {
  box-shadow: 0 1px 2px rgba(31, 26, 20, .06);
}

/* Botão de trocar o tema */
.tema-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}
.tema-btn:hover {
  color: var(--ink);
  border-color: var(--ink-muted);
}
