* {
  box-sizing: border-box;
}

:root {
  --ink: #0d0d0d;
  --paper: #ffffff;
  --line: #e2e2e2;
  --muted: #6b6b6b;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --ok: #1a7f37;
  --warn: #b8720b;
  --warn-bg: #fff4e5;
  --panel-bg: #ffffff;
  --bg: #f4f4f2;
  --accent-bg: #f7f7f5;
}

body {
  margin: 0;
  font-family: 'Montserrat', -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* --- header --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar__logo {
  height: 28px;
  width: auto;
  display: block;
}

.topbar__titles h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar__sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar__printer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

/* --- layout --- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr 320px;
  gap: 16px;
  align-items: start;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-wrap: wrap;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.panel__title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* --- estado de edição --- */
.editing-state {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.editing-state--new {
  background: var(--accent-bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

.editing-state--editing {
  background: #eef6ee;
  color: var(--ok);
  border: 1px solid #bfe3bf;
}

/* --- formulário --- */
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 18px;
}

fieldset legend {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  padding: 0 0 8px;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
}

.field input {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  font-family: inherit;
}

.field input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.field-status {
  margin: -6px 0 10px;
  font-size: 12px;
}

.field-status--ok {
  color: var(--ok);
}

.field-status--error {
  color: var(--danger);
}

.warnings {
  background: var(--warn-bg);
  border: 1px solid #f0b429;
  color: #7a4b00;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  margin-bottom: 16px;
}

.save-box {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.save-box__actions {
  display: flex;
  gap: 8px;
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 7px;
  border: 1px solid #cfcfcf;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition: filter 0.1s ease;
}

button.primary {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
  flex: 1;
}

button:hover {
  filter: brightness(0.96);
}

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

/* --- prévia --- */
.panel--preview {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview__callout {
  margin: -4px 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--accent-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
}

.preview__meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* --- etiquetas salvas --- */
.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 10px;
  font-family: inherit;
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.saved-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  flex-wrap: wrap;
}

.saved-list__item--active {
  border-color: var(--ink);
  background: var(--accent-bg);
}

.saved-list__item--seed {
  background: #fbfbf9;
}

.saved-list__main {
  flex: 1;
  min-width: 100px;
  text-align: left;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.saved-list__main strong {
  font-size: 13px;
}

.saved-list__main span {
  font-size: 11px;
  color: var(--muted);
}

.saved-list__actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.saved-list__action-btn {
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.saved-list__action-btn--danger {
  color: var(--danger);
  border-color: #e8c6c1;
}

.saved-list__action-btn--danger:hover {
  background: var(--danger-bg);
}

.saved-list__empty {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 0;
}

/* --- separação das etiquetas de exemplo/onboarding --- */
.saved-seed-wrap {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.saved-seed-wrap__title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.saved-list--seed .saved-list__item {
  border-style: dashed;
}

/* --- impressão --- */
.printer-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 20px;
}

.printer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}

.printer-row__name {
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

.status-dot--checking {
  background: #b0b0b0;
}

.status-dot--ok {
  background: var(--ok);
}

.status-dot--error {
  background: var(--danger);
}

.status-dot--unavailable {
  background: var(--warn);
}

.printer-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}

.printer-qty label {
  color: var(--muted);
}

.printer-qty input {
  width: 70px;
  padding: 7px 8px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
}

.printer-qty input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.printer-actions {
  display: flex;
  flex-wrap: wrap; /* com 3 botões a linha estourava em telas estreitas (<600px) */
  gap: 8px;
  margin-bottom: 10px;
}

.printer-actions button {
  flex: none;
}

.printer-feedback {
  font-size: 13px;
  margin: 0;
  min-height: 18px;
}

.printer-feedback--info {
  color: var(--muted);
}

.printer-feedback--ok {
  color: var(--ok);
  font-weight: 600;
}

.printer-feedback--error {
  color: var(--danger);
  font-weight: 600;
}

/* --- modal (substitui prompt/confirm/alert do navegador) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 13, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.modal-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 22px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.modal-message {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-input {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  font-family: inherit;
  margin-bottom: 16px;
}

.modal-input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 9px 16px;
}

.modal-btn--primary {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.modal-btn--danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

/* --- toast --- */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 1100;
}

.toast {
  background: var(--ink);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--error {
  background: var(--danger);
}
