:root {
  --ink: #13241a;
  --muted: #657169;
  --paper: #f7f5ee;
  --white: #fffef9;
  --green: #173f2a;
  --green-2: #245d3e;
  --lime: #b8d887;
  --sand: #e8dfc9;
  --orange: #d86e39;
  --line: #dfe3d9;
  --shadow: 0 18px 60px rgba(19, 36, 26, .1);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 0%, rgba(184, 216, 135, .22), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }

.site-header {
  height: 78px;
  padding: 0 max(24px, calc((100vw - 1160px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 63, 42, .09);
  background: rgba(247, 245, 238, .88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark {
  width: 43px; height: 43px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green); color: white; font-family: Georgia, serif; font-weight: 800;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.13);
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 18px; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }
nav { display: flex; align-items: center; gap: 10px; }
nav a { text-decoration: none; font-size: 14px; font-weight: 700; padding: 10px 14px; border-radius: 999px; }
nav a:hover { background: white; }

#app { width: min(1160px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 72px; }
.loading-card { margin: 90px auto; width: fit-content; padding: 20px 28px; background: white; border-radius: 18px; box-shadow: var(--shadow); }
.spinner { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; margin-right: 8px; border: 2px solid var(--sand); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow { margin: 0 0 10px; color: var(--orange); font-size: 12px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.05; margin-top: 0; }
h1 { font-size: clamp(36px, 5vw, 65px); letter-spacing: -.04em; }
h2 { font-size: clamp(27px, 3vw, 38px); letter-spacing: -.025em; }
h3 { font-size: 22px; }
p { line-height: 1.65; }
.muted { color: var(--muted); }
.mono { font-family: "SFMono-Regular", Consolas, monospace; letter-spacing: .015em; }

.button {
  border: 0; border-radius: 999px; padding: 12px 18px; cursor: pointer; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  background: var(--green); color: white; box-shadow: 0 8px 20px rgba(23,63,42,.18);
}
.button:hover { transform: translateY(-1px); }
.button.secondary { background: white; color: var(--green); box-shadow: inset 0 0 0 1px var(--line); }
.button.ghost { color: var(--green); background: transparent; box-shadow: none; padding-inline: 10px; }
.button.small { padding: 8px 12px; font-size: 12px; }
.button[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.admin-hero { display: grid; grid-template-columns: 1.5fr .8fr; gap: 28px; align-items: end; margin: 18px 0 34px; }
.admin-hero h1 { margin-bottom: 10px; }
.admin-hero p { max-width: 680px; color: var(--muted); margin-bottom: 0; }
.admin-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.status-strip {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 11px; padding: 12px 16px; border: 1px solid var(--line);
  border-radius: 14px; background: rgba(255,255,255,.65); font-size: 13px; color: var(--muted);
}
.dot { width: 9px; height: 9px; background: #d6a949; border-radius: 50%; box-shadow: 0 0 0 4px rgba(214,169,73,.15); }
.dot.live { background: #2f8b57; box-shadow: 0 0 0 4px rgba(47,139,87,.15); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 19px; }
.stat small { display: block; color: var(--muted); font-weight: 750; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.stat strong { font: 700 32px/1.2 Georgia, serif; display: block; margin-top: 7px; }

.panel { background: rgba(255,254,249,.9); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { padding: 22px 24px; display: flex; justify-content: space-between; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 25px; margin: 0; }
.search { min-width: 230px; border: 1px solid var(--line); border-radius: 999px; padding: 10px 15px; background: white; color: var(--ink); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 17px 24px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
td strong { display: block; font-size: 14px; }
td small { color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(184,216,135,.08); }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.status { width: fit-content; display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 7px 10px; font-size: 11px; font-weight: 850; background: #e9f5e9; color: #28623f; }
.status::before { content: ''; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.status.review { color: #93621c; background: #fff1d4; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

dialog { border: 0; padding: 0; border-radius: 24px; width: min(900px, calc(100% - 24px)); max-height: 90vh; color: var(--ink); box-shadow: 0 30px 100px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(11,24,16,.65); backdrop-filter: blur(4px); }
.dialog-head { position: sticky; top: 0; z-index: 2; padding: 22px 26px; display: flex; justify-content: space-between; align-items: center; background: white; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 27px; }
.icon-button { border: 0; background: var(--paper); border-radius: 50%; width: 38px; height: 38px; cursor: pointer; font-size: 20px; }
.batch-form { padding: 25px 26px 30px; background: var(--white); }
.form-section { margin-bottom: 25px; }
.form-section h3 { font: 800 12px/1.3 Inter, sans-serif; text-transform: uppercase; letter-spacing: .1em; color: var(--orange); margin-bottom: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; color: var(--ink); background: white; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(36,93,62,.1); }
textarea { resize: vertical; min-height: 76px; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; }

.passport-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: 1.3fr .7fr; gap: 34px;
  background: var(--green); color: white; padding: clamp(29px, 5vw, 60px); border-radius: 32px;
  box-shadow: 0 24px 70px rgba(23,63,42,.22);
}
.passport-hero::after { content: ''; position: absolute; width: 420px; height: 420px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; right: -210px; top: -120px; box-shadow: 0 0 0 80px rgba(255,255,255,.025), 0 0 0 160px rgba(255,255,255,.018); }
.passport-hero > * { position: relative; z-index: 1; }
.passport-hero h1 { margin-bottom: 12px; }
.passport-hero .eyebrow { color: var(--lime); }
.passport-hero .muted { color: rgba(255,255,255,.68); }
.verified { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 30px; padding: 8px 11px; border-radius: 999px; background: rgba(184,216,135,.14); color: #d8f4ae; font-weight: 800; font-size: 12px; }
.verified::before { content: '✓'; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; background: var(--lime); color: var(--green); }
.passport-meta { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 28px; }
.passport-meta small { display: block; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .1em; font-size: 9px; font-weight: 800; }
.passport-meta strong { display: block; margin-top: 5px; }
.qr-card { align-self: center; justify-self: end; width: min(100%, 260px); background: white; color: var(--ink); border-radius: 24px; padding: 18px; text-align: center; }
.qr-card img { width: 100%; display: block; border-radius: 11px; }
.qr-card strong { display: block; margin-top: 8px; font-size: 13px; }
.qr-card small { color: var(--muted); font-size: 10px; }

.passport-grid { margin-top: 22px; display: grid; grid-template-columns: 1.1fr .9fr; gap: 22px; }
.content-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(22px, 3vw, 32px); }
.content-card h2 { font-size: 29px; margin-bottom: 20px; }
.content-card.wide { grid-column: 1 / -1; }
.fact-list { display: grid; gap: 14px; }
.fact { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.fact:last-child { border: 0; padding-bottom: 0; }
.fact span { color: var(--muted); }
.nutrition { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.nutrient { padding: 17px 12px; text-align: center; background: #f0f3e9; border-radius: 15px; }
.nutrient strong { font: 700 25px/1.2 Georgia, serif; display: block; }
.nutrient small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.quality-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quality { border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.quality small { color: var(--muted); display: block; margin-bottom: 9px; }
.quality strong { font-size: 16px; }
.quality .pass { color: #287342; }
.timeline { margin-top: 8px; display: grid; grid-template-columns: repeat(4, 1fr); }
.timeline-step { position: relative; padding: 34px 18px 0 0; }
.timeline-step::before { content: ''; position: absolute; top: 9px; left: 0; right: 0; height: 1px; background: var(--line); }
.timeline-step::after { content: ''; position: absolute; top: 3px; left: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px #e9efe8; }
.timeline-step strong { font-size: 13px; display: block; }
.timeline-step small { color: var(--muted); display: block; margin-top: 5px; line-height: 1.4; }
.consumer-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }
.not-found { max-width: 640px; margin: 70px auto; padding: 45px; text-align: center; background: white; border-radius: 25px; box-shadow: var(--shadow); }

.label-shell { display: grid; grid-template-columns: 1fr 360px; gap: 30px; align-items: start; }
.label-preview { background: #deddd8; border-radius: 24px; padding: 38px; display: grid; place-items: center; }
.product-label { width: 340px; min-height: 520px; background: white; padding: 22px; text-align: center; box-shadow: 0 15px 45px rgba(0,0,0,.18); border: 1px solid #ddd; }
.label-brand { font: 800 25px/1 Georgia, serif; color: var(--green); }
.label-title { margin: 22px 0 6px; font: 800 26px/1.05 Georgia, serif; }
.label-subtitle { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.label-qr { width: 180px; margin: 18px auto 5px; display: block; }
.label-url { font-size: 8px; overflow-wrap: anywhere; color: var(--muted); }
.label-batch { margin: 13px 0; padding: 10px; background: var(--paper); font: 800 12px/1.5 Consolas, monospace; }
.label-barcode { width: 100%; height: 68px; object-fit: contain; }
.label-copy { font-size: 10px; line-height: 1.45; color: var(--muted); margin: 8px 0; }
.label-controls { background: white; border-radius: 22px; padding: 25px; border: 1px solid var(--line); }
.label-controls h1 { font-size: 34px; }
.label-controls .button { width: 100%; margin-top: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 12px 17px; border-radius: 999px; font-size: 13px; font-weight: 750; transition: .2s ease; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 800px) {
  .site-header { padding-inline: 16px; }
  .brand small { display: none; }
  #app { padding-top: 25px; }
  .admin-hero, .passport-hero, .passport-grid, .label-shell { grid-template-columns: 1fr; }
  .admin-actions { justify-content: flex-start; }
  .qr-card { justify-self: start; width: 190px; }
  .stats { grid-template-columns: 1fr; }
  .quality-grid { grid-template-columns: 1fr 1fr; }
  .timeline { grid-template-columns: 1fr 1fr; row-gap: 15px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .field.span-3 { grid-column: 1 / -1; }
  .label-preview { padding: 18px; }
}

@media (max-width: 520px) {
  nav .hide-mobile { display: none; }
  .passport-hero { border-radius: 22px; }
  .passport-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .nutrition { grid-template-columns: 1fr 1fr; }
  .quality-grid, .timeline, .form-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: auto; }
  .panel-head { align-items: stretch; flex-direction: column; }
  .search { min-width: 0; }
  .product-label { width: 100%; }
}

@media print {
  body { background: white; }
  .site-header, .label-controls { display: none !important; }
  #app { width: auto; padding: 0; }
  .label-shell { display: block; }
  .label-preview { padding: 0; background: white; }
  .product-label { box-shadow: none; margin: 0 auto; }
}
