:root {
  --bg: #e8e4dc;
  --bg-elev: #f7f5f0;
  --ink: #111111;
  --muted: #5c5a56;
  --line: #2a2a2a;
  --accent: #e10600;
  --accent-soft: #ffeceb;
  --ok: #1a7a3c;
  --danger: #e10600;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(17, 17, 17, 0.12);
  --font: "Outfit", "Sora", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(225, 6, 0, 0.08), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(17, 17, 17, 0.08), transparent 45%),
    linear-gradient(160deg, #f0ece4 0%, #ddd7cb 100%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--bg-elev);
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: 20px;
  padding: 2rem 1.75rem 1.75rem;
  box-shadow: var(--shadow);
}

.brand-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.brand-hero img { width: min(280px, 100%); height: auto; }
.brand-hero .tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(17, 17, 17, 0.1);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.1rem;
}
.app-header .brand img { width: 36px; height: 36px; }
.app-header nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.app-header nav a { color: var(--ink); font-weight: 500; }
.app-header nav a.active { color: var(--accent); }
.app-header .user-meta { color: var(--muted); font-size: 0.9rem; }

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.panel {
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid rgba(17, 17, 17, 0.08);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.grid-app {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1.25rem;
}

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

h1, h2, h3 { margin: 0 0 0.75rem; letter-spacing: -0.02em; }
.muted { color: var(--muted); }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.85rem 0 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(17, 17, 17, 0.18);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(225, 6, 0, 0.35);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; text-decoration: none; color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(0.95); text-decoration: none; color: #fff; }
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(17, 17, 17, 0.2);
  color: var(--ink);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin: 0 0 1rem;
  font-size: 0.92rem;
}
.alert-error { background: var(--accent-soft); color: #8a0000; }
.alert-ok { background: #e7f6ec; color: var(--ok); }
.alert-info { background: #eeebe4; color: var(--muted); }

.template-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.template-switch label {
  margin: 0;
  padding: 0.85rem;
  border: 1px solid rgba(17, 17, 17, 0.15);
  border-radius: 12px;
  cursor: pointer;
  background: #fff;
}
.template-switch input { display: none; }
.template-switch input:checked + span {
  color: var(--accent);
}
.template-switch label.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.autocomplete {
  position: relative;
}
.ac-list {
  position: absolute;
  z-index: 15;
  left: 0; right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid rgba(17, 17, 17, 0.15);
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
  display: none;
}
.ac-list.open { display: block; }
.ac-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0.55rem 0.75rem;
  font: inherit;
  cursor: pointer;
}
.ac-list button:hover,
.ac-list button.active { background: #f0ece4; }

.editor-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.editor-stage {
  overflow: auto;
  background:
    linear-gradient(45deg, #d7d2c8 25%, transparent 25%),
    linear-gradient(-45deg, #d7d2c8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d7d2c8 75%),
    linear-gradient(-45deg, transparent 75%, #d7d2c8 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border-radius: 12px;
  padding: 1.25rem;
  min-height: 280px;
  display: grid;
  place-items: center;
}

.label-canvas {
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  transform-origin: center center;
  user-select: none;
}

.label-canvas.ela001 { background: #fff; color: #111; }
.label-canvas.ela009 { background: #fff; color: #111; }

.lm-el {
  position: absolute;
  overflow: hidden;
  cursor: grab;
  outline: 1px dashed transparent;
}
.lm-el:hover { outline-color: rgba(225, 6, 0, 0.55); }
.lm-el.selected { outline: 1.5px solid #e10600; z-index: 5; }
.lm-el.dragging { cursor: grabbing; z-index: 6; }

.lm-item {
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  font-size: clamp(6px, 2.8mm, 12px);
}

.ela001 .lm-item { color: #111; }
.ela009 .lm-item,
.ela009 .lm-lot,
.ela009 .lm-mfg,
.ela009 .lm-hri { color: #111; }

.lm-lot, .lm-mfg {
  font-weight: 700;
  display: flex;
  align-items: center;
  white-space: nowrap;
  font-size: clamp(6px, 2.4mm, 11px);
}

.lm-mfr img,
.lm-lot-icon img { width: 100%; height: 100%; object-fit: contain; }

.lm-dm {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lm-hri {
  font-family: ui-monospace, Consolas, monospace;
  font-size: clamp(5px, 1.8mm, 9px);
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15em;
}

.lm-ean, .lm-ean-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.lm-ean-block {
  background: #fff;
  border-radius: 1px;
  padding: 1mm;
}

.lm-ean-block .ean-hri,
.lm-ean .ean-hri {
  color: #111;
  font-size: clamp(5px, 1.6mm, 8px);
  font-family: ui-monospace, Consolas, monospace;
}

.lm-ean svg, .lm-ean-block svg,
.lm-ean-block canvas,
.lm-dm canvas, .lm-dm img {
  max-width: 100%;
  max-height: 100%;
}

.lm-dm canvas {
  width: auto;
  height: 100%;
}

.props {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.props label { margin-top: 0; font-size: 0.75rem; }

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid rgba(17,17,17,0.08);
  white-space: nowrap;
}
table.data th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.filters label { margin-top: 0; }

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

.pagination { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
