:root {
  --brand: #d94f30;
  --brand-dark: #b83c22;
  --brand-light: #fdece6;
  --ink: #2a2420;
  --ink-soft: #6b6058;
  --paper: #ffffff;
  --bg: #f6f1ec;
  --line: #e7ddd3;
  --danger: #c0392b;
  --ok: #2e7d4f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

/* Sidebar */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.brand-icon { font-size: 26px; }
.brand-name { font-size: 18px; font-weight: 700; color: var(--brand-dark); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px;
  flex: 1;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-size: 14.5px;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--brand-light); }
.nav-btn.active { background: var(--brand); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 12px 20px 0 20px;
  font-size: 11px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

/* Content */
.content {
  flex: 1;
  padding: 28px 34px;
  overflow-y: auto;
  max-height: 100vh;
}

.view h1 {
  margin: 0 0 4px 0;
  font-size: 22px;
}
.view .subtitle {
  color: var(--ink-soft);
  margin: 0 0 22px 0;
  font-size: 13.5px;
}

/* Celular/tela estreita: barra lateral vira topo horizontal em vez de coluna fixa */
@media (max-width: 680px) {
  .app { flex-direction: column; min-height: auto; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
  }
  .brand { padding: 0 14px 10px 14px; margin-bottom: 8px; }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0 8px;
  }
  .nav-btn {
    width: auto;
    padding: 8px 12px;
    font-size: 13px;
  }
  .sidebar-footer { display: none; }
  .content { padding: 16px; max-height: none; overflow-y: visible; }
}

/* Layout helpers */
.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
}
.card h2 {
  font-size: 15px;
  margin: 0 0 16px 0;
  color: var(--brand-dark);
}

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fffdfb;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.row { display: flex; gap: 12px; }
.row > .field { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.secondary:hover { background: var(--brand-light); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #96281c; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tr:hover td { background: var(--brand-light); }
.actions-cell { display: flex; gap: 6px; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand-dark);
}
.badge.expired { background: #fbe3e0; color: var(--danger); }
.badge.soon { background: #fdf1d6; color: #9a6c00; }
.badge.ok { background: #e2f3e8; color: var(--ok); }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  z-index: 999;
  animation: fadein .15s ease-out;
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters .field { margin-bottom: 0; min-width: 160px; }

/* ---------------- Label preview (on-screen) ---------------- */
.label-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.label-sheet {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.06);
  position: relative;
  overflow: hidden;
  container-type: size;
  container-name: label;
}
.label-inner {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
  padding: 6cqh 6cqw;
  font-family: Arial, sans-serif;
  color: #000;
}
.label-inner .l-product {
  font-weight: 700;
  font-size: 15cqh;
  line-height: 1.1;
  text-align: left;
  margin-bottom: 3cqh;
  word-break: break-word;
}
.label-inner .l-hr {
  border-top: 0.6cqh solid #000;
  margin: 2.5cqh 0;
}
.label-inner .l-rows {
  margin-bottom: 1.5cqh;
}
.label-inner .l-line {
  white-space: nowrap;
  margin-bottom: 1.2cqh;
}
.label-inner .l-line:last-child { margin-bottom: 0; }
.label-inner .l-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 2cqh;
  gap: 4cqw;
}
.label-inner .l-footer-text { min-width: 0; }
.label-inner .l-footer-text .l-line:first-child { font-weight: 700; }
.label-inner .l-brand { flex-shrink: 0; }
.label-inner .l-brand .l-company {
  font-weight: 800;
  font-size: 8cqh;
  text-align: right;
}
.label-inner .l-logo {
  max-height: 22cqh;
  max-width: 38cqw;
  object-fit: contain;
  display: block;
}

